@tiptap/extension-task-item 3.0.0 → 3.0.1

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.
Files changed (176) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +5 -1
  3. package/dist/index.cjs +32 -165
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +2 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +9 -161
  8. package/dist/index.js.map +1 -1
  9. package/package.json +11 -11
  10. package/src/index.ts +3 -2
  11. package/dist/index.umd.js +0 -171
  12. package/dist/index.umd.js.map +0 -1
  13. package/dist/packages/core/src/CommandManager.d.ts +0 -20
  14. package/dist/packages/core/src/Editor.d.ts +0 -161
  15. package/dist/packages/core/src/EventEmitter.d.ts +0 -11
  16. package/dist/packages/core/src/Extension.d.ts +0 -343
  17. package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
  18. package/dist/packages/core/src/InputRule.d.ts +0 -42
  19. package/dist/packages/core/src/Mark.d.ts +0 -451
  20. package/dist/packages/core/src/Node.d.ts +0 -611
  21. package/dist/packages/core/src/NodePos.d.ts +0 -44
  22. package/dist/packages/core/src/NodeView.d.ts +0 -31
  23. package/dist/packages/core/src/PasteRule.d.ts +0 -50
  24. package/dist/packages/core/src/Tracker.d.ts +0 -11
  25. package/dist/packages/core/src/commands/blur.d.ts +0 -13
  26. package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
  27. package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
  28. package/dist/packages/core/src/commands/command.d.ts +0 -18
  29. package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
  30. package/dist/packages/core/src/commands/cut.d.ts +0 -20
  31. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
  32. package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
  33. package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
  34. package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
  35. package/dist/packages/core/src/commands/enter.d.ts +0 -13
  36. package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
  37. package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
  38. package/dist/packages/core/src/commands/first.d.ts +0 -14
  39. package/dist/packages/core/src/commands/focus.d.ts +0 -27
  40. package/dist/packages/core/src/commands/forEach.d.ts +0 -14
  41. package/dist/packages/core/src/commands/index.d.ts +0 -55
  42. package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
  43. package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
  44. package/dist/packages/core/src/commands/join.d.ts +0 -41
  45. package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
  46. package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
  47. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
  48. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
  49. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
  50. package/dist/packages/core/src/commands/lift.d.ts +0 -17
  51. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
  52. package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
  53. package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
  54. package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
  55. package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
  56. package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
  57. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
  58. package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
  59. package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
  60. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
  61. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
  62. package/dist/packages/core/src/commands/setContent.d.ts +0 -40
  63. package/dist/packages/core/src/commands/setMark.d.ts +0 -15
  64. package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
  65. package/dist/packages/core/src/commands/setNode.d.ts +0 -16
  66. package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
  67. package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
  68. package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
  69. package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
  70. package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
  71. package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
  72. package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
  73. package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
  74. package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
  75. package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
  76. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
  77. package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
  78. package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
  79. package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
  80. package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
  81. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
  82. package/dist/packages/core/src/extensions/commands.d.ts +0 -3
  83. package/dist/packages/core/src/extensions/editable.d.ts +0 -2
  84. package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
  85. package/dist/packages/core/src/extensions/index.d.ts +0 -6
  86. package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
  87. package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
  88. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
  89. package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
  90. package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
  91. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
  92. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
  93. package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
  94. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
  95. package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
  96. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
  97. package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
  98. package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
  99. package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
  100. package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
  101. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
  102. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
  103. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
  104. package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
  105. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
  106. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
  107. package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
  108. package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
  109. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
  110. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
  111. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
  112. package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
  113. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
  114. package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
  115. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
  116. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
  117. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
  118. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
  119. package/dist/packages/core/src/helpers/getText.d.ts +0 -15
  120. package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
  121. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
  122. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
  123. package/dist/packages/core/src/helpers/index.d.ts +0 -50
  124. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
  125. package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
  126. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
  127. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
  128. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
  129. package/dist/packages/core/src/helpers/isList.d.ts +0 -2
  130. package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
  131. package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
  132. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
  133. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
  134. package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
  135. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
  136. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
  137. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
  138. package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
  139. package/dist/packages/core/src/index.d.ts +0 -24
  140. package/dist/packages/core/src/inputRules/index.d.ts +0 -5
  141. package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
  142. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
  143. package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
  144. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
  145. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
  146. package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
  147. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
  148. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
  149. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
  150. package/dist/packages/core/src/style.d.ts +0 -1
  151. package/dist/packages/core/src/types.d.ts +0 -255
  152. package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
  153. package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
  154. package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
  155. package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
  156. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
  157. package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
  158. package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
  159. package/dist/packages/core/src/utilities/index.d.ts +0 -20
  160. package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
  161. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
  162. package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
  163. package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
  164. package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
  165. package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
  166. package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
  167. package/dist/packages/core/src/utilities/isString.d.ts +0 -1
  168. package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
  169. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
  170. package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
  171. package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
  172. package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
  173. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
  174. package/dist/packages/extension-task-item/src/index.d.ts +0 -3
  175. package/dist/packages/extension-task-item/src/task-item.d.ts +0 -38
  176. package/src/task-item.ts +0 -220
package/dist/index.umd.js DELETED
@@ -1,171 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-task-item"] = {}, global.core));
5
- })(this, (function (exports, core) { 'use strict';
6
-
7
- /**
8
- * Matches a task item to a - [ ] on input.
9
- */
10
- const inputRegex = /^\s*(\[([( |x])?\])\s$/;
11
- /**
12
- * This extension allows you to create task items.
13
- * @see https://www.tiptap.dev/api/nodes/task-item
14
- */
15
- const TaskItem = core.Node.create({
16
- name: 'taskItem',
17
- addOptions() {
18
- return {
19
- nested: false,
20
- HTMLAttributes: {},
21
- taskListTypeName: 'taskList',
22
- };
23
- },
24
- content() {
25
- return this.options.nested ? 'paragraph block*' : 'paragraph+';
26
- },
27
- defining: true,
28
- addAttributes() {
29
- return {
30
- checked: {
31
- default: false,
32
- keepOnSplit: false,
33
- parseHTML: element => element.getAttribute('data-checked') === 'true',
34
- renderHTML: attributes => ({
35
- 'data-checked': attributes.checked,
36
- }),
37
- },
38
- };
39
- },
40
- parseHTML() {
41
- return [
42
- {
43
- tag: `li[data-type="${this.name}"]`,
44
- priority: 51,
45
- },
46
- ];
47
- },
48
- renderHTML({ node, HTMLAttributes }) {
49
- return [
50
- 'li',
51
- core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
52
- 'data-type': this.name,
53
- }),
54
- [
55
- 'label',
56
- [
57
- 'input',
58
- {
59
- type: 'checkbox',
60
- checked: node.attrs.checked ? 'checked' : null,
61
- },
62
- ],
63
- ['span'],
64
- ],
65
- ['div', 0],
66
- ];
67
- },
68
- addKeyboardShortcuts() {
69
- const shortcuts = {
70
- Enter: () => this.editor.commands.splitListItem(this.name),
71
- 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),
72
- };
73
- if (!this.options.nested) {
74
- return shortcuts;
75
- }
76
- return {
77
- ...shortcuts,
78
- Tab: () => this.editor.commands.sinkListItem(this.name),
79
- };
80
- },
81
- addNodeView() {
82
- return ({ node, HTMLAttributes, getPos, editor, }) => {
83
- const listItem = document.createElement('li');
84
- const checkboxWrapper = document.createElement('label');
85
- const checkboxStyler = document.createElement('span');
86
- const checkbox = document.createElement('input');
87
- const content = document.createElement('div');
88
- checkboxWrapper.contentEditable = 'false';
89
- checkbox.type = 'checkbox';
90
- checkbox.addEventListener('change', event => {
91
- // if the editor isn’t editable and we don't have a handler for
92
- // readonly checks we have to undo the latest change
93
- if (!editor.isEditable && !this.options.onReadOnlyChecked) {
94
- checkbox.checked = !checkbox.checked;
95
- return;
96
- }
97
- const { checked } = event.target;
98
- if (editor.isEditable && typeof getPos === 'function') {
99
- editor
100
- .chain()
101
- .focus(undefined, { scrollIntoView: false })
102
- .command(({ tr }) => {
103
- const position = getPos();
104
- const currentNode = tr.doc.nodeAt(position);
105
- tr.setNodeMarkup(position, undefined, {
106
- ...currentNode === null || currentNode === void 0 ? void 0 : currentNode.attrs,
107
- checked,
108
- });
109
- return true;
110
- })
111
- .run();
112
- }
113
- if (!editor.isEditable && this.options.onReadOnlyChecked) {
114
- // Reset state if onReadOnlyChecked returns false
115
- if (!this.options.onReadOnlyChecked(node, checked)) {
116
- checkbox.checked = !checkbox.checked;
117
- }
118
- }
119
- });
120
- Object.entries(this.options.HTMLAttributes).forEach(([key, value]) => {
121
- listItem.setAttribute(key, value);
122
- });
123
- listItem.dataset.checked = node.attrs.checked;
124
- if (node.attrs.checked) {
125
- checkbox.setAttribute('checked', 'checked');
126
- }
127
- checkboxWrapper.append(checkbox, checkboxStyler);
128
- listItem.append(checkboxWrapper, content);
129
- Object.entries(HTMLAttributes).forEach(([key, value]) => {
130
- listItem.setAttribute(key, value);
131
- });
132
- return {
133
- dom: listItem,
134
- contentDOM: content,
135
- update: updatedNode => {
136
- if (updatedNode.type !== this.type) {
137
- return false;
138
- }
139
- listItem.dataset.checked = updatedNode.attrs.checked;
140
- if (updatedNode.attrs.checked) {
141
- checkbox.setAttribute('checked', 'checked');
142
- }
143
- else {
144
- checkbox.removeAttribute('checked');
145
- }
146
- return true;
147
- },
148
- };
149
- };
150
- },
151
- addInputRules() {
152
- return [
153
- core.wrappingInputRule({
154
- find: inputRegex,
155
- type: this.type,
156
- getAttributes: match => ({
157
- checked: match[match.length - 1] === 'x',
158
- }),
159
- }),
160
- ];
161
- },
162
- });
163
-
164
- exports.TaskItem = TaskItem;
165
- exports.default = TaskItem;
166
- exports.inputRegex = inputRegex;
167
-
168
- Object.defineProperty(exports, '__esModule', { value: true });
169
-
170
- }));
171
- //# sourceMappingURL=index.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/task-item.ts"],"sourcesContent":["import {\n KeyboardShortcutCommand, mergeAttributes, Node, wrappingInputRule,\n} from '@tiptap/core'\nimport { Node as ProseMirrorNode } from '@tiptap/pm/model'\n\nexport interface TaskItemOptions {\n /**\n * A callback function that is called when the checkbox is clicked while the editor is in readonly mode.\n * @param node The prosemirror node of the task item\n * @param checked The new checked state\n * @returns boolean\n */\n onReadOnlyChecked?: (node: ProseMirrorNode, checked: boolean) => boolean\n\n /**\n * Controls whether the task items can be nested or not.\n * @default false\n * @example true\n */\n nested: boolean\n\n /**\n * HTML attributes to add to the task item element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n\n /**\n * The node type for taskList nodes\n * @default 'taskList'\n * @example 'myCustomTaskList'\n */\n taskListTypeName: string\n}\n\n/**\n * Matches a task item to a - [ ] on input.\n */\nexport const inputRegex = /^\\s*(\\[([( |x])?\\])\\s$/\n\n/**\n * This extension allows you to create task items.\n * @see https://www.tiptap.dev/api/nodes/task-item\n */\nexport const TaskItem = Node.create<TaskItemOptions>({\n name: 'taskItem',\n\n addOptions() {\n return {\n nested: false,\n HTMLAttributes: {},\n taskListTypeName: 'taskList',\n }\n },\n\n content() {\n return this.options.nested ? 'paragraph block*' : 'paragraph+'\n },\n\n defining: true,\n\n addAttributes() {\n return {\n checked: {\n default: false,\n keepOnSplit: false,\n parseHTML: element => element.getAttribute('data-checked') === 'true',\n renderHTML: attributes => ({\n 'data-checked': attributes.checked,\n }),\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: `li[data-type=\"${this.name}\"]`,\n priority: 51,\n },\n ]\n },\n\n renderHTML({ node, HTMLAttributes }) {\n return [\n 'li',\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {\n 'data-type': this.name,\n }),\n [\n 'label',\n [\n 'input',\n {\n type: 'checkbox',\n checked: node.attrs.checked ? 'checked' : null,\n },\n ],\n ['span'],\n ],\n ['div', 0],\n ]\n },\n\n addKeyboardShortcuts() {\n const shortcuts: {\n [key: string]: KeyboardShortcutCommand\n } = {\n Enter: () => this.editor.commands.splitListItem(this.name),\n 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),\n }\n\n if (!this.options.nested) {\n return shortcuts\n }\n\n return {\n ...shortcuts,\n Tab: () => this.editor.commands.sinkListItem(this.name),\n }\n },\n\n addNodeView() {\n return ({\n node, HTMLAttributes, getPos, editor,\n }) => {\n const listItem = document.createElement('li')\n const checkboxWrapper = document.createElement('label')\n const checkboxStyler = document.createElement('span')\n const checkbox = document.createElement('input')\n const content = document.createElement('div')\n\n checkboxWrapper.contentEditable = 'false'\n checkbox.type = 'checkbox'\n checkbox.addEventListener('change', event => {\n // if the editor isn’t editable and we don't have a handler for\n // readonly checks we have to undo the latest change\n if (!editor.isEditable && !this.options.onReadOnlyChecked) {\n checkbox.checked = !checkbox.checked\n\n return\n }\n\n const { checked } = event.target as any\n\n if (editor.isEditable && typeof getPos === 'function') {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .command(({ tr }) => {\n const position = getPos()\n const currentNode = tr.doc.nodeAt(position)\n\n tr.setNodeMarkup(position, undefined, {\n ...currentNode?.attrs,\n checked,\n })\n\n return true\n })\n .run()\n }\n if (!editor.isEditable && this.options.onReadOnlyChecked) {\n // Reset state if onReadOnlyChecked returns false\n if (!this.options.onReadOnlyChecked(node, checked)) {\n checkbox.checked = !checkbox.checked\n }\n }\n })\n\n Object.entries(this.options.HTMLAttributes).forEach(([key, value]) => {\n listItem.setAttribute(key, value)\n })\n\n listItem.dataset.checked = node.attrs.checked\n if (node.attrs.checked) {\n checkbox.setAttribute('checked', 'checked')\n }\n\n checkboxWrapper.append(checkbox, checkboxStyler)\n listItem.append(checkboxWrapper, content)\n\n Object.entries(HTMLAttributes).forEach(([key, value]) => {\n listItem.setAttribute(key, value)\n })\n\n return {\n dom: listItem,\n contentDOM: content,\n update: updatedNode => {\n if (updatedNode.type !== this.type) {\n return false\n }\n\n listItem.dataset.checked = updatedNode.attrs.checked\n if (updatedNode.attrs.checked) {\n checkbox.setAttribute('checked', 'checked')\n } else {\n checkbox.removeAttribute('checked')\n }\n\n return true\n },\n }\n }\n },\n\n addInputRules() {\n return [\n wrappingInputRule({\n find: inputRegex,\n type: this.type,\n getAttributes: match => ({\n checked: match[match.length - 1] === 'x',\n }),\n }),\n ]\n },\n})\n"],"names":["Node","mergeAttributes","wrappingInputRule"],"mappings":";;;;;;EAoCA;;EAEG;AACI,QAAM,UAAU,GAAG,yBAAwB;EAElD;;;EAGG;AACU,QAAA,QAAQ,GAAGA,SAAI,CAAC,MAAM,CAAkB;EACnD,IAAA,IAAI,EAAE,UAAU;MAEhB,UAAU,GAAA;UACR,OAAO;EACL,YAAA,MAAM,EAAE,KAAK;EACb,YAAA,cAAc,EAAE,EAAE;EAClB,YAAA,gBAAgB,EAAE,UAAU;WAC7B,CAAA;OACF;MAED,OAAO,GAAA;EACL,QAAA,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,kBAAkB,GAAG,YAAY,CAAA;OAC/D;EAED,IAAA,QAAQ,EAAE,IAAI;MAEd,aAAa,GAAA;UACX,OAAO;EACL,YAAA,OAAO,EAAE;EACP,gBAAA,OAAO,EAAE,KAAK;EACd,gBAAA,WAAW,EAAE,KAAK;EAClB,gBAAA,SAAS,EAAE,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,KAAK,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AAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;EACtD,gBAAA,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;EACnC,aAAC,CAAC,CAAA;cAEF,OAAO;EACL,gBAAA,GAAG,EAAE,QAAQ;EACb,gBAAA,UAAU,EAAE,OAAO;kBACnB,MAAM,EAAE,WAAW,IAAG;sBACpB,IAAI,WAAW,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE;EAClC,wBAAA,OAAO,KAAK,CAAA;uBACb;sBAED,QAAQ,CAAC,OAAO,CAAC,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,CAAA;EACpD,oBAAA,IAAI,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE;EAC7B,wBAAA,QAAQ,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;uBAC5C;2BAAM;EACL,wBAAA,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;uBACpC;EAED,oBAAA,OAAO,IAAI,CAAA;mBACZ;eACF,CAAA;EACH,SAAC,CAAA;OACF;MAED,aAAa,GAAA;UACX,OAAO;EACL,YAAAC,sBAAiB,CAAC;EAChB,gBAAA,IAAI,EAAE,UAAU;kBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;EACf,gBAAA,aAAa,EAAE,KAAK,KAAK;sBACvB,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG;mBACzC,CAAC;eACH,CAAC;WACH,CAAA;OACF;EACF,CAAA;;;;;;;;;;;;"}
@@ -1,20 +0,0 @@
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
- }
@@ -1,161 +0,0 @@
1
- import { MarkType, NodeType, Schema } from '@tiptap/pm/model';
2
- import { EditorState, Plugin, PluginKey, Transaction } from '@tiptap/pm/state';
3
- import { EditorView } from '@tiptap/pm/view';
4
- import { EventEmitter } from './EventEmitter.js';
5
- import { ExtensionManager } from './ExtensionManager.js';
6
- import { NodePos } from './NodePos.js';
7
- import { CanCommands, ChainedCommands, EditorEvents, EditorOptions, JSONContent, SingleCommands, TextSerializer } from './types.js';
8
- export * as extensions from './extensions/index.js';
9
- declare global {
10
- interface HTMLElement {
11
- editor?: Editor;
12
- }
13
- }
14
- export declare class Editor extends EventEmitter<EditorEvents> {
15
- private commandManager;
16
- extensionManager: ExtensionManager;
17
- private css;
18
- schema: Schema;
19
- view: EditorView;
20
- isFocused: boolean;
21
- extensionStorage: Record<string, any>;
22
- options: EditorOptions;
23
- constructor(options?: Partial<EditorOptions>);
24
- /**
25
- * Returns the editor storage.
26
- */
27
- get storage(): Record<string, any>;
28
- /**
29
- * An object of all registered commands.
30
- */
31
- get commands(): SingleCommands;
32
- /**
33
- * Create a command chain to call multiple commands at once.
34
- */
35
- chain(): ChainedCommands;
36
- /**
37
- * Check if a command or a command chain can be executed. Without executing it.
38
- */
39
- can(): CanCommands;
40
- /**
41
- * Inject CSS styles.
42
- */
43
- private injectCSS;
44
- /**
45
- * Update editor options.
46
- *
47
- * @param options A list of options
48
- */
49
- setOptions(options?: Partial<EditorOptions>): void;
50
- /**
51
- * Update editable state of the editor.
52
- */
53
- setEditable(editable: boolean, emitUpdate?: boolean): void;
54
- /**
55
- * Returns whether the editor is editable.
56
- */
57
- get isEditable(): boolean;
58
- /**
59
- * Returns the editor state.
60
- */
61
- get state(): EditorState;
62
- /**
63
- * Register a ProseMirror plugin.
64
- *
65
- * @param plugin A ProseMirror plugin
66
- * @param handlePlugins Control how to merge the plugin into the existing plugins.
67
- */
68
- registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): void;
69
- /**
70
- * Unregister a ProseMirror plugin.
71
- *
72
- * @param nameOrPluginKey The plugins name
73
- */
74
- unregisterPlugin(nameOrPluginKey: string | PluginKey): void;
75
- /**
76
- * Creates an extension manager.
77
- */
78
- private createExtensionManager;
79
- /**
80
- * Creates an command manager.
81
- */
82
- private createCommandManager;
83
- /**
84
- * Creates a ProseMirror schema.
85
- */
86
- private createSchema;
87
- /**
88
- * Creates a ProseMirror view.
89
- */
90
- private createView;
91
- /**
92
- * Creates all node views.
93
- */
94
- createNodeViews(): void;
95
- /**
96
- * Prepend class name to element.
97
- */
98
- prependClass(): void;
99
- isCapturingTransaction: boolean;
100
- private capturedTransaction;
101
- captureTransaction(fn: Function): Transaction | null;
102
- /**
103
- * The callback over which to send transactions (state updates) produced by the view.
104
- *
105
- * @param transaction An editor state transaction
106
- */
107
- private dispatchTransaction;
108
- /**
109
- * Get attributes of the currently selected node or mark.
110
- */
111
- getAttributes(nameOrType: string | NodeType | MarkType): Record<string, any>;
112
- /**
113
- * Returns if the currently selected node or mark is active.
114
- *
115
- * @param name Name of the node or mark
116
- * @param attributes Attributes of the node or mark
117
- */
118
- isActive(name: string, attributes?: {}): boolean;
119
- isActive(attributes: {}): boolean;
120
- /**
121
- * Get the document as JSON.
122
- */
123
- getJSON(): JSONContent;
124
- /**
125
- * Get the document as HTML.
126
- */
127
- getHTML(): string;
128
- /**
129
- * Get the document as text.
130
- */
131
- getText(options?: {
132
- blockSeparator?: string;
133
- textSerializers?: Record<string, TextSerializer>;
134
- }): string;
135
- /**
136
- * Check if there is no content.
137
- */
138
- get isEmpty(): boolean;
139
- /**
140
- * Get the number of characters for the current document.
141
- *
142
- * @deprecated
143
- */
144
- getCharacterCount(): number;
145
- /**
146
- * Destroy the editor.
147
- */
148
- destroy(): void;
149
- /**
150
- * Check if the editor is already destroyed.
151
- */
152
- get isDestroyed(): boolean;
153
- $node(selector: string, attributes?: {
154
- [key: string]: any;
155
- }): NodePos | null;
156
- $nodes(selector: string, attributes?: {
157
- [key: string]: any;
158
- }): NodePos[] | null;
159
- $pos(pos: number): NodePos;
160
- get $doc(): NodePos;
161
- }
@@ -1,11 +0,0 @@
1
- type StringKeyOf<T> = Extract<keyof T, string>;
2
- type CallbackType<T extends Record<string, any>, EventName extends StringKeyOf<T>> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];
3
- type CallbackFunction<T extends Record<string, any>, EventName extends StringKeyOf<T>> = (...props: CallbackType<T, EventName>) => any;
4
- export declare class EventEmitter<T extends Record<string, any>> {
5
- private callbacks;
6
- on<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this;
7
- emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this;
8
- off<EventName extends StringKeyOf<T>>(event: EventName, fn?: CallbackFunction<T, EventName>): this;
9
- removeAllListeners(): void;
10
- }
11
- export {};