@tiptap/extension-link 3.0.0 → 3.0.2-beta.0

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 (181) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +5 -1
  3. package/dist/index.cjs +410 -319
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/{packages/extension-link/src/link.d.ts → index.d.cts} +57 -7
  6. package/dist/index.d.ts +149 -0
  7. package/dist/index.js +383 -315
  8. package/dist/index.js.map +1 -1
  9. package/package.json +14 -12
  10. package/src/helpers/autolink.ts +19 -31
  11. package/src/helpers/clickHandler.ts +25 -9
  12. package/src/helpers/pasteHandler.ts +6 -6
  13. package/src/helpers/whitespace.ts +7 -0
  14. package/src/link.ts +195 -47
  15. package/dist/index.umd.js +0 -344
  16. package/dist/index.umd.js.map +0 -1
  17. package/dist/packages/core/src/CommandManager.d.ts +0 -20
  18. package/dist/packages/core/src/Editor.d.ts +0 -161
  19. package/dist/packages/core/src/EventEmitter.d.ts +0 -11
  20. package/dist/packages/core/src/Extension.d.ts +0 -343
  21. package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
  22. package/dist/packages/core/src/InputRule.d.ts +0 -42
  23. package/dist/packages/core/src/Mark.d.ts +0 -451
  24. package/dist/packages/core/src/Node.d.ts +0 -611
  25. package/dist/packages/core/src/NodePos.d.ts +0 -44
  26. package/dist/packages/core/src/NodeView.d.ts +0 -31
  27. package/dist/packages/core/src/PasteRule.d.ts +0 -50
  28. package/dist/packages/core/src/Tracker.d.ts +0 -11
  29. package/dist/packages/core/src/commands/blur.d.ts +0 -13
  30. package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
  31. package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
  32. package/dist/packages/core/src/commands/command.d.ts +0 -18
  33. package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
  34. package/dist/packages/core/src/commands/cut.d.ts +0 -20
  35. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
  36. package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
  37. package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
  38. package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
  39. package/dist/packages/core/src/commands/enter.d.ts +0 -13
  40. package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
  41. package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
  42. package/dist/packages/core/src/commands/first.d.ts +0 -14
  43. package/dist/packages/core/src/commands/focus.d.ts +0 -27
  44. package/dist/packages/core/src/commands/forEach.d.ts +0 -14
  45. package/dist/packages/core/src/commands/index.d.ts +0 -55
  46. package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
  47. package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
  48. package/dist/packages/core/src/commands/join.d.ts +0 -41
  49. package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
  50. package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
  51. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
  52. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
  53. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
  54. package/dist/packages/core/src/commands/lift.d.ts +0 -17
  55. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
  56. package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
  57. package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
  58. package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
  59. package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
  60. package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
  61. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
  62. package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
  63. package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
  64. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
  65. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
  66. package/dist/packages/core/src/commands/setContent.d.ts +0 -40
  67. package/dist/packages/core/src/commands/setMark.d.ts +0 -15
  68. package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
  69. package/dist/packages/core/src/commands/setNode.d.ts +0 -16
  70. package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
  71. package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
  72. package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
  73. package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
  74. package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
  75. package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
  76. package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
  77. package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
  78. package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
  79. package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
  80. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
  81. package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
  82. package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
  83. package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
  84. package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
  85. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
  86. package/dist/packages/core/src/extensions/commands.d.ts +0 -3
  87. package/dist/packages/core/src/extensions/editable.d.ts +0 -2
  88. package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
  89. package/dist/packages/core/src/extensions/index.d.ts +0 -6
  90. package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
  91. package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
  92. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
  93. package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
  94. package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
  95. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
  96. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
  97. package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
  98. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
  99. package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
  100. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
  101. package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
  102. package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
  103. package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
  104. package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
  105. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
  106. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
  107. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
  108. package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
  109. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
  110. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
  111. package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
  112. package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
  113. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
  114. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
  115. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
  116. package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
  117. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
  118. package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
  119. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
  120. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
  121. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
  122. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
  123. package/dist/packages/core/src/helpers/getText.d.ts +0 -15
  124. package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
  125. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
  126. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
  127. package/dist/packages/core/src/helpers/index.d.ts +0 -50
  128. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
  129. package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
  130. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
  131. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
  132. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
  133. package/dist/packages/core/src/helpers/isList.d.ts +0 -2
  134. package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
  135. package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
  136. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
  137. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
  138. package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
  139. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
  140. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
  141. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
  142. package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
  143. package/dist/packages/core/src/index.d.ts +0 -24
  144. package/dist/packages/core/src/inputRules/index.d.ts +0 -5
  145. package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
  146. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
  147. package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
  148. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
  149. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
  150. package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
  151. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
  152. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
  153. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
  154. package/dist/packages/core/src/style.d.ts +0 -1
  155. package/dist/packages/core/src/types.d.ts +0 -255
  156. package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
  157. package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
  158. package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
  159. package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
  160. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
  161. package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
  162. package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
  163. package/dist/packages/core/src/utilities/index.d.ts +0 -20
  164. package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
  165. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
  166. package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
  167. package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
  168. package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
  169. package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
  170. package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
  171. package/dist/packages/core/src/utilities/isString.d.ts +0 -1
  172. package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
  173. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
  174. package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
  175. package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
  176. package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
  177. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
  178. package/dist/packages/extension-link/src/helpers/autolink.d.ts +0 -14
  179. package/dist/packages/extension-link/src/helpers/clickHandler.d.ts +0 -7
  180. package/dist/packages/extension-link/src/helpers/pasteHandler.d.ts +0 -10
  181. package/dist/packages/extension-link/src/index.d.ts +0 -3
package/dist/index.umd.js DELETED
@@ -1,344 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('linkifyjs'), require('@tiptap/pm/state')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', 'linkifyjs', '@tiptap/pm/state'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-link"] = {}, global.core, global.linkifyjs, global.state));
5
- })(this, (function (exports, core, linkifyjs, state) { 'use strict';
6
-
7
- /**
8
- * Check if the provided tokens form a valid link structure, which can either be a single link token
9
- * or a link token surrounded by parentheses or square brackets.
10
- *
11
- * This ensures that only complete and valid text is hyperlinked, preventing cases where a valid
12
- * top-level domain (TLD) is immediately followed by an invalid character, like a number. For
13
- * example, with the `find` method from Linkify, entering `example.com1` would result in
14
- * `example.com` being linked and the trailing `1` left as plain text. By using the `tokenize`
15
- * method, we can perform more comprehensive validation on the input text.
16
- */
17
- function isValidLinkStructure(tokens) {
18
- if (tokens.length === 1) {
19
- return tokens[0].isLink;
20
- }
21
- if (tokens.length === 3 && tokens[1].isLink) {
22
- return ['()', '[]'].includes(tokens[0].value + tokens[2].value);
23
- }
24
- return false;
25
- }
26
- /**
27
- * This plugin allows you to automatically add links to your editor.
28
- * @param options The plugin options
29
- * @returns The plugin instance
30
- */
31
- function autolink(options) {
32
- return new state.Plugin({
33
- key: new state.PluginKey('autolink'),
34
- appendTransaction: (transactions, oldState, newState) => {
35
- /**
36
- * Does the transaction change the document?
37
- */
38
- const docChanges = transactions.some(transaction => transaction.docChanged) && !oldState.doc.eq(newState.doc);
39
- /**
40
- * Prevent autolink if the transaction is not a document change or if the transaction has the meta `preventAutolink`.
41
- */
42
- const preventAutolink = transactions.some(transaction => transaction.getMeta('preventAutolink'));
43
- /**
44
- * Prevent autolink if the transaction is not a document change
45
- * or if the transaction has the meta `preventAutolink`.
46
- */
47
- if (!docChanges || preventAutolink) {
48
- return;
49
- }
50
- const { tr } = newState;
51
- const transform = core.combineTransactionSteps(oldState.doc, [...transactions]);
52
- const changes = core.getChangedRanges(transform);
53
- changes.forEach(({ newRange }) => {
54
- // Now let’s see if we can add new links.
55
- const nodesInChangedRanges = core.findChildrenInRange(newState.doc, newRange, node => node.isTextblock);
56
- let textBlock;
57
- let textBeforeWhitespace;
58
- if (nodesInChangedRanges.length > 1) {
59
- // Grab the first node within the changed ranges (ex. the first of two paragraphs when hitting enter).
60
- textBlock = nodesInChangedRanges[0];
61
- textBeforeWhitespace = newState.doc.textBetween(textBlock.pos, textBlock.pos + textBlock.node.nodeSize, undefined, ' ');
62
- }
63
- else if (nodesInChangedRanges.length
64
- // We want to make sure to include the block seperator argument to treat hard breaks like spaces.
65
- && newState.doc.textBetween(newRange.from, newRange.to, ' ', ' ').endsWith(' ')) {
66
- textBlock = nodesInChangedRanges[0];
67
- textBeforeWhitespace = newState.doc.textBetween(textBlock.pos, newRange.to, undefined, ' ');
68
- }
69
- if (textBlock && textBeforeWhitespace) {
70
- const wordsBeforeWhitespace = textBeforeWhitespace.split(' ').filter(s => s !== '');
71
- if (wordsBeforeWhitespace.length <= 0) {
72
- return false;
73
- }
74
- const lastWordBeforeSpace = wordsBeforeWhitespace[wordsBeforeWhitespace.length - 1];
75
- const lastWordAndBlockOffset = textBlock.pos + textBeforeWhitespace.lastIndexOf(lastWordBeforeSpace);
76
- if (!lastWordBeforeSpace) {
77
- return false;
78
- }
79
- const linksBeforeSpace = linkifyjs.tokenize(lastWordBeforeSpace).map(t => t.toObject(options.defaultProtocol));
80
- if (!isValidLinkStructure(linksBeforeSpace)) {
81
- return false;
82
- }
83
- linksBeforeSpace
84
- .filter(link => link.isLink)
85
- // Calculate link position.
86
- .map(link => ({
87
- ...link,
88
- from: lastWordAndBlockOffset + link.start + 1,
89
- to: lastWordAndBlockOffset + link.end + 1,
90
- }))
91
- // ignore link inside code mark
92
- .filter(link => {
93
- if (!newState.schema.marks.code) {
94
- return true;
95
- }
96
- return !newState.doc.rangeHasMark(link.from, link.to, newState.schema.marks.code);
97
- })
98
- // validate link
99
- .filter(link => options.validate(link.value))
100
- // Add link mark.
101
- .forEach(link => {
102
- if (core.getMarksBetween(link.from, link.to, newState.doc).some(item => item.mark.type === options.type)) {
103
- return;
104
- }
105
- tr.addMark(link.from, link.to, options.type.create({
106
- href: link.href,
107
- }));
108
- });
109
- }
110
- });
111
- if (!tr.steps.length) {
112
- return;
113
- }
114
- return tr;
115
- },
116
- });
117
- }
118
-
119
- function clickHandler(options) {
120
- return new state.Plugin({
121
- key: new state.PluginKey('handleClickLink'),
122
- props: {
123
- handleClick: (view, pos, event) => {
124
- var _a, _b;
125
- if (event.button !== 0) {
126
- return false;
127
- }
128
- let a = event.target;
129
- const els = [];
130
- while (a.nodeName !== 'DIV') {
131
- els.push(a);
132
- a = a.parentNode;
133
- }
134
- if (!els.find(value => value.nodeName === 'A')) {
135
- return false;
136
- }
137
- const attrs = core.getAttributes(view.state, options.type.name);
138
- const link = event.target;
139
- const href = (_a = link === null || link === void 0 ? void 0 : link.href) !== null && _a !== void 0 ? _a : attrs.href;
140
- const target = (_b = link === null || link === void 0 ? void 0 : link.target) !== null && _b !== void 0 ? _b : attrs.target;
141
- if (link && href) {
142
- window.open(href, target);
143
- return true;
144
- }
145
- return false;
146
- },
147
- },
148
- });
149
- }
150
-
151
- function pasteHandler(options) {
152
- return new state.Plugin({
153
- key: new state.PluginKey('handlePasteLink'),
154
- props: {
155
- handlePaste: (view, event, slice) => {
156
- const { state } = view;
157
- const { selection } = state;
158
- const { empty } = selection;
159
- if (empty) {
160
- return false;
161
- }
162
- let textContent = '';
163
- slice.content.forEach(node => {
164
- textContent += node.textContent;
165
- });
166
- const link = linkifyjs.find(textContent, { defaultProtocol: options.defaultProtocol }).find(item => item.isLink && item.value === textContent);
167
- if (!textContent || !link) {
168
- return false;
169
- }
170
- options.editor.commands.setMark(options.type, {
171
- href: link.href,
172
- });
173
- return true;
174
- },
175
- },
176
- });
177
- }
178
-
179
- const pasteRegex = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)/gi;
180
- // From DOMPurify
181
- // https://github.com/cure53/DOMPurify/blob/main/src/regexp.js
182
- const ATTR_WHITESPACE = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g; // eslint-disable-line no-control-regex
183
- const IS_ALLOWED_URI = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i; // eslint-disable-line no-useless-escape
184
- function isAllowedUri(uri) {
185
- return !uri || uri.replace(ATTR_WHITESPACE, '').match(IS_ALLOWED_URI);
186
- }
187
- /**
188
- * This extension allows you to create links.
189
- * @see https://www.tiptap.dev/api/marks/link
190
- */
191
- const Link = core.Mark.create({
192
- name: 'link',
193
- priority: 1000,
194
- keepOnSplit: false,
195
- exitable: true,
196
- onCreate() {
197
- this.options.protocols.forEach(protocol => {
198
- if (typeof protocol === 'string') {
199
- linkifyjs.registerCustomProtocol(protocol);
200
- return;
201
- }
202
- linkifyjs.registerCustomProtocol(protocol.scheme, protocol.optionalSlashes);
203
- });
204
- },
205
- onDestroy() {
206
- linkifyjs.reset();
207
- },
208
- inclusive() {
209
- return this.options.autolink;
210
- },
211
- addOptions() {
212
- return {
213
- openOnClick: true,
214
- linkOnPaste: true,
215
- autolink: true,
216
- protocols: [],
217
- defaultProtocol: 'http',
218
- HTMLAttributes: {
219
- target: '_blank',
220
- rel: 'noopener noreferrer nofollow',
221
- class: null,
222
- },
223
- validate: url => !!url,
224
- };
225
- },
226
- addAttributes() {
227
- return {
228
- href: {
229
- default: null,
230
- },
231
- target: {
232
- default: this.options.HTMLAttributes.target,
233
- },
234
- rel: {
235
- default: this.options.HTMLAttributes.rel,
236
- },
237
- class: {
238
- default: this.options.HTMLAttributes.class,
239
- },
240
- };
241
- },
242
- parseHTML() {
243
- return [{
244
- tag: 'a[href]',
245
- getAttrs: dom => {
246
- const href = dom.getAttribute('href');
247
- // prevent XSS attacks
248
- if (!href || !isAllowedUri(href)) {
249
- return false;
250
- }
251
- return { href };
252
- },
253
- }];
254
- },
255
- renderHTML({ HTMLAttributes }) {
256
- // prevent XSS attacks
257
- if (!isAllowedUri(HTMLAttributes.href)) {
258
- // strip out the href
259
- return ['a', core.mergeAttributes(this.options.HTMLAttributes, { ...HTMLAttributes, href: '' }), 0];
260
- }
261
- return ['a', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
262
- },
263
- addCommands() {
264
- return {
265
- setLink: attributes => ({ chain }) => {
266
- return chain().setMark(this.name, attributes).setMeta('preventAutolink', true).run();
267
- },
268
- toggleLink: attributes => ({ chain }) => {
269
- return chain()
270
- .toggleMark(this.name, attributes, { extendEmptyMarkRange: true })
271
- .setMeta('preventAutolink', true)
272
- .run();
273
- },
274
- unsetLink: () => ({ chain }) => {
275
- return chain()
276
- .unsetMark(this.name, { extendEmptyMarkRange: true })
277
- .setMeta('preventAutolink', true)
278
- .run();
279
- },
280
- };
281
- },
282
- addPasteRules() {
283
- return [
284
- core.markPasteRule({
285
- find: text => {
286
- const foundLinks = [];
287
- if (text) {
288
- const { validate } = this.options;
289
- const links = linkifyjs.find(text).filter(item => item.isLink && validate(item.value));
290
- if (links.length) {
291
- links.forEach(link => (foundLinks.push({
292
- text: link.value,
293
- data: {
294
- href: link.href,
295
- },
296
- index: link.start,
297
- })));
298
- }
299
- }
300
- return foundLinks;
301
- },
302
- type: this.type,
303
- getAttributes: match => {
304
- var _a;
305
- return {
306
- href: (_a = match.data) === null || _a === void 0 ? void 0 : _a.href,
307
- };
308
- },
309
- }),
310
- ];
311
- },
312
- addProseMirrorPlugins() {
313
- const plugins = [];
314
- if (this.options.autolink) {
315
- plugins.push(autolink({
316
- type: this.type,
317
- defaultProtocol: this.options.defaultProtocol,
318
- validate: this.options.validate,
319
- }));
320
- }
321
- if (this.options.openOnClick) {
322
- plugins.push(clickHandler({
323
- type: this.type,
324
- }));
325
- }
326
- if (this.options.linkOnPaste) {
327
- plugins.push(pasteHandler({
328
- editor: this.editor,
329
- defaultProtocol: this.options.defaultProtocol,
330
- type: this.type,
331
- }));
332
- }
333
- return plugins;
334
- },
335
- });
336
-
337
- exports.Link = Link;
338
- exports.default = Link;
339
- exports.pasteRegex = pasteRegex;
340
-
341
- Object.defineProperty(exports, '__esModule', { value: true });
342
-
343
- }));
344
- //# sourceMappingURL=index.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/helpers/autolink.ts","../src/helpers/clickHandler.ts","../src/helpers/pasteHandler.ts","../src/link.ts"],"sourcesContent":["import {\n combineTransactionSteps,\n findChildrenInRange,\n getChangedRanges,\n getMarksBetween,\n NodeWithPos,\n} from '@tiptap/core'\nimport { MarkType } from '@tiptap/pm/model'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport { MultiToken, tokenize } from 'linkifyjs'\n\n/**\n * Check if the provided tokens form a valid link structure, which can either be a single link token\n * or a link token surrounded by parentheses or square brackets.\n *\n * This ensures that only complete and valid text is hyperlinked, preventing cases where a valid\n * top-level domain (TLD) is immediately followed by an invalid character, like a number. For\n * example, with the `find` method from Linkify, entering `example.com1` would result in\n * `example.com` being linked and the trailing `1` left as plain text. By using the `tokenize`\n * method, we can perform more comprehensive validation on the input text.\n */\nfunction isValidLinkStructure(tokens: Array<ReturnType<MultiToken['toObject']>>) {\n if (tokens.length === 1) {\n return tokens[0].isLink\n }\n\n if (tokens.length === 3 && tokens[1].isLink) {\n return ['()', '[]'].includes(tokens[0].value + tokens[2].value)\n }\n\n return false\n}\n\ntype AutolinkOptions = {\n type: MarkType\n defaultProtocol: string\n validate: (url: string) => boolean\n}\n\n/**\n * This plugin allows you to automatically add links to your editor.\n * @param options The plugin options\n * @returns The plugin instance\n */\nexport function autolink(options: AutolinkOptions): Plugin {\n return new Plugin({\n key: new PluginKey('autolink'),\n appendTransaction: (transactions, oldState, newState) => {\n /**\n * Does the transaction change the document?\n */\n const docChanges = transactions.some(transaction => transaction.docChanged) && !oldState.doc.eq(newState.doc)\n\n /**\n * Prevent autolink if the transaction is not a document change or if the transaction has the meta `preventAutolink`.\n */\n const preventAutolink = transactions.some(transaction => transaction.getMeta('preventAutolink'))\n\n /**\n * Prevent autolink if the transaction is not a document change\n * or if the transaction has the meta `preventAutolink`.\n */\n if (!docChanges || preventAutolink) {\n return\n }\n\n const { tr } = newState\n const transform = combineTransactionSteps(oldState.doc, [...transactions])\n const changes = getChangedRanges(transform)\n\n changes.forEach(({ newRange }) => {\n // Now let’s see if we can add new links.\n const nodesInChangedRanges = findChildrenInRange(\n newState.doc,\n newRange,\n node => node.isTextblock,\n )\n\n let textBlock: NodeWithPos | undefined\n let textBeforeWhitespace: string | undefined\n\n if (nodesInChangedRanges.length > 1) {\n // Grab the first node within the changed ranges (ex. the first of two paragraphs when hitting enter).\n textBlock = nodesInChangedRanges[0]\n textBeforeWhitespace = newState.doc.textBetween(\n textBlock.pos,\n textBlock.pos + textBlock.node.nodeSize,\n undefined,\n ' ',\n )\n } else if (\n nodesInChangedRanges.length\n // We want to make sure to include the block seperator argument to treat hard breaks like spaces.\n && newState.doc.textBetween(newRange.from, newRange.to, ' ', ' ').endsWith(' ')\n ) {\n textBlock = nodesInChangedRanges[0]\n textBeforeWhitespace = newState.doc.textBetween(\n textBlock.pos,\n newRange.to,\n undefined,\n ' ',\n )\n }\n\n if (textBlock && textBeforeWhitespace) {\n const wordsBeforeWhitespace = textBeforeWhitespace.split(' ').filter(s => s !== '')\n\n if (wordsBeforeWhitespace.length <= 0) {\n return false\n }\n\n const lastWordBeforeSpace = wordsBeforeWhitespace[wordsBeforeWhitespace.length - 1]\n const lastWordAndBlockOffset = textBlock.pos + textBeforeWhitespace.lastIndexOf(lastWordBeforeSpace)\n\n if (!lastWordBeforeSpace) {\n return false\n }\n\n const linksBeforeSpace = tokenize(lastWordBeforeSpace).map(t => t.toObject(options.defaultProtocol))\n\n if (!isValidLinkStructure(linksBeforeSpace)) {\n return false\n }\n\n linksBeforeSpace\n .filter(link => link.isLink)\n // Calculate link position.\n .map(link => ({\n ...link,\n from: lastWordAndBlockOffset + link.start + 1,\n to: lastWordAndBlockOffset + link.end + 1,\n }))\n // ignore link inside code mark\n .filter(link => {\n if (!newState.schema.marks.code) {\n return true\n }\n\n return !newState.doc.rangeHasMark(\n link.from,\n link.to,\n newState.schema.marks.code,\n )\n })\n // validate link\n .filter(link => options.validate(link.value))\n // Add link mark.\n .forEach(link => {\n if (getMarksBetween(link.from, link.to, newState.doc).some(item => item.mark.type === options.type)) {\n return\n }\n\n tr.addMark(\n link.from,\n link.to,\n options.type.create({\n href: link.href,\n }),\n )\n })\n }\n })\n\n if (!tr.steps.length) {\n return\n }\n\n return tr\n },\n })\n}\n","import { getAttributes } from '@tiptap/core'\nimport { MarkType } from '@tiptap/pm/model'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\n\ntype ClickHandlerOptions = {\n type: MarkType\n}\n\nexport function clickHandler(options: ClickHandlerOptions): Plugin {\n return new Plugin({\n key: new PluginKey('handleClickLink'),\n props: {\n handleClick: (view, pos, event) => {\n if (event.button !== 0) {\n return false\n }\n\n let a = event.target as HTMLElement\n const els = []\n\n while (a.nodeName !== 'DIV') {\n els.push(a)\n a = a.parentNode as HTMLElement\n }\n\n if (!els.find(value => value.nodeName === 'A')) {\n return false\n }\n\n const attrs = getAttributes(view.state, options.type.name)\n const link = (event.target as HTMLLinkElement)\n\n const href = link?.href ?? attrs.href\n const target = link?.target ?? attrs.target\n\n if (link && href) {\n window.open(href, target)\n\n return true\n }\n\n return false\n },\n },\n })\n}\n","import { Editor } from '@tiptap/core'\nimport { MarkType } from '@tiptap/pm/model'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport { find } from 'linkifyjs'\n\ntype PasteHandlerOptions = {\n editor: Editor\n defaultProtocol: string\n type: MarkType\n}\n\nexport function pasteHandler(options: PasteHandlerOptions): Plugin {\n return new Plugin({\n key: new PluginKey('handlePasteLink'),\n props: {\n handlePaste: (view, event, slice) => {\n const { state } = view\n const { selection } = state\n const { empty } = selection\n\n if (empty) {\n return false\n }\n\n let textContent = ''\n\n slice.content.forEach(node => {\n textContent += node.textContent\n })\n\n const link = find(textContent, { defaultProtocol: options.defaultProtocol }).find(item => item.isLink && item.value === textContent)\n\n if (!textContent || !link) {\n return false\n }\n\n options.editor.commands.setMark(options.type, {\n href: link.href,\n })\n\n return true\n },\n },\n })\n}\n","import {\n Mark, markPasteRule, mergeAttributes, PasteRuleMatch,\n} from '@tiptap/core'\nimport { Plugin } from '@tiptap/pm/state'\nimport { find, registerCustomProtocol, reset } from 'linkifyjs'\n\nimport { autolink } from './helpers/autolink.js'\nimport { clickHandler } from './helpers/clickHandler.js'\nimport { pasteHandler } from './helpers/pasteHandler.js'\n\nexport interface LinkProtocolOptions {\n /**\n * The protocol scheme to be registered.\n * @default '''\n * @example 'ftp'\n * @example 'git'\n */\n scheme: string;\n\n /**\n * If enabled, it allows optional slashes after the protocol.\n * @default false\n * @example true\n */\n optionalSlashes?: boolean;\n}\n\nexport const pasteRegex = /https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z]{2,}\\b(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)/gi\n\nexport interface LinkOptions {\n /**\n * If enabled, the extension will automatically add links as you type.\n * @default true\n * @example false\n */\n autolink: boolean\n\n /**\n * An array of custom protocols to be registered with linkifyjs.\n * @default []\n * @example ['ftp', 'git']\n */\n protocols: Array<LinkProtocolOptions | string>\n\n /**\n * Default protocol to use when no protocol is specified.\n * @default 'http'\n */\n defaultProtocol: string\n /**\n * If enabled, links will be opened on click.\n * @default true\n * @example false\n * @example 'whenNotEditable'\n */\n openOnClick: boolean\n /**\n * Adds a link to the current selection if the pasted content only contains an url.\n * @default true\n * @example false\n */\n linkOnPaste: boolean\n\n /**\n * HTML attributes to add to the link element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n\n /**\n * A validation function that modifies link verification for the auto linker.\n * @param url - The url to be validated.\n * @returns - True if the url is valid, false otherwise.\n */\n validate: (url: string) => boolean\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n link: {\n /**\n * Set a link mark\n * @param attributes The link attributes\n * @example editor.commands.setLink({ href: 'https://tiptap.dev' })\n */\n setLink: (attributes: { href: string; target?: string | null; rel?: string | null; class?: string | null }) => ReturnType\n /**\n * Toggle a link mark\n * @param attributes The link attributes\n * @example editor.commands.toggleLink({ href: 'https://tiptap.dev' })\n */\n toggleLink: (attributes: { href: string; target?: string | null; rel?: string | null; class?: string | null }) => ReturnType\n /**\n * Unset a link mark\n * @example editor.commands.unsetLink()\n */\n unsetLink: () => ReturnType\n }\n }\n}\n\n// From DOMPurify\n// https://github.com/cure53/DOMPurify/blob/main/src/regexp.js\nconst ATTR_WHITESPACE = /[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g // eslint-disable-line no-control-regex\nconst IS_ALLOWED_URI = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i // eslint-disable-line no-useless-escape\n\nfunction isAllowedUri(uri: string | undefined) {\n return !uri || uri.replace(ATTR_WHITESPACE, '').match(IS_ALLOWED_URI)\n}\n\n/**\n * This extension allows you to create links.\n * @see https://www.tiptap.dev/api/marks/link\n */\nexport const Link = Mark.create<LinkOptions>({\n name: 'link',\n\n priority: 1000,\n\n keepOnSplit: false,\n\n exitable: true,\n\n onCreate() {\n this.options.protocols.forEach(protocol => {\n if (typeof protocol === 'string') {\n registerCustomProtocol(protocol)\n return\n }\n registerCustomProtocol(protocol.scheme, protocol.optionalSlashes)\n })\n },\n\n onDestroy() {\n reset()\n },\n\n inclusive() {\n return this.options.autolink\n },\n\n addOptions() {\n return {\n openOnClick: true,\n linkOnPaste: true,\n autolink: true,\n protocols: [],\n defaultProtocol: 'http',\n HTMLAttributes: {\n target: '_blank',\n rel: 'noopener noreferrer nofollow',\n class: null,\n },\n validate: url => !!url,\n }\n },\n\n addAttributes() {\n return {\n href: {\n default: null,\n },\n target: {\n default: this.options.HTMLAttributes.target,\n },\n rel: {\n default: this.options.HTMLAttributes.rel,\n },\n class: {\n default: this.options.HTMLAttributes.class,\n },\n }\n },\n\n parseHTML() {\n return [{\n tag: 'a[href]',\n getAttrs: dom => {\n const href = (dom as HTMLElement).getAttribute('href')\n\n // prevent XSS attacks\n if (!href || !isAllowedUri(href)) {\n return false\n }\n return { href }\n },\n }]\n },\n\n renderHTML({ HTMLAttributes }) {\n // prevent XSS attacks\n if (!isAllowedUri(HTMLAttributes.href)) {\n // strip out the href\n return ['a', mergeAttributes(this.options.HTMLAttributes, { ...HTMLAttributes, href: '' }), 0]\n }\n\n return ['a', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n setLink:\n attributes => ({ chain }) => {\n return chain().setMark(this.name, attributes).setMeta('preventAutolink', true).run()\n },\n\n toggleLink:\n attributes => ({ chain }) => {\n return chain()\n .toggleMark(this.name, attributes, { extendEmptyMarkRange: true })\n .setMeta('preventAutolink', true)\n .run()\n },\n\n unsetLink:\n () => ({ chain }) => {\n return chain()\n .unsetMark(this.name, { extendEmptyMarkRange: true })\n .setMeta('preventAutolink', true)\n .run()\n },\n }\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: text => {\n const foundLinks: PasteRuleMatch[] = []\n\n if (text) {\n const { validate } = this.options\n const links = find(text).filter(item => item.isLink && validate(item.value))\n\n if (links.length) {\n links.forEach(link => (foundLinks.push({\n text: link.value,\n data: {\n href: link.href,\n },\n index: link.start,\n })))\n }\n }\n\n return foundLinks\n },\n type: this.type,\n getAttributes: match => {\n return {\n href: match.data?.href,\n }\n },\n }),\n ]\n },\n\n addProseMirrorPlugins() {\n const plugins: Plugin[] = []\n\n if (this.options.autolink) {\n plugins.push(\n autolink({\n type: this.type,\n defaultProtocol: this.options.defaultProtocol,\n validate: this.options.validate,\n }),\n )\n }\n\n if (this.options.openOnClick) {\n plugins.push(\n clickHandler({\n type: this.type,\n }),\n )\n }\n\n if (this.options.linkOnPaste) {\n plugins.push(\n pasteHandler({\n editor: this.editor,\n defaultProtocol: this.options.defaultProtocol,\n type: this.type,\n }),\n )\n }\n\n return plugins\n },\n})\n"],"names":["Plugin","PluginKey","combineTransactionSteps","getChangedRanges","findChildrenInRange","tokenize","getMarksBetween","getAttributes","find","Mark","registerCustomProtocol","reset","mergeAttributes","markPasteRule"],"mappings":";;;;;;EAWA;;;;;;;;;EASG;EACH,SAAS,oBAAoB,CAAC,MAAiD,EAAA;EAC7E,IAAA,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;EACvB,QAAA,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;OACxB;EAED,IAAA,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;UAC3C,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;OAChE;EAED,IAAA,OAAO,KAAK,CAAA;EACd,CAAC;EAQD;;;;EAIG;EACG,SAAU,QAAQ,CAAC,OAAwB,EAAA;MAC/C,OAAO,IAAIA,YAAM,CAAC;EAChB,QAAA,GAAG,EAAE,IAAIC,eAAS,C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CACH,CAAA;WACF;EAED,QAAA,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;EAC5B,YAAA,OAAO,CAAC,IAAI,CACV,YAAY,CAAC;kBACX,MAAM,EAAE,IAAI,CAAC,MAAM;EACnB,gBAAA,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe;kBAC7C,IAAI,EAAE,IAAI,CAAC,IAAI;EAChB,aAAA,CAAC,CACH,CAAA;WACF;EAED,QAAA,OAAO,OAAO,CAAA;OACf;EACF,CAAA;;;;;;;;;;;;"}
@@ -1,20 +0,0 @@
1
- import { EditorState, Transaction } from '@tiptap/pm/state';
2
- import { Editor } from './Editor.js';
3
- import { AnyCommands, CanCommands, ChainedCommands, CommandProps, SingleCommands } from './types.js';
4
- export declare class CommandManager {
5
- editor: Editor;
6
- rawCommands: AnyCommands;
7
- customState?: EditorState;
8
- constructor(props: {
9
- editor: Editor;
10
- state?: EditorState;
11
- });
12
- get hasCustomState(): boolean;
13
- get state(): EditorState;
14
- get commands(): SingleCommands;
15
- get chain(): () => ChainedCommands;
16
- get can(): () => CanCommands;
17
- createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
18
- createCan(startTr?: Transaction): CanCommands;
19
- buildProps(tr: Transaction, shouldDispatch?: boolean): CommandProps;
20
- }
@@ -1,161 +0,0 @@
1
- import { MarkType, NodeType, Schema } from '@tiptap/pm/model';
2
- import { EditorState, Plugin, PluginKey, Transaction } from '@tiptap/pm/state';
3
- import { EditorView } from '@tiptap/pm/view';
4
- import { EventEmitter } from './EventEmitter.js';
5
- import { ExtensionManager } from './ExtensionManager.js';
6
- import { NodePos } from './NodePos.js';
7
- import { CanCommands, ChainedCommands, EditorEvents, EditorOptions, JSONContent, SingleCommands, TextSerializer } from './types.js';
8
- export * as extensions from './extensions/index.js';
9
- declare global {
10
- interface HTMLElement {
11
- editor?: Editor;
12
- }
13
- }
14
- export declare class Editor extends EventEmitter<EditorEvents> {
15
- private commandManager;
16
- extensionManager: ExtensionManager;
17
- private css;
18
- schema: Schema;
19
- view: EditorView;
20
- isFocused: boolean;
21
- extensionStorage: Record<string, any>;
22
- options: EditorOptions;
23
- constructor(options?: Partial<EditorOptions>);
24
- /**
25
- * Returns the editor storage.
26
- */
27
- get storage(): Record<string, any>;
28
- /**
29
- * An object of all registered commands.
30
- */
31
- get commands(): SingleCommands;
32
- /**
33
- * Create a command chain to call multiple commands at once.
34
- */
35
- chain(): ChainedCommands;
36
- /**
37
- * Check if a command or a command chain can be executed. Without executing it.
38
- */
39
- can(): CanCommands;
40
- /**
41
- * Inject CSS styles.
42
- */
43
- private injectCSS;
44
- /**
45
- * Update editor options.
46
- *
47
- * @param options A list of options
48
- */
49
- setOptions(options?: Partial<EditorOptions>): void;
50
- /**
51
- * Update editable state of the editor.
52
- */
53
- setEditable(editable: boolean, emitUpdate?: boolean): void;
54
- /**
55
- * Returns whether the editor is editable.
56
- */
57
- get isEditable(): boolean;
58
- /**
59
- * Returns the editor state.
60
- */
61
- get state(): EditorState;
62
- /**
63
- * Register a ProseMirror plugin.
64
- *
65
- * @param plugin A ProseMirror plugin
66
- * @param handlePlugins Control how to merge the plugin into the existing plugins.
67
- */
68
- registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): void;
69
- /**
70
- * Unregister a ProseMirror plugin.
71
- *
72
- * @param nameOrPluginKey The plugins name
73
- */
74
- unregisterPlugin(nameOrPluginKey: string | PluginKey): void;
75
- /**
76
- * Creates an extension manager.
77
- */
78
- private createExtensionManager;
79
- /**
80
- * Creates an command manager.
81
- */
82
- private createCommandManager;
83
- /**
84
- * Creates a ProseMirror schema.
85
- */
86
- private createSchema;
87
- /**
88
- * Creates a ProseMirror view.
89
- */
90
- private createView;
91
- /**
92
- * Creates all node views.
93
- */
94
- createNodeViews(): void;
95
- /**
96
- * Prepend class name to element.
97
- */
98
- prependClass(): void;
99
- isCapturingTransaction: boolean;
100
- private capturedTransaction;
101
- captureTransaction(fn: Function): Transaction | null;
102
- /**
103
- * The callback over which to send transactions (state updates) produced by the view.
104
- *
105
- * @param transaction An editor state transaction
106
- */
107
- private dispatchTransaction;
108
- /**
109
- * Get attributes of the currently selected node or mark.
110
- */
111
- getAttributes(nameOrType: string | NodeType | MarkType): Record<string, any>;
112
- /**
113
- * Returns if the currently selected node or mark is active.
114
- *
115
- * @param name Name of the node or mark
116
- * @param attributes Attributes of the node or mark
117
- */
118
- isActive(name: string, attributes?: {}): boolean;
119
- isActive(attributes: {}): boolean;
120
- /**
121
- * Get the document as JSON.
122
- */
123
- getJSON(): JSONContent;
124
- /**
125
- * Get the document as HTML.
126
- */
127
- getHTML(): string;
128
- /**
129
- * Get the document as text.
130
- */
131
- getText(options?: {
132
- blockSeparator?: string;
133
- textSerializers?: Record<string, TextSerializer>;
134
- }): string;
135
- /**
136
- * Check if there is no content.
137
- */
138
- get isEmpty(): boolean;
139
- /**
140
- * Get the number of characters for the current document.
141
- *
142
- * @deprecated
143
- */
144
- getCharacterCount(): number;
145
- /**
146
- * Destroy the editor.
147
- */
148
- destroy(): void;
149
- /**
150
- * Check if the editor is already destroyed.
151
- */
152
- get isDestroyed(): boolean;
153
- $node(selector: string, attributes?: {
154
- [key: string]: any;
155
- }): NodePos | null;
156
- $nodes(selector: string, attributes?: {
157
- [key: string]: any;
158
- }): NodePos[] | null;
159
- $pos(pos: number): NodePos;
160
- get $doc(): NodePos;
161
- }
@@ -1,11 +0,0 @@
1
- type StringKeyOf<T> = Extract<keyof T, string>;
2
- type CallbackType<T extends Record<string, any>, EventName extends StringKeyOf<T>> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];
3
- type CallbackFunction<T extends Record<string, any>, EventName extends StringKeyOf<T>> = (...props: CallbackType<T, EventName>) => any;
4
- export declare class EventEmitter<T extends Record<string, any>> {
5
- private callbacks;
6
- on<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this;
7
- emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this;
8
- off<EventName extends StringKeyOf<T>>(event: EventName, fn?: CallbackFunction<T, EventName>): this;
9
- removeAllListeners(): void;
10
- }
11
- export {};