@tiptap/extension-bullet-list 2.6.2 → 3.0.0-next.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/dist/index.cjs +95 -150
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/{packages/extension-bullet-list/src/bullet-list.d.ts → index.d.cts} +6 -3
  4. package/dist/index.d.ts +51 -0
  5. package/dist/index.js +70 -147
  6. package/dist/index.js.map +1 -1
  7. package/package.json +6 -8
  8. package/src/bullet-list.ts +4 -4
  9. package/dist/index.umd.js +0 -160
  10. package/dist/index.umd.js.map +0 -1
  11. package/dist/packages/core/src/CommandManager.d.ts +0 -20
  12. package/dist/packages/core/src/Editor.d.ts +0 -163
  13. package/dist/packages/core/src/EventEmitter.d.ts +0 -11
  14. package/dist/packages/core/src/Extension.d.ts +0 -344
  15. package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
  16. package/dist/packages/core/src/InputRule.d.ts +0 -42
  17. package/dist/packages/core/src/Mark.d.ts +0 -452
  18. package/dist/packages/core/src/Node.d.ts +0 -612
  19. package/dist/packages/core/src/NodePos.d.ts +0 -44
  20. package/dist/packages/core/src/NodeView.d.ts +0 -31
  21. package/dist/packages/core/src/PasteRule.d.ts +0 -50
  22. package/dist/packages/core/src/Tracker.d.ts +0 -11
  23. package/dist/packages/core/src/commands/blur.d.ts +0 -13
  24. package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
  25. package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
  26. package/dist/packages/core/src/commands/command.d.ts +0 -18
  27. package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
  28. package/dist/packages/core/src/commands/cut.d.ts +0 -20
  29. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
  30. package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
  31. package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
  32. package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
  33. package/dist/packages/core/src/commands/enter.d.ts +0 -13
  34. package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
  35. package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
  36. package/dist/packages/core/src/commands/first.d.ts +0 -14
  37. package/dist/packages/core/src/commands/focus.d.ts +0 -27
  38. package/dist/packages/core/src/commands/forEach.d.ts +0 -14
  39. package/dist/packages/core/src/commands/index.d.ts +0 -55
  40. package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
  41. package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
  42. package/dist/packages/core/src/commands/join.d.ts +0 -41
  43. package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
  44. package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
  45. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
  46. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
  47. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
  48. package/dist/packages/core/src/commands/lift.d.ts +0 -17
  49. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
  50. package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
  51. package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
  52. package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
  53. package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
  54. package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
  55. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
  56. package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
  57. package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
  58. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
  59. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
  60. package/dist/packages/core/src/commands/setContent.d.ts +0 -40
  61. package/dist/packages/core/src/commands/setMark.d.ts +0 -15
  62. package/dist/packages/core/src/commands/setMeta.d.ts +0 -16
  63. package/dist/packages/core/src/commands/setNode.d.ts +0 -16
  64. package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
  65. package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
  66. package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
  67. package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
  68. package/dist/packages/core/src/commands/splitListItem.d.ts +0 -16
  69. package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
  70. package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
  71. package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
  72. package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
  73. package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
  74. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
  75. package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
  76. package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
  77. package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
  78. package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
  79. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
  80. package/dist/packages/core/src/extensions/commands.d.ts +0 -3
  81. package/dist/packages/core/src/extensions/editable.d.ts +0 -2
  82. package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
  83. package/dist/packages/core/src/extensions/index.d.ts +0 -6
  84. package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
  85. package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
  86. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
  87. package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
  88. package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
  89. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
  90. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
  91. package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
  92. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
  93. package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
  94. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
  95. package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
  96. package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
  97. package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
  98. package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
  99. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
  100. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
  101. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
  102. package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
  103. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
  104. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
  105. package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
  106. package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
  107. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
  108. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
  109. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
  110. package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
  111. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
  112. package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
  113. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
  114. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
  115. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
  116. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
  117. package/dist/packages/core/src/helpers/getText.d.ts +0 -15
  118. package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
  119. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
  120. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
  121. package/dist/packages/core/src/helpers/index.d.ts +0 -50
  122. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
  123. package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
  124. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
  125. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
  126. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
  127. package/dist/packages/core/src/helpers/isList.d.ts +0 -2
  128. package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
  129. package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
  130. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -14
  131. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
  132. package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
  133. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
  134. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
  135. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
  136. package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
  137. package/dist/packages/core/src/index.d.ts +0 -24
  138. package/dist/packages/core/src/inputRules/index.d.ts +0 -5
  139. package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
  140. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
  141. package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
  142. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
  143. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
  144. package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
  145. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
  146. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -14
  147. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
  148. package/dist/packages/core/src/style.d.ts +0 -1
  149. package/dist/packages/core/src/types.d.ts +0 -253
  150. package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
  151. package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
  152. package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
  153. package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
  154. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
  155. package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
  156. package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
  157. package/dist/packages/core/src/utilities/index.d.ts +0 -20
  158. package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
  159. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
  160. package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
  161. package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
  162. package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
  163. package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
  164. package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
  165. package/dist/packages/core/src/utilities/isString.d.ts +0 -1
  166. package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
  167. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
  168. package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
  169. package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
  170. package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
  171. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
  172. package/dist/packages/extension-bullet-list/src/index.d.ts +0 -3
  173. package/dist/packages/extension-list-item/src/index.d.ts +0 -3
  174. package/dist/packages/extension-list-item/src/list-item.d.ts +0 -26
  175. package/dist/packages/extension-text-style/src/index.d.ts +0 -3
  176. package/dist/packages/extension-text-style/src/text-style.d.ts +0 -26
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-bullet-list",
3
3
  "description": "bullet list extension for tiptap",
4
- "version": "2.6.2",
4
+ "version": "3.0.0-next.1",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -15,24 +15,23 @@
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/packages/extension-bullet-list/src/index.d.ts",
18
+ "types": "./dist/index.d.ts",
19
19
  "import": "./dist/index.js",
20
20
  "require": "./dist/index.cjs"
21
21
  }
22
22
  },
23
23
  "main": "dist/index.cjs",
24
24
  "module": "dist/index.js",
25
- "umd": "dist/index.umd.js",
26
- "types": "dist/packages/extension-bullet-list/src/index.d.ts",
25
+ "types": "dist/index.d.ts",
27
26
  "files": [
28
27
  "src",
29
28
  "dist"
30
29
  ],
31
30
  "devDependencies": {
32
- "@tiptap/core": "^2.6.2"
31
+ "@tiptap/core": "^3.0.0-next.1"
33
32
  },
34
33
  "peerDependencies": {
35
- "@tiptap/core": "^2.6.2"
34
+ "@tiptap/core": "^3.0.0-next.1"
36
35
  },
37
36
  "repository": {
38
37
  "type": "git",
@@ -40,7 +39,6 @@
40
39
  "directory": "packages/extension-bullet-list"
41
40
  },
42
41
  "scripts": {
43
- "clean": "rm -rf dist",
44
- "build": "npm run clean && rollup -c"
42
+ "build": "tsup"
45
43
  }
46
44
  }
@@ -1,7 +1,7 @@
1
1
  import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'
2
2
 
3
- import ListItem from '../../extension-list-item/src/index.js'
4
- import TextStyle from '../../extension-text-style/src/index.js'
3
+ const ListItemName = 'listItem'
4
+ const TextStyleName = 'textStyle'
5
5
 
6
6
  export interface BulletListOptions {
7
7
  /**
@@ -87,7 +87,7 @@ export const BulletList = Node.create<BulletListOptions>({
87
87
  return {
88
88
  toggleBulletList: () => ({ commands, chain }) => {
89
89
  if (this.options.keepAttributes) {
90
- return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run()
90
+ return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run()
91
91
  }
92
92
  return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
93
93
  },
@@ -112,7 +112,7 @@ export const BulletList = Node.create<BulletListOptions>({
112
112
  type: this.type,
113
113
  keepMarks: this.options.keepMarks,
114
114
  keepAttributes: this.options.keepAttributes,
115
- getAttributes: () => { return this.editor.getAttributes(TextStyle.name) },
115
+ getAttributes: () => { return this.editor.getAttributes(TextStyleName) },
116
116
  editor: this.editor,
117
117
  })
118
118
  }
package/dist/index.umd.js DELETED
@@ -1,160 +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-bullet-list"] = {}, global.core));
5
- })(this, (function (exports, core) { 'use strict';
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
- },
39
- });
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
- priority: 101,
49
- addOptions() {
50
- return {
51
- HTMLAttributes: {},
52
- };
53
- },
54
- parseHTML() {
55
- return [
56
- {
57
- tag: 'span',
58
- getAttrs: element => {
59
- const hasStyles = element.hasAttribute('style');
60
- if (!hasStyles) {
61
- return false;
62
- }
63
- return {};
64
- },
65
- },
66
- ];
67
- },
68
- renderHTML({ HTMLAttributes }) {
69
- return ['span', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
70
- },
71
- addCommands() {
72
- return {
73
- removeEmptyTextStyle: () => ({ state, commands }) => {
74
- const attributes = core.getMarkAttributes(state, this.type);
75
- const hasStyles = Object.entries(attributes).some(([, value]) => !!value);
76
- if (hasStyles) {
77
- return true;
78
- }
79
- return commands.unsetMark(this.name);
80
- },
81
- };
82
- },
83
- });
84
-
85
- /**
86
- * Matches a bullet list to a dash or asterisk.
87
- */
88
- const inputRegex = /^\s*([-+*])\s$/;
89
- /**
90
- * This extension allows you to create bullet lists.
91
- * This requires the ListItem extension
92
- * @see https://tiptap.dev/api/nodes/bullet-list
93
- * @see https://tiptap.dev/api/nodes/list-item.
94
- */
95
- const BulletList = core.Node.create({
96
- name: 'bulletList',
97
- addOptions() {
98
- return {
99
- itemTypeName: 'listItem',
100
- HTMLAttributes: {},
101
- keepMarks: false,
102
- keepAttributes: false,
103
- };
104
- },
105
- group: 'block list',
106
- content() {
107
- return `${this.options.itemTypeName}+`;
108
- },
109
- parseHTML() {
110
- return [
111
- { tag: 'ul' },
112
- ];
113
- },
114
- renderHTML({ HTMLAttributes }) {
115
- return ['ul', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
116
- },
117
- addCommands() {
118
- return {
119
- toggleBulletList: () => ({ commands, chain }) => {
120
- if (this.options.keepAttributes) {
121
- return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run();
122
- }
123
- return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
124
- },
125
- };
126
- },
127
- addKeyboardShortcuts() {
128
- return {
129
- 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
130
- };
131
- },
132
- addInputRules() {
133
- let inputRule = core.wrappingInputRule({
134
- find: inputRegex,
135
- type: this.type,
136
- });
137
- if (this.options.keepMarks || this.options.keepAttributes) {
138
- inputRule = core.wrappingInputRule({
139
- find: inputRegex,
140
- type: this.type,
141
- keepMarks: this.options.keepMarks,
142
- keepAttributes: this.options.keepAttributes,
143
- getAttributes: () => { return this.editor.getAttributes(TextStyle.name); },
144
- editor: this.editor,
145
- });
146
- }
147
- return [
148
- inputRule,
149
- ];
150
- },
151
- });
152
-
153
- exports.BulletList = BulletList;
154
- exports.default = BulletList;
155
- exports.inputRegex = inputRegex;
156
-
157
- Object.defineProperty(exports, '__esModule', { value: true });
158
-
159
- }));
160
- //# sourceMappingURL=index.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","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 priority: 101,\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":";;;;;;EAyBA;;;EAGG;EACI,MAAM,QAAQ,GAAGA,SAAI,CAAC,MAAM,CAAkB;EACnD,IAAA,IAAI,EAAE,UAAU;MAEhB,UAAU,GAAA;UACR,OAAO;EACL,YAAA,cAAc,EAAE,EAAE;EAClB,YAAA,kBAAkB,EAAE,YAAY;EAChC,YAAA,mBAAmB,EAAE,aAAa;WACnC,CAAA;OACF;EAED,IAAA,OAAO,EAAE,kBAAkB;EAE3B,IAAA,QAAQ,EAAE,IAAI;MAEd,SAAS,GAAA;UACP,OAAO;EACL,YAAA;EACE,gBAAA,GAAG,EAAE,IAAI;EACV,aAAA;WACF,CAAA;OACF;MAED,UAAU,CAAC,EAAE,cAAc,EAAE,EAAA;EAC3B,QAAA,OAAO,CAAC,IAAI,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;OAC/E;MAED,oBAAoB,GAAA;UAClB,OAAO;EACL,YAAA,KAAK,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;EAC1D,YAAA,GAAG,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;EACvD,YAAA,WAAW,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CA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zF;WACF,CAAA;OACF;MAED,oBAAoB,GAAA;UAClB,OAAO;cACL,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE;WAC7D,CAAA;OACF;MAED,aAAa,GAAA;UACX,IAAI,SAAS,GAAGG,sBAAiB,CAAC;EAChC,YAAA,IAAI,EAAE,UAAU;cAChB,IAAI,EAAE,IAAI,CAAC,IAAI;EAChB,SAAA,CAAC,CAAA;EAEF,QAAA,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;cACzD,SAAS,GAAGA,sBAAiB,CAAC;EAC5B,gBAAA,IAAI,EAAE,UAAU;kBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;EACf,gBAAA,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;EACjC,gBAAA,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;EAC3C,gBAAA,aAAa,EAAE,MAAQ,EAAA,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA,EAAE;kBACzE,MAAM,EAAE,IAAI,CAAC,MAAM;EACpB,aAAA,CAAC,CAAA;WACH;UACD,OAAO;cACL,SAAS;WACV,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,163 +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
- export interface TiptapEditorHTMLElement extends HTMLElement {
10
- editor?: Editor;
11
- }
12
- export declare class Editor extends EventEmitter<EditorEvents> {
13
- private commandManager;
14
- extensionManager: ExtensionManager;
15
- private css;
16
- schema: Schema;
17
- view: EditorView;
18
- isFocused: boolean;
19
- /**
20
- * The editor is considered initialized after the `create` event has been emitted.
21
- */
22
- isInitialized: boolean;
23
- extensionStorage: Record<string, any>;
24
- options: EditorOptions;
25
- constructor(options?: Partial<EditorOptions>);
26
- /**
27
- * Returns the editor storage.
28
- */
29
- get storage(): Record<string, any>;
30
- /**
31
- * An object of all registered commands.
32
- */
33
- get commands(): SingleCommands;
34
- /**
35
- * Create a command chain to call multiple commands at once.
36
- */
37
- chain(): ChainedCommands;
38
- /**
39
- * Check if a command or a command chain can be executed. Without executing it.
40
- */
41
- can(): CanCommands;
42
- /**
43
- * Inject CSS styles.
44
- */
45
- private injectCSS;
46
- /**
47
- * Update editor options.
48
- *
49
- * @param options A list of options
50
- */
51
- setOptions(options?: Partial<EditorOptions>): void;
52
- /**
53
- * Update editable state of the editor.
54
- */
55
- setEditable(editable: boolean, emitUpdate?: boolean): void;
56
- /**
57
- * Returns whether the editor is editable.
58
- */
59
- get isEditable(): boolean;
60
- /**
61
- * Returns the editor state.
62
- */
63
- get state(): EditorState;
64
- /**
65
- * Register a ProseMirror plugin.
66
- *
67
- * @param plugin A ProseMirror plugin
68
- * @param handlePlugins Control how to merge the plugin into the existing plugins.
69
- */
70
- registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): void;
71
- /**
72
- * Unregister a ProseMirror plugin.
73
- *
74
- * @param nameOrPluginKey The plugins name
75
- */
76
- unregisterPlugin(nameOrPluginKey: string | PluginKey): void;
77
- /**
78
- * Creates an extension manager.
79
- */
80
- private createExtensionManager;
81
- /**
82
- * Creates an command manager.
83
- */
84
- private createCommandManager;
85
- /**
86
- * Creates a ProseMirror schema.
87
- */
88
- private createSchema;
89
- /**
90
- * Creates a ProseMirror view.
91
- */
92
- private createView;
93
- /**
94
- * Creates all node views.
95
- */
96
- createNodeViews(): void;
97
- /**
98
- * Prepend class name to element.
99
- */
100
- prependClass(): void;
101
- isCapturingTransaction: boolean;
102
- private capturedTransaction;
103
- captureTransaction(fn: Function): Transaction | null;
104
- /**
105
- * The callback over which to send transactions (state updates) produced by the view.
106
- *
107
- * @param transaction An editor state transaction
108
- */
109
- private dispatchTransaction;
110
- /**
111
- * Get attributes of the currently selected node or mark.
112
- */
113
- getAttributes(nameOrType: string | NodeType | MarkType): Record<string, any>;
114
- /**
115
- * Returns if the currently selected node or mark is active.
116
- *
117
- * @param name Name of the node or mark
118
- * @param attributes Attributes of the node or mark
119
- */
120
- isActive(name: string, attributes?: {}): boolean;
121
- isActive(attributes: {}): boolean;
122
- /**
123
- * Get the document as JSON.
124
- */
125
- getJSON(): JSONContent;
126
- /**
127
- * Get the document as HTML.
128
- */
129
- getHTML(): string;
130
- /**
131
- * Get the document as text.
132
- */
133
- getText(options?: {
134
- blockSeparator?: string;
135
- textSerializers?: Record<string, TextSerializer>;
136
- }): string;
137
- /**
138
- * Check if there is no content.
139
- */
140
- get isEmpty(): boolean;
141
- /**
142
- * Get the number of characters for the current document.
143
- *
144
- * @deprecated
145
- */
146
- getCharacterCount(): number;
147
- /**
148
- * Destroy the editor.
149
- */
150
- destroy(): void;
151
- /**
152
- * Check if the editor is already destroyed.
153
- */
154
- get isDestroyed(): boolean;
155
- $node(selector: string, attributes?: {
156
- [key: string]: any;
157
- }): NodePos | null;
158
- $nodes(selector: string, attributes?: {
159
- [key: string]: any;
160
- }): NodePos[] | null;
161
- $pos(pos: number): NodePos;
162
- get $doc(): NodePos;
163
- }
@@ -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 {};