Add more highlighter color choices (#7012)
* Add more highlighter color choices, closes #7011 * docs
This commit is contained in:
@@ -3,6 +3,13 @@ import { EditorState } from "prosemirror-state";
|
||||
import { Primitive } from "utility-types";
|
||||
import { findParentNode } from "./findParentNode";
|
||||
|
||||
/**
|
||||
* Checks if a node is active in the current selection or not.
|
||||
*
|
||||
* @param type The node type to check.
|
||||
* @param attrs The attributes to check.
|
||||
* @returns A function that checks if a node is active in the current selection or not.
|
||||
*/
|
||||
export const isNodeActive =
|
||||
(type: NodeType, attrs: Record<string, Primitive> = {}) =>
|
||||
(state: EditorState) => {
|
||||
@@ -14,9 +21,7 @@ export const isNodeActive =
|
||||
let node = nodeAfter?.type === type ? nodeAfter : undefined;
|
||||
|
||||
if (!node) {
|
||||
const parent = findParentNode((node) => node.type === type)(
|
||||
state.selection
|
||||
);
|
||||
const parent = findParentNode((n) => n.type === type)(state.selection);
|
||||
node = parent?.node;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user