@tiptap/extension-invisible-characters 3.20.1 → 3.20.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-invisible-characters",
3
3
  "description": "invisible characters extension for tiptap",
4
- "version": "3.20.1",
4
+ "version": "3.20.3",
5
5
  "homepage": "https://tiptap.dev/docs/editor/extensions/functionality/invisiblecharacters",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -31,14 +31,14 @@
31
31
  "dist"
32
32
  ],
33
33
  "devDependencies": {
34
- "@tiptap/core": "^3.20.1",
35
- "@tiptap/extension-text-style": "^3.20.1",
36
- "@tiptap/pm": "^3.20.1"
34
+ "@tiptap/core": "^3.20.3",
35
+ "@tiptap/extension-text-style": "^3.20.3",
36
+ "@tiptap/pm": "^3.20.3"
37
37
  },
38
38
  "peerDependencies": {
39
- "@tiptap/core": "^3.20.1",
40
- "@tiptap/extension-text-style": "^3.20.1",
41
- "@tiptap/pm": "^3.20.1"
39
+ "@tiptap/core": "^3.20.3",
40
+ "@tiptap/extension-text-style": "^3.20.3",
41
+ "@tiptap/pm": "^3.20.3"
42
42
  },
43
43
  "repository": {
44
44
  "type": "git",
package/dist/index.cjs DELETED
@@ -1,349 +0,0 @@
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/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- HardBreakNode: () => HardBreakNode,
24
- InvisibleCharacter: () => InvisibleCharacter,
25
- InvisibleCharacters: () => InvisibleCharacters,
26
- InvisibleNode: () => InvisibleNode,
27
- ParagraphNode: () => ParagraphNode,
28
- SpaceCharacter: () => SpaceCharacter,
29
- default: () => index_default
30
- });
31
- module.exports = __toCommonJS(index_exports);
32
-
33
- // src/invisible-characters.ts
34
- var import_core = require("@tiptap/core");
35
-
36
- // src/plugin/InvisibleCharactersPlugin.ts
37
- var import_state = require("@tiptap/pm/state");
38
- var import_view = require("@tiptap/pm/view");
39
-
40
- // src/plugin/reducers.ts
41
- var stateReducer = (state, visible) => {
42
- if (visible === void 0) {
43
- return state;
44
- }
45
- return { ...state, visible };
46
- };
47
-
48
- // src/plugin/style.ts
49
- var style = `.tiptap-invisible-character {
50
- height: 0;
51
- padding: 0;
52
- pointer-events: none;
53
- user-select: none;
54
- width: 0;
55
- }
56
-
57
- .tiptap-invisible-character::before {
58
- caret-color: inherit;
59
- color: #aaa;
60
- display: inline-block;
61
- font-style: normal;
62
- font-weight: 400;
63
- line-height: 1em;
64
- width: 0;
65
- }
66
-
67
- .tiptap-invisible-character--space::before {
68
- content: '\xB7'
69
- }
70
-
71
- .tiptap-invisible-character--break::before {
72
- content: '\xAC'
73
- }
74
-
75
- .tiptap-invisible-character--paragraph::before {
76
- content: '\xB6'
77
- }
78
-
79
- .tiptap-invisible-character + img.ProseMirror-separator {
80
- height: 0 !important;
81
- pointer-events: none;
82
- user-select: none;
83
- width: 0 !important;
84
- }
85
-
86
- .is-empty[data-placeholder].has-focus > .tiptap-invisible-character {
87
- display: none;
88
- }
89
- `;
90
-
91
- // src/plugin/utils/create-style-tag.ts
92
- var createStyleTag = (style2, nonce) => {
93
- const tiptapStyleTag = document.querySelector("style[data-tiptap-extension-invisible-characters-style]");
94
- if (tiptapStyleTag !== null) {
95
- return tiptapStyleTag;
96
- }
97
- const styleNode = document.createElement("style");
98
- if (nonce) {
99
- styleNode.setAttribute("nonce", nonce);
100
- }
101
- styleNode.setAttribute("data-tiptap-extension-invisible-characters-style", "");
102
- styleNode.innerHTML = style2;
103
- document.getElementsByTagName("head")[0].appendChild(styleNode);
104
- return styleNode;
105
- };
106
-
107
- // src/plugin/utils/get-updated-ranges.ts
108
- var getUpdatedRanges = ({ mapping }) => {
109
- const ranges = [];
110
- mapping.maps.forEach((stepMap, i) => {
111
- stepMap.forEach((_oldStart, _oldEnd, newStart, newEnd) => {
112
- ranges.push([mapping.slice(i + 1).map(newStart), mapping.slice(i + 1).map(newEnd)]);
113
- });
114
- });
115
- return ranges;
116
- };
117
-
118
- // src/plugin/InvisibleCharactersPlugin.ts
119
- var InvisibleCharactersPluginKey = new import_state.PluginKey("invisibleCharacters");
120
- var InvisibleCharactersPlugin = (state, options) => {
121
- const key = InvisibleCharactersPluginKey;
122
- const emptyDecorationSet = import_view.DecorationSet.create(state.doc, []);
123
- const addDecorationsBetweenPositions = (from, to, editorState, decorations) => {
124
- return options.builders.sort((builderA, builderB) => {
125
- if (builderA.priority > builderB.priority) {
126
- return 1;
127
- }
128
- return -1;
129
- }).reduce((newDecos, builder) => {
130
- return builder.createDecoration(from, to, editorState.doc, newDecos);
131
- }, decorations);
132
- };
133
- return new import_state.Plugin({
134
- key,
135
- state: {
136
- init: () => {
137
- const { $from, $to } = new import_state.AllSelection(state.doc);
138
- if (options.injectCSS && document) {
139
- createStyleTag(style, options.injectNonce);
140
- }
141
- return {
142
- visible: options.visible,
143
- decorations: addDecorationsBetweenPositions($from.pos, $to.pos, state, import_view.DecorationSet.empty)
144
- };
145
- },
146
- apply: (tr, pluginState, _, currentState) => {
147
- const newPluginState = stateReducer(pluginState, tr.getMeta("setInvisibleCharactersVisible"));
148
- const decorations = getUpdatedRanges(tr).reduce(
149
- (nextDecorations, [from, to]) => {
150
- return addDecorationsBetweenPositions(from, to, currentState, nextDecorations);
151
- },
152
- newPluginState.decorations.map(tr.mapping, tr.doc)
153
- );
154
- return {
155
- ...newPluginState,
156
- decorations
157
- };
158
- }
159
- },
160
- props: {
161
- decorations(editorState) {
162
- const pluginState = this.getState(editorState);
163
- const visible = pluginState == null ? void 0 : pluginState.visible;
164
- const decorations = pluginState == null ? void 0 : pluginState.decorations;
165
- return visible ? decorations : emptyDecorationSet;
166
- }
167
- }
168
- });
169
- };
170
-
171
- // src/plugin/utils/create-decoration-widget.ts
172
- var import_view2 = require("@tiptap/pm/view");
173
- var createDecorationWidget = (pos, type, content) => {
174
- const createElement = () => {
175
- const newElement = document.createElement("span");
176
- newElement.classList.add("tiptap-invisible-character");
177
- newElement.classList.add(`tiptap-invisible-character--${type}`);
178
- if (content) {
179
- newElement.textContent = content;
180
- }
181
- return newElement;
182
- };
183
- return import_view2.Decoration.widget(pos, createElement, {
184
- key: type,
185
- marks: [],
186
- side: 1e3
187
- });
188
- };
189
-
190
- // src/plugin/InvisibleNode.ts
191
- var defaultPosition = (node, pos) => pos + node.nodeSize - 1;
192
- var InvisibleNode = class {
193
- constructor(options) {
194
- this.predicate = options.predicate;
195
- this.type = options.type;
196
- this.position = options.position || defaultPosition;
197
- this.content = options.content;
198
- this.priority = options.priority || 100;
199
- }
200
- createDecoration(from, to, doc, decorations) {
201
- let newDecorations = decorations;
202
- doc.nodesBetween(from, to, (node, pos) => {
203
- if (this.test(node)) {
204
- const decorationPosition = this.position(node, pos);
205
- const oldDecorations = newDecorations.find(
206
- decorationPosition,
207
- decorationPosition,
208
- (spec) => spec.key === this.type
209
- );
210
- newDecorations = newDecorations.remove(oldDecorations).add(doc, [createDecorationWidget(decorationPosition, this.type, this.content)]);
211
- }
212
- });
213
- return newDecorations;
214
- }
215
- test(value) {
216
- return this.predicate(value);
217
- }
218
- };
219
-
220
- // src/plugin/invisible-characters/hardBreak.ts
221
- var HardBreakNode = class extends InvisibleNode {
222
- constructor() {
223
- super({
224
- type: "break",
225
- predicate: (node) => node.type === node.type.schema.nodes.hardBreak
226
- });
227
- }
228
- };
229
-
230
- // src/plugin/invisible-characters/paragraph.ts
231
- var ParagraphNode = class extends InvisibleNode {
232
- constructor() {
233
- super({
234
- type: "paragraph",
235
- predicate: (node) => node.type === node.type.schema.nodes.paragraph
236
- });
237
- }
238
- };
239
-
240
- // src/plugin/utils/text-between.ts
241
- var textBetween = (from, to, doc) => {
242
- const positions = [];
243
- doc.nodesBetween(from, to, (node, pos) => {
244
- var _a;
245
- if (node.isText) {
246
- const offset = Math.max(from, pos) - pos;
247
- positions.push({
248
- pos: pos + offset,
249
- text: ((_a = node.text) == null ? void 0 : _a.slice(offset, to - pos)) || ""
250
- });
251
- }
252
- });
253
- return positions;
254
- };
255
-
256
- // src/plugin/InvisibleCharacter.ts
257
- var InvisibleCharacter = class {
258
- constructor(options) {
259
- this.predicate = options.predicate;
260
- this.type = options.type;
261
- this.content = options.content;
262
- this.priority = options.priority || 100;
263
- }
264
- createDecoration(from, to, doc, decorations) {
265
- const textContent = textBetween(from, to, doc);
266
- return textContent.reduce((oldDecorations, currentPosition) => {
267
- return currentPosition.text.split("").reduce((innerDecorations, char, i) => {
268
- return this.test(char) ? innerDecorations.add(doc, [createDecorationWidget(currentPosition.pos + i, this.type, this.content)]) : innerDecorations;
269
- }, oldDecorations);
270
- }, decorations);
271
- }
272
- test(value) {
273
- return this.predicate(value);
274
- }
275
- };
276
-
277
- // src/plugin/invisible-characters/space.ts
278
- var SpaceCharacter = class extends InvisibleCharacter {
279
- constructor() {
280
- super({
281
- type: "space",
282
- predicate: (char) => char === " "
283
- });
284
- }
285
- };
286
-
287
- // src/invisible-characters.ts
288
- var InvisibleCharacters = import_core.Extension.create({
289
- name: "invisibleCharacters",
290
- addOptions() {
291
- return {
292
- visible: true,
293
- builders: [new SpaceCharacter(), new ParagraphNode(), new HardBreakNode()],
294
- injectCSS: true,
295
- injectNonce: void 0
296
- };
297
- },
298
- addProseMirrorPlugins() {
299
- return [InvisibleCharactersPlugin(this.editor.state, this.options)];
300
- },
301
- addStorage() {
302
- return {
303
- visibility: () => this.options.visible
304
- };
305
- },
306
- onBeforeCreate() {
307
- this.storage.visibility = () => {
308
- var _a;
309
- return (_a = InvisibleCharactersPluginKey.getState(this.editor.state)) == null ? void 0 : _a.visible;
310
- };
311
- },
312
- addCommands() {
313
- return {
314
- showInvisibleCharacters: (visibility = true) => ({ dispatch, tr }) => {
315
- if (dispatch) {
316
- tr.setMeta("setInvisibleCharactersVisible", visibility);
317
- }
318
- return true;
319
- },
320
- hideInvisibleCharacters: () => ({ dispatch, tr }) => {
321
- if (dispatch) {
322
- tr.setMeta("setInvisibleCharactersVisible", false);
323
- }
324
- return true;
325
- },
326
- toggleInvisibleCharacters: () => ({ dispatch, tr, state }) => {
327
- var _a;
328
- const visibility = !((_a = InvisibleCharactersPluginKey.getState(state)) == null ? void 0 : _a.visible);
329
- if (dispatch) {
330
- tr.setMeta("setInvisibleCharactersVisible", visibility);
331
- }
332
- return true;
333
- }
334
- };
335
- }
336
- });
337
-
338
- // src/index.ts
339
- var index_default = InvisibleCharacters;
340
- // Annotate the CommonJS export names for ESM import in node:
341
- 0 && (module.exports = {
342
- HardBreakNode,
343
- InvisibleCharacter,
344
- InvisibleCharacters,
345
- InvisibleNode,
346
- ParagraphNode,
347
- SpaceCharacter
348
- });
349
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts","../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"],"sourcesContent":["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","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.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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAA0B;;;ACC1B,mBAAgD;AAChD,kBAA8B;;;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,QAAQ,MAAM,IAAI,CAAC,EAAE,IAAI,QAAQ,G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AI,UAAU;AACZ,aAAG,QAAQ,iCAAiC,UAAU;AAAA,QACxD;AAEA,eAAO;AAAA,MACT;AAAA,MACF,yBACE,MACA,CAAC,EAAE,UAAU,GAAG,MAAM;AACpB,YAAI,UAAU;AACZ,aAAG,QAAQ,iCAAiC,KAAK;AAAA,QACnD;AAEA,eAAO;AAAA,MACT;AAAA,MACF,2BACE,MACA,CAAC,EAAE,UAAU,IAAI,MAAM,MAAM;AAjFrC;AAkFU,cAAM,aAAa,GAAC,kCAA6B,SAAS,KAAK,MAA3C,mBAA8C;AAElE,YAAI,UAAU;AACZ,aAAG,QAAQ,iCAAiC,UAAU;AAAA,QACxD;AAEA,eAAO;AAAA,MACT;AAAA,IACJ;AAAA,EACF;AACF,CAAC;;;ADlFD,IAAO,gBAAQ;","names":["style","import_view"]}
package/dist/index.d.cts DELETED
@@ -1,97 +0,0 @@
1
- import { Extension } from '@tiptap/core';
2
- import { DecorationSet } from '@tiptap/pm/view';
3
- import { Node } from '@tiptap/pm/model';
4
-
5
- interface InvisibleNodeOptions {
6
- content?: string;
7
- position?: (node: Node, pos: number) => number;
8
- predicate: (value: Node) => boolean;
9
- priority?: number;
10
- type: string;
11
- }
12
- declare class InvisibleNode {
13
- predicate: (value: Node) => boolean;
14
- position: (node: Node, pos: number) => number;
15
- content?: string;
16
- type: string;
17
- priority: number;
18
- constructor(options: InvisibleNodeOptions);
19
- createDecoration(from: number, to: number, doc: Node, decorations: DecorationSet): DecorationSet;
20
- test(value: Node): boolean;
21
- }
22
-
23
- declare class HardBreakNode extends InvisibleNode {
24
- constructor();
25
- }
26
-
27
- declare class ParagraphNode extends InvisibleNode {
28
- constructor();
29
- }
30
-
31
- interface InvisibleCharacterOptions {
32
- type: string;
33
- predicate: (value: string) => boolean;
34
- priority?: number;
35
- content?: string;
36
- }
37
- declare class InvisibleCharacter {
38
- predicate: (value: string) => boolean;
39
- content?: string;
40
- type: string;
41
- priority: number;
42
- constructor(options: InvisibleCharacterOptions);
43
- createDecoration(from: number, to: number, doc: Node, decorations: DecorationSet): DecorationSet;
44
- test(value: string): boolean;
45
- }
46
-
47
- declare class SpaceCharacter extends InvisibleCharacter {
48
- constructor();
49
- }
50
-
51
- interface InvisibleCharactersOptions {
52
- visible: boolean;
53
- builders: Array<InvisibleCharacter | InvisibleNode>;
54
- injectCSS: boolean;
55
- injectNonce: string | undefined;
56
- }
57
- interface Position {
58
- pos: number;
59
- text: string;
60
- }
61
- interface PluginState {
62
- visible: boolean;
63
- decorations: DecorationSet;
64
- }
65
- interface InvisibleCharactersStorage {
66
- /**
67
- * Get whether the invisible characters are shown or not
68
- */
69
- visibility: () => boolean;
70
- }
71
- declare module '@tiptap/core' {
72
- interface Storage {
73
- invisibleCharacters: InvisibleCharactersStorage;
74
- }
75
- }
76
-
77
- declare module '@tiptap/core' {
78
- interface Commands<ReturnType> {
79
- invisibleCharacters: {
80
- /**
81
- * Show invisible characters
82
- */
83
- showInvisibleCharacters: (show?: boolean) => ReturnType;
84
- /**
85
- * Hide invisible characters
86
- */
87
- hideInvisibleCharacters: () => ReturnType;
88
- /**
89
- * Toggle invisible characters
90
- */
91
- toggleInvisibleCharacters: () => ReturnType;
92
- };
93
- }
94
- }
95
- declare const InvisibleCharacters: Extension<InvisibleCharactersOptions, any>;
96
-
97
- export { HardBreakNode, InvisibleCharacter, type InvisibleCharacterOptions, InvisibleCharacters, type InvisibleCharactersOptions, type InvisibleCharactersStorage, InvisibleNode, type InvisibleNodeOptions, ParagraphNode, type PluginState, type Position, SpaceCharacter, InvisibleCharacters as default };
package/dist/index.d.ts DELETED
@@ -1,97 +0,0 @@
1
- import { Extension } from '@tiptap/core';
2
- import { DecorationSet } from '@tiptap/pm/view';
3
- import { Node } from '@tiptap/pm/model';
4
-
5
- interface InvisibleNodeOptions {
6
- content?: string;
7
- position?: (node: Node, pos: number) => number;
8
- predicate: (value: Node) => boolean;
9
- priority?: number;
10
- type: string;
11
- }
12
- declare class InvisibleNode {
13
- predicate: (value: Node) => boolean;
14
- position: (node: Node, pos: number) => number;
15
- content?: string;
16
- type: string;
17
- priority: number;
18
- constructor(options: InvisibleNodeOptions);
19
- createDecoration(from: number, to: number, doc: Node, decorations: DecorationSet): DecorationSet;
20
- test(value: Node): boolean;
21
- }
22
-
23
- declare class HardBreakNode extends InvisibleNode {
24
- constructor();
25
- }
26
-
27
- declare class ParagraphNode extends InvisibleNode {
28
- constructor();
29
- }
30
-
31
- interface InvisibleCharacterOptions {
32
- type: string;
33
- predicate: (value: string) => boolean;
34
- priority?: number;
35
- content?: string;
36
- }
37
- declare class InvisibleCharacter {
38
- predicate: (value: string) => boolean;
39
- content?: string;
40
- type: string;
41
- priority: number;
42
- constructor(options: InvisibleCharacterOptions);
43
- createDecoration(from: number, to: number, doc: Node, decorations: DecorationSet): DecorationSet;
44
- test(value: string): boolean;
45
- }
46
-
47
- declare class SpaceCharacter extends InvisibleCharacter {
48
- constructor();
49
- }
50
-
51
- interface InvisibleCharactersOptions {
52
- visible: boolean;
53
- builders: Array<InvisibleCharacter | InvisibleNode>;
54
- injectCSS: boolean;
55
- injectNonce: string | undefined;
56
- }
57
- interface Position {
58
- pos: number;
59
- text: string;
60
- }
61
- interface PluginState {
62
- visible: boolean;
63
- decorations: DecorationSet;
64
- }
65
- interface InvisibleCharactersStorage {
66
- /**
67
- * Get whether the invisible characters are shown or not
68
- */
69
- visibility: () => boolean;
70
- }
71
- declare module '@tiptap/core' {
72
- interface Storage {
73
- invisibleCharacters: InvisibleCharactersStorage;
74
- }
75
- }
76
-
77
- declare module '@tiptap/core' {
78
- interface Commands<ReturnType> {
79
- invisibleCharacters: {
80
- /**
81
- * Show invisible characters
82
- */
83
- showInvisibleCharacters: (show?: boolean) => ReturnType;
84
- /**
85
- * Hide invisible characters
86
- */
87
- hideInvisibleCharacters: () => ReturnType;
88
- /**
89
- * Toggle invisible characters
90
- */
91
- toggleInvisibleCharacters: () => ReturnType;
92
- };
93
- }
94
- }
95
- declare const InvisibleCharacters: Extension<InvisibleCharactersOptions, any>;
96
-
97
- export { HardBreakNode, InvisibleCharacter, type InvisibleCharacterOptions, InvisibleCharacters, type InvisibleCharactersOptions, type InvisibleCharactersStorage, InvisibleNode, type InvisibleNodeOptions, ParagraphNode, type PluginState, type Position, SpaceCharacter, InvisibleCharacters as default };
package/dist/index.js DELETED
@@ -1,317 +0,0 @@
1
- // src/invisible-characters.ts
2
- import { Extension } from "@tiptap/core";
3
-
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 };
14
- };
15
-
16
- // src/plugin/style.ts
17
- var style = `.tiptap-invisible-character {
18
- height: 0;
19
- padding: 0;
20
- pointer-events: none;
21
- user-select: none;
22
- width: 0;
23
- }
24
-
25
- .tiptap-invisible-character::before {
26
- caret-color: inherit;
27
- color: #aaa;
28
- display: inline-block;
29
- font-style: normal;
30
- font-weight: 400;
31
- line-height: 1em;
32
- width: 0;
33
- }
34
-
35
- .tiptap-invisible-character--space::before {
36
- content: '\xB7'
37
- }
38
-
39
- .tiptap-invisible-character--break::before {
40
- content: '\xAC'
41
- }
42
-
43
- .tiptap-invisible-character--paragraph::before {
44
- content: '\xB6'
45
- }
46
-
47
- .tiptap-invisible-character + img.ProseMirror-separator {
48
- height: 0 !important;
49
- pointer-events: none;
50
- user-select: none;
51
- width: 0 !important;
52
- }
53
-
54
- .is-empty[data-placeholder].has-focus > .tiptap-invisible-character {
55
- display: none;
56
- }
57
- `;
58
-
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
- }
135
- }
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;
148
- }
149
- return newElement;
150
- };
151
- return Decoration.widget(pos, createElement, {
152
- key: type,
153
- marks: [],
154
- side: 1e3
155
- });
156
- };
157
-
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
- }
180
- });
181
- return newDecorations;
182
- }
183
- test(value) {
184
- return this.predicate(value);
185
- }
186
- };
187
-
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
194
- });
195
- }
196
- };
197
-
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
204
- });
205
- }
206
- };
207
-
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
- });
219
- }
220
- });
221
- return positions;
222
- };
223
-
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
- };
244
-
245
- // src/plugin/invisible-characters/space.ts
246
- var SpaceCharacter = class extends InvisibleCharacter {
247
- constructor() {
248
- super({
249
- type: "space",
250
- predicate: (char) => char === " "
251
- });
252
- }
253
- };
254
-
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
- }
304
- });
305
-
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 DELETED
@@ -1 +0,0 @@
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.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;AACh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