@tiptap/extension-invisible-characters 2.24.2 → 3.0.0-beta.10

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 (50) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/index.cjs +285 -246
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +86 -0
  5. package/dist/index.d.ts +86 -10
  6. package/dist/index.js +255 -238
  7. package/dist/index.js.map +1 -1
  8. package/package.json +13 -9
  9. package/src/invisible-characters.ts +39 -43
  10. package/src/plugin/InvisibleCharacter.ts +3 -3
  11. package/src/plugin/InvisibleCharactersPlugin.ts +19 -16
  12. package/src/plugin/InvisibleNode.ts +5 -5
  13. package/src/plugin/reducers.ts +2 -5
  14. package/src/plugin/utils/create-style-tag.ts +3 -1
  15. package/src/plugin/utils/get-updated-ranges.ts +3 -6
  16. package/src/plugin/utils/text-between.ts +2 -2
  17. package/src/types.ts +11 -11
  18. package/dist/index.d.ts.map +0 -1
  19. package/dist/index.umd.js +0 -312
  20. package/dist/index.umd.js.map +0 -1
  21. package/dist/invisible-characters.d.ts +0 -27
  22. package/dist/invisible-characters.d.ts.map +0 -1
  23. package/dist/plugin/InvisibleCharacter.d.ts +0 -19
  24. package/dist/plugin/InvisibleCharacter.d.ts.map +0 -1
  25. package/dist/plugin/InvisibleCharactersPlugin.d.ts +0 -10
  26. package/dist/plugin/InvisibleCharactersPlugin.d.ts.map +0 -1
  27. package/dist/plugin/InvisibleNode.d.ts +0 -21
  28. package/dist/plugin/InvisibleNode.d.ts.map +0 -1
  29. package/dist/plugin/index.d.ts +0 -2
  30. package/dist/plugin/index.d.ts.map +0 -1
  31. package/dist/plugin/invisible-characters/hardBreak.d.ts +0 -6
  32. package/dist/plugin/invisible-characters/hardBreak.d.ts.map +0 -1
  33. package/dist/plugin/invisible-characters/paragraph.d.ts +0 -6
  34. package/dist/plugin/invisible-characters/paragraph.d.ts.map +0 -1
  35. package/dist/plugin/invisible-characters/space.d.ts +0 -6
  36. package/dist/plugin/invisible-characters/space.d.ts.map +0 -1
  37. package/dist/plugin/reducers.d.ts +0 -4
  38. package/dist/plugin/reducers.d.ts.map +0 -1
  39. package/dist/plugin/style.d.ts +0 -3
  40. package/dist/plugin/style.d.ts.map +0 -1
  41. package/dist/plugin/utils/create-decoration-widget.d.ts +0 -4
  42. package/dist/plugin/utils/create-decoration-widget.d.ts.map +0 -1
  43. package/dist/plugin/utils/create-style-tag.d.ts +0 -3
  44. package/dist/plugin/utils/create-style-tag.d.ts.map +0 -1
  45. package/dist/plugin/utils/get-updated-ranges.d.ts +0 -5
  46. package/dist/plugin/utils/get-updated-ranges.d.ts.map +0 -1
  47. package/dist/plugin/utils/text-between.d.ts +0 -5
  48. package/dist/plugin/utils/text-between.d.ts.map +0 -1
  49. package/dist/types.d.ts +0 -18
  50. package/dist/types.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,15 +1,20 @@
1
- import { Extension } from '@tiptap/core';
2
- import { PluginKey, Plugin, AllSelection } from '@tiptap/pm/state';
3
- import { DecorationSet, Decoration } from '@tiptap/pm/view';
1
+ // src/invisible-characters.ts
2
+ import { Extension } from "@tiptap/core";
4
3
 
5
- const stateReducer = (state, visible) => {
6
- if (visible === undefined) {
7
- return state;
8
- }
9
- return { ...state, visible };
4
+ // src/plugin/InvisibleCharactersPlugin.ts
5
+ import { AllSelection, Plugin, PluginKey } from "@tiptap/pm/state";
6
+ import { DecorationSet } from "@tiptap/pm/view";
7
+
8
+ // src/plugin/reducers.ts
9
+ var stateReducer = (state, visible) => {
10
+ if (visible === void 0) {
11
+ return state;
12
+ }
13
+ return { ...state, visible };
10
14
  };
11
15
 
12
- const style = `.Tiptap-invisible-character {
16
+ // src/plugin/style.ts
17
+ var style = `.Tiptap-invisible-character {
13
18
  height: 0;
14
19
  padding: 0;
15
20
  pointer-events: none;
@@ -28,15 +33,15 @@ const style = `.Tiptap-invisible-character {
28
33
  }
29
34
 
30
35
  .Tiptap-invisible-character--space::before {
31
- content: '·'
36
+ content: '\xB7'
32
37
  }
33
38
 
34
39
  .Tiptap-invisible-character--break::before {
35
- content: '¬'
40
+ content: '\xAC'
36
41
  }
37
42
 
38
43
  .Tiptap-invisible-character--paragraph::before {
39
- content: ''
44
+ content: '\xB6'
40
45
  }
41
46
 
42
47
  .Tiptap-invisible-character + img.ProseMirror-separator {
@@ -51,250 +56,262 @@ const style = `.Tiptap-invisible-character {
51
56
  }
52
57
  `;
53
58
 
54
- const createStyleTag = (style, nonce) => {
55
- const tiptapStyleTag = document.querySelector('style[data-tiptap-extension-invisible-characters-style]');
56
- if (tiptapStyleTag !== null) {
57
- return tiptapStyleTag;
59
+ // src/plugin/utils/create-style-tag.ts
60
+ var createStyleTag = (style2, nonce) => {
61
+ const tiptapStyleTag = document.querySelector("style[data-tiptap-extension-invisible-characters-style]");
62
+ if (tiptapStyleTag !== null) {
63
+ return tiptapStyleTag;
64
+ }
65
+ const styleNode = document.createElement("style");
66
+ if (nonce) {
67
+ styleNode.setAttribute("nonce", nonce);
68
+ }
69
+ styleNode.setAttribute("data-tiptap-extension-invisible-characters-style", "");
70
+ styleNode.innerHTML = style2;
71
+ document.getElementsByTagName("head")[0].appendChild(styleNode);
72
+ return styleNode;
73
+ };
74
+
75
+ // src/plugin/utils/get-updated-ranges.ts
76
+ var getUpdatedRanges = ({ mapping }) => {
77
+ const ranges = [];
78
+ mapping.maps.forEach((stepMap, i) => {
79
+ stepMap.forEach((_oldStart, _oldEnd, newStart, newEnd) => {
80
+ ranges.push([mapping.slice(i + 1).map(newStart), mapping.slice(i + 1).map(newEnd)]);
81
+ });
82
+ });
83
+ return ranges;
84
+ };
85
+
86
+ // src/plugin/InvisibleCharactersPlugin.ts
87
+ var InvisibleCharactersPluginKey = new PluginKey("invisibleCharacters");
88
+ var InvisibleCharactersPlugin = (state, options) => {
89
+ const key = InvisibleCharactersPluginKey;
90
+ const emptyDecorationSet = DecorationSet.create(state.doc, []);
91
+ const addDecorationsBetweenPositions = (from, to, editorState, decorations) => {
92
+ return options.builders.sort((builderA, builderB) => {
93
+ if (builderA.priority > builderB.priority) {
94
+ return 1;
95
+ }
96
+ return -1;
97
+ }).reduce((newDecos, builder) => {
98
+ return builder.createDecoration(from, to, editorState.doc, newDecos);
99
+ }, decorations);
100
+ };
101
+ return new Plugin({
102
+ key,
103
+ state: {
104
+ init: () => {
105
+ const { $from, $to } = new AllSelection(state.doc);
106
+ if (options.injectCSS && document) {
107
+ createStyleTag(style, options.injectNonce);
108
+ }
109
+ return {
110
+ visible: options.visible,
111
+ decorations: addDecorationsBetweenPositions($from.pos, $to.pos, state, DecorationSet.empty)
112
+ };
113
+ },
114
+ apply: (tr, pluginState, _, currentState) => {
115
+ const newPluginState = stateReducer(pluginState, tr.getMeta("setInvisibleCharactersVisible"));
116
+ const decorations = getUpdatedRanges(tr).reduce(
117
+ (nextDecorations, [from, to]) => {
118
+ return addDecorationsBetweenPositions(from, to, currentState, nextDecorations);
119
+ },
120
+ newPluginState.decorations.map(tr.mapping, tr.doc)
121
+ );
122
+ return {
123
+ ...newPluginState,
124
+ decorations
125
+ };
126
+ }
127
+ },
128
+ props: {
129
+ decorations(editorState) {
130
+ const pluginState = this.getState(editorState);
131
+ const visible = pluginState == null ? void 0 : pluginState.visible;
132
+ const decorations = pluginState == null ? void 0 : pluginState.decorations;
133
+ return visible ? decorations : emptyDecorationSet;
134
+ }
58
135
  }
59
- const styleNode = document.createElement('style');
60
- if (nonce) {
61
- styleNode.setAttribute('nonce', nonce);
136
+ });
137
+ };
138
+
139
+ // src/plugin/utils/create-decoration-widget.ts
140
+ import { Decoration } from "@tiptap/pm/view";
141
+ var createDecorationWidget = (pos, type, content) => {
142
+ const createElement = () => {
143
+ const newElement = document.createElement("span");
144
+ newElement.classList.add("Tiptap-invisible-character");
145
+ newElement.classList.add(`Tiptap-invisible-character--${type}`);
146
+ if (content) {
147
+ newElement.textContent = content;
62
148
  }
63
- styleNode.setAttribute('data-tiptap-extension-invisible-characters-style', '');
64
- styleNode.innerHTML = style;
65
- document.getElementsByTagName('head')[0].appendChild(styleNode);
66
- return styleNode;
149
+ return newElement;
150
+ };
151
+ return Decoration.widget(pos, createElement, {
152
+ key: type,
153
+ marks: [],
154
+ side: 1e3
155
+ });
67
156
  };
68
157
 
69
- const getUpdatedRanges = ({ mapping }) => {
70
- const ranges = [];
71
- mapping.maps.forEach((stepMap, i) => {
72
- stepMap.forEach((_oldStart, _oldEnd, newStart, newEnd) => {
73
- ranges.push([
74
- mapping.slice(i + 1).map(newStart),
75
- mapping.slice(i + 1).map(newEnd),
76
- ]);
77
- });
158
+ // src/plugin/InvisibleNode.ts
159
+ var defaultPosition = (node, pos) => pos + node.nodeSize - 1;
160
+ var InvisibleNode = class {
161
+ constructor(options) {
162
+ this.predicate = options.predicate;
163
+ this.type = options.type;
164
+ this.position = options.position || defaultPosition;
165
+ this.content = options.content;
166
+ this.priority = options.priority || 100;
167
+ }
168
+ createDecoration(from, to, doc, decorations) {
169
+ let newDecorations = decorations;
170
+ doc.nodesBetween(from, to, (node, pos) => {
171
+ if (this.test(node)) {
172
+ const decorationPosition = this.position(node, pos);
173
+ const oldDecorations = newDecorations.find(
174
+ decorationPosition,
175
+ decorationPosition,
176
+ (spec) => spec.key === this.type
177
+ );
178
+ newDecorations = newDecorations.remove(oldDecorations).add(doc, [createDecorationWidget(decorationPosition, this.type, this.content)]);
179
+ }
78
180
  });
79
- return ranges;
181
+ return newDecorations;
182
+ }
183
+ test(value) {
184
+ return this.predicate(value);
185
+ }
80
186
  };
81
187
 
82
- const InvisibleCharactersPluginKey = new PluginKey('invisibleCharacters');
83
- const InvisibleCharactersPlugin = (state, options) => {
84
- const key = InvisibleCharactersPluginKey;
85
- const emptyDecorationSet = DecorationSet.create(state.doc, []);
86
- const addDecorationsBetweenPositions = (from, to, editorState, decorations) => {
87
- return options.builders.sort((builderA, builderB) => {
88
- if (builderA.priority > builderB.priority) {
89
- return 1;
90
- }
91
- return -1;
92
- }).reduce((newDecos, builder) => {
93
- return builder.createDecoration(from, to, editorState.doc, newDecos);
94
- }, decorations);
95
- };
96
- return new Plugin({
97
- key,
98
- state: {
99
- init: () => {
100
- const { $from, $to } = new AllSelection(state.doc);
101
- if (options.injectCSS && document) {
102
- createStyleTag(style, options.injectNonce);
103
- }
104
- return {
105
- visible: options.visible,
106
- decorations: addDecorationsBetweenPositions($from.pos, $to.pos, state, DecorationSet.empty),
107
- };
108
- },
109
- apply: (tr, pluginState, _, currentState) => {
110
- const newPluginState = stateReducer(pluginState, tr.getMeta('setInvisibleCharactersVisible'));
111
- const decorations = getUpdatedRanges(tr).reduce((nextDecorations, [from, to]) => {
112
- return addDecorationsBetweenPositions(from, to, currentState, nextDecorations);
113
- }, newPluginState.decorations.map(tr.mapping, tr.doc));
114
- return {
115
- ...newPluginState,
116
- decorations,
117
- };
118
- },
119
- },
120
- props: {
121
- decorations(editorState) {
122
- const pluginState = this.getState(editorState);
123
- const visible = pluginState === null || pluginState === void 0 ? void 0 : pluginState.visible;
124
- const decorations = pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations;
125
- return visible ? decorations : emptyDecorationSet;
126
- },
127
- },
188
+ // src/plugin/invisible-characters/hardBreak.ts
189
+ var HardBreakNode = class extends InvisibleNode {
190
+ constructor() {
191
+ super({
192
+ type: "break",
193
+ predicate: (node) => node.type === node.type.schema.nodes.hardBreak
128
194
  });
195
+ }
129
196
  };
130
197
 
131
- const createDecorationWidget = (pos, type, content) => {
132
- const createElement = () => {
133
- const newElement = document.createElement('span');
134
- newElement.classList.add('Tiptap-invisible-character');
135
- newElement.classList.add(`Tiptap-invisible-character--${type}`);
136
- if (content) {
137
- newElement.textContent = content;
138
- }
139
- return newElement;
140
- };
141
- // return Decoration.inline(pos - 1, pos, {
142
- // class: `Tiptap-invisible-character Tiptap-invisible-character--${type}`,
143
- // })
144
- return Decoration.widget(pos, createElement, {
145
- key: type,
146
- marks: [],
147
- side: 1000,
198
+ // src/plugin/invisible-characters/paragraph.ts
199
+ var ParagraphNode = class extends InvisibleNode {
200
+ constructor() {
201
+ super({
202
+ type: "paragraph",
203
+ predicate: (node) => node.type === node.type.schema.nodes.paragraph
148
204
  });
205
+ }
149
206
  };
150
207
 
151
- /** Default position for nodes is always at the end of the node */
152
- const defaultPosition = (node, pos) => pos + node.nodeSize - 1;
153
- class InvisibleNode {
154
- constructor(options) {
155
- this.predicate = options.predicate;
156
- this.type = options.type;
157
- this.position = options.position || defaultPosition;
158
- this.content = options.content;
159
- this.priority = options.priority || 100;
160
- }
161
- createDecoration(from, to, doc, decorations) {
162
- let newDecorations = decorations;
163
- doc.nodesBetween(from, to, (node, pos) => {
164
- if (this.test(node)) {
165
- const decorationPosition = this.position(node, pos);
166
- const oldDecorations = newDecorations.find(decorationPosition, decorationPosition, spec => spec.key === this.type);
167
- newDecorations = newDecorations
168
- .remove(oldDecorations)
169
- .add(doc, [createDecorationWidget(decorationPosition, this.type, this.content)]);
170
- }
171
- });
172
- return newDecorations;
173
- }
174
- test(value) {
175
- return this.predicate(value);
176
- }
177
- }
178
-
179
- class HardBreakNode extends InvisibleNode {
180
- constructor() {
181
- super({
182
- type: 'break',
183
- predicate: node => node.type === node.type.schema.nodes.hardBreak,
184
- });
208
+ // src/plugin/utils/text-between.ts
209
+ var textBetween = (from, to, doc) => {
210
+ const positions = [];
211
+ doc.nodesBetween(from, to, (node, pos) => {
212
+ var _a;
213
+ if (node.isText) {
214
+ const offset = Math.max(from, pos) - pos;
215
+ positions.push({
216
+ pos: pos + offset,
217
+ text: ((_a = node.text) == null ? void 0 : _a.slice(offset, to - pos)) || ""
218
+ });
185
219
  }
186
- }
220
+ });
221
+ return positions;
222
+ };
187
223
 
188
- class ParagraphNode extends InvisibleNode {
189
- constructor() {
190
- super({
191
- type: 'paragraph',
192
- predicate: node => node.type === node.type.schema.nodes.paragraph,
193
- });
194
- }
195
- }
224
+ // src/plugin/InvisibleCharacter.ts
225
+ var InvisibleCharacter = class {
226
+ constructor(options) {
227
+ this.predicate = options.predicate;
228
+ this.type = options.type;
229
+ this.content = options.content;
230
+ this.priority = options.priority || 100;
231
+ }
232
+ createDecoration(from, to, doc, decorations) {
233
+ const textContent = textBetween(from, to, doc);
234
+ return textContent.reduce((oldDecorations, currentPosition) => {
235
+ return currentPosition.text.split("").reduce((innerDecorations, char, i) => {
236
+ return this.test(char) ? innerDecorations.add(doc, [createDecorationWidget(currentPosition.pos + i, this.type, this.content)]) : innerDecorations;
237
+ }, oldDecorations);
238
+ }, decorations);
239
+ }
240
+ test(value) {
241
+ return this.predicate(value);
242
+ }
243
+ };
196
244
 
197
- const textBetween = (from, to, doc) => {
198
- const positions = [];
199
- doc.nodesBetween(from, to, (node, pos) => {
200
- var _a;
201
- if (node.isText) {
202
- const offset = Math.max(from, pos) - pos;
203
- positions.push({
204
- pos: pos + offset,
205
- text: ((_a = node.text) === null || _a === void 0 ? void 0 : _a.slice(offset, to - pos)) || '',
206
- });
207
- }
245
+ // src/plugin/invisible-characters/space.ts
246
+ var SpaceCharacter = class extends InvisibleCharacter {
247
+ constructor() {
248
+ super({
249
+ type: "space",
250
+ predicate: (char) => char === " "
208
251
  });
209
- return positions;
252
+ }
210
253
  };
211
254
 
212
- class InvisibleCharacter {
213
- constructor(options) {
214
- this.predicate = options.predicate;
215
- this.type = options.type;
216
- this.content = options.content;
217
- this.priority = options.priority || 100;
218
- }
219
- createDecoration(from, to, doc, decorations) {
220
- const textContent = textBetween(from, to, doc);
221
- return textContent.reduce((oldDecorations, currentPosition) => {
222
- return currentPosition.text.split('').reduce((innerDecorations, char, i) => {
223
- return this.test(char)
224
- ? innerDecorations.add(doc, [createDecorationWidget(currentPosition.pos + i, this.type, this.content)])
225
- : innerDecorations;
226
- }, oldDecorations);
227
- }, decorations);
228
- }
229
- test(value) {
230
- return this.predicate(value);
231
- }
232
- }
233
-
234
- class SpaceCharacter extends InvisibleCharacter {
235
- constructor() {
236
- super({
237
- type: 'space',
238
- predicate: (char) => char === ' ',
239
- });
240
- }
241
- }
242
-
243
- const InvisibleCharacters = Extension.create({
244
- name: 'invisibleCharacters',
245
- addOptions() {
246
- return {
247
- visible: true,
248
- builders: [
249
- new SpaceCharacter(),
250
- new ParagraphNode(),
251
- new HardBreakNode(),
252
- ],
253
- injectCSS: true,
254
- injectNonce: undefined,
255
- };
256
- },
257
- addProseMirrorPlugins() {
258
- return [
259
- InvisibleCharactersPlugin(this.editor.state, this.options),
260
- ];
261
- },
262
- addStorage() {
263
- return {
264
- visibility: () => this.options.visible,
265
- };
266
- },
267
- onBeforeCreate() {
268
- this.storage.visibility = () => {
269
- var _a;
270
- return (_a = InvisibleCharactersPluginKey.getState(this.editor.state)) === null || _a === void 0 ? void 0 : _a.visible;
271
- };
272
- },
273
- addCommands() {
274
- return {
275
- showInvisibleCharacters: (visibility = true) => ({ dispatch, tr }) => {
276
- if (dispatch) {
277
- tr.setMeta('setInvisibleCharactersVisible', visibility);
278
- }
279
- return true;
280
- },
281
- hideInvisibleCharacters: () => ({ dispatch, tr }) => {
282
- if (dispatch) {
283
- tr.setMeta('setInvisibleCharactersVisible', false);
284
- }
285
- return true;
286
- },
287
- toggleInvisibleCharacters: () => ({ dispatch, tr, state }) => {
288
- var _a;
289
- const visibility = !((_a = InvisibleCharactersPluginKey.getState(state)) === null || _a === void 0 ? void 0 : _a.visible);
290
- if (dispatch) {
291
- tr.setMeta('setInvisibleCharactersVisible', visibility);
292
- }
293
- return true;
294
- },
295
- };
296
- },
255
+ // src/invisible-characters.ts
256
+ var InvisibleCharacters = Extension.create({
257
+ name: "invisibleCharacters",
258
+ addOptions() {
259
+ return {
260
+ visible: true,
261
+ builders: [new SpaceCharacter(), new ParagraphNode(), new HardBreakNode()],
262
+ injectCSS: true,
263
+ injectNonce: void 0
264
+ };
265
+ },
266
+ addProseMirrorPlugins() {
267
+ return [InvisibleCharactersPlugin(this.editor.state, this.options)];
268
+ },
269
+ addStorage() {
270
+ return {
271
+ visibility: () => this.options.visible
272
+ };
273
+ },
274
+ onBeforeCreate() {
275
+ this.storage.visibility = () => {
276
+ var _a;
277
+ return (_a = InvisibleCharactersPluginKey.getState(this.editor.state)) == null ? void 0 : _a.visible;
278
+ };
279
+ },
280
+ addCommands() {
281
+ return {
282
+ showInvisibleCharacters: (visibility = true) => ({ dispatch, tr }) => {
283
+ if (dispatch) {
284
+ tr.setMeta("setInvisibleCharactersVisible", visibility);
285
+ }
286
+ return true;
287
+ },
288
+ hideInvisibleCharacters: () => ({ dispatch, tr }) => {
289
+ if (dispatch) {
290
+ tr.setMeta("setInvisibleCharactersVisible", false);
291
+ }
292
+ return true;
293
+ },
294
+ toggleInvisibleCharacters: () => ({ dispatch, tr, state }) => {
295
+ var _a;
296
+ const visibility = !((_a = InvisibleCharactersPluginKey.getState(state)) == null ? void 0 : _a.visible);
297
+ if (dispatch) {
298
+ tr.setMeta("setInvisibleCharactersVisible", visibility);
299
+ }
300
+ return true;
301
+ }
302
+ };
303
+ }
297
304
  });
298
305
 
299
- export { HardBreakNode, InvisibleCharacter, InvisibleCharacters, InvisibleNode, ParagraphNode, SpaceCharacter, InvisibleCharacters as default };
300
- //# sourceMappingURL=index.js.map
306
+ // src/index.ts
307
+ var index_default = InvisibleCharacters;
308
+ export {
309
+ HardBreakNode,
310
+ InvisibleCharacter,
311
+ InvisibleCharacters,
312
+ InvisibleNode,
313
+ ParagraphNode,
314
+ SpaceCharacter,
315
+ index_default as default
316
+ };
317
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/plugin/reducers.ts","../src/plugin/style.ts","../src/plugin/utils/create-style-tag.ts","../src/plugin/utils/get-updated-ranges.ts","../src/plugin/InvisibleCharactersPlugin.ts","../src/plugin/utils/create-decoration-widget.ts","../src/plugin/InvisibleNode.ts","../src/plugin/invisible-characters/hardBreak.ts","../src/plugin/invisible-characters/paragraph.ts","../src/plugin/utils/text-between.ts","../src/plugin/InvisibleCharacter.ts","../src/plugin/invisible-characters/space.ts","../src/invisible-characters.ts"],"sourcesContent":["import { PluginState } from '../types.js'\n\nexport const stateReducer = (\n state: PluginState,\n visible: boolean,\n): PluginState => {\n if (visible === undefined) {\n return state\n }\n\n return { ...state, visible }\n}\n\nexport default stateReducer\n","export const style = `.Tiptap-invisible-character {\n height: 0;\n padding: 0;\n pointer-events: none;\n user-select: none;\n width: 0;\n}\n\n.Tiptap-invisible-character::before {\n caret-color: inherit;\n color: #aaa;\n display: inline-block;\n font-style: normal;\n font-weight: 400;\n line-height: 1em;\n width: 0;\n}\n\n.Tiptap-invisible-character--space::before {\n content: '·'\n}\n\n.Tiptap-invisible-character--break::before {\n content: '¬'\n}\n\n.Tiptap-invisible-character--paragraph::before {\n content: '¶'\n}\n\n.Tiptap-invisible-character + img.ProseMirror-separator {\n height: 0 !important;\n pointer-events: none;\n user-select: none;\n width: 0 !important;\n}\n\n.is-empty[data-placeholder].has-focus > .Tiptap-invisible-character {\n display: none;\n}\n`\n\nexport default style\n","export const createStyleTag = (style: string, nonce?: string): HTMLStyleElement => {\n const tiptapStyleTag = (<HTMLStyleElement>document.querySelector('style[data-tiptap-extension-invisible-characters-style]'))\n\n if (tiptapStyleTag !== null) {\n return tiptapStyleTag\n }\n\n const styleNode = document.createElement('style')\n\n if (nonce) {\n styleNode.setAttribute('nonce', nonce)\n }\n\n styleNode.setAttribute('data-tiptap-extension-invisible-characters-style', '')\n styleNode.innerHTML = style\n document.getElementsByTagName('head')[0].appendChild(styleNode)\n\n return styleNode\n}\n\nexport default createStyleTag\n","import { Transaction } from '@tiptap/pm/state'\n\ntype StepRange = [from: number, to: number];\n\nexport const getUpdatedRanges = ({ mapping }: Transaction): StepRange[] => {\n const ranges: StepRange[] = []\n\n mapping.maps.forEach((stepMap, i) => {\n stepMap.forEach((_oldStart, _oldEnd, newStart, newEnd) => {\n ranges.push([\n mapping.slice(i + 1).map(newStart),\n mapping.slice(i + 1).map(newEnd),\n ])\n })\n })\n\n return ranges\n}\n\nexport default getUpdatedRanges\n","import {\n AllSelection, EditorState, Plugin, PluginKey,\n} from '@tiptap/pm/state'\nimport { DecorationSet } from '@tiptap/pm/view'\n\nimport { InvisibleCharactersOptions, PluginState } from '../types.js'\nimport { stateReducer } from './reducers.js'\nimport { style } from './style.js'\nimport { createStyleTag } from './utils/create-style-tag.js'\nimport { getUpdatedRanges } from './utils/get-updated-ranges.js'\n\nexport const InvisibleCharactersPluginKey = new PluginKey<PluginState>('invisibleCharacters')\n\nexport const InvisibleCharactersPlugin = (state: EditorState, options: InvisibleCharactersOptions) => {\n const key = InvisibleCharactersPluginKey\n const emptyDecorationSet = DecorationSet.create(state.doc, [])\n\n const addDecorationsBetweenPositions = (\n from: number,\n to: number,\n editorState: EditorState,\n decorations: DecorationSet,\n ) => {\n return options.builders.sort((builderA, builderB) => {\n if (builderA.priority > builderB.priority) {\n return 1\n }\n\n return -1\n }).reduce((newDecos, builder) => {\n return builder.createDecoration(from, to, editorState.doc, newDecos)\n }, decorations)\n }\n\n return new Plugin({\n key,\n\n state: {\n init: () => {\n const { $from, $to } = new AllSelection(state.doc)\n\n if (options.injectCSS && document) {\n createStyleTag(style, options.injectNonce)\n }\n\n return {\n visible: options.visible,\n decorations: addDecorationsBetweenPositions($from.pos, $to.pos, state, DecorationSet.empty),\n }\n },\n apply: (tr, pluginState, _, currentState) => {\n const newPluginState = stateReducer(pluginState, tr.getMeta('setInvisibleCharactersVisible'))\n\n const decorations = getUpdatedRanges(tr).reduce((nextDecorations, [from, to]) => {\n return addDecorationsBetweenPositions(from, to, currentState, nextDecorations)\n }, newPluginState.decorations.map(tr.mapping, tr.doc))\n\n return {\n ...newPluginState,\n decorations,\n }\n },\n },\n\n props: {\n decorations(editorState) {\n const pluginState = this.getState(editorState)\n\n const visible = pluginState?.visible\n const decorations = pluginState?.decorations\n\n return visible ? decorations : emptyDecorationSet\n },\n },\n\n })\n}\n\nexport default InvisibleCharactersPlugin\n","import { Decoration } from '@tiptap/pm/view'\n\nexport const createDecorationWidget = (pos: number, type: string, content?: string) => {\n const createElement = () => {\n const newElement = document.createElement('span')\n\n newElement.classList.add('Tiptap-invisible-character')\n newElement.classList.add(`Tiptap-invisible-character--${type}`)\n\n if (content) {\n newElement.textContent = content\n }\n\n return newElement\n }\n\n // return Decoration.inline(pos - 1, pos, {\n // class: `Tiptap-invisible-character Tiptap-invisible-character--${type}`,\n // })\n\n return Decoration.widget(pos, createElement, {\n key: type,\n marks: [],\n side: 1000,\n })\n}\n\nexport default createDecorationWidget\n","import { Node } from '@tiptap/pm/model'\nimport { DecorationSet } from '@tiptap/pm/view'\n\nimport { createDecorationWidget } from './utils/create-decoration-widget.js'\n\nexport interface InvisibleNodeOptions {\n content?: string\n position?: (node: Node, pos: number) => number;\n predicate: (value: Node) => boolean\n priority?: number\n type: string;\n}\n\n/** Default position for nodes is always at the end of the node */\nconst defaultPosition = (node: Node, pos: number) => pos + node.nodeSize - 1\n\nexport class InvisibleNode {\n predicate: (value: Node) => boolean\n\n position: (node: Node, pos: number) => number\n\n content ?: string\n\n type: string\n\n priority: number\n\n constructor(options: InvisibleNodeOptions) {\n this.predicate = options.predicate\n this.type = options.type\n this.position = options.position || defaultPosition\n this.content = options.content\n this.priority = options.priority || 100\n }\n\n createDecoration(from: number, to: number, doc: Node, decorations: DecorationSet) {\n let newDecorations = decorations\n\n doc.nodesBetween(from, to, (node, pos) => {\n if (this.test(node)) {\n const decorationPosition = this.position(node, pos)\n const oldDecorations = newDecorations.find(\n decorationPosition,\n decorationPosition,\n spec => spec.key === this.type,\n )\n\n newDecorations = newDecorations\n .remove(oldDecorations)\n .add(doc, [createDecorationWidget(decorationPosition, this.type, this.content)])\n }\n })\n return newDecorations\n }\n\n test(value: Node) {\n return this.predicate(value)\n }\n}\n\nexport default InvisibleNode\n","import { InvisibleNode } from '../InvisibleNode.js'\n\nexport class HardBreakNode extends InvisibleNode {\n constructor() {\n super({\n type: 'break',\n predicate: node => node.type === node.type.schema.nodes.hardBreak,\n })\n }\n}\n\nexport default HardBreakNode\n","import { InvisibleNode } from '../InvisibleNode.js'\n\nexport class ParagraphNode extends InvisibleNode {\n constructor() {\n super({\n type: 'paragraph',\n predicate: node => node.type === node.type.schema.nodes.paragraph,\n })\n }\n}\n\nexport default ParagraphNode\n","import { Node } from '@tiptap/pm/model'\n\nimport { Position } from '../../types.js'\n\nexport const textBetween = (from: number, to: number, doc: Node) => {\n const positions: Position[] = []\n\n doc.nodesBetween(from, to, (node, pos) => {\n if (node.isText) {\n const offset = Math.max(from, pos) - pos\n\n positions.push({\n pos: pos + offset,\n text: node.text?.slice(offset, to - pos) || '',\n })\n }\n })\n\n return positions\n}\n\nexport default textBetween\n","import { Node } from '@tiptap/pm/model'\nimport { DecorationSet } from '@tiptap/pm/view'\n\nimport { createDecorationWidget } from './utils/create-decoration-widget.js'\nimport { textBetween } from './utils/text-between.js'\n\nexport interface InvisibleCharacterOptions {\n type: string;\n predicate: (value: string) => boolean\n priority?: number\n content?: string\n}\n\nexport class InvisibleCharacter {\n predicate: (value: string) => boolean\n\n content?: string\n\n type: string\n\n priority: number\n\n constructor(options: InvisibleCharacterOptions) {\n this.predicate = options.predicate\n this.type = options.type\n this.content = options.content\n this.priority = options.priority || 100\n }\n\n createDecoration(from: number, to: number, doc: Node, decorations: DecorationSet) {\n const textContent = textBetween(from, to, doc)\n\n return textContent.reduce((oldDecorations, currentPosition) => {\n return currentPosition.text.split('').reduce((innerDecorations, char, i) => {\n return this.test(char)\n ? innerDecorations.add(doc, [createDecorationWidget(currentPosition.pos + i, this.type, this.content)])\n : innerDecorations\n }, oldDecorations)\n }, decorations)\n }\n\n test(value: string) {\n return this.predicate(value)\n }\n}\n\nexport default InvisibleCharacter\n","import { InvisibleCharacter } from '../InvisibleCharacter.js'\n\nexport class SpaceCharacter extends InvisibleCharacter {\n constructor() {\n super({\n type: 'space',\n predicate: (char: string) => char === ' ',\n })\n }\n}\n\nexport default SpaceCharacter\n","import { Extension } from '@tiptap/core'\n\nimport { InvisibleCharactersPlugin, InvisibleCharactersPluginKey } from './plugin/index.js'\nimport { HardBreakNode } from './plugin/invisible-characters/hardBreak.js'\nimport { ParagraphNode } from './plugin/invisible-characters/paragraph.js'\nimport { SpaceCharacter } from './plugin/invisible-characters/space.js'\nimport { InvisibleCharactersOptions } from './types.js'\n\nexport {\n HardBreakNode,\n ParagraphNode,\n SpaceCharacter,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n invisibleCharacters: {\n /**\n * Show invisible characters\n */\n showInvisibleCharacters: (show?: boolean) => ReturnType\n\n /**\n * Hide invisible characters\n */\n hideInvisibleCharacters: () => ReturnType\n\n /**\n * Toggle invisible characters\n */\n toggleInvisibleCharacters: () => ReturnType\n }\n }\n}\n\nexport const InvisibleCharacters = Extension.create<InvisibleCharactersOptions>({\n name: 'invisibleCharacters',\n\n addOptions() {\n return {\n visible: true,\n builders: [\n new SpaceCharacter(),\n new ParagraphNode(),\n new HardBreakNode(),\n ],\n injectCSS: true,\n injectNonce: undefined,\n }\n },\n\n addProseMirrorPlugins() {\n return [\n InvisibleCharactersPlugin(this.editor.state, this.options),\n ]\n },\n\n addStorage() {\n return {\n visibility: () => this.options.visible,\n }\n },\n\n onBeforeCreate() {\n this.storage.visibility = () => {\n return InvisibleCharactersPluginKey.getState(this.editor.state)?.visible\n }\n },\n\n addCommands() {\n return {\n showInvisibleCharacters: (visibility = true) => ({ dispatch, tr }) => {\n if (dispatch) {\n tr.setMeta('setInvisibleCharactersVisible', visibility)\n }\n\n return true\n },\n hideInvisibleCharacters: () => ({ dispatch, tr }) => {\n if (dispatch) {\n tr.setMeta('setInvisibleCharactersVisible', false)\n }\n\n return true\n },\n toggleInvisibleCharacters: () => ({ dispatch, tr, state }) => {\n const visibility = !InvisibleCharactersPluginKey.getState(state)?.visible\n\n if (dispatch) {\n tr.setMeta('setInvisibleCharactersVisible', visibility)\n }\n\n return true\n },\n }\n },\n})\n\nexport default InvisibleCharacters\n"],"names":[],"mappings":";;;;AAEO,MAAM,YAAY,GAAG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,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,OAAO;AAC1E,SAAC;KACF;IAED,WAAW,GAAA;QACT,OAAO;AACL,YAAA,uBAAuB,EAAE,CAAC,UAAU,GAAG,IAAI,KAAK,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAI;gBACnE,IAAI,QAAQ,EAAE;AACZ,oBAAA,EAAE,CAAC,OAAO,CAAC,+BAA+B,EAAE,UAAU,CAAC;;AAGzD,gBAAA,OAAO,IAAI;aACZ;YACD,uBAAuB,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAI;gBAClD,IAAI,QAAQ,EAAE;AACZ,oBAAA,EAAE,CAAC,OAAO,CAAC,+BAA+B,EAAE,KAAK,CAAC;;AAGpD,gBAAA,OAAO,IAAI;aACZ;AACD,YAAA,yBAAyB,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,KAAI;;AAC3D,gBAAA,MAAM,UAAU,GAAG,EAAC,MAAA,4BAA4B,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAO,CAAA;gBAEzE,IAAI,QAAQ,EAAE;AACZ,oBAAA,EAAE,CAAC,OAAO,CAAC,+BAA+B,EAAE,UAAU,CAAC;;AAGzD,gBAAA,OAAO,IAAI;aACZ;SACF;KACF;AACF,CAAA;;;;"}
1
+ {"version":3,"sources":["../src/invisible-characters.ts","../src/plugin/InvisibleCharactersPlugin.ts","../src/plugin/reducers.ts","../src/plugin/style.ts","../src/plugin/utils/create-style-tag.ts","../src/plugin/utils/get-updated-ranges.ts","../src/plugin/utils/create-decoration-widget.ts","../src/plugin/InvisibleNode.ts","../src/plugin/invisible-characters/hardBreak.ts","../src/plugin/invisible-characters/paragraph.ts","../src/plugin/utils/text-between.ts","../src/plugin/InvisibleCharacter.ts","../src/plugin/invisible-characters/space.ts","../src/index.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\n\nimport { InvisibleCharactersPlugin, InvisibleCharactersPluginKey } from './plugin/index.js'\nimport { HardBreakNode } from './plugin/invisible-characters/hardBreak.js'\nimport { ParagraphNode } from './plugin/invisible-characters/paragraph.js'\nimport { SpaceCharacter } from './plugin/invisible-characters/space.js'\nimport type { InvisibleCharactersOptions } from './types.js'\n\nexport { HardBreakNode, ParagraphNode, SpaceCharacter }\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n invisibleCharacters: {\n /**\n * Show invisible characters\n */\n showInvisibleCharacters: (show?: boolean) => ReturnType\n\n /**\n * Hide invisible characters\n */\n hideInvisibleCharacters: () => ReturnType\n\n /**\n * Toggle invisible characters\n */\n toggleInvisibleCharacters: () => ReturnType\n }\n }\n}\n\nexport const InvisibleCharacters = Extension.create<InvisibleCharactersOptions>({\n name: 'invisibleCharacters',\n\n addOptions() {\n return {\n visible: true,\n builders: [new SpaceCharacter(), new ParagraphNode(), new HardBreakNode()],\n injectCSS: true,\n injectNonce: undefined,\n }\n },\n\n addProseMirrorPlugins() {\n return [InvisibleCharactersPlugin(this.editor.state, this.options)]\n },\n\n addStorage() {\n return {\n visibility: () => this.options.visible,\n }\n },\n\n onBeforeCreate() {\n this.storage.visibility = () => {\n return InvisibleCharactersPluginKey.getState(this.editor.state)?.visible\n }\n },\n\n addCommands() {\n return {\n showInvisibleCharacters:\n (visibility = true) =>\n ({ dispatch, tr }) => {\n if (dispatch) {\n tr.setMeta('setInvisibleCharactersVisible', visibility)\n }\n\n return true\n },\n hideInvisibleCharacters:\n () =>\n ({ dispatch, tr }) => {\n if (dispatch) {\n tr.setMeta('setInvisibleCharactersVisible', false)\n }\n\n return true\n },\n toggleInvisibleCharacters:\n () =>\n ({ dispatch, tr, state }) => {\n const visibility = !InvisibleCharactersPluginKey.getState(state)?.visible\n\n if (dispatch) {\n tr.setMeta('setInvisibleCharactersVisible', visibility)\n }\n\n return true\n },\n }\n },\n})\n\nexport default InvisibleCharacters\n","import type { EditorState } from '@tiptap/pm/state'\nimport { AllSelection, Plugin, PluginKey } from '@tiptap/pm/state'\nimport { DecorationSet } from '@tiptap/pm/view'\n\nimport type { InvisibleCharactersOptions, PluginState } from '../types.js'\nimport { stateReducer } from './reducers.js'\nimport { style } from './style.js'\nimport { createStyleTag } from './utils/create-style-tag.js'\nimport { getUpdatedRanges } from './utils/get-updated-ranges.js'\n\nexport const InvisibleCharactersPluginKey = new PluginKey<PluginState>('invisibleCharacters')\n\nexport const InvisibleCharactersPlugin = (state: EditorState, options: InvisibleCharactersOptions) => {\n const key = InvisibleCharactersPluginKey\n const emptyDecorationSet = DecorationSet.create(state.doc, [])\n\n const addDecorationsBetweenPositions = (\n from: number,\n to: number,\n editorState: EditorState,\n decorations: DecorationSet,\n ) => {\n return options.builders\n .sort((builderA, builderB) => {\n if (builderA.priority > builderB.priority) {\n return 1\n }\n\n return -1\n })\n .reduce((newDecos, builder) => {\n return builder.createDecoration(from, to, editorState.doc, newDecos)\n }, decorations)\n }\n\n return new Plugin({\n key,\n\n state: {\n init: () => {\n const { $from, $to } = new AllSelection(state.doc)\n\n if (options.injectCSS && document) {\n createStyleTag(style, options.injectNonce)\n }\n\n return {\n visible: options.visible,\n decorations: addDecorationsBetweenPositions($from.pos, $to.pos, state, DecorationSet.empty),\n }\n },\n apply: (tr, pluginState, _, currentState) => {\n const newPluginState = stateReducer(pluginState, tr.getMeta('setInvisibleCharactersVisible'))\n\n const decorations = getUpdatedRanges(tr).reduce(\n (nextDecorations, [from, to]) => {\n return addDecorationsBetweenPositions(from, to, currentState, nextDecorations)\n },\n newPluginState.decorations.map(tr.mapping, tr.doc),\n )\n\n return {\n ...newPluginState,\n decorations,\n }\n },\n },\n\n props: {\n decorations(editorState) {\n const pluginState = this.getState(editorState)\n\n const visible = pluginState?.visible\n const decorations = pluginState?.decorations\n\n return visible ? decorations : emptyDecorationSet\n },\n },\n })\n}\n\nexport default InvisibleCharactersPlugin\n","import type { PluginState } from '../types.js'\n\nexport const stateReducer = (state: PluginState, visible: boolean): PluginState => {\n if (visible === undefined) {\n return state\n }\n\n return { ...state, visible }\n}\n\nexport default stateReducer\n","export const style = `.Tiptap-invisible-character {\n height: 0;\n padding: 0;\n pointer-events: none;\n user-select: none;\n width: 0;\n}\n\n.Tiptap-invisible-character::before {\n caret-color: inherit;\n color: #aaa;\n display: inline-block;\n font-style: normal;\n font-weight: 400;\n line-height: 1em;\n width: 0;\n}\n\n.Tiptap-invisible-character--space::before {\n content: '·'\n}\n\n.Tiptap-invisible-character--break::before {\n content: '¬'\n}\n\n.Tiptap-invisible-character--paragraph::before {\n content: '¶'\n}\n\n.Tiptap-invisible-character + img.ProseMirror-separator {\n height: 0 !important;\n pointer-events: none;\n user-select: none;\n width: 0 !important;\n}\n\n.is-empty[data-placeholder].has-focus > .Tiptap-invisible-character {\n display: none;\n}\n`\n\nexport default style\n","export const createStyleTag = (style: string, nonce?: string): HTMLStyleElement => {\n const tiptapStyleTag = <HTMLStyleElement>(\n document.querySelector('style[data-tiptap-extension-invisible-characters-style]')\n )\n\n if (tiptapStyleTag !== null) {\n return tiptapStyleTag\n }\n\n const styleNode = document.createElement('style')\n\n if (nonce) {\n styleNode.setAttribute('nonce', nonce)\n }\n\n styleNode.setAttribute('data-tiptap-extension-invisible-characters-style', '')\n styleNode.innerHTML = style\n document.getElementsByTagName('head')[0].appendChild(styleNode)\n\n return styleNode\n}\n\nexport default createStyleTag\n","import type { Transaction } from '@tiptap/pm/state'\n\ntype StepRange = [from: number, to: number]\n\nexport const getUpdatedRanges = ({ mapping }: Transaction): StepRange[] => {\n const ranges: StepRange[] = []\n\n mapping.maps.forEach((stepMap, i) => {\n stepMap.forEach((_oldStart, _oldEnd, newStart, newEnd) => {\n ranges.push([mapping.slice(i + 1).map(newStart), mapping.slice(i + 1).map(newEnd)])\n })\n })\n\n return ranges\n}\n\nexport default getUpdatedRanges\n","import { Decoration } from '@tiptap/pm/view'\n\nexport const createDecorationWidget = (pos: number, type: string, content?: string) => {\n const createElement = () => {\n const newElement = document.createElement('span')\n\n newElement.classList.add('Tiptap-invisible-character')\n newElement.classList.add(`Tiptap-invisible-character--${type}`)\n\n if (content) {\n newElement.textContent = content\n }\n\n return newElement\n }\n\n // return Decoration.inline(pos - 1, pos, {\n // class: `Tiptap-invisible-character Tiptap-invisible-character--${type}`,\n // })\n\n return Decoration.widget(pos, createElement, {\n key: type,\n marks: [],\n side: 1000,\n })\n}\n\nexport default createDecorationWidget\n","import type { Node } from '@tiptap/pm/model'\nimport type { DecorationSet } from '@tiptap/pm/view'\n\nimport { createDecorationWidget } from './utils/create-decoration-widget.js'\n\nexport interface InvisibleNodeOptions {\n content?: string\n position?: (node: Node, pos: number) => number\n predicate: (value: Node) => boolean\n priority?: number\n type: string\n}\n\n/** Default position for nodes is always at the end of the node */\nconst defaultPosition = (node: Node, pos: number) => pos + node.nodeSize - 1\n\nexport class InvisibleNode {\n predicate: (value: Node) => boolean\n\n position: (node: Node, pos: number) => number\n\n content?: string\n\n type: string\n\n priority: number\n\n constructor(options: InvisibleNodeOptions) {\n this.predicate = options.predicate\n this.type = options.type\n this.position = options.position || defaultPosition\n this.content = options.content\n this.priority = options.priority || 100\n }\n\n createDecoration(from: number, to: number, doc: Node, decorations: DecorationSet) {\n let newDecorations = decorations\n\n doc.nodesBetween(from, to, (node, pos) => {\n if (this.test(node)) {\n const decorationPosition = this.position(node, pos)\n const oldDecorations = newDecorations.find(\n decorationPosition,\n decorationPosition,\n spec => spec.key === this.type,\n )\n\n newDecorations = newDecorations\n .remove(oldDecorations)\n .add(doc, [createDecorationWidget(decorationPosition, this.type, this.content)])\n }\n })\n return newDecorations\n }\n\n test(value: Node) {\n return this.predicate(value)\n }\n}\n\nexport default InvisibleNode\n","import { InvisibleNode } from '../InvisibleNode.js'\n\nexport class HardBreakNode extends InvisibleNode {\n constructor() {\n super({\n type: 'break',\n predicate: node => node.type === node.type.schema.nodes.hardBreak,\n })\n }\n}\n\nexport default HardBreakNode\n","import { InvisibleNode } from '../InvisibleNode.js'\n\nexport class ParagraphNode extends InvisibleNode {\n constructor() {\n super({\n type: 'paragraph',\n predicate: node => node.type === node.type.schema.nodes.paragraph,\n })\n }\n}\n\nexport default ParagraphNode\n","import type { Node } from '@tiptap/pm/model'\n\nimport type { Position } from '../../types.js'\n\nexport const textBetween = (from: number, to: number, doc: Node) => {\n const positions: Position[] = []\n\n doc.nodesBetween(from, to, (node, pos) => {\n if (node.isText) {\n const offset = Math.max(from, pos) - pos\n\n positions.push({\n pos: pos + offset,\n text: node.text?.slice(offset, to - pos) || '',\n })\n }\n })\n\n return positions\n}\n\nexport default textBetween\n","import type { Node } from '@tiptap/pm/model'\nimport type { DecorationSet } from '@tiptap/pm/view'\n\nimport { createDecorationWidget } from './utils/create-decoration-widget.js'\nimport { textBetween } from './utils/text-between.js'\n\nexport interface InvisibleCharacterOptions {\n type: string\n predicate: (value: string) => boolean\n priority?: number\n content?: string\n}\n\nexport class InvisibleCharacter {\n predicate: (value: string) => boolean\n\n content?: string\n\n type: string\n\n priority: number\n\n constructor(options: InvisibleCharacterOptions) {\n this.predicate = options.predicate\n this.type = options.type\n this.content = options.content\n this.priority = options.priority || 100\n }\n\n createDecoration(from: number, to: number, doc: Node, decorations: DecorationSet) {\n const textContent = textBetween(from, to, doc)\n\n return textContent.reduce((oldDecorations, currentPosition) => {\n return currentPosition.text.split('').reduce((innerDecorations, char, i) => {\n return this.test(char)\n ? innerDecorations.add(doc, [createDecorationWidget(currentPosition.pos + i, this.type, this.content)])\n : innerDecorations\n }, oldDecorations)\n }, decorations)\n }\n\n test(value: string) {\n return this.predicate(value)\n }\n}\n\nexport default InvisibleCharacter\n","import { InvisibleCharacter } from '../InvisibleCharacter.js'\n\nexport class SpaceCharacter extends InvisibleCharacter {\n constructor() {\n super({\n type: 'space',\n predicate: (char: string) => char === ' ',\n })\n }\n}\n\nexport default SpaceCharacter\n","import { InvisibleCharacters } from './invisible-characters.js'\n\nexport * from './invisible-characters.js'\nexport * from './plugin/invisible-characters/hardBreak.js'\nexport * from './plugin/invisible-characters/paragraph.js'\nexport * from './plugin/invisible-characters/space.js'\nexport * from './plugin/InvisibleCharacter.js'\nexport * from './plugin/InvisibleNode.js'\nexport * from './types.js'\n\nexport default InvisibleCharacters\n"],"mappings":";AAAA,SAAS,iBAAiB;;;ACC1B,SAAS,cAAc,QAAQ,iBAAiB;AAChD,SAAS,qBAAqB;;;ACAvB,IAAM,eAAe,CAAC,OAAoB,YAAkC;AACjF,MAAI,YAAY,QAAW;AACzB,WAAO;AAAA,EACT;AAEA,SAAO,EAAE,GAAG,OAAO,QAAQ;AAC7B;;;ACRO,IAAM,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAd,IAAM,iBAAiB,CAACA,QAAe,UAAqC;AACjF,QAAM,iBACJ,SAAS,cAAc,yDAAyD;AAGlF,MAAI,mBAAmB,MAAM;AAC3B,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,SAAS,cAAc,OAAO;AAEhD,MAAI,OAAO;AACT,cAAU,aAAa,SAAS,KAAK;AAAA,EACvC;AAEA,YAAU,aAAa,oDAAoD,EAAE;AAC7E,YAAU,YAAYA;AACtB,WAAS,qBAAqB,MAAM,EAAE,CAAC,EAAE,YAAY,SAAS;AAE9D,SAAO;AACT;;;AChBO,IAAM,mBAAmB,CAAC,EAAE,QAAQ,MAAgC;AACzE,QAAM,SAAsB,CAAC;AAE7B,UAAQ,KAAK,QAAQ,CAAC,SAAS,MAAM;AACnC,YAAQ,QAAQ,CAAC,WAAW,SAAS,UAAU,WAAW;AACxD,aAAO,KAAK,CAAC,Q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