@tiptap/extensions 3.0.0-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.
- package/LICENSE.md +21 -0
- package/README.md +18 -0
- package/dist/character-count/index.cjs +129 -0
- package/dist/character-count/index.cjs.map +1 -0
- package/dist/character-count/index.d.cts +62 -0
- package/dist/character-count/index.d.ts +62 -0
- package/dist/character-count/index.js +102 -0
- package/dist/character-count/index.js.map +1 -0
- package/dist/drop-cursor/index.cjs +47 -0
- package/dist/drop-cursor/index.cjs.map +1 -0
- package/dist/drop-cursor/index.d.cts +31 -0
- package/dist/drop-cursor/index.d.ts +31 -0
- package/dist/drop-cursor/index.js +20 -0
- package/dist/drop-cursor/index.js.map +1 -0
- package/dist/focus/index.cjs +95 -0
- package/dist/focus/index.cjs.map +1 -0
- package/dist/focus/index.d.cts +28 -0
- package/dist/focus/index.d.ts +28 -0
- package/dist/focus/index.js +68 -0
- package/dist/focus/index.js.map +1 -0
- package/dist/gap-cursor/index.cjs +51 -0
- package/dist/gap-cursor/index.cjs.map +1 -0
- package/dist/gap-cursor/index.d.cts +25 -0
- package/dist/gap-cursor/index.d.ts +25 -0
- package/dist/gap-cursor/index.js +24 -0
- package/dist/gap-cursor/index.js.map +1 -0
- package/dist/index.cjs +421 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +272 -0
- package/dist/index.d.ts +272 -0
- package/dist/index.js +387 -0
- package/dist/index.js.map +1 -0
- package/dist/placeholder/index.cjs +88 -0
- package/dist/placeholder/index.cjs.map +1 -0
- package/dist/placeholder/index.d.cts +59 -0
- package/dist/placeholder/index.d.ts +59 -0
- package/dist/placeholder/index.js +61 -0
- package/dist/placeholder/index.js.map +1 -0
- package/dist/selection/index.cjs +63 -0
- package/dist/selection/index.cjs.map +1 -0
- package/dist/selection/index.d.cts +17 -0
- package/dist/selection/index.d.ts +17 -0
- package/dist/selection/index.js +36 -0
- package/dist/selection/index.js.map +1 -0
- package/dist/trailing-node/index.cjs +78 -0
- package/dist/trailing-node/index.cjs.map +1 -0
- package/dist/trailing-node/index.d.cts +28 -0
- package/dist/trailing-node/index.d.ts +28 -0
- package/dist/trailing-node/index.js +51 -0
- package/dist/trailing-node/index.js.map +1 -0
- package/dist/undo-redo/index.cjs +66 -0
- package/dist/undo-redo/index.cjs.map +1 -0
- package/dist/undo-redo/index.d.cts +44 -0
- package/dist/undo-redo/index.d.ts +44 -0
- package/dist/undo-redo/index.js +39 -0
- package/dist/undo-redo/index.js.map +1 -0
- package/package.json +114 -0
- package/src/character-count/character-count.ts +195 -0
- package/src/character-count/index.ts +1 -0
- package/src/drop-cursor/drop-cursor.ts +47 -0
- package/src/drop-cursor/index.ts +1 -0
- package/src/focus/focus.ts +110 -0
- package/src/focus/index.ts +1 -0
- package/src/gap-cursor/gap-cursor.ts +47 -0
- package/src/gap-cursor/index.ts +1 -0
- package/src/index.ts +8 -0
- package/src/placeholder/index.ts +1 -0
- package/src/placeholder/placeholder.ts +129 -0
- package/src/selection/index.ts +1 -0
- package/src/selection/selection.ts +51 -0
- package/src/trailing-node/index.ts +1 -0
- package/src/trailing-node/trailing-node.ts +84 -0
- package/src/undo-redo/index.ts +1 -0
- package/src/undo-redo/undo-redo.ts +86 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Tiptap GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @tiptap/extensions
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@tiptap/extension-focus)
|
|
4
|
+
[](https://npmcharts.com/compare/tiptap?minimal=true)
|
|
5
|
+
[](https://www.npmjs.com/package/@tiptap/extension-focus)
|
|
6
|
+
[](https://github.com/sponsors/ueberdosis)
|
|
7
|
+
|
|
8
|
+
## Introduction
|
|
9
|
+
|
|
10
|
+
Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as _New York Times_, _The Guardian_ or _Atlassian_.
|
|
11
|
+
|
|
12
|
+
## Official Documentation
|
|
13
|
+
|
|
14
|
+
Documentation can be found on the [Tiptap website](https://tiptap.dev).
|
|
15
|
+
|
|
16
|
+
## License
|
|
17
|
+
|
|
18
|
+
Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
|
|
@@ -0,0 +1,129 @@
|
|
|
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);
|
|
19
|
+
|
|
20
|
+
// src/character-count/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
CharacterCount: () => CharacterCount
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/character-count/character-count.ts
|
|
28
|
+
var import_core = require("@tiptap/core");
|
|
29
|
+
var import_state = require("@tiptap/pm/state");
|
|
30
|
+
var CharacterCount = import_core.Extension.create({
|
|
31
|
+
name: "characterCount",
|
|
32
|
+
addOptions() {
|
|
33
|
+
return {
|
|
34
|
+
limit: null,
|
|
35
|
+
mode: "textSize",
|
|
36
|
+
textCounter: (text) => text.length,
|
|
37
|
+
wordCounter: (text) => text.split(" ").filter((word) => word !== "").length
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
addStorage() {
|
|
41
|
+
return {
|
|
42
|
+
characters: () => 0,
|
|
43
|
+
words: () => 0
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
onBeforeCreate() {
|
|
47
|
+
this.storage.characters = (options) => {
|
|
48
|
+
const node = (options == null ? void 0 : options.node) || this.editor.state.doc;
|
|
49
|
+
const mode = (options == null ? void 0 : options.mode) || this.options.mode;
|
|
50
|
+
if (mode === "textSize") {
|
|
51
|
+
const text = node.textBetween(0, node.content.size, void 0, " ");
|
|
52
|
+
return this.options.textCounter(text);
|
|
53
|
+
}
|
|
54
|
+
return node.nodeSize;
|
|
55
|
+
};
|
|
56
|
+
this.storage.words = (options) => {
|
|
57
|
+
const node = (options == null ? void 0 : options.node) || this.editor.state.doc;
|
|
58
|
+
const text = node.textBetween(0, node.content.size, " ", " ");
|
|
59
|
+
return this.options.wordCounter(text);
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
addProseMirrorPlugins() {
|
|
63
|
+
let initialEvaluationDone = false;
|
|
64
|
+
return [
|
|
65
|
+
new import_state.Plugin({
|
|
66
|
+
key: new import_state.PluginKey("characterCount"),
|
|
67
|
+
appendTransaction: (transactions, oldState, newState) => {
|
|
68
|
+
if (initialEvaluationDone) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const limit = this.options.limit;
|
|
72
|
+
if (limit === null || limit === void 0 || limit === 0) {
|
|
73
|
+
initialEvaluationDone = true;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const initialContentSize = this.storage.characters({ node: newState.doc });
|
|
77
|
+
if (initialContentSize > limit) {
|
|
78
|
+
const over = initialContentSize - limit;
|
|
79
|
+
const from = 0;
|
|
80
|
+
const to = over;
|
|
81
|
+
console.warn(
|
|
82
|
+
`[CharacterCount] Initial content exceeded limit of ${limit} characters. Content was automatically trimmed.`
|
|
83
|
+
);
|
|
84
|
+
const tr = newState.tr.deleteRange(from, to);
|
|
85
|
+
initialEvaluationDone = true;
|
|
86
|
+
return tr;
|
|
87
|
+
}
|
|
88
|
+
initialEvaluationDone = true;
|
|
89
|
+
},
|
|
90
|
+
filterTransaction: (transaction, state) => {
|
|
91
|
+
const limit = this.options.limit;
|
|
92
|
+
if (!transaction.docChanged || limit === 0 || limit === null || limit === void 0) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
const oldSize = this.storage.characters({ node: state.doc });
|
|
96
|
+
const newSize = this.storage.characters({ node: transaction.doc });
|
|
97
|
+
if (newSize <= limit) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
if (oldSize > limit && newSize > limit && newSize <= oldSize) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
if (oldSize > limit && newSize > limit && newSize > oldSize) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
const isPaste = transaction.getMeta("paste");
|
|
107
|
+
if (!isPaste) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
const pos = transaction.selection.$head.pos;
|
|
111
|
+
const over = newSize - limit;
|
|
112
|
+
const from = pos - over;
|
|
113
|
+
const to = pos;
|
|
114
|
+
transaction.deleteRange(from, to);
|
|
115
|
+
const updatedSize = this.storage.characters({ node: transaction.doc });
|
|
116
|
+
if (updatedSize > limit) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
126
|
+
0 && (module.exports = {
|
|
127
|
+
CharacterCount
|
|
128
|
+
});
|
|
129
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/character-count/index.ts","../../src/character-count/character-count.ts"],"sourcesContent":["export * from './character-count.js'\n","import { Extension } from '@tiptap/core'\nimport type { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\n\nexport interface CharacterCountOptions {\n /**\n * The maximum number of characters that should be allowed. Defaults to `0`.\n * @default null\n * @example 180\n */\n limit: number | null | undefined\n /**\n * The mode by which the size is calculated. If set to `textSize`, the textContent of the document is used.\n * If set to `nodeSize`, the nodeSize of the document is used.\n * @default 'textSize'\n * @example 'textSize'\n */\n mode: 'textSize' | 'nodeSize'\n /**\n * The text counter function to use. Defaults to a simple character count.\n * @default (text) => text.length\n * @example (text) => [...new Intl.Segmenter().segment(text)].length\n */\n textCounter: (text: string) => number\n /**\n * The word counter function to use. Defaults to a simple word count.\n * @default (text) => text.split(' ').filter(word => word !== '').length\n * @example (text) => text.split(/\\s+/).filter(word => word !== '').length\n */\n wordCounter: (text: string) => number\n}\n\nexport interface CharacterCountStorage {\n /**\n * Get the number of characters for the current document.\n * @param options The options for the character count. (optional)\n * @param options.node The node to get the characters from. Defaults to the current document.\n * @param options.mode The mode by which the size is calculated. If set to `textSize`, the textContent of the document is used.\n */\n characters: (options?: { node?: ProseMirrorNode; mode?: 'textSize' | 'nodeSize' }) => number\n\n /**\n * Get the number of words for the current document.\n * @param options The options for the character count. (optional)\n * @param options.node The node to get the words from. Defaults to the current document.\n */\n words: (options?: { node?: ProseMirrorNode }) => number\n}\n\ndeclare module '@tiptap/core' {\n interface Storage {\n characterCount: CharacterCountStorage\n }\n}\n\n/**\n * This extension allows you to count the characters and words of your document.\n * @see https://tiptap.dev/api/extensions/character-count\n */\nexport const CharacterCount = Extension.create<CharacterCountOptions, CharacterCountStorage>({\n name: 'characterCount',\n\n addOptions() {\n return {\n limit: null,\n mode: 'textSize',\n textCounter: text => text.length,\n wordCounter: text => text.split(' ').filter(word => word !== '').length,\n }\n },\n\n addStorage() {\n return {\n characters: () => 0,\n words: () => 0,\n }\n },\n\n onBeforeCreate() {\n this.storage.characters = options => {\n const node = options?.node || this.editor.state.doc\n const mode = options?.mode || this.options.mode\n\n if (mode === 'textSize') {\n const text = node.textBetween(0, node.content.size, undefined, ' ')\n\n return this.options.textCounter(text)\n }\n\n return node.nodeSize\n }\n\n this.storage.words = options => {\n const node = options?.node || this.editor.state.doc\n const text = node.textBetween(0, node.content.size, ' ', ' ')\n\n return this.options.wordCounter(text)\n }\n },\n\n addProseMirrorPlugins() {\n let initialEvaluationDone = false\n\n return [\n new Plugin({\n key: new PluginKey('characterCount'),\n appendTransaction: (transactions, oldState, newState) => {\n if (initialEvaluationDone) {\n return\n }\n\n const limit = this.options.limit\n\n if (limit === null || limit === undefined || limit === 0) {\n initialEvaluationDone = true\n return\n }\n\n const initialContentSize = this.storage.characters({ node: newState.doc })\n\n if (initialContentSize > limit) {\n const over = initialContentSize - limit\n const from = 0\n const to = over\n\n console.warn(\n `[CharacterCount] Initial content exceeded limit of ${limit} characters. Content was automatically trimmed.`,\n )\n const tr = newState.tr.deleteRange(from, to)\n\n initialEvaluationDone = true\n return tr\n }\n\n initialEvaluationDone = true\n },\n filterTransaction: (transaction, state) => {\n const limit = this.options.limit\n\n // Nothing has changed or no limit is defined. Ignore it.\n if (!transaction.docChanged || limit === 0 || limit === null || limit === undefined) {\n return true\n }\n\n const oldSize = this.storage.characters({ node: state.doc })\n const newSize = this.storage.characters({ node: transaction.doc })\n\n // Everything is in the limit. Good.\n if (newSize <= limit) {\n return true\n }\n\n // The limit has already been exceeded but will be reduced.\n if (oldSize > limit && newSize > limit && newSize <= oldSize) {\n return true\n }\n\n // The limit has already been exceeded and will be increased further.\n if (oldSize > limit && newSize > limit && newSize > oldSize) {\n return false\n }\n\n const isPaste = transaction.getMeta('paste')\n\n // Block all exceeding transactions that were not pasted.\n if (!isPaste) {\n return false\n }\n\n // For pasted content, we try to remove the exceeding content.\n const pos = transaction.selection.$head.pos\n const over = newSize - limit\n const from = pos - over\n const to = pos\n\n // It’s probably a bad idea to mutate transactions within `filterTransaction`\n // but for now this is working fine.\n transaction.deleteRange(from, to)\n\n // In some situations, the limit will continue to be exceeded after trimming.\n // This happens e.g. when truncating within a complex node (e.g. table)\n // and ProseMirror has to close this node again.\n // If this is the case, we prevent the transaction completely.\n const updatedSize = this.storage.characters({ node: transaction.doc })\n\n if (updatedSize > limit) {\n return false\n }\n\n return true\n },\n }),\n ]\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;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AA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
import { Node } from '@tiptap/pm/model';
|
|
3
|
+
|
|
4
|
+
interface CharacterCountOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The maximum number of characters that should be allowed. Defaults to `0`.
|
|
7
|
+
* @default null
|
|
8
|
+
* @example 180
|
|
9
|
+
*/
|
|
10
|
+
limit: number | null | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* The mode by which the size is calculated. If set to `textSize`, the textContent of the document is used.
|
|
13
|
+
* If set to `nodeSize`, the nodeSize of the document is used.
|
|
14
|
+
* @default 'textSize'
|
|
15
|
+
* @example 'textSize'
|
|
16
|
+
*/
|
|
17
|
+
mode: 'textSize' | 'nodeSize';
|
|
18
|
+
/**
|
|
19
|
+
* The text counter function to use. Defaults to a simple character count.
|
|
20
|
+
* @default (text) => text.length
|
|
21
|
+
* @example (text) => [...new Intl.Segmenter().segment(text)].length
|
|
22
|
+
*/
|
|
23
|
+
textCounter: (text: string) => number;
|
|
24
|
+
/**
|
|
25
|
+
* The word counter function to use. Defaults to a simple word count.
|
|
26
|
+
* @default (text) => text.split(' ').filter(word => word !== '').length
|
|
27
|
+
* @example (text) => text.split(/\s+/).filter(word => word !== '').length
|
|
28
|
+
*/
|
|
29
|
+
wordCounter: (text: string) => number;
|
|
30
|
+
}
|
|
31
|
+
interface CharacterCountStorage {
|
|
32
|
+
/**
|
|
33
|
+
* Get the number of characters for the current document.
|
|
34
|
+
* @param options The options for the character count. (optional)
|
|
35
|
+
* @param options.node The node to get the characters from. Defaults to the current document.
|
|
36
|
+
* @param options.mode The mode by which the size is calculated. If set to `textSize`, the textContent of the document is used.
|
|
37
|
+
*/
|
|
38
|
+
characters: (options?: {
|
|
39
|
+
node?: Node;
|
|
40
|
+
mode?: 'textSize' | 'nodeSize';
|
|
41
|
+
}) => number;
|
|
42
|
+
/**
|
|
43
|
+
* Get the number of words for the current document.
|
|
44
|
+
* @param options The options for the character count. (optional)
|
|
45
|
+
* @param options.node The node to get the words from. Defaults to the current document.
|
|
46
|
+
*/
|
|
47
|
+
words: (options?: {
|
|
48
|
+
node?: Node;
|
|
49
|
+
}) => number;
|
|
50
|
+
}
|
|
51
|
+
declare module '@tiptap/core' {
|
|
52
|
+
interface Storage {
|
|
53
|
+
characterCount: CharacterCountStorage;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* This extension allows you to count the characters and words of your document.
|
|
58
|
+
* @see https://tiptap.dev/api/extensions/character-count
|
|
59
|
+
*/
|
|
60
|
+
declare const CharacterCount: Extension<CharacterCountOptions, CharacterCountStorage>;
|
|
61
|
+
|
|
62
|
+
export { CharacterCount, type CharacterCountOptions, type CharacterCountStorage };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
import { Node } from '@tiptap/pm/model';
|
|
3
|
+
|
|
4
|
+
interface CharacterCountOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The maximum number of characters that should be allowed. Defaults to `0`.
|
|
7
|
+
* @default null
|
|
8
|
+
* @example 180
|
|
9
|
+
*/
|
|
10
|
+
limit: number | null | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* The mode by which the size is calculated. If set to `textSize`, the textContent of the document is used.
|
|
13
|
+
* If set to `nodeSize`, the nodeSize of the document is used.
|
|
14
|
+
* @default 'textSize'
|
|
15
|
+
* @example 'textSize'
|
|
16
|
+
*/
|
|
17
|
+
mode: 'textSize' | 'nodeSize';
|
|
18
|
+
/**
|
|
19
|
+
* The text counter function to use. Defaults to a simple character count.
|
|
20
|
+
* @default (text) => text.length
|
|
21
|
+
* @example (text) => [...new Intl.Segmenter().segment(text)].length
|
|
22
|
+
*/
|
|
23
|
+
textCounter: (text: string) => number;
|
|
24
|
+
/**
|
|
25
|
+
* The word counter function to use. Defaults to a simple word count.
|
|
26
|
+
* @default (text) => text.split(' ').filter(word => word !== '').length
|
|
27
|
+
* @example (text) => text.split(/\s+/).filter(word => word !== '').length
|
|
28
|
+
*/
|
|
29
|
+
wordCounter: (text: string) => number;
|
|
30
|
+
}
|
|
31
|
+
interface CharacterCountStorage {
|
|
32
|
+
/**
|
|
33
|
+
* Get the number of characters for the current document.
|
|
34
|
+
* @param options The options for the character count. (optional)
|
|
35
|
+
* @param options.node The node to get the characters from. Defaults to the current document.
|
|
36
|
+
* @param options.mode The mode by which the size is calculated. If set to `textSize`, the textContent of the document is used.
|
|
37
|
+
*/
|
|
38
|
+
characters: (options?: {
|
|
39
|
+
node?: Node;
|
|
40
|
+
mode?: 'textSize' | 'nodeSize';
|
|
41
|
+
}) => number;
|
|
42
|
+
/**
|
|
43
|
+
* Get the number of words for the current document.
|
|
44
|
+
* @param options The options for the character count. (optional)
|
|
45
|
+
* @param options.node The node to get the words from. Defaults to the current document.
|
|
46
|
+
*/
|
|
47
|
+
words: (options?: {
|
|
48
|
+
node?: Node;
|
|
49
|
+
}) => number;
|
|
50
|
+
}
|
|
51
|
+
declare module '@tiptap/core' {
|
|
52
|
+
interface Storage {
|
|
53
|
+
characterCount: CharacterCountStorage;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* This extension allows you to count the characters and words of your document.
|
|
58
|
+
* @see https://tiptap.dev/api/extensions/character-count
|
|
59
|
+
*/
|
|
60
|
+
declare const CharacterCount: Extension<CharacterCountOptions, CharacterCountStorage>;
|
|
61
|
+
|
|
62
|
+
export { CharacterCount, type CharacterCountOptions, type CharacterCountStorage };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// src/character-count/character-count.ts
|
|
2
|
+
import { Extension } from "@tiptap/core";
|
|
3
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
4
|
+
var CharacterCount = Extension.create({
|
|
5
|
+
name: "characterCount",
|
|
6
|
+
addOptions() {
|
|
7
|
+
return {
|
|
8
|
+
limit: null,
|
|
9
|
+
mode: "textSize",
|
|
10
|
+
textCounter: (text) => text.length,
|
|
11
|
+
wordCounter: (text) => text.split(" ").filter((word) => word !== "").length
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
addStorage() {
|
|
15
|
+
return {
|
|
16
|
+
characters: () => 0,
|
|
17
|
+
words: () => 0
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
onBeforeCreate() {
|
|
21
|
+
this.storage.characters = (options) => {
|
|
22
|
+
const node = (options == null ? void 0 : options.node) || this.editor.state.doc;
|
|
23
|
+
const mode = (options == null ? void 0 : options.mode) || this.options.mode;
|
|
24
|
+
if (mode === "textSize") {
|
|
25
|
+
const text = node.textBetween(0, node.content.size, void 0, " ");
|
|
26
|
+
return this.options.textCounter(text);
|
|
27
|
+
}
|
|
28
|
+
return node.nodeSize;
|
|
29
|
+
};
|
|
30
|
+
this.storage.words = (options) => {
|
|
31
|
+
const node = (options == null ? void 0 : options.node) || this.editor.state.doc;
|
|
32
|
+
const text = node.textBetween(0, node.content.size, " ", " ");
|
|
33
|
+
return this.options.wordCounter(text);
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
addProseMirrorPlugins() {
|
|
37
|
+
let initialEvaluationDone = false;
|
|
38
|
+
return [
|
|
39
|
+
new Plugin({
|
|
40
|
+
key: new PluginKey("characterCount"),
|
|
41
|
+
appendTransaction: (transactions, oldState, newState) => {
|
|
42
|
+
if (initialEvaluationDone) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const limit = this.options.limit;
|
|
46
|
+
if (limit === null || limit === void 0 || limit === 0) {
|
|
47
|
+
initialEvaluationDone = true;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const initialContentSize = this.storage.characters({ node: newState.doc });
|
|
51
|
+
if (initialContentSize > limit) {
|
|
52
|
+
const over = initialContentSize - limit;
|
|
53
|
+
const from = 0;
|
|
54
|
+
const to = over;
|
|
55
|
+
console.warn(
|
|
56
|
+
`[CharacterCount] Initial content exceeded limit of ${limit} characters. Content was automatically trimmed.`
|
|
57
|
+
);
|
|
58
|
+
const tr = newState.tr.deleteRange(from, to);
|
|
59
|
+
initialEvaluationDone = true;
|
|
60
|
+
return tr;
|
|
61
|
+
}
|
|
62
|
+
initialEvaluationDone = true;
|
|
63
|
+
},
|
|
64
|
+
filterTransaction: (transaction, state) => {
|
|
65
|
+
const limit = this.options.limit;
|
|
66
|
+
if (!transaction.docChanged || limit === 0 || limit === null || limit === void 0) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
const oldSize = this.storage.characters({ node: state.doc });
|
|
70
|
+
const newSize = this.storage.characters({ node: transaction.doc });
|
|
71
|
+
if (newSize <= limit) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
if (oldSize > limit && newSize > limit && newSize <= oldSize) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
if (oldSize > limit && newSize > limit && newSize > oldSize) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
const isPaste = transaction.getMeta("paste");
|
|
81
|
+
if (!isPaste) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
const pos = transaction.selection.$head.pos;
|
|
85
|
+
const over = newSize - limit;
|
|
86
|
+
const from = pos - over;
|
|
87
|
+
const to = pos;
|
|
88
|
+
transaction.deleteRange(from, to);
|
|
89
|
+
const updatedSize = this.storage.characters({ node: transaction.doc });
|
|
90
|
+
if (updatedSize > limit) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
export {
|
|
100
|
+
CharacterCount
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/character-count/character-count.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport type { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\n\nexport interface CharacterCountOptions {\n /**\n * The maximum number of characters that should be allowed. Defaults to `0`.\n * @default null\n * @example 180\n */\n limit: number | null | undefined\n /**\n * The mode by which the size is calculated. If set to `textSize`, the textContent of the document is used.\n * If set to `nodeSize`, the nodeSize of the document is used.\n * @default 'textSize'\n * @example 'textSize'\n */\n mode: 'textSize' | 'nodeSize'\n /**\n * The text counter function to use. Defaults to a simple character count.\n * @default (text) => text.length\n * @example (text) => [...new Intl.Segmenter().segment(text)].length\n */\n textCounter: (text: string) => number\n /**\n * The word counter function to use. Defaults to a simple word count.\n * @default (text) => text.split(' ').filter(word => word !== '').length\n * @example (text) => text.split(/\\s+/).filter(word => word !== '').length\n */\n wordCounter: (text: string) => number\n}\n\nexport interface CharacterCountStorage {\n /**\n * Get the number of characters for the current document.\n * @param options The options for the character count. (optional)\n * @param options.node The node to get the characters from. Defaults to the current document.\n * @param options.mode The mode by which the size is calculated. If set to `textSize`, the textContent of the document is used.\n */\n characters: (options?: { node?: ProseMirrorNode; mode?: 'textSize' | 'nodeSize' }) => number\n\n /**\n * Get the number of words for the current document.\n * @param options The options for the character count. (optional)\n * @param options.node The node to get the words from. Defaults to the current document.\n */\n words: (options?: { node?: ProseMirrorNode }) => number\n}\n\ndeclare module '@tiptap/core' {\n interface Storage {\n characterCount: CharacterCountStorage\n }\n}\n\n/**\n * This extension allows you to count the characters and words of your document.\n * @see https://tiptap.dev/api/extensions/character-count\n */\nexport const CharacterCount = Extension.create<CharacterCountOptions, CharacterCountStorage>({\n name: 'characterCount',\n\n addOptions() {\n return {\n limit: null,\n mode: 'textSize',\n textCounter: text => text.length,\n wordCounter: text => text.split(' ').filter(word => word !== '').length,\n }\n },\n\n addStorage() {\n return {\n characters: () => 0,\n words: () => 0,\n }\n },\n\n onBeforeCreate() {\n this.storage.characters = options => {\n const node = options?.node || this.editor.state.doc\n const mode = options?.mode || this.options.mode\n\n if (mode === 'textSize') {\n const text = node.textBetween(0, node.content.size, undefined, ' ')\n\n return this.options.textCounter(text)\n }\n\n return node.nodeSize\n }\n\n this.storage.words = options => {\n const node = options?.node || this.editor.state.doc\n const text = node.textBetween(0, node.content.size, ' ', ' ')\n\n return this.options.wordCounter(text)\n }\n },\n\n addProseMirrorPlugins() {\n let initialEvaluationDone = false\n\n return [\n new Plugin({\n key: new PluginKey('characterCount'),\n appendTransaction: (transactions, oldState, newState) => {\n if (initialEvaluationDone) {\n return\n }\n\n const limit = this.options.limit\n\n if (limit === null || limit === undefined || limit === 0) {\n initialEvaluationDone = true\n return\n }\n\n const initialContentSize = this.storage.characters({ node: newState.doc })\n\n if (initialContentSize > limit) {\n const over = initialContentSize - limit\n const from = 0\n const to = over\n\n console.warn(\n `[CharacterCount] Initial content exceeded limit of ${limit} characters. Content was automatically trimmed.`,\n )\n const tr = newState.tr.deleteRange(from, to)\n\n initialEvaluationDone = true\n return tr\n }\n\n initialEvaluationDone = true\n },\n filterTransaction: (transaction, state) => {\n const limit = this.options.limit\n\n // Nothing has changed or no limit is defined. Ignore it.\n if (!transaction.docChanged || limit === 0 || limit === null || limit === undefined) {\n return true\n }\n\n const oldSize = this.storage.characters({ node: state.doc })\n const newSize = this.storage.characters({ node: transaction.doc })\n\n // Everything is in the limit. Good.\n if (newSize <= limit) {\n return true\n }\n\n // The limit has already been exceeded but will be reduced.\n if (oldSize > limit && newSize > limit && newSize <= oldSize) {\n return true\n }\n\n // The limit has already been exceeded and will be increased further.\n if (oldSize > limit && newSize > limit && newSize > oldSize) {\n return false\n }\n\n const isPaste = transaction.getMeta('paste')\n\n // Block all exceeding transactions that were not pasted.\n if (!isPaste) {\n return false\n }\n\n // For pasted content, we try to remove the exceeding content.\n const pos = transaction.selection.$head.pos\n const over = newSize - limit\n const from = pos - over\n const to = pos\n\n // It’s probably a bad idea to mutate transactions within `filterTransaction`\n // but for now this is working fine.\n transaction.deleteRange(from, to)\n\n // In some situations, the limit will continue to be exceeded after trimming.\n // This happens e.g. when truncating within a complex node (e.g. table)\n // and ProseMirror has to close this node again.\n // If this is the case, we prevent the transaction completely.\n const updatedSize = this.storage.characters({ node: transaction.doc })\n\n if (updatedSize > limit) {\n return false\n }\n\n return true\n },\n }),\n ]\n },\n})\n"],"mappings":";AAAA,SAAS,iBAAiB;AAE1B,SAAS,QAAQ,iBAAiB;AAyD3B,IAAM,iBAAiB,UAAU,OAAqD;AAAA,EAC3F,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,OAAO;AAAA,MACP,MAAM;AAAA,MACN,aAAa,UAAQ,KAAK;AAAA,MAC1B,aAAa,UAAQ,KAAK,MAAM,GAAG,EAAE,OAAO,UAAQ,SAAS,EAAE,EAAE;AAAA,IACnE;AAAA,EACF;AAAA,EAEA,aAAa;AACX,WAAO;AAAA,MACL,YAAY,MAAM;AAAA,MAClB,OAAO,MAAM;AAAA,IACf;AAAA,EACF;AAAA,EAEA,iBAAiB;AACf,SAAK,QAAQ,aAAa,aAAW;AACnC,YAAM,QAAO,mCAAS,SAAQ,KAAK,OAAO,MAAM;AAChD,YAAM,QAAO,mCAAS,SAAQ,KAAK,QAAQ;AAE3C,UAAI,SAAS,YAAY;AACvB,cAAM,OAAO,KAAK,YAAY,GAAG,KAAK,QAAQ,MAAM,QAAW,GAAG;AAElE,eAAO,KAAK,QAAQ,YAAY,IAAI;AAAA,MACtC;AAEA,aAAO,KAAK;AAAA,IACd;AAEA,SAAK,QAAQ,QAAQ,aAAW;AAC9B,YAAM,QAAO,mCAAS,SAAQ,KAAK,OAAO,MAAM;AAChD,YAAM,OAAO,KAAK,YAAY,GAAG,KAAK,QAAQ,MAAM,KAAK,GAAG;AAE5D,aAAO,KAAK,QAAQ,YAAY,IAAI;AAAA,IACtC;AAAA,EACF;AAAA,EAEA,wBAAwB;AACtB,QAAI,wBAAwB;AAE5B,WAAO;AAAA,MACL,IAAI,OAAO;AAAA,QACT,KAAK,IAAI,UAAU,g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AIX,sBAAY,YAAY,MAAM,EAAE;AAMhC,gBAAM,cAAc,KAAK,QAAQ,WAAW,EAAE,MAAM,YAAY,IAAI,CAAC;AAErE,cAAI,cAAc,OAAO;AACvB,mBAAO;AAAA,UACT;AAEA,iBAAO;AAAA,QACT;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
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);
|
|
19
|
+
|
|
20
|
+
// src/drop-cursor/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Dropcursor: () => Dropcursor
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/drop-cursor/drop-cursor.ts
|
|
28
|
+
var import_core = require("@tiptap/core");
|
|
29
|
+
var import_dropcursor = require("@tiptap/pm/dropcursor");
|
|
30
|
+
var Dropcursor = import_core.Extension.create({
|
|
31
|
+
name: "dropCursor",
|
|
32
|
+
addOptions() {
|
|
33
|
+
return {
|
|
34
|
+
color: "currentColor",
|
|
35
|
+
width: 1,
|
|
36
|
+
class: void 0
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
addProseMirrorPlugins() {
|
|
40
|
+
return [(0, import_dropcursor.dropCursor)(this.options)];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
Dropcursor
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/drop-cursor/index.ts","../../src/drop-cursor/drop-cursor.ts"],"sourcesContent":["export * from './drop-cursor.js'\n","import { Extension } from '@tiptap/core'\nimport { dropCursor } from '@tiptap/pm/dropcursor'\n\nexport interface DropcursorOptions {\n /**\n * The color of the drop cursor\n * @default 'currentColor'\n * @example 'red'\n */\n color: string | undefined\n\n /**\n * The width of the drop cursor\n * @default 1\n * @example 2\n */\n width: number | undefined\n\n /**\n * The class of the drop cursor\n * @default undefined\n * @example 'drop-cursor'\n */\n class: string | undefined\n}\n\n/**\n * This extension allows you to add a drop cursor to your editor.\n * A drop cursor is a line that appears when you drag and drop content\n * in-between nodes.\n * @see https://tiptap.dev/api/extensions/dropcursor\n */\nexport const Dropcursor = Extension.create<DropcursorOptions>({\n name: 'dropCursor',\n\n addOptions() {\n return {\n color: 'currentColor',\n width: 1,\n class: undefined,\n }\n },\n\n addProseMirrorPlugins() {\n return [dropCursor(this.options)]\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAA0B;AAC1B,wBAA2B;AA+BpB,IAAM,aAAa,sBAAU,OAA0B;AAAA,EAC5D,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,OAAO;AAAA,MACP,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,wBAAwB;AACtB,WAAO,KAAC,8BAAW,KAAK,OAAO,CAAC;AAAA,EAClC;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
interface DropcursorOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The color of the drop cursor
|
|
6
|
+
* @default 'currentColor'
|
|
7
|
+
* @example 'red'
|
|
8
|
+
*/
|
|
9
|
+
color: string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* The width of the drop cursor
|
|
12
|
+
* @default 1
|
|
13
|
+
* @example 2
|
|
14
|
+
*/
|
|
15
|
+
width: number | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* The class of the drop cursor
|
|
18
|
+
* @default undefined
|
|
19
|
+
* @example 'drop-cursor'
|
|
20
|
+
*/
|
|
21
|
+
class: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* This extension allows you to add a drop cursor to your editor.
|
|
25
|
+
* A drop cursor is a line that appears when you drag and drop content
|
|
26
|
+
* in-between nodes.
|
|
27
|
+
* @see https://tiptap.dev/api/extensions/dropcursor
|
|
28
|
+
*/
|
|
29
|
+
declare const Dropcursor: Extension<DropcursorOptions, any>;
|
|
30
|
+
|
|
31
|
+
export { Dropcursor, type DropcursorOptions };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
interface DropcursorOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The color of the drop cursor
|
|
6
|
+
* @default 'currentColor'
|
|
7
|
+
* @example 'red'
|
|
8
|
+
*/
|
|
9
|
+
color: string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* The width of the drop cursor
|
|
12
|
+
* @default 1
|
|
13
|
+
* @example 2
|
|
14
|
+
*/
|
|
15
|
+
width: number | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* The class of the drop cursor
|
|
18
|
+
* @default undefined
|
|
19
|
+
* @example 'drop-cursor'
|
|
20
|
+
*/
|
|
21
|
+
class: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* This extension allows you to add a drop cursor to your editor.
|
|
25
|
+
* A drop cursor is a line that appears when you drag and drop content
|
|
26
|
+
* in-between nodes.
|
|
27
|
+
* @see https://tiptap.dev/api/extensions/dropcursor
|
|
28
|
+
*/
|
|
29
|
+
declare const Dropcursor: Extension<DropcursorOptions, any>;
|
|
30
|
+
|
|
31
|
+
export { Dropcursor, type DropcursorOptions };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/drop-cursor/drop-cursor.ts
|
|
2
|
+
import { Extension } from "@tiptap/core";
|
|
3
|
+
import { dropCursor } from "@tiptap/pm/dropcursor";
|
|
4
|
+
var Dropcursor = Extension.create({
|
|
5
|
+
name: "dropCursor",
|
|
6
|
+
addOptions() {
|
|
7
|
+
return {
|
|
8
|
+
color: "currentColor",
|
|
9
|
+
width: 1,
|
|
10
|
+
class: void 0
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
addProseMirrorPlugins() {
|
|
14
|
+
return [dropCursor(this.options)];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export {
|
|
18
|
+
Dropcursor
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/drop-cursor/drop-cursor.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { dropCursor } from '@tiptap/pm/dropcursor'\n\nexport interface DropcursorOptions {\n /**\n * The color of the drop cursor\n * @default 'currentColor'\n * @example 'red'\n */\n color: string | undefined\n\n /**\n * The width of the drop cursor\n * @default 1\n * @example 2\n */\n width: number | undefined\n\n /**\n * The class of the drop cursor\n * @default undefined\n * @example 'drop-cursor'\n */\n class: string | undefined\n}\n\n/**\n * This extension allows you to add a drop cursor to your editor.\n * A drop cursor is a line that appears when you drag and drop content\n * in-between nodes.\n * @see https://tiptap.dev/api/extensions/dropcursor\n */\nexport const Dropcursor = Extension.create<DropcursorOptions>({\n name: 'dropCursor',\n\n addOptions() {\n return {\n color: 'currentColor',\n width: 1,\n class: undefined,\n }\n },\n\n addProseMirrorPlugins() {\n return [dropCursor(this.options)]\n },\n})\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AA+BpB,IAAM,aAAa,UAAU,OAA0B;AAAA,EAC5D,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,OAAO;AAAA,MACP,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,wBAAwB;AACtB,WAAO,CAAC,WAAW,KAAK,OAAO,CAAC;AAAA,EAClC;AACF,CAAC;","names":[]}
|