@tiptap/extension-bullet-list 2.5.0-beta.2 → 2.5.0-beta.4

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 (174) hide show
  1. package/dist/index.cjs +140 -140
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +139 -139
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.umd.js +140 -140
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/packages/core/src/CommandManager.d.ts +20 -0
  8. package/dist/packages/core/src/Editor.d.ts +161 -0
  9. package/dist/packages/core/src/EventEmitter.d.ts +11 -0
  10. package/dist/packages/core/src/Extension.d.ts +343 -0
  11. package/dist/packages/core/src/ExtensionManager.d.ts +55 -0
  12. package/dist/packages/core/src/InputRule.d.ts +42 -0
  13. package/dist/packages/core/src/Mark.d.ts +451 -0
  14. package/dist/packages/core/src/Node.d.ts +611 -0
  15. package/dist/packages/core/src/NodePos.d.ts +44 -0
  16. package/dist/packages/core/src/NodeView.d.ts +31 -0
  17. package/dist/packages/core/src/PasteRule.d.ts +50 -0
  18. package/dist/packages/core/src/Tracker.d.ts +11 -0
  19. package/dist/packages/core/src/commands/blur.d.ts +13 -0
  20. package/dist/packages/core/src/commands/clearContent.d.ts +14 -0
  21. package/dist/packages/core/src/commands/clearNodes.d.ts +13 -0
  22. package/dist/packages/core/src/commands/command.d.ts +18 -0
  23. package/dist/packages/core/src/commands/createParagraphNear.d.ts +13 -0
  24. package/dist/packages/core/src/commands/cut.d.ts +20 -0
  25. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +13 -0
  26. package/dist/packages/core/src/commands/deleteNode.d.ts +15 -0
  27. package/dist/packages/core/src/commands/deleteRange.d.ts +14 -0
  28. package/dist/packages/core/src/commands/deleteSelection.d.ts +13 -0
  29. package/dist/packages/core/src/commands/enter.d.ts +13 -0
  30. package/dist/packages/core/src/commands/exitCode.d.ts +13 -0
  31. package/dist/packages/core/src/commands/extendMarkRange.d.ts +25 -0
  32. package/dist/packages/core/src/commands/first.d.ts +14 -0
  33. package/dist/packages/core/src/commands/focus.d.ts +27 -0
  34. package/dist/packages/core/src/commands/forEach.d.ts +14 -0
  35. package/dist/packages/core/src/commands/index.d.ts +55 -0
  36. package/dist/packages/core/src/commands/insertContent.d.ts +34 -0
  37. package/dist/packages/core/src/commands/insertContentAt.d.ts +47 -0
  38. package/dist/packages/core/src/commands/join.d.ts +41 -0
  39. package/dist/packages/core/src/commands/joinItemBackward.d.ts +13 -0
  40. package/dist/packages/core/src/commands/joinItemForward.d.ts +13 -0
  41. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +12 -0
  42. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +12 -0
  43. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +14 -0
  44. package/dist/packages/core/src/commands/lift.d.ts +17 -0
  45. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +13 -0
  46. package/dist/packages/core/src/commands/liftListItem.d.ts +15 -0
  47. package/dist/packages/core/src/commands/newlineInCode.d.ts +13 -0
  48. package/dist/packages/core/src/commands/resetAttributes.d.ts +16 -0
  49. package/dist/packages/core/src/commands/scrollIntoView.d.ts +13 -0
  50. package/dist/packages/core/src/commands/selectAll.d.ts +13 -0
  51. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +13 -0
  52. package/dist/packages/core/src/commands/selectNodeForward.d.ts +13 -0
  53. package/dist/packages/core/src/commands/selectParentNode.d.ts +13 -0
  54. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +13 -0
  55. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +13 -0
  56. package/dist/packages/core/src/commands/setContent.d.ts +40 -0
  57. package/dist/packages/core/src/commands/setMark.d.ts +15 -0
  58. package/dist/packages/core/src/commands/setMeta.d.ts +15 -0
  59. package/dist/packages/core/src/commands/setNode.d.ts +16 -0
  60. package/dist/packages/core/src/commands/setNodeSelection.d.ts +14 -0
  61. package/dist/packages/core/src/commands/setTextSelection.d.ts +14 -0
  62. package/dist/packages/core/src/commands/sinkListItem.d.ts +15 -0
  63. package/dist/packages/core/src/commands/splitBlock.d.ts +17 -0
  64. package/dist/packages/core/src/commands/splitListItem.d.ts +15 -0
  65. package/dist/packages/core/src/commands/toggleList.d.ts +18 -0
  66. package/dist/packages/core/src/commands/toggleMark.d.ts +30 -0
  67. package/dist/packages/core/src/commands/toggleNode.d.ts +17 -0
  68. package/dist/packages/core/src/commands/toggleWrap.d.ts +16 -0
  69. package/dist/packages/core/src/commands/undoInputRule.d.ts +13 -0
  70. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +13 -0
  71. package/dist/packages/core/src/commands/unsetMark.d.ts +25 -0
  72. package/dist/packages/core/src/commands/updateAttributes.d.ts +24 -0
  73. package/dist/packages/core/src/commands/wrapIn.d.ts +16 -0
  74. package/dist/packages/core/src/commands/wrapInList.d.ts +16 -0
  75. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +5 -0
  76. package/dist/packages/core/src/extensions/commands.d.ts +3 -0
  77. package/dist/packages/core/src/extensions/editable.d.ts +2 -0
  78. package/dist/packages/core/src/extensions/focusEvents.d.ts +2 -0
  79. package/dist/packages/core/src/extensions/index.d.ts +6 -0
  80. package/dist/packages/core/src/extensions/keymap.d.ts +2 -0
  81. package/dist/packages/core/src/extensions/tabindex.d.ts +2 -0
  82. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +10 -0
  83. package/dist/packages/core/src/helpers/createChainableState.d.ts +10 -0
  84. package/dist/packages/core/src/helpers/createDocument.d.ts +12 -0
  85. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +15 -0
  86. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +7 -0
  87. package/dist/packages/core/src/helpers/findChildren.d.ts +9 -0
  88. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +10 -0
  89. package/dist/packages/core/src/helpers/findParentNode.d.ts +16 -0
  90. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +17 -0
  91. package/dist/packages/core/src/helpers/generateHTML.d.ts +8 -0
  92. package/dist/packages/core/src/helpers/generateJSON.d.ts +8 -0
  93. package/dist/packages/core/src/helpers/generateText.d.ts +12 -0
  94. package/dist/packages/core/src/helpers/getAttributes.d.ts +9 -0
  95. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +6 -0
  96. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +11 -0
  97. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +8 -0
  98. package/dist/packages/core/src/helpers/getExtensionField.d.ts +9 -0
  99. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +2 -0
  100. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +3 -0
  101. package/dist/packages/core/src/helpers/getMarkRange.d.ts +3 -0
  102. package/dist/packages/core/src/helpers/getMarkType.d.ts +2 -0
  103. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +3 -0
  104. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +11 -0
  105. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +3 -0
  106. package/dist/packages/core/src/helpers/getNodeType.d.ts +2 -0
  107. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +3 -0
  108. package/dist/packages/core/src/helpers/getSchema.d.ts +4 -0
  109. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +10 -0
  110. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +8 -0
  111. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +8 -0
  112. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +9 -0
  113. package/dist/packages/core/src/helpers/getText.d.ts +15 -0
  114. package/dist/packages/core/src/helpers/getTextBetween.d.ts +14 -0
  115. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +8 -0
  116. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +8 -0
  117. package/dist/packages/core/src/helpers/index.d.ts +50 -0
  118. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +9 -0
  119. package/dist/packages/core/src/helpers/isActive.d.ts +2 -0
  120. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +2 -0
  121. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +2 -0
  122. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +2 -0
  123. package/dist/packages/core/src/helpers/isList.d.ts +2 -0
  124. package/dist/packages/core/src/helpers/isMarkActive.d.ts +3 -0
  125. package/dist/packages/core/src/helpers/isNodeActive.d.ts +3 -0
  126. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +2 -0
  127. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +2 -0
  128. package/dist/packages/core/src/helpers/isTextSelection.d.ts +2 -0
  129. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +2 -0
  130. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +4 -0
  131. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +2 -0
  132. package/dist/packages/core/src/helpers/splitExtensions.d.ts +9 -0
  133. package/dist/packages/core/src/index.d.ts +24 -0
  134. package/dist/packages/core/src/inputRules/index.d.ts +5 -0
  135. package/dist/packages/core/src/inputRules/markInputRule.d.ts +13 -0
  136. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +23 -0
  137. package/dist/packages/core/src/inputRules/textInputRule.d.ts +10 -0
  138. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +15 -0
  139. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +28 -0
  140. package/dist/packages/core/src/pasteRules/index.d.ts +3 -0
  141. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +13 -0
  142. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +13 -0
  143. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +10 -0
  144. package/dist/packages/core/src/style.d.ts +1 -0
  145. package/dist/packages/core/src/types.d.ts +250 -0
  146. package/dist/packages/core/src/utilities/callOrReturn.d.ts +9 -0
  147. package/dist/packages/core/src/utilities/createStyleTag.d.ts +1 -0
  148. package/dist/packages/core/src/utilities/deleteProps.d.ts +6 -0
  149. package/dist/packages/core/src/utilities/elementFromString.d.ts +1 -0
  150. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +1 -0
  151. package/dist/packages/core/src/utilities/findDuplicates.d.ts +1 -0
  152. package/dist/packages/core/src/utilities/fromString.d.ts +1 -0
  153. package/dist/packages/core/src/utilities/index.d.ts +20 -0
  154. package/dist/packages/core/src/utilities/isAndroid.d.ts +1 -0
  155. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +1 -0
  156. package/dist/packages/core/src/utilities/isFunction.d.ts +1 -0
  157. package/dist/packages/core/src/utilities/isMacOS.d.ts +1 -0
  158. package/dist/packages/core/src/utilities/isNumber.d.ts +1 -0
  159. package/dist/packages/core/src/utilities/isPlainObject.d.ts +1 -0
  160. package/dist/packages/core/src/utilities/isRegExp.d.ts +1 -0
  161. package/dist/packages/core/src/utilities/isString.d.ts +1 -0
  162. package/dist/packages/core/src/utilities/isiOS.d.ts +1 -0
  163. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +1 -0
  164. package/dist/packages/core/src/utilities/mergeDeep.d.ts +1 -0
  165. package/dist/packages/core/src/utilities/minMax.d.ts +1 -0
  166. package/dist/packages/core/src/utilities/objectIncludes.d.ts +8 -0
  167. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +8 -0
  168. package/dist/packages/extension-bullet-list/src/bullet-list.d.ts +48 -48
  169. package/dist/packages/extension-bullet-list/src/index.d.ts +3 -3
  170. package/dist/packages/extension-list-item/src/index.d.ts +3 -3
  171. package/dist/packages/extension-list-item/src/list-item.d.ts +26 -26
  172. package/dist/packages/extension-text-style/src/index.d.ts +3 -3
  173. package/dist/packages/extension-text-style/src/text-style.d.ts +26 -26
  174. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -4,152 +4,152 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@tiptap/core');
6
6
 
7
- /**
8
- * This extension allows you to create list items.
9
- * @see https://www.tiptap.dev/api/nodes/list-item
10
- */
11
- const ListItem = core.Node.create({
12
- name: 'listItem',
13
- addOptions() {
14
- return {
15
- HTMLAttributes: {},
16
- bulletListTypeName: 'bulletList',
17
- orderedListTypeName: 'orderedList',
18
- };
19
- },
20
- content: 'paragraph block*',
21
- defining: true,
22
- parseHTML() {
23
- return [
24
- {
25
- tag: 'li',
26
- },
27
- ];
28
- },
29
- renderHTML({ HTMLAttributes }) {
30
- return ['li', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
31
- },
32
- addKeyboardShortcuts() {
33
- return {
34
- Enter: () => this.editor.commands.splitListItem(this.name),
35
- Tab: () => this.editor.commands.sinkListItem(this.name),
36
- 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),
37
- };
38
- },
7
+ /**
8
+ * This extension allows you to create list items.
9
+ * @see https://www.tiptap.dev/api/nodes/list-item
10
+ */
11
+ const ListItem = core.Node.create({
12
+ name: 'listItem',
13
+ addOptions() {
14
+ return {
15
+ HTMLAttributes: {},
16
+ bulletListTypeName: 'bulletList',
17
+ orderedListTypeName: 'orderedList',
18
+ };
19
+ },
20
+ content: 'paragraph block*',
21
+ defining: true,
22
+ parseHTML() {
23
+ return [
24
+ {
25
+ tag: 'li',
26
+ },
27
+ ];
28
+ },
29
+ renderHTML({ HTMLAttributes }) {
30
+ return ['li', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
31
+ },
32
+ addKeyboardShortcuts() {
33
+ return {
34
+ Enter: () => this.editor.commands.splitListItem(this.name),
35
+ Tab: () => this.editor.commands.sinkListItem(this.name),
36
+ 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),
37
+ };
38
+ },
39
39
  });
40
40
 
41
- /**
42
- * This extension allows you to create text styles. It is required by default
43
- * for the `textColor` and `backgroundColor` extensions.
44
- * @see https://www.tiptap.dev/api/marks/text-style
45
- */
46
- const TextStyle = core.Mark.create({
47
- name: 'textStyle',
48
- addOptions() {
49
- return {
50
- HTMLAttributes: {},
51
- };
52
- },
53
- parseHTML() {
54
- return [
55
- {
56
- tag: 'span',
57
- getAttrs: element => {
58
- const hasStyles = element.hasAttribute('style');
59
- if (!hasStyles) {
60
- return false;
61
- }
62
- return {};
63
- },
64
- },
65
- ];
66
- },
67
- renderHTML({ HTMLAttributes }) {
68
- return ['span', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
69
- },
70
- addCommands() {
71
- return {
72
- removeEmptyTextStyle: () => ({ state, commands }) => {
73
- const attributes = core.getMarkAttributes(state, this.type);
74
- const hasStyles = Object.entries(attributes).some(([, value]) => !!value);
75
- if (hasStyles) {
76
- return true;
77
- }
78
- return commands.unsetMark(this.name);
79
- },
80
- };
81
- },
41
+ /**
42
+ * This extension allows you to create text styles. It is required by default
43
+ * for the `textColor` and `backgroundColor` extensions.
44
+ * @see https://www.tiptap.dev/api/marks/text-style
45
+ */
46
+ const TextStyle = core.Mark.create({
47
+ name: 'textStyle',
48
+ addOptions() {
49
+ return {
50
+ HTMLAttributes: {},
51
+ };
52
+ },
53
+ parseHTML() {
54
+ return [
55
+ {
56
+ tag: 'span',
57
+ getAttrs: element => {
58
+ const hasStyles = element.hasAttribute('style');
59
+ if (!hasStyles) {
60
+ return false;
61
+ }
62
+ return {};
63
+ },
64
+ },
65
+ ];
66
+ },
67
+ renderHTML({ HTMLAttributes }) {
68
+ return ['span', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
69
+ },
70
+ addCommands() {
71
+ return {
72
+ removeEmptyTextStyle: () => ({ state, commands }) => {
73
+ const attributes = core.getMarkAttributes(state, this.type);
74
+ const hasStyles = Object.entries(attributes).some(([, value]) => !!value);
75
+ if (hasStyles) {
76
+ return true;
77
+ }
78
+ return commands.unsetMark(this.name);
79
+ },
80
+ };
81
+ },
82
82
  });
83
83
 
84
- /**
85
- * Matches a bullet list to a dash or asterisk.
86
- */
87
- const inputRegex = /^\s*([-+*])\s$/;
88
- /**
89
- * This extension allows you to create bullet lists.
90
- * This requires the ListItem extension
91
- * @see https://tiptap.dev/api/nodes/bullet-list
92
- * @see https://tiptap.dev/api/nodes/list-item.
93
- */
94
- const BulletList = core.Node.create({
95
- name: 'bulletList',
96
- addOptions() {
97
- return {
98
- itemTypeName: 'listItem',
99
- HTMLAttributes: {},
100
- keepMarks: false,
101
- keepAttributes: false,
102
- };
103
- },
104
- group: 'block list',
105
- content() {
106
- return `${this.options.itemTypeName}+`;
107
- },
108
- parseHTML() {
109
- return [
110
- { tag: 'ul' },
111
- ];
112
- },
113
- renderHTML({ HTMLAttributes }) {
114
- return ['ul', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
115
- },
116
- addCommands() {
117
- return {
118
- toggleBulletList: () => ({ commands, chain }) => {
119
- if (this.options.keepAttributes) {
120
- return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run();
121
- }
122
- return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
123
- },
124
- };
125
- },
126
- addKeyboardShortcuts() {
127
- return {
128
- 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
129
- };
130
- },
131
- addInputRules() {
132
- let inputRule = core.wrappingInputRule({
133
- find: inputRegex,
134
- type: this.type,
135
- });
136
- if (this.options.keepMarks || this.options.keepAttributes) {
137
- inputRule = core.wrappingInputRule({
138
- find: inputRegex,
139
- type: this.type,
140
- keepMarks: this.options.keepMarks,
141
- keepAttributes: this.options.keepAttributes,
142
- getAttributes: () => { return this.editor.getAttributes(TextStyle.name); },
143
- editor: this.editor,
144
- });
145
- }
146
- return [
147
- inputRule,
148
- ];
149
- },
84
+ /**
85
+ * Matches a bullet list to a dash or asterisk.
86
+ */
87
+ const inputRegex = /^\s*([-+*])\s$/;
88
+ /**
89
+ * This extension allows you to create bullet lists.
90
+ * This requires the ListItem extension
91
+ * @see https://tiptap.dev/api/nodes/bullet-list
92
+ * @see https://tiptap.dev/api/nodes/list-item.
93
+ */
94
+ const BulletList = core.Node.create({
95
+ name: 'bulletList',
96
+ addOptions() {
97
+ return {
98
+ itemTypeName: 'listItem',
99
+ HTMLAttributes: {},
100
+ keepMarks: false,
101
+ keepAttributes: false,
102
+ };
103
+ },
104
+ group: 'block list',
105
+ content() {
106
+ return `${this.options.itemTypeName}+`;
107
+ },
108
+ parseHTML() {
109
+ return [
110
+ { tag: 'ul' },
111
+ ];
112
+ },
113
+ renderHTML({ HTMLAttributes }) {
114
+ return ['ul', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
115
+ },
116
+ addCommands() {
117
+ return {
118
+ toggleBulletList: () => ({ commands, chain }) => {
119
+ if (this.options.keepAttributes) {
120
+ return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run();
121
+ }
122
+ return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
123
+ },
124
+ };
125
+ },
126
+ addKeyboardShortcuts() {
127
+ return {
128
+ 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
129
+ };
130
+ },
131
+ addInputRules() {
132
+ let inputRule = core.wrappingInputRule({
133
+ find: inputRegex,
134
+ type: this.type,
135
+ });
136
+ if (this.options.keepMarks || this.options.keepAttributes) {
137
+ inputRule = core.wrappingInputRule({
138
+ find: inputRegex,
139
+ type: this.type,
140
+ keepMarks: this.options.keepMarks,
141
+ keepAttributes: this.options.keepAttributes,
142
+ getAttributes: () => { return this.editor.getAttributes(TextStyle.name); },
143
+ editor: this.editor,
144
+ });
145
+ }
146
+ return [
147
+ inputRule,
148
+ ];
149
+ },
150
150
  });
151
151
 
152
152
  exports.BulletList = BulletList;
153
- exports["default"] = BulletList;
153
+ exports.default = BulletList;
154
154
  exports.inputRegex = inputRegex;
155
155
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../extension-list-item/src/list-item.ts","../../extension-text-style/src/text-style.ts","../src/bullet-list.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\n\nexport interface ListItemOptions {\n /**\n * The HTML attributes for a list item node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n\n /**\n * The node type for bulletList nodes\n * @default 'bulletList'\n * @example 'myCustomBulletList'\n */\n bulletListTypeName: string\n\n /**\n * The node type for orderedList nodes\n * @default 'orderedList'\n * @example 'myCustomOrderedList'\n */\n orderedListTypeName: string\n}\n\n/**\n * This extension allows you to create list items.\n * @see https://www.tiptap.dev/api/nodes/list-item\n */\nexport const ListItem = Node.create<ListItemOptions>({\n name: 'listItem',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n bulletListTypeName: 'bulletList',\n orderedListTypeName: 'orderedList',\n }\n },\n\n content: 'paragraph block*',\n\n defining: true,\n\n parseHTML() {\n return [\n {\n tag: 'li',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['li', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addKeyboardShortcuts() {\n return {\n Enter: () => this.editor.commands.splitListItem(this.name),\n Tab: () => this.editor.commands.sinkListItem(this.name),\n 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),\n }\n },\n})\n","import {\n getMarkAttributes,\n Mark,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface TextStyleOptions {\n /**\n * HTML attributes to add to the span element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n textStyle: {\n /**\n * Remove spans without inline style attributes.\n * @example editor.commands.removeEmptyTextStyle()\n */\n removeEmptyTextStyle: () => ReturnType,\n }\n }\n}\n\n/**\n * This extension allows you to create text styles. It is required by default\n * for the `textColor` and `backgroundColor` extensions.\n * @see https://www.tiptap.dev/api/marks/text-style\n */\nexport const TextStyle = Mark.create<TextStyleOptions>({\n name: 'textStyle',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'span',\n getAttrs: element => {\n const hasStyles = (element as HTMLElement).hasAttribute('style')\n\n if (!hasStyles) {\n return false\n }\n\n return {}\n },\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n removeEmptyTextStyle: () => ({ state, commands }) => {\n const attributes = getMarkAttributes(state, this.type)\n const hasStyles = Object.entries(attributes).some(([, value]) => !!value)\n\n if (hasStyles) {\n return true\n }\n\n return commands.unsetMark(this.name)\n },\n }\n },\n\n})\n","import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'\n\nimport ListItem from '../../extension-list-item/src/index.js'\nimport TextStyle from '../../extension-text-style/src/index.js'\n\nexport interface BulletListOptions {\n /**\n * The node name for the list items\n * @default 'listItem'\n * @example 'paragraph'\n */\n itemTypeName: string,\n\n /**\n * HTML attributes to add to the bullet list element\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n\n /**\n * Keep the marks when splitting the list\n * @default false\n * @example true\n */\n keepMarks: boolean,\n\n /**\n * Keep the attributes when splitting the list\n * @default false\n * @example true\n */\n keepAttributes: boolean,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n bulletList: {\n /**\n * Toggle a bullet list\n */\n toggleBulletList: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches a bullet list to a dash or asterisk.\n */\nexport const inputRegex = /^\\s*([-+*])\\s$/\n\n/**\n * This extension allows you to create bullet lists.\n * This requires the ListItem extension\n * @see https://tiptap.dev/api/nodes/bullet-list\n * @see https://tiptap.dev/api/nodes/list-item.\n */\nexport const BulletList = Node.create<BulletListOptions>({\n name: 'bulletList',\n\n addOptions() {\n return {\n itemTypeName: 'listItem',\n HTMLAttributes: {},\n keepMarks: false,\n keepAttributes: false,\n }\n },\n\n group: 'block list',\n\n content() {\n return `${this.options.itemTypeName}+`\n },\n\n parseHTML() {\n return [\n { tag: 'ul' },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n toggleBulletList: () => ({ commands, chain }) => {\n if (this.options.keepAttributes) {\n return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run()\n }\n return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),\n }\n },\n\n addInputRules() {\n let inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n })\n\n if (this.options.keepMarks || this.options.keepAttributes) {\n inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n keepMarks: this.options.keepMarks,\n keepAttributes: this.options.keepAttributes,\n getAttributes: () => { return this.editor.getAttributes(TextStyle.name) },\n editor: this.editor,\n })\n }\n return [\n inputRule,\n ]\n },\n})\n"],"names":["Node","mergeAttributes","Mark","getMarkAttributes","wrappingInputRule"],"mappings":";;;;;;AAyBA;;;AAGG;AACI,MAAM,QAAQ,GAAGA,SAAI,CAAC,MAAM,CAAkB;AACnD,IAAA,IAAI,EAAE,UAAU;IAEhB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,cAAc,EAAE,EAAE;AAClB,YAAA,kBAAkB,EAAE,YAAY;AAChC,YAAA,mBAAmB,EAAE,aAAa;SACnC,CAAA;KACF;AAED,IAAA,OAAO,EAAE,kBAAkB;AAE3B,IAAA,QAAQ,EAAE,IAAI;IAEd,SAAS,GAAA;QACP,OAAO;AACL,YAAA;AACE,gBAAA,GAAG,EAAE,IAAI;AACV,aAAA;SACF,CAAA;KACF;IAED,UAAU,CA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ACpB,aAAA,CAAC,CAAA;AACH,SAAA;QACD,OAAO;YACL,SAAS;SACV,CAAA;KACF;AACF,CAAA;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../extension-list-item/src/list-item.ts","../../extension-text-style/src/text-style.ts","../src/bullet-list.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\n\nexport interface ListItemOptions {\n /**\n * The HTML attributes for a list item node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n\n /**\n * The node type for bulletList nodes\n * @default 'bulletList'\n * @example 'myCustomBulletList'\n */\n bulletListTypeName: string\n\n /**\n * The node type for orderedList nodes\n * @default 'orderedList'\n * @example 'myCustomOrderedList'\n */\n orderedListTypeName: string\n}\n\n/**\n * This extension allows you to create list items.\n * @see https://www.tiptap.dev/api/nodes/list-item\n */\nexport const ListItem = Node.create<ListItemOptions>({\n name: 'listItem',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n bulletListTypeName: 'bulletList',\n orderedListTypeName: 'orderedList',\n }\n },\n\n content: 'paragraph block*',\n\n defining: true,\n\n parseHTML() {\n return [\n {\n tag: 'li',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['li', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addKeyboardShortcuts() {\n return {\n Enter: () => this.editor.commands.splitListItem(this.name),\n Tab: () => this.editor.commands.sinkListItem(this.name),\n 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),\n }\n },\n})\n","import {\n getMarkAttributes,\n Mark,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface TextStyleOptions {\n /**\n * HTML attributes to add to the span element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n textStyle: {\n /**\n * Remove spans without inline style attributes.\n * @example editor.commands.removeEmptyTextStyle()\n */\n removeEmptyTextStyle: () => ReturnType,\n }\n }\n}\n\n/**\n * This extension allows you to create text styles. It is required by default\n * for the `textColor` and `backgroundColor` extensions.\n * @see https://www.tiptap.dev/api/marks/text-style\n */\nexport const TextStyle = Mark.create<TextStyleOptions>({\n name: 'textStyle',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'span',\n getAttrs: element => {\n const hasStyles = (element as HTMLElement).hasAttribute('style')\n\n if (!hasStyles) {\n return false\n }\n\n return {}\n },\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n removeEmptyTextStyle: () => ({ state, commands }) => {\n const attributes = getMarkAttributes(state, this.type)\n const hasStyles = Object.entries(attributes).some(([, value]) => !!value)\n\n if (hasStyles) {\n return true\n }\n\n return commands.unsetMark(this.name)\n },\n }\n },\n\n})\n","import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'\n\nimport ListItem from '../../extension-list-item/src/index.js'\nimport TextStyle from '../../extension-text-style/src/index.js'\n\nexport interface BulletListOptions {\n /**\n * The node name for the list items\n * @default 'listItem'\n * @example 'paragraph'\n */\n itemTypeName: string,\n\n /**\n * HTML attributes to add to the bullet list element\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n\n /**\n * Keep the marks when splitting the list\n * @default false\n * @example true\n */\n keepMarks: boolean,\n\n /**\n * Keep the attributes when splitting the list\n * @default false\n * @example true\n */\n keepAttributes: boolean,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n bulletList: {\n /**\n * Toggle a bullet list\n */\n toggleBulletList: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches a bullet list to a dash or asterisk.\n */\nexport const inputRegex = /^\\s*([-+*])\\s$/\n\n/**\n * This extension allows you to create bullet lists.\n * This requires the ListItem extension\n * @see https://tiptap.dev/api/nodes/bullet-list\n * @see https://tiptap.dev/api/nodes/list-item.\n */\nexport const BulletList = Node.create<BulletListOptions>({\n name: 'bulletList',\n\n addOptions() {\n return {\n itemTypeName: 'listItem',\n HTMLAttributes: {},\n keepMarks: false,\n keepAttributes: false,\n }\n },\n\n group: 'block list',\n\n content() {\n return `${this.options.itemTypeName}+`\n },\n\n parseHTML() {\n return [\n { tag: 'ul' },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n toggleBulletList: () => ({ commands, chain }) => {\n if (this.options.keepAttributes) {\n return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run()\n }\n return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),\n }\n },\n\n addInputRules() {\n let inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n })\n\n if (this.options.keepMarks || this.options.keepAttributes) {\n inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n keepMarks: this.options.keepMarks,\n keepAttributes: this.options.keepAttributes,\n getAttributes: () => { return this.editor.getAttributes(TextStyle.name) },\n editor: this.editor,\n })\n }\n return [\n inputRule,\n ]\n },\n})\n"],"names":["Node","mergeAttributes","Mark","getMarkAttributes","wrappingInputRule"],"mappings":";;;;;;AAyBA;;;AAGG;AACI,MAAM,QAAQ,GAAGA,SAAI,CAAC,MAAM,CAAkB;AACnD,IAAA,IAAI,EAAE,UAAU;IAEhB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,cAAc,EAAE,EAAE;AAClB,YAAA,kBAAkB,EAAE,YAAY;AAChC,YAAA,mBAAmB,EAAE,aAAa;SACnC,CAAA;KACF;AAED,IAAA,OAAO,EAAE,kBAAkB;AAE3B,IAAA,QAAQ,EAAE,IAAI;IAEd,SAAS,GAAA;QACP,O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AAC,IAAI,CAAC,CAAA,EAAE;gBACzE,MAAM,EAAE,IAAI,CAAC,MAAM;AACpB,aAAA,CAAC,CAAA;SACH;QACD,OAAO;YACL,SAAS;SACV,CAAA;KACF;AACF,CAAA;;;;;;"}
package/dist/index.js CHANGED
@@ -1,148 +1,148 @@
1
1
  import { Node, mergeAttributes, Mark, getMarkAttributes, wrappingInputRule } from '@tiptap/core';
2
2
 
3
- /**
4
- * This extension allows you to create list items.
5
- * @see https://www.tiptap.dev/api/nodes/list-item
6
- */
7
- const ListItem = Node.create({
8
- name: 'listItem',
9
- addOptions() {
10
- return {
11
- HTMLAttributes: {},
12
- bulletListTypeName: 'bulletList',
13
- orderedListTypeName: 'orderedList',
14
- };
15
- },
16
- content: 'paragraph block*',
17
- defining: true,
18
- parseHTML() {
19
- return [
20
- {
21
- tag: 'li',
22
- },
23
- ];
24
- },
25
- renderHTML({ HTMLAttributes }) {
26
- return ['li', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
27
- },
28
- addKeyboardShortcuts() {
29
- return {
30
- Enter: () => this.editor.commands.splitListItem(this.name),
31
- Tab: () => this.editor.commands.sinkListItem(this.name),
32
- 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),
33
- };
34
- },
3
+ /**
4
+ * This extension allows you to create list items.
5
+ * @see https://www.tiptap.dev/api/nodes/list-item
6
+ */
7
+ const ListItem = Node.create({
8
+ name: 'listItem',
9
+ addOptions() {
10
+ return {
11
+ HTMLAttributes: {},
12
+ bulletListTypeName: 'bulletList',
13
+ orderedListTypeName: 'orderedList',
14
+ };
15
+ },
16
+ content: 'paragraph block*',
17
+ defining: true,
18
+ parseHTML() {
19
+ return [
20
+ {
21
+ tag: 'li',
22
+ },
23
+ ];
24
+ },
25
+ renderHTML({ HTMLAttributes }) {
26
+ return ['li', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
27
+ },
28
+ addKeyboardShortcuts() {
29
+ return {
30
+ Enter: () => this.editor.commands.splitListItem(this.name),
31
+ Tab: () => this.editor.commands.sinkListItem(this.name),
32
+ 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),
33
+ };
34
+ },
35
35
  });
36
36
 
37
- /**
38
- * This extension allows you to create text styles. It is required by default
39
- * for the `textColor` and `backgroundColor` extensions.
40
- * @see https://www.tiptap.dev/api/marks/text-style
41
- */
42
- const TextStyle = Mark.create({
43
- name: 'textStyle',
44
- addOptions() {
45
- return {
46
- HTMLAttributes: {},
47
- };
48
- },
49
- parseHTML() {
50
- return [
51
- {
52
- tag: 'span',
53
- getAttrs: element => {
54
- const hasStyles = element.hasAttribute('style');
55
- if (!hasStyles) {
56
- return false;
57
- }
58
- return {};
59
- },
60
- },
61
- ];
62
- },
63
- renderHTML({ HTMLAttributes }) {
64
- return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
65
- },
66
- addCommands() {
67
- return {
68
- removeEmptyTextStyle: () => ({ state, commands }) => {
69
- const attributes = getMarkAttributes(state, this.type);
70
- const hasStyles = Object.entries(attributes).some(([, value]) => !!value);
71
- if (hasStyles) {
72
- return true;
73
- }
74
- return commands.unsetMark(this.name);
75
- },
76
- };
77
- },
37
+ /**
38
+ * This extension allows you to create text styles. It is required by default
39
+ * for the `textColor` and `backgroundColor` extensions.
40
+ * @see https://www.tiptap.dev/api/marks/text-style
41
+ */
42
+ const TextStyle = Mark.create({
43
+ name: 'textStyle',
44
+ addOptions() {
45
+ return {
46
+ HTMLAttributes: {},
47
+ };
48
+ },
49
+ parseHTML() {
50
+ return [
51
+ {
52
+ tag: 'span',
53
+ getAttrs: element => {
54
+ const hasStyles = element.hasAttribute('style');
55
+ if (!hasStyles) {
56
+ return false;
57
+ }
58
+ return {};
59
+ },
60
+ },
61
+ ];
62
+ },
63
+ renderHTML({ HTMLAttributes }) {
64
+ return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
65
+ },
66
+ addCommands() {
67
+ return {
68
+ removeEmptyTextStyle: () => ({ state, commands }) => {
69
+ const attributes = getMarkAttributes(state, this.type);
70
+ const hasStyles = Object.entries(attributes).some(([, value]) => !!value);
71
+ if (hasStyles) {
72
+ return true;
73
+ }
74
+ return commands.unsetMark(this.name);
75
+ },
76
+ };
77
+ },
78
78
  });
79
79
 
80
- /**
81
- * Matches a bullet list to a dash or asterisk.
82
- */
83
- const inputRegex = /^\s*([-+*])\s$/;
84
- /**
85
- * This extension allows you to create bullet lists.
86
- * This requires the ListItem extension
87
- * @see https://tiptap.dev/api/nodes/bullet-list
88
- * @see https://tiptap.dev/api/nodes/list-item.
89
- */
90
- const BulletList = Node.create({
91
- name: 'bulletList',
92
- addOptions() {
93
- return {
94
- itemTypeName: 'listItem',
95
- HTMLAttributes: {},
96
- keepMarks: false,
97
- keepAttributes: false,
98
- };
99
- },
100
- group: 'block list',
101
- content() {
102
- return `${this.options.itemTypeName}+`;
103
- },
104
- parseHTML() {
105
- return [
106
- { tag: 'ul' },
107
- ];
108
- },
109
- renderHTML({ HTMLAttributes }) {
110
- return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
111
- },
112
- addCommands() {
113
- return {
114
- toggleBulletList: () => ({ commands, chain }) => {
115
- if (this.options.keepAttributes) {
116
- return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run();
117
- }
118
- return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
119
- },
120
- };
121
- },
122
- addKeyboardShortcuts() {
123
- return {
124
- 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
125
- };
126
- },
127
- addInputRules() {
128
- let inputRule = wrappingInputRule({
129
- find: inputRegex,
130
- type: this.type,
131
- });
132
- if (this.options.keepMarks || this.options.keepAttributes) {
133
- inputRule = wrappingInputRule({
134
- find: inputRegex,
135
- type: this.type,
136
- keepMarks: this.options.keepMarks,
137
- keepAttributes: this.options.keepAttributes,
138
- getAttributes: () => { return this.editor.getAttributes(TextStyle.name); },
139
- editor: this.editor,
140
- });
141
- }
142
- return [
143
- inputRule,
144
- ];
145
- },
80
+ /**
81
+ * Matches a bullet list to a dash or asterisk.
82
+ */
83
+ const inputRegex = /^\s*([-+*])\s$/;
84
+ /**
85
+ * This extension allows you to create bullet lists.
86
+ * This requires the ListItem extension
87
+ * @see https://tiptap.dev/api/nodes/bullet-list
88
+ * @see https://tiptap.dev/api/nodes/list-item.
89
+ */
90
+ const BulletList = Node.create({
91
+ name: 'bulletList',
92
+ addOptions() {
93
+ return {
94
+ itemTypeName: 'listItem',
95
+ HTMLAttributes: {},
96
+ keepMarks: false,
97
+ keepAttributes: false,
98
+ };
99
+ },
100
+ group: 'block list',
101
+ content() {
102
+ return `${this.options.itemTypeName}+`;
103
+ },
104
+ parseHTML() {
105
+ return [
106
+ { tag: 'ul' },
107
+ ];
108
+ },
109
+ renderHTML({ HTMLAttributes }) {
110
+ return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
111
+ },
112
+ addCommands() {
113
+ return {
114
+ toggleBulletList: () => ({ commands, chain }) => {
115
+ if (this.options.keepAttributes) {
116
+ return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run();
117
+ }
118
+ return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
119
+ },
120
+ };
121
+ },
122
+ addKeyboardShortcuts() {
123
+ return {
124
+ 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
125
+ };
126
+ },
127
+ addInputRules() {
128
+ let inputRule = wrappingInputRule({
129
+ find: inputRegex,
130
+ type: this.type,
131
+ });
132
+ if (this.options.keepMarks || this.options.keepAttributes) {
133
+ inputRule = wrappingInputRule({
134
+ find: inputRegex,
135
+ type: this.type,
136
+ keepMarks: this.options.keepMarks,
137
+ keepAttributes: this.options.keepAttributes,
138
+ getAttributes: () => { return this.editor.getAttributes(TextStyle.name); },
139
+ editor: this.editor,
140
+ });
141
+ }
142
+ return [
143
+ inputRule,
144
+ ];
145
+ },
146
146
  });
147
147
 
148
148
  export { BulletList, BulletList as default, inputRegex };