@tiptap/extension-highlight 2.5.0-beta.1 → 2.5.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +85 -85
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +84 -84
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +85 -85
- package/dist/index.umd.js.map +1 -1
- package/dist/packages/core/src/CommandManager.d.ts +20 -0
- package/dist/packages/core/src/Editor.d.ts +161 -0
- package/dist/packages/core/src/EventEmitter.d.ts +11 -0
- package/dist/packages/core/src/Extension.d.ts +343 -0
- package/dist/packages/core/src/ExtensionManager.d.ts +55 -0
- package/dist/packages/core/src/InputRule.d.ts +42 -0
- package/dist/packages/core/src/Mark.d.ts +451 -0
- package/dist/packages/core/src/Node.d.ts +611 -0
- package/dist/packages/core/src/NodePos.d.ts +44 -0
- package/dist/packages/core/src/NodeView.d.ts +31 -0
- package/dist/packages/core/src/PasteRule.d.ts +50 -0
- package/dist/packages/core/src/Tracker.d.ts +11 -0
- package/dist/packages/core/src/commands/blur.d.ts +13 -0
- package/dist/packages/core/src/commands/clearContent.d.ts +14 -0
- package/dist/packages/core/src/commands/clearNodes.d.ts +13 -0
- package/dist/packages/core/src/commands/command.d.ts +18 -0
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +13 -0
- package/dist/packages/core/src/commands/cut.d.ts +20 -0
- package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +13 -0
- package/dist/packages/core/src/commands/deleteNode.d.ts +15 -0
- package/dist/packages/core/src/commands/deleteRange.d.ts +14 -0
- package/dist/packages/core/src/commands/deleteSelection.d.ts +13 -0
- package/dist/packages/core/src/commands/enter.d.ts +13 -0
- package/dist/packages/core/src/commands/exitCode.d.ts +13 -0
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +25 -0
- package/dist/packages/core/src/commands/first.d.ts +14 -0
- package/dist/packages/core/src/commands/focus.d.ts +27 -0
- package/dist/packages/core/src/commands/forEach.d.ts +14 -0
- package/dist/packages/core/src/commands/index.d.ts +55 -0
- package/dist/packages/core/src/commands/insertContent.d.ts +34 -0
- package/dist/packages/core/src/commands/insertContentAt.d.ts +47 -0
- package/dist/packages/core/src/commands/join.d.ts +41 -0
- package/dist/packages/core/src/commands/joinItemBackward.d.ts +13 -0
- package/dist/packages/core/src/commands/joinItemForward.d.ts +13 -0
- package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +12 -0
- package/dist/packages/core/src/commands/joinTextblockForward.d.ts +12 -0
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +14 -0
- package/dist/packages/core/src/commands/lift.d.ts +17 -0
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +13 -0
- package/dist/packages/core/src/commands/liftListItem.d.ts +15 -0
- package/dist/packages/core/src/commands/newlineInCode.d.ts +13 -0
- package/dist/packages/core/src/commands/resetAttributes.d.ts +16 -0
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +13 -0
- package/dist/packages/core/src/commands/selectAll.d.ts +13 -0
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +13 -0
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +13 -0
- package/dist/packages/core/src/commands/selectParentNode.d.ts +13 -0
- package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +13 -0
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +13 -0
- package/dist/packages/core/src/commands/setContent.d.ts +40 -0
- package/dist/packages/core/src/commands/setMark.d.ts +15 -0
- package/dist/packages/core/src/commands/setMeta.d.ts +15 -0
- package/dist/packages/core/src/commands/setNode.d.ts +16 -0
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +14 -0
- package/dist/packages/core/src/commands/setTextSelection.d.ts +14 -0
- package/dist/packages/core/src/commands/sinkListItem.d.ts +15 -0
- package/dist/packages/core/src/commands/splitBlock.d.ts +17 -0
- package/dist/packages/core/src/commands/splitListItem.d.ts +15 -0
- package/dist/packages/core/src/commands/toggleList.d.ts +18 -0
- package/dist/packages/core/src/commands/toggleMark.d.ts +30 -0
- package/dist/packages/core/src/commands/toggleNode.d.ts +17 -0
- package/dist/packages/core/src/commands/toggleWrap.d.ts +16 -0
- package/dist/packages/core/src/commands/undoInputRule.d.ts +13 -0
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +13 -0
- package/dist/packages/core/src/commands/unsetMark.d.ts +25 -0
- package/dist/packages/core/src/commands/updateAttributes.d.ts +24 -0
- package/dist/packages/core/src/commands/wrapIn.d.ts +16 -0
- package/dist/packages/core/src/commands/wrapInList.d.ts +16 -0
- package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +5 -0
- package/dist/packages/core/src/extensions/commands.d.ts +3 -0
- package/dist/packages/core/src/extensions/editable.d.ts +2 -0
- package/dist/packages/core/src/extensions/focusEvents.d.ts +2 -0
- package/dist/packages/core/src/extensions/index.d.ts +6 -0
- package/dist/packages/core/src/extensions/keymap.d.ts +2 -0
- package/dist/packages/core/src/extensions/tabindex.d.ts +2 -0
- package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +10 -0
- package/dist/packages/core/src/helpers/createChainableState.d.ts +10 -0
- package/dist/packages/core/src/helpers/createDocument.d.ts +12 -0
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +15 -0
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +7 -0
- package/dist/packages/core/src/helpers/findChildren.d.ts +9 -0
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +10 -0
- package/dist/packages/core/src/helpers/findParentNode.d.ts +16 -0
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +17 -0
- package/dist/packages/core/src/helpers/generateHTML.d.ts +8 -0
- package/dist/packages/core/src/helpers/generateJSON.d.ts +8 -0
- package/dist/packages/core/src/helpers/generateText.d.ts +12 -0
- package/dist/packages/core/src/helpers/getAttributes.d.ts +9 -0
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +6 -0
- package/dist/packages/core/src/helpers/getChangedRanges.d.ts +11 -0
- package/dist/packages/core/src/helpers/getDebugJSON.d.ts +8 -0
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +9 -0
- package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +2 -0
- package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +3 -0
- package/dist/packages/core/src/helpers/getMarkRange.d.ts +3 -0
- package/dist/packages/core/src/helpers/getMarkType.d.ts +2 -0
- package/dist/packages/core/src/helpers/getMarksBetween.d.ts +3 -0
- package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +11 -0
- package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +3 -0
- package/dist/packages/core/src/helpers/getNodeType.d.ts +2 -0
- package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +3 -0
- package/dist/packages/core/src/helpers/getSchema.d.ts +4 -0
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +10 -0
- package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +8 -0
- package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +8 -0
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +9 -0
- package/dist/packages/core/src/helpers/getText.d.ts +15 -0
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +14 -0
- package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +8 -0
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +8 -0
- package/dist/packages/core/src/helpers/index.d.ts +50 -0
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +9 -0
- package/dist/packages/core/src/helpers/isActive.d.ts +2 -0
- package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +2 -0
- package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +2 -0
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +2 -0
- package/dist/packages/core/src/helpers/isList.d.ts +2 -0
- package/dist/packages/core/src/helpers/isMarkActive.d.ts +3 -0
- package/dist/packages/core/src/helpers/isNodeActive.d.ts +3 -0
- package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +2 -0
- package/dist/packages/core/src/helpers/isNodeSelection.d.ts +2 -0
- package/dist/packages/core/src/helpers/isTextSelection.d.ts +2 -0
- package/dist/packages/core/src/helpers/posToDOMRect.d.ts +2 -0
- package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +4 -0
- package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +2 -0
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +9 -0
- package/dist/packages/core/src/index.d.ts +24 -0
- package/dist/packages/core/src/inputRules/index.d.ts +5 -0
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +13 -0
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +23 -0
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +10 -0
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +15 -0
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +28 -0
- package/dist/packages/core/src/pasteRules/index.d.ts +3 -0
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +13 -0
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +13 -0
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +10 -0
- package/dist/packages/core/src/style.d.ts +1 -0
- package/dist/packages/core/src/types.d.ts +250 -0
- package/dist/packages/core/src/utilities/callOrReturn.d.ts +9 -0
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +1 -0
- package/dist/packages/core/src/utilities/deleteProps.d.ts +6 -0
- package/dist/packages/core/src/utilities/elementFromString.d.ts +1 -0
- package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +1 -0
- package/dist/packages/core/src/utilities/findDuplicates.d.ts +1 -0
- package/dist/packages/core/src/utilities/fromString.d.ts +1 -0
- package/dist/packages/core/src/utilities/index.d.ts +20 -0
- package/dist/packages/core/src/utilities/isAndroid.d.ts +1 -0
- package/dist/packages/core/src/utilities/isEmptyObject.d.ts +1 -0
- package/dist/packages/core/src/utilities/isFunction.d.ts +1 -0
- package/dist/packages/core/src/utilities/isMacOS.d.ts +1 -0
- package/dist/packages/core/src/utilities/isNumber.d.ts +1 -0
- package/dist/packages/core/src/utilities/isPlainObject.d.ts +1 -0
- package/dist/packages/core/src/utilities/isRegExp.d.ts +1 -0
- package/dist/packages/core/src/utilities/isString.d.ts +1 -0
- package/dist/packages/core/src/utilities/isiOS.d.ts +1 -0
- package/dist/packages/core/src/utilities/mergeAttributes.d.ts +1 -0
- package/dist/packages/core/src/utilities/mergeDeep.d.ts +1 -0
- package/dist/packages/core/src/utilities/minMax.d.ts +1 -0
- package/dist/packages/core/src/utilities/objectIncludes.d.ts +8 -0
- package/dist/packages/core/src/utilities/removeDuplicates.d.ts +8 -0
- package/dist/packages/extension-highlight/src/highlight.d.ts +55 -55
- package/dist/packages/extension-highlight/src/index.d.ts +3 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4,94 +4,94 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var core = require('@tiptap/core');
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Matches a highlight to a ==highlight== on input.
|
|
9
|
-
*/
|
|
10
|
-
const inputRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/;
|
|
11
|
-
/**
|
|
12
|
-
* Matches a highlight to a ==highlight== on paste.
|
|
13
|
-
*/
|
|
14
|
-
const pasteRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g;
|
|
15
|
-
/**
|
|
16
|
-
* This extension allows you to highlight text.
|
|
17
|
-
* @see https://www.tiptap.dev/api/marks/highlight
|
|
18
|
-
*/
|
|
19
|
-
const Highlight = core.Mark.create({
|
|
20
|
-
name: 'highlight',
|
|
21
|
-
addOptions() {
|
|
22
|
-
return {
|
|
23
|
-
multicolor: false,
|
|
24
|
-
HTMLAttributes: {},
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
addAttributes() {
|
|
28
|
-
if (!this.options.multicolor) {
|
|
29
|
-
return {};
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
color: {
|
|
33
|
-
default: null,
|
|
34
|
-
parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,
|
|
35
|
-
renderHTML: attributes => {
|
|
36
|
-
if (!attributes.color) {
|
|
37
|
-
return {};
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
'data-color': attributes.color,
|
|
41
|
-
style: `background-color: ${attributes.color}; color: inherit`,
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
parseHTML() {
|
|
48
|
-
return [
|
|
49
|
-
{
|
|
50
|
-
tag: 'mark',
|
|
51
|
-
},
|
|
52
|
-
];
|
|
53
|
-
},
|
|
54
|
-
renderHTML({ HTMLAttributes }) {
|
|
55
|
-
return ['mark', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
56
|
-
},
|
|
57
|
-
addCommands() {
|
|
58
|
-
return {
|
|
59
|
-
setHighlight: attributes => ({ commands }) => {
|
|
60
|
-
return commands.setMark(this.name, attributes);
|
|
61
|
-
},
|
|
62
|
-
toggleHighlight: attributes => ({ commands }) => {
|
|
63
|
-
return commands.toggleMark(this.name, attributes);
|
|
64
|
-
},
|
|
65
|
-
unsetHighlight: () => ({ commands }) => {
|
|
66
|
-
return commands.unsetMark(this.name);
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
addKeyboardShortcuts() {
|
|
71
|
-
return {
|
|
72
|
-
'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),
|
|
73
|
-
};
|
|
74
|
-
},
|
|
75
|
-
addInputRules() {
|
|
76
|
-
return [
|
|
77
|
-
core.markInputRule({
|
|
78
|
-
find: inputRegex,
|
|
79
|
-
type: this.type,
|
|
80
|
-
}),
|
|
81
|
-
];
|
|
82
|
-
},
|
|
83
|
-
addPasteRules() {
|
|
84
|
-
return [
|
|
85
|
-
core.markPasteRule({
|
|
86
|
-
find: pasteRegex,
|
|
87
|
-
type: this.type,
|
|
88
|
-
}),
|
|
89
|
-
];
|
|
90
|
-
},
|
|
7
|
+
/**
|
|
8
|
+
* Matches a highlight to a ==highlight== on input.
|
|
9
|
+
*/
|
|
10
|
+
const inputRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/;
|
|
11
|
+
/**
|
|
12
|
+
* Matches a highlight to a ==highlight== on paste.
|
|
13
|
+
*/
|
|
14
|
+
const pasteRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g;
|
|
15
|
+
/**
|
|
16
|
+
* This extension allows you to highlight text.
|
|
17
|
+
* @see https://www.tiptap.dev/api/marks/highlight
|
|
18
|
+
*/
|
|
19
|
+
const Highlight = core.Mark.create({
|
|
20
|
+
name: 'highlight',
|
|
21
|
+
addOptions() {
|
|
22
|
+
return {
|
|
23
|
+
multicolor: false,
|
|
24
|
+
HTMLAttributes: {},
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
addAttributes() {
|
|
28
|
+
if (!this.options.multicolor) {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
color: {
|
|
33
|
+
default: null,
|
|
34
|
+
parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,
|
|
35
|
+
renderHTML: attributes => {
|
|
36
|
+
if (!attributes.color) {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
'data-color': attributes.color,
|
|
41
|
+
style: `background-color: ${attributes.color}; color: inherit`,
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
parseHTML() {
|
|
48
|
+
return [
|
|
49
|
+
{
|
|
50
|
+
tag: 'mark',
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
},
|
|
54
|
+
renderHTML({ HTMLAttributes }) {
|
|
55
|
+
return ['mark', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
56
|
+
},
|
|
57
|
+
addCommands() {
|
|
58
|
+
return {
|
|
59
|
+
setHighlight: attributes => ({ commands }) => {
|
|
60
|
+
return commands.setMark(this.name, attributes);
|
|
61
|
+
},
|
|
62
|
+
toggleHighlight: attributes => ({ commands }) => {
|
|
63
|
+
return commands.toggleMark(this.name, attributes);
|
|
64
|
+
},
|
|
65
|
+
unsetHighlight: () => ({ commands }) => {
|
|
66
|
+
return commands.unsetMark(this.name);
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
addKeyboardShortcuts() {
|
|
71
|
+
return {
|
|
72
|
+
'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
addInputRules() {
|
|
76
|
+
return [
|
|
77
|
+
core.markInputRule({
|
|
78
|
+
find: inputRegex,
|
|
79
|
+
type: this.type,
|
|
80
|
+
}),
|
|
81
|
+
];
|
|
82
|
+
},
|
|
83
|
+
addPasteRules() {
|
|
84
|
+
return [
|
|
85
|
+
core.markPasteRule({
|
|
86
|
+
find: pasteRegex,
|
|
87
|
+
type: this.type,
|
|
88
|
+
}),
|
|
89
|
+
];
|
|
90
|
+
},
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
exports.Highlight = Highlight;
|
|
94
|
-
exports
|
|
94
|
+
exports.default = Highlight;
|
|
95
95
|
exports.inputRegex = inputRegex;
|
|
96
96
|
exports.pasteRegex = pasteRegex;
|
|
97
97
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/highlight.ts"],"sourcesContent":["import {\n Mark,\n markInputRule,\n markPasteRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface HighlightOptions {\n /**\n * Allow multiple highlight colors\n * @default false\n * @example true\n */\n multicolor: boolean,\n\n /**\n * HTML attributes to add to the highlight element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n highlight: {\n /**\n * Set a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.setHighlight({ color: 'red' })\n */\n setHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Toggle a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.toggleHighlight({ color: 'red' })\n */\n toggleHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Unset a highlight mark\n * @example editor.commands.unsetHighlight()\n */\n unsetHighlight: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches a highlight to a ==highlight== on input.\n */\nexport const inputRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))$/\n\n/**\n * Matches a highlight to a ==highlight== on paste.\n */\nexport const pasteRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))/g\n\n/**\n * This extension allows you to highlight text.\n * @see https://www.tiptap.dev/api/marks/highlight\n */\nexport const Highlight = Mark.create<HighlightOptions>({\n name: 'highlight',\n\n addOptions() {\n return {\n multicolor: false,\n HTMLAttributes: {},\n }\n },\n\n addAttributes() {\n if (!this.options.multicolor) {\n return {}\n }\n\n return {\n color: {\n default: null,\n parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n 'data-color': attributes.color,\n style: `background-color: ${attributes.color}; color: inherit`,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'mark',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['mark', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n setHighlight: attributes => ({ commands }) => {\n return commands.setMark(this.name, attributes)\n },\n toggleHighlight: attributes => ({ commands }) => {\n return commands.toggleMark(this.name, attributes)\n },\n unsetHighlight: () => ({ commands }) => {\n return commands.unsetMark(this.name)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),\n }\n },\n\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n"],"names":["Mark","mergeAttributes","markInputRule","markPasteRule"],"mappings":";;;;;;AA+CA;;AAEG;AACI,MAAM,UAAU,GAAG,+CAA8C;AAExE;;AAEG;AACI,MAAM,UAAU,GAAG,+CAA8C;AAExE;;;AAGG;AACU,MAAA,SAAS,GAAGA,SAAI,CAAC,MAAM,CAAmB;AACrD,IAAA,IAAI,EAAE,WAAW;IAEjB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,UAAU,EAAE,KAAK;AACjB,YAAA,cAAc,EAAE,EAAE;SACnB,CAAA;KACF;IAED,aAAa,GAAA;AACX,QAAA,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;AAC5B,YAAA,OAAO,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/highlight.ts"],"sourcesContent":["import {\n Mark,\n markInputRule,\n markPasteRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface HighlightOptions {\n /**\n * Allow multiple highlight colors\n * @default false\n * @example true\n */\n multicolor: boolean,\n\n /**\n * HTML attributes to add to the highlight element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n highlight: {\n /**\n * Set a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.setHighlight({ color: 'red' })\n */\n setHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Toggle a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.toggleHighlight({ color: 'red' })\n */\n toggleHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Unset a highlight mark\n * @example editor.commands.unsetHighlight()\n */\n unsetHighlight: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches a highlight to a ==highlight== on input.\n */\nexport const inputRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))$/\n\n/**\n * Matches a highlight to a ==highlight== on paste.\n */\nexport const pasteRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))/g\n\n/**\n * This extension allows you to highlight text.\n * @see https://www.tiptap.dev/api/marks/highlight\n */\nexport const Highlight = Mark.create<HighlightOptions>({\n name: 'highlight',\n\n addOptions() {\n return {\n multicolor: false,\n HTMLAttributes: {},\n }\n },\n\n addAttributes() {\n if (!this.options.multicolor) {\n return {}\n }\n\n return {\n color: {\n default: null,\n parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n 'data-color': attributes.color,\n style: `background-color: ${attributes.color}; color: inherit`,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'mark',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['mark', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n setHighlight: attributes => ({ commands }) => {\n return commands.setMark(this.name, attributes)\n },\n toggleHighlight: attributes => ({ commands }) => {\n return commands.toggleMark(this.name, attributes)\n },\n unsetHighlight: () => ({ commands }) => {\n return commands.unsetMark(this.name)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),\n }\n },\n\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n"],"names":["Mark","mergeAttributes","markInputRule","markPasteRule"],"mappings":";;;;;;AA+CA;;AAEG;AACI,MAAM,UAAU,GAAG,+CAA8C;AAExE;;AAEG;AACI,MAAM,UAAU,GAAG,+CAA8C;AAExE;;;AAGG;AACU,MAAA,SAAS,GAAGA,SAAI,CAAC,MAAM,CAAmB;AACrD,IAAA,IAAI,EAAE,WAAW;IAEjB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,UAAU,EAAE,KAAK;AACjB,YAAA,cAAc,EAAE,EAAE;SACnB,CAAA;KACF;IAED,aAAa,GAAA;AACX,QAAA,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;AAC5B,YAAA,OAAO,EAAE,CAAA;SACV;QAED,OAAO;AACL,YAAA,KAAK,EAAE;AACL,gBAAA,OAAO,EAAE,IAAI;AACb,gBAAA,SAAS,EAAE,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe;gBACzF,UAAU,EAAE,UAAU,IAAG;AACvB,oBAAA,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;AACrB,wBAAA,OAAO,EAAE,CAAA;qBACV;oBAED,OAAO;wBACL,YAAY,EAAE,UAAU,CAAC,KAAK;AAC9B,wBAAA,KAAK,EAAE,CAAA,kBAAA,EAAqB,UAAU,CAAC,KAAK,CAAkB,gBAAA,CAAA;qBAC/D,CAAA;iBACF;AACF,aAAA;SACF,CAAA;KACF;IAED,SAAS,GAAA;QACP,OAAO;AACL,YAAA;AACE,gBAAA,GAAG,EAAE,MAAM;AACZ,aAAA;SACF,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE,EAAA;AAC3B,QAAA,OAAO,CAAC,MAAM,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;KACjF;IAED,WAAW,GAAA;QACT,OAAO;YACL,YAAY,EAAE,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAI;gBAC3C,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;aAC/C;YACD,eAAe,EAAE,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAI;gBAC9C,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;aAClD;YACD,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;gBACrC,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aACrC;SACF,CAAA;KACF;IAED,oBAAoB,GAAA;QAClB,OAAO;YACL,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE;SAC5D,CAAA;KACF;IAED,aAAa,GAAA;QACX,OAAO;AACL,YAAAC,kBAAa,CAAC;AACZ,gBAAA,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC;SACH,CAAA;KACF;IAED,aAAa,GAAA;QACX,OAAO;AACL,YAAAC,kBAAa,CAAC;AACZ,gBAAA,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC;SACH,CAAA;KACF;AACF,CAAA;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
1
|
import { Mark, mergeAttributes, markInputRule, markPasteRule } from '@tiptap/core';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Matches a highlight to a ==highlight== on input.
|
|
5
|
-
*/
|
|
6
|
-
const inputRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/;
|
|
7
|
-
/**
|
|
8
|
-
* Matches a highlight to a ==highlight== on paste.
|
|
9
|
-
*/
|
|
10
|
-
const pasteRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g;
|
|
11
|
-
/**
|
|
12
|
-
* This extension allows you to highlight text.
|
|
13
|
-
* @see https://www.tiptap.dev/api/marks/highlight
|
|
14
|
-
*/
|
|
15
|
-
const Highlight = Mark.create({
|
|
16
|
-
name: 'highlight',
|
|
17
|
-
addOptions() {
|
|
18
|
-
return {
|
|
19
|
-
multicolor: false,
|
|
20
|
-
HTMLAttributes: {},
|
|
21
|
-
};
|
|
22
|
-
},
|
|
23
|
-
addAttributes() {
|
|
24
|
-
if (!this.options.multicolor) {
|
|
25
|
-
return {};
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
color: {
|
|
29
|
-
default: null,
|
|
30
|
-
parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,
|
|
31
|
-
renderHTML: attributes => {
|
|
32
|
-
if (!attributes.color) {
|
|
33
|
-
return {};
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
'data-color': attributes.color,
|
|
37
|
-
style: `background-color: ${attributes.color}; color: inherit`,
|
|
38
|
-
};
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
parseHTML() {
|
|
44
|
-
return [
|
|
45
|
-
{
|
|
46
|
-
tag: 'mark',
|
|
47
|
-
},
|
|
48
|
-
];
|
|
49
|
-
},
|
|
50
|
-
renderHTML({ HTMLAttributes }) {
|
|
51
|
-
return ['mark', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
52
|
-
},
|
|
53
|
-
addCommands() {
|
|
54
|
-
return {
|
|
55
|
-
setHighlight: attributes => ({ commands }) => {
|
|
56
|
-
return commands.setMark(this.name, attributes);
|
|
57
|
-
},
|
|
58
|
-
toggleHighlight: attributes => ({ commands }) => {
|
|
59
|
-
return commands.toggleMark(this.name, attributes);
|
|
60
|
-
},
|
|
61
|
-
unsetHighlight: () => ({ commands }) => {
|
|
62
|
-
return commands.unsetMark(this.name);
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
addKeyboardShortcuts() {
|
|
67
|
-
return {
|
|
68
|
-
'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),
|
|
69
|
-
};
|
|
70
|
-
},
|
|
71
|
-
addInputRules() {
|
|
72
|
-
return [
|
|
73
|
-
markInputRule({
|
|
74
|
-
find: inputRegex,
|
|
75
|
-
type: this.type,
|
|
76
|
-
}),
|
|
77
|
-
];
|
|
78
|
-
},
|
|
79
|
-
addPasteRules() {
|
|
80
|
-
return [
|
|
81
|
-
markPasteRule({
|
|
82
|
-
find: pasteRegex,
|
|
83
|
-
type: this.type,
|
|
84
|
-
}),
|
|
85
|
-
];
|
|
86
|
-
},
|
|
3
|
+
/**
|
|
4
|
+
* Matches a highlight to a ==highlight== on input.
|
|
5
|
+
*/
|
|
6
|
+
const inputRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/;
|
|
7
|
+
/**
|
|
8
|
+
* Matches a highlight to a ==highlight== on paste.
|
|
9
|
+
*/
|
|
10
|
+
const pasteRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g;
|
|
11
|
+
/**
|
|
12
|
+
* This extension allows you to highlight text.
|
|
13
|
+
* @see https://www.tiptap.dev/api/marks/highlight
|
|
14
|
+
*/
|
|
15
|
+
const Highlight = Mark.create({
|
|
16
|
+
name: 'highlight',
|
|
17
|
+
addOptions() {
|
|
18
|
+
return {
|
|
19
|
+
multicolor: false,
|
|
20
|
+
HTMLAttributes: {},
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
addAttributes() {
|
|
24
|
+
if (!this.options.multicolor) {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
color: {
|
|
29
|
+
default: null,
|
|
30
|
+
parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,
|
|
31
|
+
renderHTML: attributes => {
|
|
32
|
+
if (!attributes.color) {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
'data-color': attributes.color,
|
|
37
|
+
style: `background-color: ${attributes.color}; color: inherit`,
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
parseHTML() {
|
|
44
|
+
return [
|
|
45
|
+
{
|
|
46
|
+
tag: 'mark',
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
},
|
|
50
|
+
renderHTML({ HTMLAttributes }) {
|
|
51
|
+
return ['mark', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
52
|
+
},
|
|
53
|
+
addCommands() {
|
|
54
|
+
return {
|
|
55
|
+
setHighlight: attributes => ({ commands }) => {
|
|
56
|
+
return commands.setMark(this.name, attributes);
|
|
57
|
+
},
|
|
58
|
+
toggleHighlight: attributes => ({ commands }) => {
|
|
59
|
+
return commands.toggleMark(this.name, attributes);
|
|
60
|
+
},
|
|
61
|
+
unsetHighlight: () => ({ commands }) => {
|
|
62
|
+
return commands.unsetMark(this.name);
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
addKeyboardShortcuts() {
|
|
67
|
+
return {
|
|
68
|
+
'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
addInputRules() {
|
|
72
|
+
return [
|
|
73
|
+
markInputRule({
|
|
74
|
+
find: inputRegex,
|
|
75
|
+
type: this.type,
|
|
76
|
+
}),
|
|
77
|
+
];
|
|
78
|
+
},
|
|
79
|
+
addPasteRules() {
|
|
80
|
+
return [
|
|
81
|
+
markPasteRule({
|
|
82
|
+
find: pasteRegex,
|
|
83
|
+
type: this.type,
|
|
84
|
+
}),
|
|
85
|
+
];
|
|
86
|
+
},
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
export { Highlight, Highlight as default, inputRegex, pasteRegex };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/highlight.ts"],"sourcesContent":["import {\n Mark,\n markInputRule,\n markPasteRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface HighlightOptions {\n /**\n * Allow multiple highlight colors\n * @default false\n * @example true\n */\n multicolor: boolean,\n\n /**\n * HTML attributes to add to the highlight element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n highlight: {\n /**\n * Set a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.setHighlight({ color: 'red' })\n */\n setHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Toggle a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.toggleHighlight({ color: 'red' })\n */\n toggleHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Unset a highlight mark\n * @example editor.commands.unsetHighlight()\n */\n unsetHighlight: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches a highlight to a ==highlight== on input.\n */\nexport const inputRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))$/\n\n/**\n * Matches a highlight to a ==highlight== on paste.\n */\nexport const pasteRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))/g\n\n/**\n * This extension allows you to highlight text.\n * @see https://www.tiptap.dev/api/marks/highlight\n */\nexport const Highlight = Mark.create<HighlightOptions>({\n name: 'highlight',\n\n addOptions() {\n return {\n multicolor: false,\n HTMLAttributes: {},\n }\n },\n\n addAttributes() {\n if (!this.options.multicolor) {\n return {}\n }\n\n return {\n color: {\n default: null,\n parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n 'data-color': attributes.color,\n style: `background-color: ${attributes.color}; color: inherit`,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'mark',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['mark', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n setHighlight: attributes => ({ commands }) => {\n return commands.setMark(this.name, attributes)\n },\n toggleHighlight: attributes => ({ commands }) => {\n return commands.toggleMark(this.name, attributes)\n },\n unsetHighlight: () => ({ commands }) => {\n return commands.unsetMark(this.name)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),\n }\n },\n\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n"],"names":[],"mappings":";;AA+CA;;AAEG;AACI,MAAM,UAAU,GAAG,+CAA8C;AAExE;;AAEG;AACI,MAAM,UAAU,GAAG,+CAA8C;AAExE;;;AAGG;AACU,MAAA,SAAS,GAAG,IAAI,CAAC,MAAM,CAAmB;AACrD,IAAA,IAAI,EAAE,WAAW;IAEjB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,UAAU,EAAE,KAAK;AACjB,YAAA,cAAc,EAAE,EAAE;SACnB,CAAA;KACF;IAED,aAAa,GAAA;AACX,QAAA,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;AAC5B,YAAA,OAAO,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/highlight.ts"],"sourcesContent":["import {\n Mark,\n markInputRule,\n markPasteRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface HighlightOptions {\n /**\n * Allow multiple highlight colors\n * @default false\n * @example true\n */\n multicolor: boolean,\n\n /**\n * HTML attributes to add to the highlight element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n highlight: {\n /**\n * Set a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.setHighlight({ color: 'red' })\n */\n setHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Toggle a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.toggleHighlight({ color: 'red' })\n */\n toggleHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Unset a highlight mark\n * @example editor.commands.unsetHighlight()\n */\n unsetHighlight: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches a highlight to a ==highlight== on input.\n */\nexport const inputRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))$/\n\n/**\n * Matches a highlight to a ==highlight== on paste.\n */\nexport const pasteRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))/g\n\n/**\n * This extension allows you to highlight text.\n * @see https://www.tiptap.dev/api/marks/highlight\n */\nexport const Highlight = Mark.create<HighlightOptions>({\n name: 'highlight',\n\n addOptions() {\n return {\n multicolor: false,\n HTMLAttributes: {},\n }\n },\n\n addAttributes() {\n if (!this.options.multicolor) {\n return {}\n }\n\n return {\n color: {\n default: null,\n parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n 'data-color': attributes.color,\n style: `background-color: ${attributes.color}; color: inherit`,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'mark',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['mark', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n setHighlight: attributes => ({ commands }) => {\n return commands.setMark(this.name, attributes)\n },\n toggleHighlight: attributes => ({ commands }) => {\n return commands.toggleMark(this.name, attributes)\n },\n unsetHighlight: () => ({ commands }) => {\n return commands.unsetMark(this.name)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),\n }\n },\n\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n"],"names":[],"mappings":";;AA+CA;;AAEG;AACI,MAAM,UAAU,GAAG,+CAA8C;AAExE;;AAEG;AACI,MAAM,UAAU,GAAG,+CAA8C;AAExE;;;AAGG;AACU,MAAA,SAAS,GAAG,IAAI,CAAC,MAAM,CAAmB;AACrD,IAAA,IAAI,EAAE,WAAW;IAEjB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,UAAU,EAAE,KAAK;AACjB,YAAA,cAAc,EAAE,EAAE;SACnB,CAAA;KACF;IAED,aAAa,GAAA;AACX,QAAA,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;AAC5B,YAAA,OAAO,EAAE,CAAA;SACV;QAED,OAAO;AACL,YAAA,KAAK,EAAE;AACL,gBAAA,OAAO,EAAE,IAAI;AACb,gBAAA,SAAS,EAAE,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe;gBACzF,UAAU,EAAE,UAAU,IAAG;AACvB,oBAAA,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;AACrB,wBAAA,OAAO,EAAE,CAAA;qBACV;oBAED,OAAO;wBACL,YAAY,EAAE,UAAU,CAAC,KAAK;AAC9B,wBAAA,KAAK,EAAE,CAAA,kBAAA,EAAqB,UAAU,CAAC,KAAK,CAAkB,gBAAA,CAAA;qBAC/D,CAAA;iBACF;AACF,aAAA;SACF,CAAA;KACF;IAED,SAAS,GAAA;QACP,OAAO;AACL,YAAA;AACE,gBAAA,GAAG,EAAE,MAAM;AACZ,aAAA;SACF,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE,EAAA;AAC3B,QAAA,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;KACjF;IAED,WAAW,GAAA;QACT,OAAO;YACL,YAAY,EAAE,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAI;gBAC3C,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;aAC/C;YACD,eAAe,EAAE,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAI;gBAC9C,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;aAClD;YACD,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;gBACrC,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aACrC;SACF,CAAA;KACF;IAED,oBAAoB,GAAA;QAClB,OAAO;YACL,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE;SAC5D,CAAA;KACF;IAED,aAAa,GAAA;QACX,OAAO;AACL,YAAA,aAAa,CAAC;AACZ,gBAAA,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC;SACH,CAAA;KACF;IAED,aAAa,GAAA;QACX,OAAO;AACL,YAAA,aAAa,CAAC;AACZ,gBAAA,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC;SACH,CAAA;KACF;AACF,CAAA;;;;"}
|
package/dist/index.umd.js
CHANGED
|
@@ -4,94 +4,94 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-highlight"] = {}, global.core));
|
|
5
5
|
})(this, (function (exports, core) { 'use strict';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Matches a highlight to a ==highlight== on input.
|
|
9
|
-
*/
|
|
10
|
-
const inputRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/;
|
|
11
|
-
/**
|
|
12
|
-
* Matches a highlight to a ==highlight== on paste.
|
|
13
|
-
*/
|
|
14
|
-
const pasteRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g;
|
|
15
|
-
/**
|
|
16
|
-
* This extension allows you to highlight text.
|
|
17
|
-
* @see https://www.tiptap.dev/api/marks/highlight
|
|
18
|
-
*/
|
|
19
|
-
const Highlight = core.Mark.create({
|
|
20
|
-
name: 'highlight',
|
|
21
|
-
addOptions() {
|
|
22
|
-
return {
|
|
23
|
-
multicolor: false,
|
|
24
|
-
HTMLAttributes: {},
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
addAttributes() {
|
|
28
|
-
if (!this.options.multicolor) {
|
|
29
|
-
return {};
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
color: {
|
|
33
|
-
default: null,
|
|
34
|
-
parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,
|
|
35
|
-
renderHTML: attributes => {
|
|
36
|
-
if (!attributes.color) {
|
|
37
|
-
return {};
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
'data-color': attributes.color,
|
|
41
|
-
style: `background-color: ${attributes.color}; color: inherit`,
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
parseHTML() {
|
|
48
|
-
return [
|
|
49
|
-
{
|
|
50
|
-
tag: 'mark',
|
|
51
|
-
},
|
|
52
|
-
];
|
|
53
|
-
},
|
|
54
|
-
renderHTML({ HTMLAttributes }) {
|
|
55
|
-
return ['mark', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
56
|
-
},
|
|
57
|
-
addCommands() {
|
|
58
|
-
return {
|
|
59
|
-
setHighlight: attributes => ({ commands }) => {
|
|
60
|
-
return commands.setMark(this.name, attributes);
|
|
61
|
-
},
|
|
62
|
-
toggleHighlight: attributes => ({ commands }) => {
|
|
63
|
-
return commands.toggleMark(this.name, attributes);
|
|
64
|
-
},
|
|
65
|
-
unsetHighlight: () => ({ commands }) => {
|
|
66
|
-
return commands.unsetMark(this.name);
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
addKeyboardShortcuts() {
|
|
71
|
-
return {
|
|
72
|
-
'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),
|
|
73
|
-
};
|
|
74
|
-
},
|
|
75
|
-
addInputRules() {
|
|
76
|
-
return [
|
|
77
|
-
core.markInputRule({
|
|
78
|
-
find: inputRegex,
|
|
79
|
-
type: this.type,
|
|
80
|
-
}),
|
|
81
|
-
];
|
|
82
|
-
},
|
|
83
|
-
addPasteRules() {
|
|
84
|
-
return [
|
|
85
|
-
core.markPasteRule({
|
|
86
|
-
find: pasteRegex,
|
|
87
|
-
type: this.type,
|
|
88
|
-
}),
|
|
89
|
-
];
|
|
90
|
-
},
|
|
7
|
+
/**
|
|
8
|
+
* Matches a highlight to a ==highlight== on input.
|
|
9
|
+
*/
|
|
10
|
+
const inputRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/;
|
|
11
|
+
/**
|
|
12
|
+
* Matches a highlight to a ==highlight== on paste.
|
|
13
|
+
*/
|
|
14
|
+
const pasteRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g;
|
|
15
|
+
/**
|
|
16
|
+
* This extension allows you to highlight text.
|
|
17
|
+
* @see https://www.tiptap.dev/api/marks/highlight
|
|
18
|
+
*/
|
|
19
|
+
const Highlight = core.Mark.create({
|
|
20
|
+
name: 'highlight',
|
|
21
|
+
addOptions() {
|
|
22
|
+
return {
|
|
23
|
+
multicolor: false,
|
|
24
|
+
HTMLAttributes: {},
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
addAttributes() {
|
|
28
|
+
if (!this.options.multicolor) {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
color: {
|
|
33
|
+
default: null,
|
|
34
|
+
parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,
|
|
35
|
+
renderHTML: attributes => {
|
|
36
|
+
if (!attributes.color) {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
'data-color': attributes.color,
|
|
41
|
+
style: `background-color: ${attributes.color}; color: inherit`,
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
parseHTML() {
|
|
48
|
+
return [
|
|
49
|
+
{
|
|
50
|
+
tag: 'mark',
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
},
|
|
54
|
+
renderHTML({ HTMLAttributes }) {
|
|
55
|
+
return ['mark', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
56
|
+
},
|
|
57
|
+
addCommands() {
|
|
58
|
+
return {
|
|
59
|
+
setHighlight: attributes => ({ commands }) => {
|
|
60
|
+
return commands.setMark(this.name, attributes);
|
|
61
|
+
},
|
|
62
|
+
toggleHighlight: attributes => ({ commands }) => {
|
|
63
|
+
return commands.toggleMark(this.name, attributes);
|
|
64
|
+
},
|
|
65
|
+
unsetHighlight: () => ({ commands }) => {
|
|
66
|
+
return commands.unsetMark(this.name);
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
addKeyboardShortcuts() {
|
|
71
|
+
return {
|
|
72
|
+
'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
addInputRules() {
|
|
76
|
+
return [
|
|
77
|
+
core.markInputRule({
|
|
78
|
+
find: inputRegex,
|
|
79
|
+
type: this.type,
|
|
80
|
+
}),
|
|
81
|
+
];
|
|
82
|
+
},
|
|
83
|
+
addPasteRules() {
|
|
84
|
+
return [
|
|
85
|
+
core.markPasteRule({
|
|
86
|
+
find: pasteRegex,
|
|
87
|
+
type: this.type,
|
|
88
|
+
}),
|
|
89
|
+
];
|
|
90
|
+
},
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
exports.Highlight = Highlight;
|
|
94
|
-
exports
|
|
94
|
+
exports.default = Highlight;
|
|
95
95
|
exports.inputRegex = inputRegex;
|
|
96
96
|
exports.pasteRegex = pasteRegex;
|
|
97
97
|
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/highlight.ts"],"sourcesContent":["import {\n Mark,\n markInputRule,\n markPasteRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface HighlightOptions {\n /**\n * Allow multiple highlight colors\n * @default false\n * @example true\n */\n multicolor: boolean,\n\n /**\n * HTML attributes to add to the highlight element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n highlight: {\n /**\n * Set a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.setHighlight({ color: 'red' })\n */\n setHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Toggle a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.toggleHighlight({ color: 'red' })\n */\n toggleHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Unset a highlight mark\n * @example editor.commands.unsetHighlight()\n */\n unsetHighlight: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches a highlight to a ==highlight== on input.\n */\nexport const inputRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))$/\n\n/**\n * Matches a highlight to a ==highlight== on paste.\n */\nexport const pasteRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))/g\n\n/**\n * This extension allows you to highlight text.\n * @see https://www.tiptap.dev/api/marks/highlight\n */\nexport const Highlight = Mark.create<HighlightOptions>({\n name: 'highlight',\n\n addOptions() {\n return {\n multicolor: false,\n HTMLAttributes: {},\n }\n },\n\n addAttributes() {\n if (!this.options.multicolor) {\n return {}\n }\n\n return {\n color: {\n default: null,\n parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n 'data-color': attributes.color,\n style: `background-color: ${attributes.color}; color: inherit`,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'mark',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['mark', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n setHighlight: attributes => ({ commands }) => {\n return commands.setMark(this.name, attributes)\n },\n toggleHighlight: attributes => ({ commands }) => {\n return commands.toggleMark(this.name, attributes)\n },\n unsetHighlight: () => ({ commands }) => {\n return commands.unsetMark(this.name)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),\n }\n },\n\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n"],"names":["Mark","mergeAttributes","markInputRule","markPasteRule"],"mappings":";;;;;;EA+CA;;EAEG;AACI,QAAM,UAAU,GAAG,+CAA8C;EAExE;;EAEG;AACI,QAAM,UAAU,GAAG,+CAA8C;EAExE;;;EAGG;AACU,QAAA,SAAS,GAAGA,SAAI,CAAC,MAAM,CAAmB;EACrD,IAAA,IAAI,EAAE,WAAW;MAEjB,UAAU,GAAA;UACR,OAAO;EACL,YAAA,UAAU,EAAE,KAAK;EACjB,YAAA,cAAc,EAAE,EAAE;WACnB,CAAA;OACF;MAED,aAAa,GAAA;EACX,QAAA,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;EAC5B,YAAA,OAAO,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/highlight.ts"],"sourcesContent":["import {\n Mark,\n markInputRule,\n markPasteRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface HighlightOptions {\n /**\n * Allow multiple highlight colors\n * @default false\n * @example true\n */\n multicolor: boolean,\n\n /**\n * HTML attributes to add to the highlight element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n highlight: {\n /**\n * Set a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.setHighlight({ color: 'red' })\n */\n setHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Toggle a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.toggleHighlight({ color: 'red' })\n */\n toggleHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Unset a highlight mark\n * @example editor.commands.unsetHighlight()\n */\n unsetHighlight: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches a highlight to a ==highlight== on input.\n */\nexport const inputRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))$/\n\n/**\n * Matches a highlight to a ==highlight== on paste.\n */\nexport const pasteRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))/g\n\n/**\n * This extension allows you to highlight text.\n * @see https://www.tiptap.dev/api/marks/highlight\n */\nexport const Highlight = Mark.create<HighlightOptions>({\n name: 'highlight',\n\n addOptions() {\n return {\n multicolor: false,\n HTMLAttributes: {},\n }\n },\n\n addAttributes() {\n if (!this.options.multicolor) {\n return {}\n }\n\n return {\n color: {\n default: null,\n parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n 'data-color': attributes.color,\n style: `background-color: ${attributes.color}; color: inherit`,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'mark',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['mark', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n setHighlight: attributes => ({ commands }) => {\n return commands.setMark(this.name, attributes)\n },\n toggleHighlight: attributes => ({ commands }) => {\n return commands.toggleMark(this.name, attributes)\n },\n unsetHighlight: () => ({ commands }) => {\n return commands.unsetMark(this.name)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),\n }\n },\n\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n"],"names":["Mark","mergeAttributes","markInputRule","markPasteRule"],"mappings":";;;;;;EA+CA;;EAEG;AACI,QAAM,UAAU,GAAG,+CAA8C;EAExE;;EAEG;AACI,QAAM,UAAU,GAAG,+CAA8C;EAExE;;;EAGG;AACU,QAAA,SAAS,GAAGA,SAAI,CAAC,MAAM,CAAmB;EACrD,IAAA,IAAI,EAAE,WAAW;MAEjB,UAAU,GAAA;UACR,OAAO;EACL,YAAA,UAAU,EAAE,KAAK;EACjB,YAAA,cAAc,EAAE,EAAE;WACnB,CAAA;OACF;MAED,aAAa,GAAA;EACX,QAAA,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;EAC5B,YAAA,OAAO,EAAE,CAAA;WACV;UAED,OAAO;EACL,YAAA,KAAK,EAAE;EACL,gBAAA,OAAO,EAAE,IAAI;EACb,gBAAA,SAAS,EAAE,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe;kBACzF,UAAU,EAAE,UAAU,IAAG;EACvB,oBAAA,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;EACrB,wBAAA,OAAO,EAAE,CAAA;uBACV;sBAED,OAAO;0BACL,YAAY,EAAE,UAAU,CAAC,KAAK;EAC9B,wBAAA,KAAK,EAAE,CAAA,kBAAA,EAAqB,UAAU,CAAC,KAAK,CAAkB,gBAAA,CAAA;uBAC/D,CAAA;mBACF;EACF,aAAA;WACF,CAAA;OACF;MAED,SAAS,GAAA;UACP,OAAO;EACL,YAAA;EACE,gBAAA,GAAG,EAAE,MAAM;EACZ,aAAA;WACF,CAAA;OACF;MAED,UAAU,CAAC,EAAE,cAAc,EAAE,EAAA;EAC3B,QAAA,OAAO,CAAC,MAAM,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;OACjF;MAED,WAAW,GAAA;UACT,OAAO;cACL,YAAY,EAAE,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAI;kBAC3C,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;eAC/C;cACD,eAAe,EAAE,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAI;kBAC9C,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;eAClD;cACD,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;kBACrC,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;eACrC;WACF,CAAA;OACF;MAED,oBAAoB,GAAA;UAClB,OAAO;cACL,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE;WAC5D,CAAA;OACF;MAED,aAAa,GAAA;UACX,OAAO;EACL,YAAAC,kBAAa,CAAC;EACZ,gBAAA,IAAI,EAAE,UAAU;kBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;eAChB,CAAC;WACH,CAAA;OACF;MAED,aAAa,GAAA;UACX,OAAO;EACL,YAAAC,kBAAa,CAAC;EACZ,gBAAA,IAAI,EAAE,UAAU;kBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;eAChB,CAAC;WACH,CAAA;OACF;EACF,CAAA;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EditorState, Transaction } from '@tiptap/pm/state';
|
|
2
|
+
import { Editor } from './Editor.js';
|
|
3
|
+
import { AnyCommands, CanCommands, ChainedCommands, CommandProps, SingleCommands } from './types.js';
|
|
4
|
+
export declare class CommandManager {
|
|
5
|
+
editor: Editor;
|
|
6
|
+
rawCommands: AnyCommands;
|
|
7
|
+
customState?: EditorState;
|
|
8
|
+
constructor(props: {
|
|
9
|
+
editor: Editor;
|
|
10
|
+
state?: EditorState;
|
|
11
|
+
});
|
|
12
|
+
get hasCustomState(): boolean;
|
|
13
|
+
get state(): EditorState;
|
|
14
|
+
get commands(): SingleCommands;
|
|
15
|
+
get chain(): () => ChainedCommands;
|
|
16
|
+
get can(): () => CanCommands;
|
|
17
|
+
createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
|
|
18
|
+
createCan(startTr?: Transaction): CanCommands;
|
|
19
|
+
buildProps(tr: Transaction, shouldDispatch?: boolean): CommandProps;
|
|
20
|
+
}
|