@folijs/core 0.2.0 → 0.3.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.
Files changed (115) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +1 -1
  3. package/dist/document.d.ts +10 -16
  4. package/dist/document.d.ts.map +1 -1
  5. package/dist/document.js +22 -22
  6. package/dist/document.js.map +1 -1
  7. package/dist/index.d.ts +3 -2
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +3 -2
  10. package/dist/index.js.map +1 -1
  11. package/dist/model/fragment.d.ts +5 -2
  12. package/dist/model/fragment.d.ts.map +1 -1
  13. package/dist/model/fragment.js +5 -2
  14. package/dist/model/fragment.js.map +1 -1
  15. package/dist/model/node.d.ts +1 -1
  16. package/dist/model/node.d.ts.map +1 -1
  17. package/dist/model/node.js.map +1 -1
  18. package/dist/schema.d.ts +10 -1
  19. package/dist/schema.d.ts.map +1 -1
  20. package/dist/schema.js +11 -1
  21. package/dist/schema.js.map +1 -1
  22. package/dist/state/commands.d.ts +7 -6
  23. package/dist/state/commands.d.ts.map +1 -1
  24. package/dist/state/commands.js +134 -97
  25. package/dist/state/commands.js.map +1 -1
  26. package/dist/state/editor.d.ts +25 -15
  27. package/dist/state/editor.d.ts.map +1 -1
  28. package/dist/state/editor.js +44 -16
  29. package/dist/state/editor.js.map +1 -1
  30. package/dist/state/format.d.ts +8 -22
  31. package/dist/state/format.d.ts.map +1 -1
  32. package/dist/state/format.js +16 -140
  33. package/dist/state/format.js.map +1 -1
  34. package/dist/state/index.d.ts +8 -4
  35. package/dist/state/index.d.ts.map +1 -1
  36. package/dist/state/index.js +8 -4
  37. package/dist/state/index.js.map +1 -1
  38. package/dist/state/links.d.ts.map +1 -1
  39. package/dist/state/links.js +10 -2
  40. package/dist/state/links.js.map +1 -1
  41. package/dist/state/lists.d.ts +19 -32
  42. package/dist/state/lists.d.ts.map +1 -1
  43. package/dist/state/lists.js +23 -372
  44. package/dist/state/lists.js.map +1 -1
  45. package/dist/state/mark.d.ts +25 -0
  46. package/dist/state/mark.d.ts.map +1 -0
  47. package/dist/state/mark.js +40 -0
  48. package/dist/state/mark.js.map +1 -0
  49. package/dist/state/state.d.ts.map +1 -1
  50. package/dist/state/state.js +11 -0
  51. package/dist/state/state.js.map +1 -1
  52. package/dist/state/word.d.ts +72 -0
  53. package/dist/state/word.d.ts.map +1 -0
  54. package/dist/state/word.js +173 -0
  55. package/dist/state/word.js.map +1 -0
  56. package/dist/state/wordclip.d.ts +43 -0
  57. package/dist/state/wordclip.d.ts.map +1 -0
  58. package/dist/state/wordclip.js +412 -0
  59. package/dist/state/wordclip.js.map +1 -0
  60. package/dist/state/wordformat.d.ts +136 -0
  61. package/dist/state/wordformat.d.ts.map +1 -0
  62. package/dist/state/wordformat.js +846 -0
  63. package/dist/state/wordformat.js.map +1 -0
  64. package/dist/v3/check.d.ts +33 -0
  65. package/dist/v3/check.d.ts.map +1 -0
  66. package/dist/v3/check.js +90 -0
  67. package/dist/v3/check.js.map +1 -0
  68. package/dist/v3/document.d.ts +217 -0
  69. package/dist/v3/document.d.ts.map +1 -0
  70. package/dist/v3/document.js +225 -0
  71. package/dist/v3/document.js.map +1 -0
  72. package/dist/v3/index.d.ts +6 -0
  73. package/dist/v3/index.d.ts.map +1 -0
  74. package/dist/v3/index.js +6 -0
  75. package/dist/v3/index.js.map +1 -0
  76. package/dist/v3/migrate.d.ts +19 -0
  77. package/dist/v3/migrate.d.ts.map +1 -0
  78. package/dist/v3/migrate.js +227 -0
  79. package/dist/v3/migrate.js.map +1 -0
  80. package/dist/v3/resolve.d.ts +129 -0
  81. package/dist/v3/resolve.d.ts.map +1 -0
  82. package/dist/v3/resolve.js +534 -0
  83. package/dist/v3/resolve.js.map +1 -0
  84. package/dist/v3/schema.d.ts +27 -0
  85. package/dist/v3/schema.d.ts.map +1 -0
  86. package/dist/v3/schema.js +429 -0
  87. package/dist/v3/schema.js.map +1 -0
  88. package/dist/v3/units.d.ts +16 -0
  89. package/dist/v3/units.d.ts.map +1 -0
  90. package/dist/v3/units.js +28 -0
  91. package/dist/v3/units.js.map +1 -0
  92. package/package.json +1 -1
  93. package/src/document.ts +26 -26
  94. package/src/index.ts +3 -6
  95. package/src/model/fragment.ts +11 -3
  96. package/src/model/node.ts +6 -1
  97. package/src/schema.ts +13 -1
  98. package/src/state/commands.ts +147 -91
  99. package/src/state/editor.ts +81 -35
  100. package/src/state/format.ts +24 -122
  101. package/src/state/index.ts +34 -3
  102. package/src/state/links.ts +10 -2
  103. package/src/state/lists.ts +31 -408
  104. package/src/state/mark.ts +47 -0
  105. package/src/state/state.ts +11 -0
  106. package/src/state/word.ts +245 -0
  107. package/src/state/wordclip.ts +445 -0
  108. package/src/state/wordformat.ts +982 -0
  109. package/src/v3/check.ts +119 -0
  110. package/src/v3/document.ts +456 -0
  111. package/src/v3/index.ts +33 -0
  112. package/src/v3/migrate.ts +267 -0
  113. package/src/v3/resolve.ts +646 -0
  114. package/src/v3/schema.ts +479 -0
  115. package/src/v3/units.ts +34 -0
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Editing a schema v3 document as Word edits it (8.7). An editor holding a v3 document keeps
3
+ * the document's envelope (styles, numbering, defaults, theme) in a plugin state field, and the
4
+ * generic commands consult it: Enter splits a paragraph as Word does, the bold, italic,
5
+ * underline and strike toggles act on the formatting text shows (a heading's style bold
6
+ * included), and Backspace and Delete step over the invisible markers (bookmarks, comment
7
+ * ranges) and select opaque content before deleting it.
8
+ *
9
+ * shortcut: v2 and v3 editing live side by side until 8.7d makes v3 the only schema; then these
10
+ * become the commands themselves.
11
+ */
12
+ import type { Attrs, Mark, MarkType, Node } from "../model/index.js";
13
+ import type { FoliDocument } from "../v3/document.js";
14
+ import { Resolver } from "../v3/resolve.js";
15
+ import { NodeSelection, TextSelection } from "./selection.js";
16
+ import { type EditorState, Plugin, type Transaction } from "./state.js";
17
+ /** A v3 document without its content: what the editor keeps beside the edited tree. */
18
+ export type WordEnvelope = Omit<FoliDocument, "content">;
19
+ export interface WordContext {
20
+ readonly envelope: WordEnvelope;
21
+ readonly resolver: Resolver;
22
+ /**
23
+ * Made when the document is loaded and kept while it is edited: a copy carries it, so a paste
24
+ * tells this document's lists from another's (Word's `w:nsid`; Foli makes equal definitions
25
+ * in every document).
26
+ */
27
+ readonly id: string;
28
+ }
29
+ /**
30
+ * The plugin that gives commands a v3 document's envelope. A transaction changes it with
31
+ * `withEnvelope` (a new list's numbering definition); undo leaves such additions, as Word does.
32
+ */
33
+ export declare function wordPlugin(envelope: WordEnvelope): Plugin<WordContext>;
34
+ /** Makes `tr` change the document's envelope to `envelope` (styles, numbering…). */
35
+ export declare function withEnvelope(tr: Transaction, envelope: WordEnvelope): Transaction;
36
+ /** The envelope and resolver of the v3 document in `state`, or null for a v2 editor. */
37
+ export declare function wordContext(state: EditorState): WordContext | null;
38
+ /**
39
+ * The attributes of the two paragraphs Enter makes of `paragraph`. The first gets a new mark
40
+ * with the same properties; the second keeps the original mark. At the end of a paragraph whose
41
+ * style names another as the next (a heading: Normal), the second paragraph is in that style,
42
+ * without the first's direct formatting. `before` is null when the first keeps every attribute.
43
+ */
44
+ export declare function splitAttrs(context: WordContext, paragraph: Node, atEnd: boolean): {
45
+ before: Attrs | null;
46
+ after: Attrs;
47
+ };
48
+ /** Whether `type` is a run property the toggles handle on a v3 document. */
49
+ export declare function isWordToggle(context: WordContext | null, type: MarkType): boolean;
50
+ /** Whether all the selected text (or the text typed at a caret) shows the toggle `type`. */
51
+ export declare function wordToggleActive(context: WordContext, state: EditorState, type: MarkType, caretMarks: readonly Mark[] | null): boolean;
52
+ /**
53
+ * The stored marks for a toggle at a caret: what makes the next typed text show the opposite of
54
+ * what text typed there would show now.
55
+ */
56
+ export declare function toggledCaretMarks(context: WordContext, paragraph: Node, marks: readonly Mark[], type: MarkType): readonly Mark[];
57
+ /**
58
+ * The mark changes that make every inline node in `from..to` show the toggle `type` as `on`:
59
+ * per node, a direct mark where its style does not already give that, none where it does.
60
+ */
61
+ export declare function toggleRanges(context: WordContext, state: EditorState, from: number, to: number, type: MarkType, on: boolean): {
62
+ from: number;
63
+ to: number;
64
+ mark: Mark | null;
65
+ }[];
66
+ /** Whether `node` is an invisible marker of a v3 document. */
67
+ export declare function isMarker(context: WordContext | null, node: Node | null | undefined): boolean;
68
+ /** Opaque content: deleted only once selected, as Word selects a field before deleting it. */
69
+ export declare function isOpaque(context: WordContext | null, node: Node | null | undefined): boolean;
70
+ /** A node selection of the node at `pos`, or a text selection when it cannot be selected. */
71
+ export declare function selectionAt(state: EditorState, pos: number): NodeSelection | TextSelection;
72
+ //# sourceMappingURL=word.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"word.d.ts","sourceRoot":"","sources":["../../src/state/word.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAkB,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,EAAa,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAEnF,uFAAuF;AACvF,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAEzD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAID;;;GAGG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CActE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AAI,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAE5F;AAED,8FAA8F;AAC9F,wBAAgB,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAM5F;AAED,6FAA6F;AAC7F,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,aAAa,CAK1F"}
@@ -0,0 +1,173 @@
1
+ import { Resolver } from "../v3/resolve.js";
2
+ import { MARK_ATTRS } from "./mark.js";
3
+ import { NodeSelection, TextSelection } from "./selection.js";
4
+ import { Plugin, PluginKey } from "./state.js";
5
+ const key = new PluginKey("word");
6
+ /**
7
+ * The plugin that gives commands a v3 document's envelope. A transaction changes it with
8
+ * `withEnvelope` (a new list's numbering definition); undo leaves such additions, as Word does.
9
+ */
10
+ export function wordPlugin(envelope) {
11
+ // Not a secret: only tells documents apart.
12
+ const id = `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`;
13
+ const context = { envelope, resolver: new Resolver(envelope), id };
14
+ return new Plugin({
15
+ key,
16
+ state: {
17
+ init: () => context,
18
+ apply: (tr, value) => {
19
+ const next = tr.getMeta(key);
20
+ return next ? { envelope: next, resolver: new Resolver(next), id: value.id } : value;
21
+ },
22
+ },
23
+ });
24
+ }
25
+ /** Makes `tr` change the document's envelope to `envelope` (styles, numbering…). */
26
+ export function withEnvelope(tr, envelope) {
27
+ return tr.setMeta(key, envelope);
28
+ }
29
+ /** The envelope and resolver of the v3 document in `state`, or null for a v2 editor. */
30
+ export function wordContext(state) {
31
+ return key.getState(state) ?? null;
32
+ }
33
+ /**
34
+ * What the paragraph mark carries alone (`MARK_ATTRS`): a split leaves it on the second
35
+ * paragraph, which keeps the original mark.
36
+ */
37
+ const MARK_ONLY = Object.fromEntries(MARK_ATTRS.map((key) => [key, null]));
38
+ /** The id of the default paragraph style: the last one marked default, as `Resolver` reads it. */
39
+ function defaultParagraphStyle(envelope) {
40
+ let id;
41
+ for (const style of envelope.styles)
42
+ if (style.type === "paragraph" && style.isDefault)
43
+ id = style.id;
44
+ return id;
45
+ }
46
+ /**
47
+ * The attributes of the two paragraphs Enter makes of `paragraph`. The first gets a new mark
48
+ * with the same properties; the second keeps the original mark. At the end of a paragraph whose
49
+ * style names another as the next (a heading: Normal), the second paragraph is in that style,
50
+ * without the first's direct formatting. `before` is null when the first keeps every attribute.
51
+ */
52
+ export function splitAttrs(context, paragraph, atEnd) {
53
+ const attrs = paragraph.attrs;
54
+ const markOnly = Object.keys(MARK_ONLY).some((k) => attrs[k] !== null);
55
+ const before = markOnly ? { ...attrs, ...MARK_ONLY } : null;
56
+ if (!atEnd)
57
+ return { before, after: attrs };
58
+ const id = attrs.style ?? defaultParagraphStyle(context.envelope);
59
+ const style = context.envelope.styles.find((s) => s.id === id);
60
+ const next = style?.next;
61
+ if (next === undefined || next === id)
62
+ return { before, after: attrs };
63
+ const mark = Object.fromEntries(Object.keys(MARK_ONLY).map((k) => [k, attrs[k] ?? null]));
64
+ return { before, after: { ...mark, style: next } };
65
+ }
66
+ /** Run toggles: whether text shows the property, from its resolved formatting. */
67
+ const TOGGLES = {
68
+ bold: (run) => run.bold,
69
+ italic: (run) => run.italic,
70
+ underline: (run) => run.underline !== null,
71
+ strike: (run) => run.strike,
72
+ doubleStrike: (run) => run.doubleStrike,
73
+ caps: (run) => run.caps,
74
+ smallCaps: (run) => run.smallCaps,
75
+ hidden: (run) => run.hidden,
76
+ };
77
+ /** Whether `type` is a run property the toggles handle on a v3 document. */
78
+ export function isWordToggle(context, type) {
79
+ return context !== null && Object.hasOwn(TOGGLES, type.name);
80
+ }
81
+ /** Whether text with `marks` in `paragraph` shows the toggle `type` (marks included or not). */
82
+ function shows(context, paragraph, marks, type, own = true) {
83
+ const { run } = context.resolver.paragraph(paragraph.attrs);
84
+ const json = marks.filter((m) => own || m.type !== type).map((m) => m.toJSON());
85
+ return TOGGLES[type.name](context.resolver.run(run, json));
86
+ }
87
+ /**
88
+ * The direct mark that makes text show the toggle `type` as `on`, given what it shows without
89
+ * one (`inherited`); null when no mark is needed. Bold and italic keep their complex-script twin.
90
+ */
91
+ function directMark(type, on, inherited, existing) {
92
+ const twin = existing?.attrs.complexScript ?? null;
93
+ const hasTwin = Object.hasOwn(type.spec.attrs ?? {}, "complexScript");
94
+ if (on === inherited)
95
+ return hasTwin && twin !== null ? type.create({ value: null, complexScript: twin }) : null;
96
+ if (type.name === "underline")
97
+ return type.create({ style: on ? "single" : "none" });
98
+ return type.create(hasTwin ? { value: on, complexScript: twin } : { value: on });
99
+ }
100
+ /**
101
+ * The inline nodes a toggle formats in a range (not markers: nothing to format), and those it
102
+ * judges: text nodes, or every one when there is none.
103
+ */
104
+ function inlineIn(state, from, to, type) {
105
+ const found = [];
106
+ state.doc.nodesBetween(from, to, (node, pos, parent) => {
107
+ if (!node.isInline || !parent?.type.allowsMarkType(type))
108
+ return undefined;
109
+ if (MARKERS.has(node.type.name))
110
+ return false;
111
+ found.push({ node, pos, parent });
112
+ return false;
113
+ });
114
+ const text = found.filter((f) => f.node.isText);
115
+ return text.length ? { all: found, judged: text } : { all: found, judged: found };
116
+ }
117
+ /** Whether all the selected text (or the text typed at a caret) shows the toggle `type`. */
118
+ export function wordToggleActive(context, state, type, caretMarks) {
119
+ const { selection } = state;
120
+ if (caretMarks)
121
+ return shows(context, selection.$from.parent, caretMarks, type);
122
+ const { judged } = inlineIn(state, selection.from, selection.to, type);
123
+ return judged.length > 0 && judged.every((f) => shows(context, f.parent, f.node.marks, type));
124
+ }
125
+ /**
126
+ * The stored marks for a toggle at a caret: what makes the next typed text show the opposite of
127
+ * what text typed there would show now.
128
+ */
129
+ export function toggledCaretMarks(context, paragraph, marks, type) {
130
+ const on = !shows(context, paragraph, marks, type);
131
+ const existing = type.isInSet(marks);
132
+ const rest = existing ? existing.removeFromSet(marks) : marks;
133
+ const mark = directMark(type, on, shows(context, paragraph, marks, type, false), existing);
134
+ return mark ? mark.addToSet(rest) : rest;
135
+ }
136
+ /**
137
+ * The mark changes that make every inline node in `from..to` show the toggle `type` as `on`:
138
+ * per node, a direct mark where its style does not already give that, none where it does.
139
+ */
140
+ export function toggleRanges(context, state, from, to, type, on) {
141
+ return inlineIn(state, from, to, type).all.map(({ node, pos, parent }) => ({
142
+ from: Math.max(from, pos),
143
+ to: Math.min(to, pos + node.nodeSize),
144
+ mark: directMark(type, on, shows(context, parent, node.marks, type, false), type.isInSet(node.marks)),
145
+ }));
146
+ }
147
+ /** Zero-width markers: nothing to see, so the caret and deletion step over them. */
148
+ const MARKERS = new Set([
149
+ "bookmarkStart",
150
+ "bookmarkEnd",
151
+ "commentStart",
152
+ "commentEnd",
153
+ // A comment's reference mark: deleting it would take the comment's anchor.
154
+ "commentReference",
155
+ ]);
156
+ /** Whether `node` is an invisible marker of a v3 document. */
157
+ export function isMarker(context, node) {
158
+ return context !== null && !!node && MARKERS.has(node.type.name);
159
+ }
160
+ /** Opaque content: deleted only once selected, as Word selects a field before deleting it. */
161
+ export function isOpaque(context, node) {
162
+ return (context !== null &&
163
+ !!node &&
164
+ (node.type.name === "opaqueInline" || node.type.name === "opaqueBlock"));
165
+ }
166
+ /** A node selection of the node at `pos`, or a text selection when it cannot be selected. */
167
+ export function selectionAt(state, pos) {
168
+ const node = state.doc.nodeAt(pos);
169
+ return node && NodeSelection.isSelectable(node)
170
+ ? NodeSelection.create(state.doc, pos)
171
+ : TextSelection.create(state.doc, pos);
172
+ }
173
+ //# sourceMappingURL=word.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"word.js","sourceRoot":"","sources":["../../src/state/word.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAkB,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,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AC,CAAC;IACnC,OAAO,IAAI,IAAI,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC;QAC7C,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC;QACtC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { Node } from "../model/index.js";
2
+ import { type AbstractNumberingJSON, type CommentJSON, type NumberingInstanceJSON, type StyleJSON } from "../v3/document.js";
3
+ import type { EditorState } from "./state.js";
4
+ import { type WordContext, type WordEnvelope } from "./word.js";
5
+ /** What a v3 copy carries beside its content: the definitions the content references. */
6
+ export interface WordDefinitions {
7
+ /** The document copied from (`WordContext.id`). */
8
+ document?: string;
9
+ styles: StyleJSON[];
10
+ numbering: {
11
+ abstracts: AbstractNumberingJSON[];
12
+ instances: NumberingInstanceJSON[];
13
+ };
14
+ comments: CommentJSON[];
15
+ }
16
+ /**
17
+ * The definitions `content` (copied from the document of `context`) references: its paragraphs'
18
+ * and runs' styles (the paragraph mark's and a tracked change's too) with the styles they are
19
+ * based on, link to or are followed by, its lists' numbering (a style's included), and its
20
+ * comments; with the document's id.
21
+ */
22
+ export declare function copiedDefinitions(context: WordContext, content: Node): WordDefinitions;
23
+ /**
24
+ * Pasted HTML, read as schema v2 content (`htmlToDoc`, validated), fitted to the v3 document in
25
+ * `state` like `fitPaste`: structured by `migrateToV3`, with Word's built-in heading, List
26
+ * Paragraph and Hyperlink styles where the document lacks them, and the list levels the list
27
+ * buttons make (the document's definition where it has one). Each list is a new one.
28
+ */
29
+ export declare function fitPastedV2(state: EditorState, content: Node): {
30
+ doc: Node;
31
+ envelope: WordEnvelope;
32
+ };
33
+ /**
34
+ * Fits pasted v3 `content` (untrusted) to the document in `state`: `definitions` are the ones
35
+ * the copy carried (`copiedDefinitions`, untrusted), or none for content of this document (plain
36
+ * text, older copies). Returns the content to insert and the envelope with what it added (the
37
+ * same object when nothing was added). Throws FoliDocumentError on invalid input.
38
+ */
39
+ export declare function fitPaste(state: EditorState, content: unknown, definitions?: unknown): {
40
+ doc: Node;
41
+ envelope: WordEnvelope;
42
+ };
43
+ //# sourceMappingURL=wordclip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wordclip.d.ts","sourceRoot":"","sources":["../../src/state/wordclip.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAY,IAAI,EAAY,MAAM,mBAAmB,CAAC;AAElE,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAK1B,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAe,MAAM,WAAW,CAAC;AAG7E,yFAAyF;AACzF,MAAM,WAAW,eAAe;IAC9B,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,SAAS,EAAE;QAAE,SAAS,EAAE,qBAAqB,EAAE,CAAC;QAAC,SAAS,EAAE,qBAAqB,EAAE,CAAA;KAAE,CAAC;IACtF,QAAQ,EAAE,WAAW,EAAE,CAAC;CACzB;AAeD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,GAAG,eAAe,CA+DtF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,IAAI,GACZ;IAAE,GAAG,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAA;CAAE,CA2CvC;AAeD;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,OAAO,EAChB,WAAW,CAAC,EAAE,OAAO,GACpB;IAAE,GAAG,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAA;CAAE,CAkBvC"}