@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.
- package/LICENSE.md +21 -0
- package/dist/index.cjs +285 -246
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +86 -0
- package/dist/index.d.ts +86 -10
- package/dist/index.js +255 -238
- package/dist/index.js.map +1 -1
- package/package.json +13 -9
- package/src/invisible-characters.ts +39 -43
- package/src/plugin/InvisibleCharacter.ts +3 -3
- package/src/plugin/InvisibleCharactersPlugin.ts +19 -16
- package/src/plugin/InvisibleNode.ts +5 -5
- package/src/plugin/reducers.ts +2 -5
- package/src/plugin/utils/create-style-tag.ts +3 -1
- package/src/plugin/utils/get-updated-ranges.ts +3 -6
- package/src/plugin/utils/text-between.ts +2 -2
- package/src/types.ts +11 -11
- package/dist/index.d.ts.map +0 -1
- package/dist/index.umd.js +0 -312
- package/dist/index.umd.js.map +0 -1
- package/dist/invisible-characters.d.ts +0 -27
- package/dist/invisible-characters.d.ts.map +0 -1
- package/dist/plugin/InvisibleCharacter.d.ts +0 -19
- package/dist/plugin/InvisibleCharacter.d.ts.map +0 -1
- package/dist/plugin/InvisibleCharactersPlugin.d.ts +0 -10
- package/dist/plugin/InvisibleCharactersPlugin.d.ts.map +0 -1
- package/dist/plugin/InvisibleNode.d.ts +0 -21
- package/dist/plugin/InvisibleNode.d.ts.map +0 -1
- package/dist/plugin/index.d.ts +0 -2
- package/dist/plugin/index.d.ts.map +0 -1
- package/dist/plugin/invisible-characters/hardBreak.d.ts +0 -6
- package/dist/plugin/invisible-characters/hardBreak.d.ts.map +0 -1
- package/dist/plugin/invisible-characters/paragraph.d.ts +0 -6
- package/dist/plugin/invisible-characters/paragraph.d.ts.map +0 -1
- package/dist/plugin/invisible-characters/space.d.ts +0 -6
- package/dist/plugin/invisible-characters/space.d.ts.map +0 -1
- package/dist/plugin/reducers.d.ts +0 -4
- package/dist/plugin/reducers.d.ts.map +0 -1
- package/dist/plugin/style.d.ts +0 -3
- package/dist/plugin/style.d.ts.map +0 -1
- package/dist/plugin/utils/create-decoration-widget.d.ts +0 -4
- package/dist/plugin/utils/create-decoration-widget.d.ts.map +0 -1
- package/dist/plugin/utils/create-style-tag.d.ts +0 -3
- package/dist/plugin/utils/create-style-tag.d.ts.map +0 -1
- package/dist/plugin/utils/get-updated-ranges.d.ts +0 -5
- package/dist/plugin/utils/get-updated-ranges.d.ts.map +0 -1
- package/dist/plugin/utils/text-between.d.ts +0 -5
- package/dist/plugin/utils/text-between.d.ts.map +0 -1
- package/dist/types.d.ts +0 -18
- package/dist/types.d.ts.map +0 -1
package/dist/index.umd.js
DELETED
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('@tiptap/pm/state'), require('@tiptap/pm/view')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', '@tiptap/pm/state', '@tiptap/pm/view'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-invisible-characters"] = {}, global.core, global.state, global.view));
|
|
5
|
-
})(this, (function (exports, core, state, view) { 'use strict';
|
|
6
|
-
|
|
7
|
-
const stateReducer = (state, visible) => {
|
|
8
|
-
if (visible === undefined) {
|
|
9
|
-
return state;
|
|
10
|
-
}
|
|
11
|
-
return { ...state, visible };
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const style = `.Tiptap-invisible-character {
|
|
15
|
-
height: 0;
|
|
16
|
-
padding: 0;
|
|
17
|
-
pointer-events: none;
|
|
18
|
-
user-select: none;
|
|
19
|
-
width: 0;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.Tiptap-invisible-character::before {
|
|
23
|
-
caret-color: inherit;
|
|
24
|
-
color: #aaa;
|
|
25
|
-
display: inline-block;
|
|
26
|
-
font-style: normal;
|
|
27
|
-
font-weight: 400;
|
|
28
|
-
line-height: 1em;
|
|
29
|
-
width: 0;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.Tiptap-invisible-character--space::before {
|
|
33
|
-
content: '·'
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.Tiptap-invisible-character--break::before {
|
|
37
|
-
content: '¬'
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.Tiptap-invisible-character--paragraph::before {
|
|
41
|
-
content: '¶'
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.Tiptap-invisible-character + img.ProseMirror-separator {
|
|
45
|
-
height: 0 !important;
|
|
46
|
-
pointer-events: none;
|
|
47
|
-
user-select: none;
|
|
48
|
-
width: 0 !important;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.is-empty[data-placeholder].has-focus > .Tiptap-invisible-character {
|
|
52
|
-
display: none;
|
|
53
|
-
}
|
|
54
|
-
`;
|
|
55
|
-
|
|
56
|
-
const createStyleTag = (style, nonce) => {
|
|
57
|
-
const tiptapStyleTag = document.querySelector('style[data-tiptap-extension-invisible-characters-style]');
|
|
58
|
-
if (tiptapStyleTag !== null) {
|
|
59
|
-
return tiptapStyleTag;
|
|
60
|
-
}
|
|
61
|
-
const styleNode = document.createElement('style');
|
|
62
|
-
if (nonce) {
|
|
63
|
-
styleNode.setAttribute('nonce', nonce);
|
|
64
|
-
}
|
|
65
|
-
styleNode.setAttribute('data-tiptap-extension-invisible-characters-style', '');
|
|
66
|
-
styleNode.innerHTML = style;
|
|
67
|
-
document.getElementsByTagName('head')[0].appendChild(styleNode);
|
|
68
|
-
return styleNode;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const getUpdatedRanges = ({ mapping }) => {
|
|
72
|
-
const ranges = [];
|
|
73
|
-
mapping.maps.forEach((stepMap, i) => {
|
|
74
|
-
stepMap.forEach((_oldStart, _oldEnd, newStart, newEnd) => {
|
|
75
|
-
ranges.push([
|
|
76
|
-
mapping.slice(i + 1).map(newStart),
|
|
77
|
-
mapping.slice(i + 1).map(newEnd),
|
|
78
|
-
]);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
return ranges;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const InvisibleCharactersPluginKey = new state.PluginKey('invisibleCharacters');
|
|
85
|
-
const InvisibleCharactersPlugin = (state$1, options) => {
|
|
86
|
-
const key = InvisibleCharactersPluginKey;
|
|
87
|
-
const emptyDecorationSet = view.DecorationSet.create(state$1.doc, []);
|
|
88
|
-
const addDecorationsBetweenPositions = (from, to, editorState, decorations) => {
|
|
89
|
-
return options.builders.sort((builderA, builderB) => {
|
|
90
|
-
if (builderA.priority > builderB.priority) {
|
|
91
|
-
return 1;
|
|
92
|
-
}
|
|
93
|
-
return -1;
|
|
94
|
-
}).reduce((newDecos, builder) => {
|
|
95
|
-
return builder.createDecoration(from, to, editorState.doc, newDecos);
|
|
96
|
-
}, decorations);
|
|
97
|
-
};
|
|
98
|
-
return new state.Plugin({
|
|
99
|
-
key,
|
|
100
|
-
state: {
|
|
101
|
-
init: () => {
|
|
102
|
-
const { $from, $to } = new state.AllSelection(state$1.doc);
|
|
103
|
-
if (options.injectCSS && document) {
|
|
104
|
-
createStyleTag(style, options.injectNonce);
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
visible: options.visible,
|
|
108
|
-
decorations: addDecorationsBetweenPositions($from.pos, $to.pos, state$1, view.DecorationSet.empty),
|
|
109
|
-
};
|
|
110
|
-
},
|
|
111
|
-
apply: (tr, pluginState, _, currentState) => {
|
|
112
|
-
const newPluginState = stateReducer(pluginState, tr.getMeta('setInvisibleCharactersVisible'));
|
|
113
|
-
const decorations = getUpdatedRanges(tr).reduce((nextDecorations, [from, to]) => {
|
|
114
|
-
return addDecorationsBetweenPositions(from, to, currentState, nextDecorations);
|
|
115
|
-
}, newPluginState.decorations.map(tr.mapping, tr.doc));
|
|
116
|
-
return {
|
|
117
|
-
...newPluginState,
|
|
118
|
-
decorations,
|
|
119
|
-
};
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
props: {
|
|
123
|
-
decorations(editorState) {
|
|
124
|
-
const pluginState = this.getState(editorState);
|
|
125
|
-
const visible = pluginState === null || pluginState === void 0 ? void 0 : pluginState.visible;
|
|
126
|
-
const decorations = pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations;
|
|
127
|
-
return visible ? decorations : emptyDecorationSet;
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const createDecorationWidget = (pos, type, content) => {
|
|
134
|
-
const createElement = () => {
|
|
135
|
-
const newElement = document.createElement('span');
|
|
136
|
-
newElement.classList.add('Tiptap-invisible-character');
|
|
137
|
-
newElement.classList.add(`Tiptap-invisible-character--${type}`);
|
|
138
|
-
if (content) {
|
|
139
|
-
newElement.textContent = content;
|
|
140
|
-
}
|
|
141
|
-
return newElement;
|
|
142
|
-
};
|
|
143
|
-
// return Decoration.inline(pos - 1, pos, {
|
|
144
|
-
// class: `Tiptap-invisible-character Tiptap-invisible-character--${type}`,
|
|
145
|
-
// })
|
|
146
|
-
return view.Decoration.widget(pos, createElement, {
|
|
147
|
-
key: type,
|
|
148
|
-
marks: [],
|
|
149
|
-
side: 1000,
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
/** Default position for nodes is always at the end of the node */
|
|
154
|
-
const defaultPosition = (node, pos) => pos + node.nodeSize - 1;
|
|
155
|
-
class InvisibleNode {
|
|
156
|
-
constructor(options) {
|
|
157
|
-
this.predicate = options.predicate;
|
|
158
|
-
this.type = options.type;
|
|
159
|
-
this.position = options.position || defaultPosition;
|
|
160
|
-
this.content = options.content;
|
|
161
|
-
this.priority = options.priority || 100;
|
|
162
|
-
}
|
|
163
|
-
createDecoration(from, to, doc, decorations) {
|
|
164
|
-
let newDecorations = decorations;
|
|
165
|
-
doc.nodesBetween(from, to, (node, pos) => {
|
|
166
|
-
if (this.test(node)) {
|
|
167
|
-
const decorationPosition = this.position(node, pos);
|
|
168
|
-
const oldDecorations = newDecorations.find(decorationPosition, decorationPosition, spec => spec.key === this.type);
|
|
169
|
-
newDecorations = newDecorations
|
|
170
|
-
.remove(oldDecorations)
|
|
171
|
-
.add(doc, [createDecorationWidget(decorationPosition, this.type, this.content)]);
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
return newDecorations;
|
|
175
|
-
}
|
|
176
|
-
test(value) {
|
|
177
|
-
return this.predicate(value);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
class HardBreakNode extends InvisibleNode {
|
|
182
|
-
constructor() {
|
|
183
|
-
super({
|
|
184
|
-
type: 'break',
|
|
185
|
-
predicate: node => node.type === node.type.schema.nodes.hardBreak,
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
class ParagraphNode extends InvisibleNode {
|
|
191
|
-
constructor() {
|
|
192
|
-
super({
|
|
193
|
-
type: 'paragraph',
|
|
194
|
-
predicate: node => node.type === node.type.schema.nodes.paragraph,
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const textBetween = (from, to, doc) => {
|
|
200
|
-
const positions = [];
|
|
201
|
-
doc.nodesBetween(from, to, (node, pos) => {
|
|
202
|
-
var _a;
|
|
203
|
-
if (node.isText) {
|
|
204
|
-
const offset = Math.max(from, pos) - pos;
|
|
205
|
-
positions.push({
|
|
206
|
-
pos: pos + offset,
|
|
207
|
-
text: ((_a = node.text) === null || _a === void 0 ? void 0 : _a.slice(offset, to - pos)) || '',
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
return positions;
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
class InvisibleCharacter {
|
|
215
|
-
constructor(options) {
|
|
216
|
-
this.predicate = options.predicate;
|
|
217
|
-
this.type = options.type;
|
|
218
|
-
this.content = options.content;
|
|
219
|
-
this.priority = options.priority || 100;
|
|
220
|
-
}
|
|
221
|
-
createDecoration(from, to, doc, decorations) {
|
|
222
|
-
const textContent = textBetween(from, to, doc);
|
|
223
|
-
return textContent.reduce((oldDecorations, currentPosition) => {
|
|
224
|
-
return currentPosition.text.split('').reduce((innerDecorations, char, i) => {
|
|
225
|
-
return this.test(char)
|
|
226
|
-
? innerDecorations.add(doc, [createDecorationWidget(currentPosition.pos + i, this.type, this.content)])
|
|
227
|
-
: innerDecorations;
|
|
228
|
-
}, oldDecorations);
|
|
229
|
-
}, decorations);
|
|
230
|
-
}
|
|
231
|
-
test(value) {
|
|
232
|
-
return this.predicate(value);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
class SpaceCharacter extends InvisibleCharacter {
|
|
237
|
-
constructor() {
|
|
238
|
-
super({
|
|
239
|
-
type: 'space',
|
|
240
|
-
predicate: (char) => char === ' ',
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
const InvisibleCharacters = core.Extension.create({
|
|
246
|
-
name: 'invisibleCharacters',
|
|
247
|
-
addOptions() {
|
|
248
|
-
return {
|
|
249
|
-
visible: true,
|
|
250
|
-
builders: [
|
|
251
|
-
new SpaceCharacter(),
|
|
252
|
-
new ParagraphNode(),
|
|
253
|
-
new HardBreakNode(),
|
|
254
|
-
],
|
|
255
|
-
injectCSS: true,
|
|
256
|
-
injectNonce: undefined,
|
|
257
|
-
};
|
|
258
|
-
},
|
|
259
|
-
addProseMirrorPlugins() {
|
|
260
|
-
return [
|
|
261
|
-
InvisibleCharactersPlugin(this.editor.state, this.options),
|
|
262
|
-
];
|
|
263
|
-
},
|
|
264
|
-
addStorage() {
|
|
265
|
-
return {
|
|
266
|
-
visibility: () => this.options.visible,
|
|
267
|
-
};
|
|
268
|
-
},
|
|
269
|
-
onBeforeCreate() {
|
|
270
|
-
this.storage.visibility = () => {
|
|
271
|
-
var _a;
|
|
272
|
-
return (_a = InvisibleCharactersPluginKey.getState(this.editor.state)) === null || _a === void 0 ? void 0 : _a.visible;
|
|
273
|
-
};
|
|
274
|
-
},
|
|
275
|
-
addCommands() {
|
|
276
|
-
return {
|
|
277
|
-
showInvisibleCharacters: (visibility = true) => ({ dispatch, tr }) => {
|
|
278
|
-
if (dispatch) {
|
|
279
|
-
tr.setMeta('setInvisibleCharactersVisible', visibility);
|
|
280
|
-
}
|
|
281
|
-
return true;
|
|
282
|
-
},
|
|
283
|
-
hideInvisibleCharacters: () => ({ dispatch, tr }) => {
|
|
284
|
-
if (dispatch) {
|
|
285
|
-
tr.setMeta('setInvisibleCharactersVisible', false);
|
|
286
|
-
}
|
|
287
|
-
return true;
|
|
288
|
-
},
|
|
289
|
-
toggleInvisibleCharacters: () => ({ dispatch, tr, state }) => {
|
|
290
|
-
var _a;
|
|
291
|
-
const visibility = !((_a = InvisibleCharactersPluginKey.getState(state)) === null || _a === void 0 ? void 0 : _a.visible);
|
|
292
|
-
if (dispatch) {
|
|
293
|
-
tr.setMeta('setInvisibleCharactersVisible', visibility);
|
|
294
|
-
}
|
|
295
|
-
return true;
|
|
296
|
-
},
|
|
297
|
-
};
|
|
298
|
-
},
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
exports.HardBreakNode = HardBreakNode;
|
|
302
|
-
exports.InvisibleCharacter = InvisibleCharacter;
|
|
303
|
-
exports.InvisibleCharacters = InvisibleCharacters;
|
|
304
|
-
exports.InvisibleNode = InvisibleNode;
|
|
305
|
-
exports.ParagraphNode = ParagraphNode;
|
|
306
|
-
exports.SpaceCharacter = SpaceCharacter;
|
|
307
|
-
exports.default = InvisibleCharacters;
|
|
308
|
-
|
|
309
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
310
|
-
|
|
311
|
-
}));
|
|
312
|
-
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.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":["PluginKey","state","DecorationSet","Plugin","AllSelection","Decoration","Extension"],"mappings":";;;;;;EAEO,MAAM,YAAY,GAAG,CAC1B,KAAkB,EAClB,OAAgB,KACD;EACf,IAAA,IAAI,OAAO,KAAK,SAAS,EAAE;EACzB,QAAA,OAAO,KAAK;;EAGd,IAAA,OAAO,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE;EAC9B,CAAC;;ECXM,MAAM,KAAK,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCpB;;ECxCM,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,KAAc,KAAsB;MAChF,MAAM,cAAc,GAAsB,QAAQ,CAAC,aAAa,CAAC,yDAAyD,CAAE;EAE5H,IAAA,IAAI,cAAc,KAAK,IAAI,EAAE;EAC3B,QAAA,OAAO,cAAc;;MAGvB,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;MAEjD,IAAI,KAAK,EAAE;EACT,QAAA,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC;;EAGxC,IAAA,SAAS,CAAC,YAAY,CAAC,kDAAkD,EAAE,EAAE,CAAC;EAC9E,IAAA,SAAS,CAAC,SAAS,GAAG,KAAK;EAC3B,IAAA,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC;EAE/D,IAAA,OAAO,SAAS;EAClB,CAAC;;ECdM,MAAM,gBAAgB,GAAG,CAAC,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AC;;EAGzD,gBAAA,OAAO,IAAI;eACZ;WACF;OACF;EACF,CAAA;;;;;;;;;;;;;;;;"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
|
-
import { HardBreakNode } from './plugin/invisible-characters/hardBreak.js';
|
|
3
|
-
import { ParagraphNode } from './plugin/invisible-characters/paragraph.js';
|
|
4
|
-
import { SpaceCharacter } from './plugin/invisible-characters/space.js';
|
|
5
|
-
import { InvisibleCharactersOptions } from './types.js';
|
|
6
|
-
export { HardBreakNode, ParagraphNode, SpaceCharacter, };
|
|
7
|
-
declare module '@tiptap/core' {
|
|
8
|
-
interface Commands<ReturnType> {
|
|
9
|
-
invisibleCharacters: {
|
|
10
|
-
/**
|
|
11
|
-
* Show invisible characters
|
|
12
|
-
*/
|
|
13
|
-
showInvisibleCharacters: (show?: boolean) => ReturnType;
|
|
14
|
-
/**
|
|
15
|
-
* Hide invisible characters
|
|
16
|
-
*/
|
|
17
|
-
hideInvisibleCharacters: () => ReturnType;
|
|
18
|
-
/**
|
|
19
|
-
* Toggle invisible characters
|
|
20
|
-
*/
|
|
21
|
-
toggleInvisibleCharacters: () => ReturnType;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export declare const InvisibleCharacters: Extension<InvisibleCharactersOptions, any>;
|
|
26
|
-
export default InvisibleCharacters;
|
|
27
|
-
//# sourceMappingURL=invisible-characters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invisible-characters.d.ts","sourceRoot":"","sources":["../src/invisible-characters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAGxC,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAA;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAEvD,OAAO,EACL,aAAa,EACb,aAAa,EACb,cAAc,GACf,CAAA;AAED,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,mBAAmB,EAAE;YACnB;;cAEE;YACF,uBAAuB,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK,UAAU,CAAA;YAEvD;;cAEE;YACF,uBAAuB,EAAE,MAAM,UAAU,CAAA;YAEzC;;cAEE;YACF,yBAAyB,EAAE,MAAM,UAAU,CAAA;SAC5C,CAAA;KACF;CACF;AAED,eAAO,MAAM,mBAAmB,4CA6D9B,CAAA;AAEF,eAAe,mBAAmB,CAAA"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Node } from '@tiptap/pm/model';
|
|
2
|
-
import { DecorationSet } from '@tiptap/pm/view';
|
|
3
|
-
export interface InvisibleCharacterOptions {
|
|
4
|
-
type: string;
|
|
5
|
-
predicate: (value: string) => boolean;
|
|
6
|
-
priority?: number;
|
|
7
|
-
content?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare class InvisibleCharacter {
|
|
10
|
-
predicate: (value: string) => boolean;
|
|
11
|
-
content?: string;
|
|
12
|
-
type: string;
|
|
13
|
-
priority: number;
|
|
14
|
-
constructor(options: InvisibleCharacterOptions);
|
|
15
|
-
createDecoration(from: number, to: number, doc: Node, decorations: DecorationSet): DecorationSet;
|
|
16
|
-
test(value: string): boolean;
|
|
17
|
-
}
|
|
18
|
-
export default InvisibleCharacter;
|
|
19
|
-
//# sourceMappingURL=InvisibleCharacter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InvisibleCharacter.d.ts","sourceRoot":"","sources":["../../src/plugin/InvisibleCharacter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAK/C,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAA;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,qBAAa,kBAAkB;IAC7B,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAA;IAErC,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB,IAAI,EAAE,MAAM,CAAA;IAEZ,QAAQ,EAAE,MAAM,CAAA;gBAEJ,OAAO,EAAE,yBAAyB;IAO9C,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa;IAYhF,IAAI,CAAC,KAAK,EAAE,MAAM;CAGnB;AAED,eAAe,kBAAkB,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { EditorState, Plugin, PluginKey } from '@tiptap/pm/state';
|
|
2
|
-
import { DecorationSet } from '@tiptap/pm/view';
|
|
3
|
-
import { InvisibleCharactersOptions, PluginState } from '../types.js';
|
|
4
|
-
export declare const InvisibleCharactersPluginKey: PluginKey<PluginState>;
|
|
5
|
-
export declare const InvisibleCharactersPlugin: (state: EditorState, options: InvisibleCharactersOptions) => Plugin<{
|
|
6
|
-
visible: boolean;
|
|
7
|
-
decorations: DecorationSet;
|
|
8
|
-
}>;
|
|
9
|
-
export default InvisibleCharactersPlugin;
|
|
10
|
-
//# sourceMappingURL=InvisibleCharactersPlugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InvisibleCharactersPlugin.d.ts","sourceRoot":"","sources":["../../src/plugin/InvisibleCharactersPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACS,WAAW,EAAE,MAAM,EAAE,SAAS,EAC7C,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAMrE,eAAO,MAAM,4BAA4B,wBAAoD,CAAA;AAE7F,eAAO,MAAM,yBAAyB,UAAW,WAAW,WAAW,0BAA0B;;;EA+DhG,CAAA;AAED,eAAe,yBAAyB,CAAA"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Node } from '@tiptap/pm/model';
|
|
2
|
-
import { DecorationSet } from '@tiptap/pm/view';
|
|
3
|
-
export interface InvisibleNodeOptions {
|
|
4
|
-
content?: string;
|
|
5
|
-
position?: (node: Node, pos: number) => number;
|
|
6
|
-
predicate: (value: Node) => boolean;
|
|
7
|
-
priority?: number;
|
|
8
|
-
type: string;
|
|
9
|
-
}
|
|
10
|
-
export declare class InvisibleNode {
|
|
11
|
-
predicate: (value: Node) => boolean;
|
|
12
|
-
position: (node: Node, pos: number) => number;
|
|
13
|
-
content?: string;
|
|
14
|
-
type: string;
|
|
15
|
-
priority: number;
|
|
16
|
-
constructor(options: InvisibleNodeOptions);
|
|
17
|
-
createDecoration(from: number, to: number, doc: Node, decorations: DecorationSet): DecorationSet;
|
|
18
|
-
test(value: Node): boolean;
|
|
19
|
-
}
|
|
20
|
-
export default InvisibleNode;
|
|
21
|
-
//# sourceMappingURL=InvisibleNode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InvisibleNode.d.ts","sourceRoot":"","sources":["../../src/plugin/InvisibleNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAI/C,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/C,SAAS,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,OAAO,CAAA;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAKD,qBAAa,aAAa;IACxB,SAAS,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,OAAO,CAAA;IAEnC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;IAE7C,OAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB,IAAI,EAAE,MAAM,CAAA;IAEZ,QAAQ,EAAE,MAAM,CAAA;gBAEJ,OAAO,EAAE,oBAAoB;IAQzC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa;IAoBhF,IAAI,CAAC,KAAK,EAAE,IAAI;CAGjB;AAED,eAAe,aAAa,CAAA"}
|
package/dist/plugin/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hardBreak.d.ts","sourceRoot":"","sources":["../../../src/plugin/invisible-characters/hardBreak.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,qBAAa,aAAc,SAAQ,aAAa;;CAO/C;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../../src/plugin/invisible-characters/paragraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,qBAAa,aAAc,SAAQ,aAAa;;CAO/C;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../../../src/plugin/invisible-characters/space.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAE7D,qBAAa,cAAe,SAAQ,kBAAkB;;CAOrD;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reducers.d.ts","sourceRoot":"","sources":["../../src/plugin/reducers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,eAAO,MAAM,YAAY,UAChB,WAAW,WACT,OAAO,KACf,WAMF,CAAA;AAED,eAAe,YAAY,CAAA"}
|
package/dist/plugin/style.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare 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: '\u00B7'\n}\n\n.Tiptap-invisible-character--break::before {\n content: '\u00AC'\n}\n\n.Tiptap-invisible-character--paragraph::before {\n content: '\u00B6'\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";
|
|
2
|
-
export default style;
|
|
3
|
-
//# sourceMappingURL=style.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/plugin/style.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,uxBAwCjB,CAAA;AAED,eAAe,KAAK,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-decoration-widget.d.ts","sourceRoot":"","sources":["../../../src/plugin/utils/create-decoration-widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,eAAO,MAAM,sBAAsB,QAAS,MAAM,QAAQ,MAAM,YAAY,MAAM,eAuBjF,CAAA;AAED,eAAe,sBAAsB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-style-tag.d.ts","sourceRoot":"","sources":["../../../src/plugin/utils/create-style-tag.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,UAAW,MAAM,UAAU,MAAM,KAAG,gBAkB9D,CAAA;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-updated-ranges.d.ts","sourceRoot":"","sources":["../../../src/plugin/utils/get-updated-ranges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,KAAK,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;AAE5C,eAAO,MAAM,gBAAgB,gBAAiB,WAAW,KAAG,SAAS,EAapE,CAAA;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text-between.d.ts","sourceRoot":"","sources":["../../../src/plugin/utils/text-between.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,eAAO,MAAM,WAAW,SAAU,MAAM,MAAM,MAAM,OAAO,IAAI,eAe9D,CAAA;AAED,eAAe,WAAW,CAAA"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { DecorationSet } from '@tiptap/pm/view';
|
|
2
|
-
import { InvisibleCharacter } from './plugin/InvisibleCharacter.js';
|
|
3
|
-
import { InvisibleNode } from './plugin/InvisibleNode.js';
|
|
4
|
-
export interface InvisibleCharactersOptions {
|
|
5
|
-
visible: boolean;
|
|
6
|
-
builders: Array<InvisibleCharacter | InvisibleNode>;
|
|
7
|
-
injectCSS: boolean;
|
|
8
|
-
injectNonce: string | undefined;
|
|
9
|
-
}
|
|
10
|
-
export interface Position {
|
|
11
|
-
pos: number;
|
|
12
|
-
text: string;
|
|
13
|
-
}
|
|
14
|
-
export interface PluginState {
|
|
15
|
-
visible: boolean;
|
|
16
|
-
decorations: DecorationSet;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEzD,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,KAAK,CAAC,kBAAkB,GAAG,aAAa,CAAC,CAAC;IACpD,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,aAAa,CAAC;CAC5B"}
|