@knapsack/tiptap-utils 4.100.0 → 4.100.1--canary.7985.eb739a3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,297 +0,0 @@
1
- /**
2
- * A doc tiptap can always render, used only when the root node's own `type`
3
- * is unrecognized and nothing was preserved from it (mode `'salvage'` found
4
- * no text) - there's no parent to drop it from, so this is the one case
5
- * where some emptying can be unavoidable. Every other unrecognized
6
- * node/mark is handled in place, keeping all valid siblings intact.
7
- *
8
- * Handed out by reference to every caller hitting this fallback - frozen
9
- * for the same reason `findUnrecognizedTypesCached` freezes its cached
10
- * arrays (see doctor's detect-unrecognized-tiptap-content.ts): an
11
- * accidental downstream mutation must fail loudly instead of silently
12
- * corrupting this shared instance for every other block that reaches it.
13
- */
14
- const EMPTY_DOC = Object.freeze({
15
- type: 'doc',
16
- content: [{ type: 'paragraph' }],
17
- });
18
- /**
19
- * Node types whose `content` is inline (text runs), not block content - an
20
- * unrecognized child here is replaced with an inline node. Everywhere else
21
- * (doc, blockquote, list items, table cells, ...) a replacement needs its
22
- * own block-level node, since an inline node isn't valid block content.
23
- */
24
- const INLINE_CONTAINER_TYPES = new Set([
25
- 'paragraph',
26
- 'heading',
27
- ]);
28
- const PLACEHOLDER_TYPES = new Set([
29
- 'unrecognizedContentPlaceholder',
30
- 'unrecognizedContentPlaceholderBlock',
31
- ]);
32
- /** See `UnrecognizedContentPlaceholderRoot`'s doc comment for why this is kept distinct from `PLACEHOLDER_TYPES`. */
33
- const ROOT_PLACEHOLDER_TYPE = 'unrecognizedContentPlaceholderRoot';
34
- /**
35
- * A placeholder's `original` attr is plain HTML-attribute text, editable by
36
- * anyone who can paste HTML into the editor (tiptap's `parseHTML` accepts
37
- * it from clipboard content, not just content this module itself wrote) -
38
- * treat it as untrusted input, not a value only this module ever produces.
39
- * A generous cap on genuine concealed content, but bounds how much an
40
- * unrelated forged attribute can bloat storage.
41
- */
42
- const MAX_ORIGINAL_JSON_LENGTH = 100_000;
43
- /**
44
- * Parses `original`, returning `undefined` for anything malformed, oversized,
45
- * or absent - never throws. `undefined` is unambiguous as a "parse failed"
46
- * sentinel because a placeholder's `original` is always itself valid JSON
47
- * (an object or array), never the JSON value `undefined`.
48
- */
49
- function parseOriginal(raw) {
50
- if (!raw || raw.length > MAX_ORIGINAL_JSON_LENGTH)
51
- return undefined;
52
- try {
53
- return JSON.parse(raw);
54
- }
55
- catch {
56
- return undefined;
57
- }
58
- }
59
- /**
60
- * The minimum shape `restoreConcealedContent` trusts enough to splice back
61
- * in - anything else is left as the inert, non-rendering placeholder
62
- * rather than guessed at. Checks the *whole* nested tree (every
63
- * `content`/`marks` entry, at every depth), not just the top node - a
64
- * forged `original` attr can be well-formed JSON with a valid-looking
65
- * `type` at the root while carrying garbage (a string instead of an array,
66
- * a number where a mark belongs) underneath, which would otherwise splice
67
- * structurally-invalid JSONContent into the persisted document. This
68
- * intentionally does NOT check that `type` names are recognized - a
69
- * genuinely concealed node's `type` is unrecognized by definition, and
70
- * restoring it is this function's entire purpose.
71
- */
72
- function isPlausibleJSONContent(value) {
73
- if (typeof value !== 'object' || value === null || Array.isArray(value)) {
74
- return false;
75
- }
76
- const { type, content, marks } = value;
77
- if (typeof type !== 'string')
78
- return false;
79
- if (content !== undefined) {
80
- if (!Array.isArray(content) || !content.every(isPlausibleJSONContent)) {
81
- return false;
82
- }
83
- }
84
- if (marks !== undefined) {
85
- if (!Array.isArray(marks) ||
86
- !marks.every((mark) => typeof mark === 'object' &&
87
- mark !== null &&
88
- typeof mark.type === 'string')) {
89
- return false;
90
- }
91
- }
92
- return true;
93
- }
94
- function extractPlainText(node) {
95
- if (node.type === 'text')
96
- return node.text ?? '';
97
- return (node.content ?? []).map(extractPlainText).join('');
98
- }
99
- function isInlineContext(parentType) {
100
- return !!parentType && INLINE_CONTAINER_TYPES.has(parentType);
101
- }
102
- /**
103
- * The stand-in for an unrecognized node, wrapped to be valid in its
104
- * parent's content model. In `'salvage'` mode this is the unstyled
105
- * plain-text content wrapped in an `unsupportedFormatting` node (null - the
106
- * node is dropped entirely - when there's no text to show). In `'conceal'`
107
- * mode this is always an invisible placeholder carrying the original node
108
- * losslessly, regardless of whether it has text.
109
- */
110
- function buildReplacement(node, parentType, mode) {
111
- const inline = isInlineContext(parentType);
112
- if (mode === 'conceal') {
113
- return {
114
- type: inline
115
- ? 'unrecognizedContentPlaceholder'
116
- : 'unrecognizedContentPlaceholderBlock',
117
- attrs: { original: JSON.stringify([node]) },
118
- };
119
- }
120
- const text = extractPlainText(node);
121
- if (!text)
122
- return null;
123
- const notice = {
124
- type: 'unsupportedFormatting',
125
- content: [{ type: 'text', text }],
126
- };
127
- return inline ? notice : { type: 'paragraph', content: [notice] };
128
- }
129
- function collectUnrecognizedTypes(node, recognizedTypeNames, found) {
130
- if (node.type && !recognizedTypeNames.has(node.type)) {
131
- found.add(node.type);
132
- }
133
- node.marks?.forEach((mark) => {
134
- if (!recognizedTypeNames.has(mark.type)) {
135
- found.add(mark.type);
136
- }
137
- });
138
- node.content?.forEach((child) => collectUnrecognizedTypes(child, recognizedTypeNames, found));
139
- }
140
- /**
141
- * Walks a JSONContent tree (node.type, node.marks[].type at every level,
142
- * including nested `content` arrays) and returns the deduped list of type
143
- * names not present in `recognizedTypeNames`. Never calls
144
- * `schema.nodeFromJSON`/`createNodeFromContent` - cannot trigger tiptap's
145
- * destructive "empty the whole doc" fallback.
146
- */
147
- export function findUnrecognizedTiptapTypes(content, recognizedTypeNames) {
148
- if (!content)
149
- return [];
150
- const found = new Set();
151
- collectUnrecognizedTypes(content, recognizedTypeNames, found);
152
- return [...found];
153
- }
154
- function cleanNode(node, recognizedTypeNames, removed, mode) {
155
- const cleaned = { ...node };
156
- if (node.marks) {
157
- const hasUnrecognizedMark = node.marks.some((mark) => !recognizedTypeNames.has(mark.type));
158
- // Conceal mode's guarantee is lossless until an admin explicitly fixes
159
- // it - dropping an unrecognized mark from `node.marks` below would
160
- // permanently destroy it on a non-admin's save. Instead conceal the
161
- // whole node (marks and all) behind the same placeholder mechanism
162
- // used for unrecognized node types - always the inline placeholder,
163
- // since marks only ever apply to inline/text nodes.
164
- if (hasUnrecognizedMark && mode === 'conceal') {
165
- node.marks.forEach((mark) => {
166
- if (!recognizedTypeNames.has(mark.type))
167
- removed.add(mark.type);
168
- });
169
- return {
170
- type: 'unrecognizedContentPlaceholder',
171
- attrs: { original: JSON.stringify([node]) },
172
- };
173
- }
174
- const keptMarks = node.marks.filter((mark) => {
175
- const isRecognized = recognizedTypeNames.has(mark.type);
176
- if (!isRecognized)
177
- removed.add(mark.type);
178
- return isRecognized;
179
- });
180
- if (keptMarks.length > 0) {
181
- cleaned.marks = keptMarks;
182
- }
183
- else {
184
- delete cleaned.marks;
185
- }
186
- }
187
- if (node.content) {
188
- cleaned.content = node.content.flatMap((child) => {
189
- const isRecognized = !child.type || recognizedTypeNames.has(child.type);
190
- if (isRecognized) {
191
- return [cleanNode(child, recognizedTypeNames, removed, mode)];
192
- }
193
- removed.add(child.type);
194
- const replacement = buildReplacement(child, node.type, mode);
195
- return replacement ? [replacement] : [];
196
- });
197
- }
198
- return cleaned;
199
- }
200
- /**
201
- * Returns a new tree with the unrecognized nodes/marks handled per `mode`
202
- * (see `UnrecognizedContentMode`) - every recognized sibling/ancestor is
203
- * left untouched. Unrecognized marks are mode-dependent, like unrecognized
204
- * nodes: `'salvage'` drops the mark from the node's `marks` array, leaving
205
- * the text unstyled and visibly rendering; `'conceal'` preserves the mark
206
- * losslessly by concealing the whole marked node behind the same
207
- * placeholder mechanism used for unrecognized node types, since dropping
208
- * it would otherwise permanently destroy data conceal mode guarantees
209
- * survives until an admin explicitly acts. Only if the root node's own
210
- * `type` is unrecognized and nothing was preserved (salvage mode with no
211
- * text) does this fall back to an empty doc, since there's no parent to
212
- * replace it in place - reported via `removedTypes` either way, never
213
- * silent to the caller.
214
- */
215
- export function stripUnrecognizedTiptapContent(content, recognizedTypeNames, { mode = 'salvage' } = {}) {
216
- if (!content)
217
- return { content, removedTypes: [] };
218
- if (content.type && !recognizedTypeNames.has(content.type)) {
219
- if (mode === 'conceal') {
220
- return {
221
- content: {
222
- type: 'doc',
223
- content: [
224
- {
225
- type: ROOT_PLACEHOLDER_TYPE,
226
- // The whole original root node (its own type/attrs included,
227
- // not just its children) - `restoreConcealedContent` returns
228
- // this verbatim in place of the synthetic wrapping `doc`.
229
- attrs: { original: JSON.stringify(content) },
230
- },
231
- ],
232
- },
233
- removedTypes: [content.type],
234
- };
235
- }
236
- const text = extractPlainText(content);
237
- return {
238
- content: text
239
- ? {
240
- type: 'doc',
241
- content: [
242
- {
243
- type: 'paragraph',
244
- content: [
245
- {
246
- type: 'unsupportedFormatting',
247
- content: [{ type: 'text', text }],
248
- },
249
- ],
250
- },
251
- ],
252
- }
253
- : EMPTY_DOC,
254
- removedTypes: [content.type],
255
- };
256
- }
257
- const removed = new Set();
258
- const cleaned = cleanNode(content, recognizedTypeNames, removed, mode);
259
- return { content: cleaned, removedTypes: [...removed] };
260
- }
261
- export function restoreConcealedContent(content) {
262
- if (!content?.content)
263
- return content;
264
- // The whole document was concealed (the root's own type was
265
- // unrecognized) - restore the original root node itself instead of
266
- // leaving it nested inside a synthetic `doc` it never actually had.
267
- const [onlyChild] = content.content;
268
- if (content.type === 'doc' &&
269
- content.content.length === 1 &&
270
- onlyChild.type === ROOT_PLACEHOLDER_TYPE) {
271
- const restored = parseOriginal(onlyChild.attrs?.original);
272
- return isPlausibleJSONContent(restored) ? restored : content;
273
- }
274
- return {
275
- ...content,
276
- content: content.content.flatMap((child) => {
277
- if (child.type && PLACEHOLDER_TYPES.has(child.type)) {
278
- const restored = parseOriginal(child.attrs?.original);
279
- return Array.isArray(restored) && restored.every(isPlausibleJSONContent)
280
- ? restored
281
- : [child];
282
- }
283
- // A root placeholder that's no longer the doc's sole child (a sibling
284
- // was added before save) misses the fast path above. Splice the
285
- // original root node back in anyway - its type is still unrecognized,
286
- // so the next load re-conceals it and detection keeps reporting it,
287
- // rather than letting the raw (now-"recognized") placeholder type
288
- // persist to storage unnoticed.
289
- if (child.type === ROOT_PLACEHOLDER_TYPE) {
290
- const restored = parseOriginal(child.attrs?.original);
291
- return isPlausibleJSONContent(restored) ? [restored] : [child];
292
- }
293
- return [restoreConcealedContent(child)];
294
- }),
295
- };
296
- }
297
- //# sourceMappingURL=find-unrecognized-content.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find-unrecognized-content.js","sourceRoot":"","sources":["../src/find-unrecognized-content.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,SAAS,GAAgB,MAAM,CAAC,MAAM,CAAC;IAC3C,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;CACjC,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAC;IAC1D,WAAW;IACX,SAAS;CACV,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC;IACrD,gCAAgC;IAChC,qCAAqC;CACtC,CAAC,CAAC;AAEH,qHAAqH;AACrH,MAAM,qBAAqB,GAAG,oCAAoC,CAAC;AAEnE;;;;;;;GAOG;AACH,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAEzC;;;;;GAKG;AACH,SAAS,aAAa,CAAC,GAAuB;IAC5C,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,wBAAwB;QAAE,OAAO,SAAS,CAAC;IACpE,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAS,sBAAsB,CAAC,KAAc;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAA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C,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;gBACtD,OAAO,sBAAsB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YACjE,CAAC;YACD,OAAO,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1C,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -1,16 +0,0 @@
1
- import { Node } from '@tiptap/core';
2
- export declare const UnrecognizedContentPlaceholder: Node<any, any>;
3
- export declare const UnrecognizedContentPlaceholderBlock: Node<any, any>;
4
- /**
5
- * Distinct from `UnrecognizedContentPlaceholderBlock` even though it's
6
- * schema-identical - this one is only ever the sole child of the
7
- * synthetic wrapping `doc` `stripUnrecognizedTiptapContent` builds when
8
- * the ROOT node's own type is unrecognized (there's no real parent to
9
- * hold a child placeholder in that case). The distinct name lets
10
- * `restoreConcealedContent` tell "the whole document was concealed" apart
11
- * from "one ordinary child among others was concealed" and restore the
12
- * original root type itself, rather than leaving it wrapped in a `doc` it
13
- * never actually had.
14
- */
15
- export declare const UnrecognizedContentPlaceholderRoot: Node<any, any>;
16
- //# sourceMappingURL=unrecognized-content-placeholder-node.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unrecognized-content-placeholder-node.d.ts","sourceRoot":"","sources":["../src/unrecognized-content-placeholder-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AAoBrD,eAAO,MAAM,8BAA8B,gBAoBzC,CAAC;AAEH,eAAO,MAAM,mCAAmC,gBAmB9C,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kCAAkC,gBAmB7C,CAAC"}
@@ -1,88 +0,0 @@
1
- import { Node, mergeAttributes } from '@tiptap/core';
2
- /**
3
- * `stripUnrecognizedTiptapContent`'s `mode: 'conceal'` (see
4
- * `find-unrecognized-content.ts`) substitutes one of these for an
5
- * unrecognized node - never a bare `text`/`unsupportedFormatting` node, so
6
- * nothing about the removed content renders. The original node's exact
7
- * JSON is round-tripped through the `original` attr (as a JSON string, so
8
- * its own possibly-unrecognized nested types never reach the schema) and
9
- * spliced back in verbatim by `restoreConcealedContent` before a save is
10
- * persisted - so an edit elsewhere in the same document never destroys it.
11
- * `selectable: false` keeps it out of normal selection; nothing renders so
12
- * there's nothing to click on regardless.
13
- */
14
- function addOriginalAttribute() {
15
- return {
16
- original: { default: '[]' },
17
- };
18
- }
19
- export const UnrecognizedContentPlaceholder = Node.create({
20
- name: 'unrecognizedContentPlaceholder',
21
- group: 'inline',
22
- inline: true,
23
- atom: true,
24
- selectable: false,
25
- addAttributes: addOriginalAttribute,
26
- parseHTML() {
27
- return [{ tag: 'span[data-unrecognized-content-placeholder]' }];
28
- },
29
- renderHTML({ HTMLAttributes }) {
30
- return [
31
- 'span',
32
- mergeAttributes(HTMLAttributes, {
33
- 'data-unrecognized-content-placeholder': '',
34
- style: 'display:none',
35
- }),
36
- ];
37
- },
38
- });
39
- export const UnrecognizedContentPlaceholderBlock = Node.create({
40
- name: 'unrecognizedContentPlaceholderBlock',
41
- group: 'block',
42
- atom: true,
43
- selectable: false,
44
- addAttributes: addOriginalAttribute,
45
- parseHTML() {
46
- return [{ tag: 'div[data-unrecognized-content-placeholder-block]' }];
47
- },
48
- renderHTML({ HTMLAttributes }) {
49
- return [
50
- 'div',
51
- mergeAttributes(HTMLAttributes, {
52
- 'data-unrecognized-content-placeholder-block': '',
53
- style: 'display:none',
54
- }),
55
- ];
56
- },
57
- });
58
- /**
59
- * Distinct from `UnrecognizedContentPlaceholderBlock` even though it's
60
- * schema-identical - this one is only ever the sole child of the
61
- * synthetic wrapping `doc` `stripUnrecognizedTiptapContent` builds when
62
- * the ROOT node's own type is unrecognized (there's no real parent to
63
- * hold a child placeholder in that case). The distinct name lets
64
- * `restoreConcealedContent` tell "the whole document was concealed" apart
65
- * from "one ordinary child among others was concealed" and restore the
66
- * original root type itself, rather than leaving it wrapped in a `doc` it
67
- * never actually had.
68
- */
69
- export const UnrecognizedContentPlaceholderRoot = Node.create({
70
- name: 'unrecognizedContentPlaceholderRoot',
71
- group: 'block',
72
- atom: true,
73
- selectable: false,
74
- addAttributes: addOriginalAttribute,
75
- parseHTML() {
76
- return [{ tag: 'div[data-unrecognized-content-placeholder-root]' }];
77
- },
78
- renderHTML({ HTMLAttributes }) {
79
- return [
80
- 'div',
81
- mergeAttributes(HTMLAttributes, {
82
- 'data-unrecognized-content-placeholder-root': '',
83
- style: 'display:none',
84
- }),
85
- ];
86
- },
87
- });
88
- //# sourceMappingURL=unrecognized-content-placeholder-node.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unrecognized-content-placeholder-node.js","sourceRoot":"","sources":["../src/unrecognized-content-placeholder-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAErD;;;;;;;;;;;GAWG;AACH,SAAS,oBAAoB;IAC3B,OAAO;QACL,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;KAC5B,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,CAAC,MAAM,CAAC;IACxD,IAAI,EAAE,gCAAgC;IACtC,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,IAAI;IACV,UAAU,EAAE,KAAK;IACjB,aAAa,EAAE,oBAAoB;IAEnC,SAAS;QACP,OAAO,CAAC,EAAE,GAAG,EAAE,6CAA6C,EAAE,CAAC,CAAC;IAClE,CAAC;IACD,UAAU,CAAC,EAAE,cAAc,EAAE;QAC3B,OAAO;YACL,MAAM;YACN,eAAe,CAAC,cAAc,EAAE;gBAC9B,uCAAuC,EAAE,EAAE;gBAC3C,KAAK,EAAE,cAAc;aACtB,CAAC;SACH,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mCAAmC,GAAG,IAAI,CAAC,MAAM,CAAC;IAC7D,IAAI,EAAE,qCAAqC;IAC3C,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,IAAI;IACV,UAAU,EAAE,KAAK;IACjB,aAAa,EAAE,oBAAoB;IAEnC,SAAS;QACP,OAAO,CAAC,EAAE,GAAG,EAAE,kDAAkD,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,UAAU,CAAC,EAAE,cAAc,EAAE;QAC3B,OAAO;YACL,KAAK;YACL,eAAe,CAAC,cAAc,EAAE;gBAC9B,6CAA6C,EAAE,EAAE;gBACjD,KAAK,EAAE,cAAc;aACtB,CAAC;SACH,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5D,IAAI,EAAE,oCAAoC;IAC1C,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,IAAI;IACV,UAAU,EAAE,KAAK;IACjB,aAAa,EAAE,oBAAoB;IAEnC,SAAS;QACP,OAAO,CAAC,EAAE,GAAG,EAAE,iDAAiD,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,UAAU,CAAC,EAAE,cAAc,EAAE;QAC3B,OAAO;YACL,KAAK;YACL,eAAe,CAAC,cAAc,EAAE;gBAC9B,4CAA4C,EAAE,EAAE;gBAChD,KAAK,EAAE,cAAc;aACtB,CAAC;SACH,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -1,10 +0,0 @@
1
- import { Node } from '@tiptap/core';
2
- /**
3
- * Marks the plain-text stand-in `stripUnrecognizedTiptapContent` (see
4
- * `find-unrecognized-content.ts`) substitutes for a node/mark type the
5
- * editor doesn't recognize. Schema-only here (no rendering) - the live
6
- * editor extends this with a NodeView that shows a warning badge next to
7
- * the text (`apps/ui/app-ui/src/components/text-editor/unsupported-formatting.node.tsx`).
8
- */
9
- export declare const UnsupportedFormatting: Node<any, any>;
10
- //# sourceMappingURL=unsupported-formatting-node.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unsupported-formatting-node.d.ts","sourceRoot":"","sources":["../src/unsupported-formatting-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AAErD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,gBAiBhC,CAAC"}
@@ -1,26 +0,0 @@
1
- import { Node, mergeAttributes } from '@tiptap/core';
2
- /**
3
- * Marks the plain-text stand-in `stripUnrecognizedTiptapContent` (see
4
- * `find-unrecognized-content.ts`) substitutes for a node/mark type the
5
- * editor doesn't recognize. Schema-only here (no rendering) - the live
6
- * editor extends this with a NodeView that shows a warning badge next to
7
- * the text (`apps/ui/app-ui/src/components/text-editor/unsupported-formatting.node.tsx`).
8
- */
9
- export const UnsupportedFormatting = Node.create({
10
- name: 'unsupportedFormatting',
11
- group: 'inline',
12
- inline: true,
13
- content: 'text*',
14
- selectable: true,
15
- parseHTML() {
16
- return [{ tag: 'span[data-unsupported-formatting]' }];
17
- },
18
- renderHTML({ HTMLAttributes }) {
19
- return [
20
- 'span',
21
- mergeAttributes(HTMLAttributes, { 'data-unsupported-formatting': '' }),
22
- 0,
23
- ];
24
- },
25
- });
26
- //# sourceMappingURL=unsupported-formatting-node.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unsupported-formatting-node.js","sourceRoot":"","sources":["../src/unsupported-formatting-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC/C,IAAI,EAAE,uBAAuB;IAC7B,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE,IAAI;IAEhB,SAAS;QACP,OAAO,CAAC,EAAE,GAAG,EAAE,mCAAmC,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,UAAU,CAAC,EAAE,cAAc,EAAE;QAC3B,OAAO;YACL,MAAM;YACN,eAAe,CAAC,cAAc,EAAE,EAAE,6BAA6B,EAAE,EAAE,EAAE,CAAC;YACtE,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}