@tiptap/extension-color 3.0.0-next.0 → 3.0.0-next.2

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 (173) hide show
  1. package/dist/index.cjs +75 -54
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/{packages/extension-color/src/color.d.ts → index.d.cts} +5 -3
  4. package/dist/index.d.ts +34 -0
  5. package/dist/index.js +50 -51
  6. package/dist/index.js.map +1 -1
  7. package/package.json +8 -10
  8. package/dist/index.umd.js +0 -62
  9. package/dist/index.umd.js.map +0 -1
  10. package/dist/packages/core/src/CommandManager.d.ts +0 -20
  11. package/dist/packages/core/src/Editor.d.ts +0 -159
  12. package/dist/packages/core/src/EventEmitter.d.ts +0 -11
  13. package/dist/packages/core/src/Extension.d.ts +0 -343
  14. package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
  15. package/dist/packages/core/src/InputRule.d.ts +0 -42
  16. package/dist/packages/core/src/Mark.d.ts +0 -451
  17. package/dist/packages/core/src/Node.d.ts +0 -611
  18. package/dist/packages/core/src/NodePos.d.ts +0 -44
  19. package/dist/packages/core/src/NodeView.d.ts +0 -31
  20. package/dist/packages/core/src/PasteRule.d.ts +0 -50
  21. package/dist/packages/core/src/Tracker.d.ts +0 -11
  22. package/dist/packages/core/src/commands/blur.d.ts +0 -13
  23. package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
  24. package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
  25. package/dist/packages/core/src/commands/command.d.ts +0 -18
  26. package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
  27. package/dist/packages/core/src/commands/cut.d.ts +0 -20
  28. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
  29. package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
  30. package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
  31. package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
  32. package/dist/packages/core/src/commands/enter.d.ts +0 -13
  33. package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
  34. package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
  35. package/dist/packages/core/src/commands/first.d.ts +0 -14
  36. package/dist/packages/core/src/commands/focus.d.ts +0 -27
  37. package/dist/packages/core/src/commands/forEach.d.ts +0 -14
  38. package/dist/packages/core/src/commands/index.d.ts +0 -55
  39. package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
  40. package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
  41. package/dist/packages/core/src/commands/join.d.ts +0 -41
  42. package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
  43. package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
  44. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
  45. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
  46. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
  47. package/dist/packages/core/src/commands/lift.d.ts +0 -17
  48. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
  49. package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
  50. package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
  51. package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
  52. package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
  53. package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
  54. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
  55. package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
  56. package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
  57. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
  58. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
  59. package/dist/packages/core/src/commands/setContent.d.ts +0 -40
  60. package/dist/packages/core/src/commands/setMark.d.ts +0 -15
  61. package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
  62. package/dist/packages/core/src/commands/setNode.d.ts +0 -16
  63. package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
  64. package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
  65. package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
  66. package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
  67. package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
  68. package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
  69. package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
  70. package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
  71. package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
  72. package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
  73. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
  74. package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
  75. package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
  76. package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
  77. package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
  78. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
  79. package/dist/packages/core/src/extensions/commands.d.ts +0 -3
  80. package/dist/packages/core/src/extensions/editable.d.ts +0 -2
  81. package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
  82. package/dist/packages/core/src/extensions/index.d.ts +0 -6
  83. package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
  84. package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
  85. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
  86. package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
  87. package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
  88. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
  89. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
  90. package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
  91. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
  92. package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
  93. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
  94. package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
  95. package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
  96. package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
  97. package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
  98. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
  99. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
  100. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
  101. package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
  102. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
  103. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
  104. package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
  105. package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
  106. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
  107. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
  108. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
  109. package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
  110. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
  111. package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
  112. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
  113. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
  114. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
  115. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
  116. package/dist/packages/core/src/helpers/getText.d.ts +0 -15
  117. package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
  118. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
  119. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
  120. package/dist/packages/core/src/helpers/index.d.ts +0 -50
  121. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
  122. package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
  123. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
  124. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
  125. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
  126. package/dist/packages/core/src/helpers/isList.d.ts +0 -2
  127. package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
  128. package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
  129. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -8
  130. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
  131. package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
  132. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
  133. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
  134. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
  135. package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
  136. package/dist/packages/core/src/index.d.ts +0 -24
  137. package/dist/packages/core/src/inputRules/index.d.ts +0 -5
  138. package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
  139. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
  140. package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
  141. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
  142. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
  143. package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
  144. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
  145. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
  146. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
  147. package/dist/packages/core/src/style.d.ts +0 -1
  148. package/dist/packages/core/src/types.d.ts +0 -253
  149. package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
  150. package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
  151. package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
  152. package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
  153. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
  154. package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
  155. package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
  156. package/dist/packages/core/src/utilities/index.d.ts +0 -20
  157. package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
  158. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
  159. package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
  160. package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
  161. package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
  162. package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
  163. package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
  164. package/dist/packages/core/src/utilities/isString.d.ts +0 -1
  165. package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
  166. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
  167. package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
  168. package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
  169. package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
  170. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
  171. package/dist/packages/extension-color/src/index.d.ts +0 -3
  172. package/dist/packages/extension-text-style/src/index.d.ts +0 -3
  173. package/dist/packages/extension-text-style/src/text-style.d.ts +0 -26
package/dist/index.cjs CHANGED
@@ -1,59 +1,80 @@
1
- 'use strict';
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
19
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- require('@tiptap/extension-text-style');
6
- var core = require('@tiptap/core');
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ Color: () => Color,
24
+ default: () => src_default
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
7
27
 
8
- /**
9
- * This extension allows you to color your text.
10
- * @see https://tiptap.dev/api/extensions/color
11
- */
12
- const Color = core.Extension.create({
13
- name: 'color',
14
- addOptions() {
15
- return {
16
- types: ['textStyle'],
17
- };
18
- },
19
- addGlobalAttributes() {
20
- return [
21
- {
22
- types: this.options.types,
23
- attributes: {
24
- color: {
25
- default: null,
26
- parseHTML: element => { var _a; return (_a = element.style.color) === null || _a === void 0 ? void 0 : _a.replace(/['"]+/g, ''); },
27
- renderHTML: attributes => {
28
- if (!attributes.color) {
29
- return {};
30
- }
31
- return {
32
- style: `color: ${attributes.color}`,
33
- };
34
- },
35
- },
36
- },
37
- },
38
- ];
39
- },
40
- addCommands() {
41
- return {
42
- setColor: color => ({ chain }) => {
43
- return chain()
44
- .setMark('textStyle', { color })
45
- .run();
28
+ // src/color.ts
29
+ var import_extension_text_style = require("@tiptap/extension-text-style");
30
+ var import_core = require("@tiptap/core");
31
+ var Color = import_core.Extension.create({
32
+ name: "color",
33
+ addOptions() {
34
+ return {
35
+ types: ["textStyle"]
36
+ };
37
+ },
38
+ addGlobalAttributes() {
39
+ return [
40
+ {
41
+ types: this.options.types,
42
+ attributes: {
43
+ color: {
44
+ default: null,
45
+ parseHTML: (element) => {
46
+ var _a;
47
+ return (_a = element.style.color) == null ? void 0 : _a.replace(/['"]+/g, "");
46
48
  },
47
- unsetColor: () => ({ chain }) => {
48
- return chain()
49
- .setMark('textStyle', { color: null })
50
- .removeEmptyTextStyle()
51
- .run();
52
- },
53
- };
54
- },
49
+ renderHTML: (attributes) => {
50
+ if (!attributes.color) {
51
+ return {};
52
+ }
53
+ return {
54
+ style: `color: ${attributes.color}`
55
+ };
56
+ }
57
+ }
58
+ }
59
+ }
60
+ ];
61
+ },
62
+ addCommands() {
63
+ return {
64
+ setColor: (color) => ({ chain }) => {
65
+ return chain().setMark("textStyle", { color }).run();
66
+ },
67
+ unsetColor: () => ({ chain }) => {
68
+ return chain().setMark("textStyle", { color: null }).removeEmptyTextStyle().run();
69
+ }
70
+ };
71
+ }
55
72
  });
56
73
 
57
- exports.Color = Color;
58
- exports.default = Color;
59
- //# sourceMappingURL=index.cjs.map
74
+ // src/index.ts
75
+ var src_default = Color;
76
+ // Annotate the CommonJS export names for ESM import in node:
77
+ 0 && (module.exports = {
78
+ Color
79
+ });
80
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/color.ts"],"sourcesContent":["import '@tiptap/extension-text-style'\n\nimport { Extension } from '@tiptap/core'\n\nexport type ColorOptions = {\n /**\n * The types where the color can be applied\n * @default ['textStyle']\n * @example ['heading', 'paragraph']\n */\n types: string[],\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n color: {\n /**\n * Set the text color\n * @param color The color to set\n * @example editor.commands.setColor('red')\n */\n setColor: (color: string) => ReturnType,\n\n /**\n * Unset the text color\n * @example editor.commands.unsetColor()\n */\n unsetColor: () => ReturnType,\n }\n }\n}\n\n/**\n * This extension allows you to color your text.\n * @see https://tiptap.dev/api/extensions/color\n */\nexport const Color = Extension.create<ColorOptions>({\n name: 'color',\n\n addOptions() {\n return {\n types: ['textStyle'],\n }\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n color: {\n default: null,\n parseHTML: element => element.style.color?.replace(/['\"]+/g, ''),\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n style: `color: ${attributes.color}`,\n }\n },\n },\n },\n },\n ]\n },\n\n addCommands() {\n return {\n setColor: color => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color })\n .run()\n },\n unsetColor: () => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color: null })\n .removeEmptyTextStyle()\n .run()\n },\n }\n },\n})\n"],"names":["Extension"],"mappings":";;;;;;;AAgCA;;;AAGG;AACU,MAAA,KAAK,GAAGA,cAAS,CAAC,MAAM,CAAe;AAClD,IAAA,IAAI,EAAE,OAAO;IAEb,UAAU,GAAA;QACR,OAAO;YACL,KAAK,EAAE,CAAC,WAAW,CAAC;SACrB,CAAA;KACF;IAED,mBAAmB,GAAA;QACjB,OAAO;AACL,YAAA;AACE,gBAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;AACzB,gBAAA,UAAU,EAAE;AACV,oBAAA,KAAK,EAAE;AACL,wBAAA,OAAO,EAAE,IAAI;wBACb,SAAS,EAAE,OAAO,cAAI,OAAA,CAAA,EAAA,GAAA,OAAO,CAAC,KAAK,CAAC,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA,EAAA;wBAChE,UAAU,EAAE,UAAU,IAAG;AACvB,4BAAA,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;AACrB,gCAAA,OAAO,EAAE,CAAA;6BACV;4BAED,OAAO;AACL,gCAAA,KAAK,EAAE,CAAA,OAAA,EAAU,UAAU,CAAC,KAAK,CAAE,CAAA;6BACpC,CAAA;yBACF;AACF,qBAAA;AACF,iBAAA;AACF,aAAA;SACF,CAAA;KACF;IAED,WAAW,GAAA;QACT,OAAO;YACL,QAAQ,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,KAAI;AAC/B,gBAAA,OAAO,KAAK,EAAE;AACX,qBAAA,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC;AAC/B,qBAAA,GAAG,EAAE,CAAA;aACT;YACD,UAAU,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,KAAI;AAC9B,gBAAA,OAAO,KAAK,EAAE;qBACX,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACrC,qBAAA,oBAAoB,EAAE;AACtB,qBAAA,GAAG,EAAE,CAAA;aACT;SACF,CAAA;KACF;AACF,CAAA;;;;;"}
1
+ {"version":3,"sources":["../src/index.ts","../src/color.ts"],"sourcesContent":["import { Color } from './color.js'\n\nexport * from './color.js'\n\nexport default Color\n","import '@tiptap/extension-text-style'\n\nimport { Extension } from '@tiptap/core'\n\nexport type ColorOptions = {\n /**\n * The types where the color can be applied\n * @default ['textStyle']\n * @example ['heading', 'paragraph']\n */\n types: string[],\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n color: {\n /**\n * Set the text color\n * @param color The color to set\n * @example editor.commands.setColor('red')\n */\n setColor: (color: string) => ReturnType,\n\n /**\n * Unset the text color\n * @example editor.commands.unsetColor()\n */\n unsetColor: () => ReturnType,\n }\n }\n}\n\n/**\n * This extension allows you to color your text.\n * @see https://tiptap.dev/api/extensions/color\n */\nexport const Color = Extension.create<ColorOptions>({\n name: 'color',\n\n addOptions() {\n return {\n types: ['textStyle'],\n }\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n color: {\n default: null,\n parseHTML: element => element.style.color?.replace(/['\"]+/g, ''),\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n style: `color: ${attributes.color}`,\n }\n },\n },\n },\n },\n ]\n },\n\n addCommands() {\n return {\n setColor: color => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color })\n .run()\n },\n unsetColor: () => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color: null })\n .removeEmptyTextStyle()\n .run()\n },\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kCAAO;AAEP,kBAA0B;AAkCnB,IAAM,QAAQ,sBAAU,OAAqB;AAAA,EAClD,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,OAAO,CAAC,WAAW;AAAA,IACrB;AAAA,EACF;AAAA,EAEA,sBAAsB;AACpB,WAAO;AAAA,MACL;AAAA,QACE,OAAO,KAAK,QAAQ;AAAA,QACpB,YAAY;AAAA,UACV,OAAO;AAAA,YACL,SAAS;AAAA,YACT,WAAW,aAAQ;AApD/B;AAoDkC,mCAAQ,MAAM,UAAd,mBAAqB,QAAQ,UAAU;AAAA;AAAA,YAC7D,YAAY,gBAAc;AACxB,kBAAI,CAAC,WAAW,OAAO;AACrB,uBAAO,CAAC;AAAA,cACV;AAEA,qBAAO;AAAA,gBACL,OAAO,UAAU,WAAW,KAAK;AAAA,cACnC;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,cAAc;AACZ,WAAO;AAAA,MACL,UAAU,WAAS,CAAC,EAAE,MAAM,MAAM;AAChC,eAAO,MAAM,EACV,QAAQ,aAAa,EAAE,MAAM,CAAC,EAC9B,IAAI;AAAA,MACT;AAAA,MACA,YAAY,MAAM,CAAC,EAAE,MAAM,MAAM;AAC/B,eAAO,MAAM,EACV,QAAQ,aAAa,EAAE,OAAO,KAAK,CAAC,EACpC,qBAAqB,EACrB,IAAI;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;AD/ED,IAAO,cAAQ;","names":[]}
@@ -1,6 +1,6 @@
1
- import '@tiptap/extension-text-style';
2
1
  import { Extension } from '@tiptap/core';
3
- export type ColorOptions = {
2
+
3
+ type ColorOptions = {
4
4
  /**
5
5
  * The types where the color can be applied
6
6
  * @default ['textStyle']
@@ -29,4 +29,6 @@ declare module '@tiptap/core' {
29
29
  * This extension allows you to color your text.
30
30
  * @see https://tiptap.dev/api/extensions/color
31
31
  */
32
- export declare const Color: Extension<ColorOptions, any>;
32
+ declare const Color: Extension<ColorOptions, any>;
33
+
34
+ export { Color, type ColorOptions, Color as default };
@@ -0,0 +1,34 @@
1
+ import { Extension } from '@tiptap/core';
2
+
3
+ type ColorOptions = {
4
+ /**
5
+ * The types where the color can be applied
6
+ * @default ['textStyle']
7
+ * @example ['heading', 'paragraph']
8
+ */
9
+ types: string[];
10
+ };
11
+ declare module '@tiptap/core' {
12
+ interface Commands<ReturnType> {
13
+ color: {
14
+ /**
15
+ * Set the text color
16
+ * @param color The color to set
17
+ * @example editor.commands.setColor('red')
18
+ */
19
+ setColor: (color: string) => ReturnType;
20
+ /**
21
+ * Unset the text color
22
+ * @example editor.commands.unsetColor()
23
+ */
24
+ unsetColor: () => ReturnType;
25
+ };
26
+ }
27
+ }
28
+ /**
29
+ * This extension allows you to color your text.
30
+ * @see https://tiptap.dev/api/extensions/color
31
+ */
32
+ declare const Color: Extension<ColorOptions, any>;
33
+
34
+ export { Color, type ColorOptions, Color as default };
package/dist/index.js CHANGED
@@ -1,54 +1,53 @@
1
- import '@tiptap/extension-text-style';
2
- import { Extension } from '@tiptap/core';
3
-
4
- /**
5
- * This extension allows you to color your text.
6
- * @see https://tiptap.dev/api/extensions/color
7
- */
8
- const Color = Extension.create({
9
- name: 'color',
10
- addOptions() {
11
- return {
12
- types: ['textStyle'],
13
- };
14
- },
15
- addGlobalAttributes() {
16
- return [
17
- {
18
- types: this.options.types,
19
- attributes: {
20
- color: {
21
- default: null,
22
- parseHTML: element => { var _a; return (_a = element.style.color) === null || _a === void 0 ? void 0 : _a.replace(/['"]+/g, ''); },
23
- renderHTML: attributes => {
24
- if (!attributes.color) {
25
- return {};
26
- }
27
- return {
28
- style: `color: ${attributes.color}`,
29
- };
30
- },
31
- },
32
- },
33
- },
34
- ];
35
- },
36
- addCommands() {
37
- return {
38
- setColor: color => ({ chain }) => {
39
- return chain()
40
- .setMark('textStyle', { color })
41
- .run();
42
- },
43
- unsetColor: () => ({ chain }) => {
44
- return chain()
45
- .setMark('textStyle', { color: null })
46
- .removeEmptyTextStyle()
47
- .run();
1
+ // src/color.ts
2
+ import "@tiptap/extension-text-style";
3
+ import { Extension } from "@tiptap/core";
4
+ var Color = Extension.create({
5
+ name: "color",
6
+ addOptions() {
7
+ return {
8
+ types: ["textStyle"]
9
+ };
10
+ },
11
+ addGlobalAttributes() {
12
+ return [
13
+ {
14
+ types: this.options.types,
15
+ attributes: {
16
+ color: {
17
+ default: null,
18
+ parseHTML: (element) => {
19
+ var _a;
20
+ return (_a = element.style.color) == null ? void 0 : _a.replace(/['"]+/g, "");
48
21
  },
49
- };
50
- },
22
+ renderHTML: (attributes) => {
23
+ if (!attributes.color) {
24
+ return {};
25
+ }
26
+ return {
27
+ style: `color: ${attributes.color}`
28
+ };
29
+ }
30
+ }
31
+ }
32
+ }
33
+ ];
34
+ },
35
+ addCommands() {
36
+ return {
37
+ setColor: (color) => ({ chain }) => {
38
+ return chain().setMark("textStyle", { color }).run();
39
+ },
40
+ unsetColor: () => ({ chain }) => {
41
+ return chain().setMark("textStyle", { color: null }).removeEmptyTextStyle().run();
42
+ }
43
+ };
44
+ }
51
45
  });
52
46
 
53
- export { Color, Color as default };
54
- //# sourceMappingURL=index.js.map
47
+ // src/index.ts
48
+ var src_default = Color;
49
+ export {
50
+ Color,
51
+ src_default as default
52
+ };
53
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/color.ts"],"sourcesContent":["import '@tiptap/extension-text-style'\n\nimport { Extension } from '@tiptap/core'\n\nexport type ColorOptions = {\n /**\n * The types where the color can be applied\n * @default ['textStyle']\n * @example ['heading', 'paragraph']\n */\n types: string[],\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n color: {\n /**\n * Set the text color\n * @param color The color to set\n * @example editor.commands.setColor('red')\n */\n setColor: (color: string) => ReturnType,\n\n /**\n * Unset the text color\n * @example editor.commands.unsetColor()\n */\n unsetColor: () => ReturnType,\n }\n }\n}\n\n/**\n * This extension allows you to color your text.\n * @see https://tiptap.dev/api/extensions/color\n */\nexport const Color = Extension.create<ColorOptions>({\n name: 'color',\n\n addOptions() {\n return {\n types: ['textStyle'],\n }\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n color: {\n default: null,\n parseHTML: element => element.style.color?.replace(/['\"]+/g, ''),\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n style: `color: ${attributes.color}`,\n }\n },\n },\n },\n },\n ]\n },\n\n addCommands() {\n return {\n setColor: color => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color })\n .run()\n },\n unsetColor: () => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color: null })\n .removeEmptyTextStyle()\n .run()\n },\n }\n },\n})\n"],"names":[],"mappings":";;;AAgCA;;;AAGG;AACU,MAAA,KAAK,GAAG,SAAS,CAAC,MAAM,CAAe;AAClD,IAAA,IAAI,EAAE,OAAO;IAEb,UAAU,GAAA;QACR,OAAO;YACL,KAAK,EAAE,CAAC,WAAW,CAAC;SACrB,CAAA;KACF;IAED,mBAAmB,GAAA;QACjB,OAAO;AACL,YAAA;AACE,gBAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;AACzB,gBAAA,UAAU,EAAE;AACV,oBAAA,KAAK,EAAE;AACL,wBAAA,OAAO,EAAE,IAAI;wBACb,SAAS,EAAE,OAAO,cAAI,OAAA,CAAA,EAAA,GAAA,OAAO,CAAC,KAAK,CAAC,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA,EAAA;wBAChE,UAAU,EAAE,UAAU,IAAG;AACvB,4BAAA,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;AACrB,gCAAA,OAAO,EAAE,CAAA;6BACV;4BAED,OAAO;AACL,gCAAA,KAAK,EAAE,CAAA,OAAA,EAAU,UAAU,CAAC,KAAK,CAAE,CAAA;6BACpC,CAAA;yBACF;AACF,qBAAA;AACF,iBAAA;AACF,aAAA;SACF,CAAA;KACF;IAED,WAAW,GAAA;QACT,OAAO;YACL,QAAQ,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,KAAI;AAC/B,gBAAA,OAAO,KAAK,EAAE;AACX,qBAAA,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC;AAC/B,qBAAA,GAAG,EAAE,CAAA;aACT;YACD,UAAU,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,KAAI;AAC9B,gBAAA,OAAO,KAAK,EAAE;qBACX,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACrC,qBAAA,oBAAoB,EAAE;AACtB,qBAAA,GAAG,EAAE,CAAA;aACT;SACF,CAAA;KACF;AACF,CAAA;;;;"}
1
+ {"version":3,"sources":["../src/color.ts","../src/index.ts"],"sourcesContent":["import '@tiptap/extension-text-style'\n\nimport { Extension } from '@tiptap/core'\n\nexport type ColorOptions = {\n /**\n * The types where the color can be applied\n * @default ['textStyle']\n * @example ['heading', 'paragraph']\n */\n types: string[],\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n color: {\n /**\n * Set the text color\n * @param color The color to set\n * @example editor.commands.setColor('red')\n */\n setColor: (color: string) => ReturnType,\n\n /**\n * Unset the text color\n * @example editor.commands.unsetColor()\n */\n unsetColor: () => ReturnType,\n }\n }\n}\n\n/**\n * This extension allows you to color your text.\n * @see https://tiptap.dev/api/extensions/color\n */\nexport const Color = Extension.create<ColorOptions>({\n name: 'color',\n\n addOptions() {\n return {\n types: ['textStyle'],\n }\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n color: {\n default: null,\n parseHTML: element => element.style.color?.replace(/['\"]+/g, ''),\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n style: `color: ${attributes.color}`,\n }\n },\n },\n },\n },\n ]\n },\n\n addCommands() {\n return {\n setColor: color => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color })\n .run()\n },\n unsetColor: () => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color: null })\n .removeEmptyTextStyle()\n .run()\n },\n }\n },\n})\n","import { Color } from './color.js'\n\nexport * from './color.js'\n\nexport default Color\n"],"mappings":";AAAA,OAAO;AAEP,SAAS,iBAAiB;AAkCnB,IAAM,QAAQ,UAAU,OAAqB;AAAA,EAClD,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,OAAO,CAAC,WAAW;AAAA,IACrB;AAAA,EACF;AAAA,EAEA,sBAAsB;AACpB,WAAO;AAAA,MACL;AAAA,QACE,OAAO,KAAK,QAAQ;AAAA,QACpB,YAAY;AAAA,UACV,OAAO;AAAA,YACL,SAAS;AAAA,YACT,WAAW,aAAQ;AApD/B;AAoDkC,mCAAQ,MAAM,UAAd,mBAAqB,QAAQ,UAAU;AAAA;AAAA,YAC7D,YAAY,gBAAc;AACxB,kBAAI,CAAC,WAAW,OAAO;AACrB,uBAAO,CAAC;AAAA,cACV;AAEA,qBAAO;AAAA,gBACL,OAAO,UAAU,WAAW,KAAK;AAAA,cACnC;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,cAAc;AACZ,WAAO;AAAA,MACL,UAAU,WAAS,CAAC,EAAE,MAAM,MAAM;AAChC,eAAO,MAAM,EACV,QAAQ,aAAa,EAAE,MAAM,CAAC,EAC9B,IAAI;AAAA,MACT;AAAA,MACA,YAAY,MAAM,CAAC,EAAE,MAAM,MAAM;AAC/B,eAAO,MAAM,EACV,QAAQ,aAAa,EAAE,OAAO,KAAK,CAAC,EACpC,qBAAqB,EACrB,IAAI;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;AC/ED,IAAO,cAAQ;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-color",
3
3
  "description": "text color extension for tiptap",
4
- "version": "3.0.0-next.0",
4
+ "version": "3.0.0-next.2",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -15,26 +15,25 @@
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/packages/extension-color/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-color/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": "^3.0.0-next.0",
33
- "@tiptap/extension-text-style": "^3.0.0-next.0"
31
+ "@tiptap/core": "^3.0.0-next.2",
32
+ "@tiptap/extension-text-style": "^3.0.0-next.2"
34
33
  },
35
34
  "peerDependencies": {
36
- "@tiptap/core": "^3.0.0-next.0",
37
- "@tiptap/extension-text-style": "^3.0.0-next.0"
35
+ "@tiptap/core": "^3.0.0-next.1",
36
+ "@tiptap/extension-text-style": "^3.0.0-next.1"
38
37
  },
39
38
  "repository": {
40
39
  "type": "git",
@@ -42,7 +41,6 @@
42
41
  "directory": "packages/extension-color"
43
42
  },
44
43
  "scripts": {
45
- "clean": "rm -rf dist",
46
- "build": "npm run clean && rollup -c"
44
+ "build": "tsup"
47
45
  }
48
46
  }
package/dist/index.umd.js DELETED
@@ -1,62 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/extension-text-style'), require('@tiptap/core')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tiptap/extension-text-style', '@tiptap/core'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-color"] = {}, null, global.core));
5
- })(this, (function (exports, extensionTextStyle, core) { 'use strict';
6
-
7
- /**
8
- * This extension allows you to color your text.
9
- * @see https://tiptap.dev/api/extensions/color
10
- */
11
- const Color = core.Extension.create({
12
- name: 'color',
13
- addOptions() {
14
- return {
15
- types: ['textStyle'],
16
- };
17
- },
18
- addGlobalAttributes() {
19
- return [
20
- {
21
- types: this.options.types,
22
- attributes: {
23
- color: {
24
- default: null,
25
- parseHTML: element => { var _a; return (_a = element.style.color) === null || _a === void 0 ? void 0 : _a.replace(/['"]+/g, ''); },
26
- renderHTML: attributes => {
27
- if (!attributes.color) {
28
- return {};
29
- }
30
- return {
31
- style: `color: ${attributes.color}`,
32
- };
33
- },
34
- },
35
- },
36
- },
37
- ];
38
- },
39
- addCommands() {
40
- return {
41
- setColor: color => ({ chain }) => {
42
- return chain()
43
- .setMark('textStyle', { color })
44
- .run();
45
- },
46
- unsetColor: () => ({ chain }) => {
47
- return chain()
48
- .setMark('textStyle', { color: null })
49
- .removeEmptyTextStyle()
50
- .run();
51
- },
52
- };
53
- },
54
- });
55
-
56
- exports.Color = Color;
57
- exports.default = Color;
58
-
59
- Object.defineProperty(exports, '__esModule', { value: true });
60
-
61
- }));
62
- //# sourceMappingURL=index.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/color.ts"],"sourcesContent":["import '@tiptap/extension-text-style'\n\nimport { Extension } from '@tiptap/core'\n\nexport type ColorOptions = {\n /**\n * The types where the color can be applied\n * @default ['textStyle']\n * @example ['heading', 'paragraph']\n */\n types: string[],\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n color: {\n /**\n * Set the text color\n * @param color The color to set\n * @example editor.commands.setColor('red')\n */\n setColor: (color: string) => ReturnType,\n\n /**\n * Unset the text color\n * @example editor.commands.unsetColor()\n */\n unsetColor: () => ReturnType,\n }\n }\n}\n\n/**\n * This extension allows you to color your text.\n * @see https://tiptap.dev/api/extensions/color\n */\nexport const Color = Extension.create<ColorOptions>({\n name: 'color',\n\n addOptions() {\n return {\n types: ['textStyle'],\n }\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n color: {\n default: null,\n parseHTML: element => element.style.color?.replace(/['\"]+/g, ''),\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n style: `color: ${attributes.color}`,\n }\n },\n },\n },\n },\n ]\n },\n\n addCommands() {\n return {\n setColor: color => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color })\n .run()\n },\n unsetColor: () => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color: null })\n .removeEmptyTextStyle()\n .run()\n },\n }\n },\n})\n"],"names":["Extension"],"mappings":";;;;;;EAgCA;;;EAGG;AACU,QAAA,KAAK,GAAGA,cAAS,CAAC,MAAM,CAAe;EAClD,IAAA,IAAI,EAAE,OAAO;MAEb,UAAU,GAAA;UACR,OAAO;cACL,KAAK,EAAE,CAAC,WAAW,CAAC;WACrB,CAAA;OACF;MAED,mBAAmB,GAAA;UACjB,OAAO;EACL,YAAA;EACE,gBAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;EACzB,gBAAA,UAAU,EAAE;EACV,oBAAA,KAAK,EAAE;EACL,wBAAA,OAAO,EAAE,IAAI;0BACb,SAAS,EAAE,OAAO,cAAI,OAAA,CAAA,EAAA,GAAA,OAAO,CAAC,KAAK,CAAC,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA,EAAA;0BAChE,UAAU,EAAE,UAAU,IAAG;EACvB,4BAAA,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;EACrB,gCAAA,OAAO,EAAE,CAAA;+BACV;8BAED,OAAO;EACL,gCAAA,KAAK,EAAE,CAAA,OAAA,EAAU,UAAU,CAAC,KAAK,CAAE,CAAA;+BACpC,CAAA;2BACF;EACF,qBAAA;EACF,iBAAA;EACF,aAAA;WACF,CAAA;OACF;MAED,WAAW,GAAA;UACT,OAAO;cACL,QAAQ,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,KAAI;EAC/B,gBAAA,OAAO,KAAK,EAAE;EACX,qBAAA,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC;EAC/B,qBAAA,GAAG,EAAE,CAAA;eACT;cACD,UAAU,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,KAAI;EAC9B,gBAAA,OAAO,KAAK,EAAE;uBACX,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;EACrC,qBAAA,oBAAoB,EAAE;EACtB,qBAAA,GAAG,EAAE,CAAA;eACT;WACF,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,159 +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
- extensionStorage: Record<string, any>;
20
- options: EditorOptions;
21
- constructor(options?: Partial<EditorOptions>);
22
- /**
23
- * Returns the editor storage.
24
- */
25
- get storage(): Record<string, any>;
26
- /**
27
- * An object of all registered commands.
28
- */
29
- get commands(): SingleCommands;
30
- /**
31
- * Create a command chain to call multiple commands at once.
32
- */
33
- chain(): ChainedCommands;
34
- /**
35
- * Check if a command or a command chain can be executed. Without executing it.
36
- */
37
- can(): CanCommands;
38
- /**
39
- * Inject CSS styles.
40
- */
41
- private injectCSS;
42
- /**
43
- * Update editor options.
44
- *
45
- * @param options A list of options
46
- */
47
- setOptions(options?: Partial<EditorOptions>): void;
48
- /**
49
- * Update editable state of the editor.
50
- */
51
- setEditable(editable: boolean, emitUpdate?: boolean): void;
52
- /**
53
- * Returns whether the editor is editable.
54
- */
55
- get isEditable(): boolean;
56
- /**
57
- * Returns the editor state.
58
- */
59
- get state(): EditorState;
60
- /**
61
- * Register a ProseMirror plugin.
62
- *
63
- * @param plugin A ProseMirror plugin
64
- * @param handlePlugins Control how to merge the plugin into the existing plugins.
65
- */
66
- registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): void;
67
- /**
68
- * Unregister a ProseMirror plugin.
69
- *
70
- * @param nameOrPluginKey The plugins name
71
- */
72
- unregisterPlugin(nameOrPluginKey: string | PluginKey): void;
73
- /**
74
- * Creates an extension manager.
75
- */
76
- private createExtensionManager;
77
- /**
78
- * Creates an command manager.
79
- */
80
- private createCommandManager;
81
- /**
82
- * Creates a ProseMirror schema.
83
- */
84
- private createSchema;
85
- /**
86
- * Creates a ProseMirror view.
87
- */
88
- private createView;
89
- /**
90
- * Creates all node views.
91
- */
92
- createNodeViews(): void;
93
- /**
94
- * Prepend class name to element.
95
- */
96
- prependClass(): void;
97
- isCapturingTransaction: boolean;
98
- private capturedTransaction;
99
- captureTransaction(fn: Function): Transaction | null;
100
- /**
101
- * The callback over which to send transactions (state updates) produced by the view.
102
- *
103
- * @param transaction An editor state transaction
104
- */
105
- private dispatchTransaction;
106
- /**
107
- * Get attributes of the currently selected node or mark.
108
- */
109
- getAttributes(nameOrType: string | NodeType | MarkType): Record<string, any>;
110
- /**
111
- * Returns if the currently selected node or mark is active.
112
- *
113
- * @param name Name of the node or mark
114
- * @param attributes Attributes of the node or mark
115
- */
116
- isActive(name: string, attributes?: {}): boolean;
117
- isActive(attributes: {}): boolean;
118
- /**
119
- * Get the document as JSON.
120
- */
121
- getJSON(): JSONContent;
122
- /**
123
- * Get the document as HTML.
124
- */
125
- getHTML(): string;
126
- /**
127
- * Get the document as text.
128
- */
129
- getText(options?: {
130
- blockSeparator?: string;
131
- textSerializers?: Record<string, TextSerializer>;
132
- }): string;
133
- /**
134
- * Check if there is no content.
135
- */
136
- get isEmpty(): boolean;
137
- /**
138
- * Get the number of characters for the current document.
139
- *
140
- * @deprecated
141
- */
142
- getCharacterCount(): number;
143
- /**
144
- * Destroy the editor.
145
- */
146
- destroy(): void;
147
- /**
148
- * Check if the editor is already destroyed.
149
- */
150
- get isDestroyed(): boolean;
151
- $node(selector: string, attributes?: {
152
- [key: string]: any;
153
- }): NodePos | null;
154
- $nodes(selector: string, attributes?: {
155
- [key: string]: any;
156
- }): NodePos[] | null;
157
- $pos(pos: number): NodePos;
158
- get $doc(): NodePos;
159
- }
@@ -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 {};