@pixerate/editor 0.268.1 → 0.269.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.
- package/dist/agent/index.cjs +27 -27
- package/dist/agent/index.js +1 -1
- package/dist/animation-editor/index.cjs +61 -61
- package/dist/animation-editor/index.js +5 -5
- package/dist/brushes/import/abr.d.cts +48 -0
- package/dist/brushes/import/abr.d.ts +48 -0
- package/dist/brushes/import/bplist.d.cts +24 -0
- package/dist/brushes/import/bplist.d.ts +24 -0
- package/dist/brushes/import/pack.d.cts +82 -0
- package/dist/brushes/import/pack.d.ts +82 -0
- package/dist/brushes/import/zip.d.cts +31 -0
- package/dist/brushes/import/zip.d.ts +31 -0
- package/dist/brushes/index.cjs +26 -6
- package/dist/brushes/index.d.cts +2 -0
- package/dist/brushes/index.d.ts +2 -0
- package/dist/brushes/index.js +22 -2
- package/dist/{chunk-SIFAIGB3.js → chunk-3AJCEJNH.js} +2 -162
- package/dist/{chunk-YXP6X3SY.cjs → chunk-3KNQ2W6X.cjs} +697 -10
- package/dist/{chunk-QNY7BDFP.js → chunk-4CPOKP27.js} +1 -1
- package/dist/{chunk-J4GXP53R.cjs → chunk-4NMPUJUK.cjs} +86 -86
- package/dist/{chunk-LDOD7VCT.js → chunk-4YSPQGZW.js} +1 -1
- package/dist/{chunk-JBB3GDBB.cjs → chunk-56RHCIJV.cjs} +2 -2
- package/dist/{chunk-4IMD2TLY.cjs → chunk-AI4F33IV.cjs} +3166 -2966
- package/dist/{chunk-YOVXQHA3.cjs → chunk-BENSE3VX.cjs} +23 -23
- package/dist/{chunk-VDGBHYC7.js → chunk-F7OO3DHP.js} +157 -1
- package/dist/{chunk-UVTO3D4E.js → chunk-FUDP5QBB.js} +1 -1
- package/dist/{chunk-3XDSNIGF.js → chunk-ININNHLM.js} +687 -0
- package/dist/{chunk-WIC7TG73.cjs → chunk-M4UQA2T4.cjs} +18 -18
- package/dist/{chunk-ITURMC2M.js → chunk-N3UMQVKX.js} +176 -176
- package/dist/{chunk-UWEQ55MY.cjs → chunk-N4KP3UQR.cjs} +157 -1
- package/dist/{chunk-D5BXSOSU.js → chunk-QGVTOCNB.js} +3118 -2918
- package/dist/{chunk-M6DNZNVY.js → chunk-RWDSSK2I.js} +4 -2
- package/dist/{chunk-CVFAAZXE.cjs → chunk-SPIO2GJU.cjs} +8 -6
- package/dist/{chunk-RHEMMGCN.cjs → chunk-T4JPGBW3.cjs} +173 -173
- package/dist/{chunk-HFY5LG5J.js → chunk-THBJHPUL.js} +1 -1
- package/dist/{chunk-NPWWSCWT.cjs → chunk-VBRHE4AM.cjs} +35 -35
- package/dist/{chunk-AZC2NDAR.js → chunk-WB22XMW3.js} +6 -6
- package/dist/{chunk-NIBFDFYW.cjs → chunk-YBMUHIOM.cjs} +12 -172
- package/dist/extensions/index.cjs +18 -4
- package/dist/extensions/index.d.cts +1 -0
- package/dist/extensions/index.d.ts +1 -0
- package/dist/extensions/index.js +17 -3
- package/dist/extensions/prompt-editor.d.cts +109 -0
- package/dist/extensions/prompt-editor.d.ts +109 -0
- package/dist/generation/index.cjs +15 -15
- package/dist/generation/index.js +3 -3
- package/dist/grammar/index.cjs +4 -4
- package/dist/grammar/index.js +7 -7
- package/dist/image-editor/index.cjs +785 -785
- package/dist/image-editor/index.js +6 -6
- package/dist/index.cjs +27 -13
- package/dist/index.js +23 -9
- package/dist/paint-editor/index.cjs +91 -91
- package/dist/paint-editor/index.js +6 -6
- package/dist/vector/index.cjs +1001 -1001
- package/dist/vector/index.js +6 -6
- package/package.json +1 -1
- package/skills/pixerate-brushes/SKILL.md +11 -2
- package/skills/pixerate-brushes-design/SKILL.md +2 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getLatestVersion,
|
|
3
3
|
getTemplateBody,
|
|
4
|
-
resolvePrompt
|
|
4
|
+
resolvePrompt
|
|
5
|
+
} from "./chunk-3AJCEJNH.js";
|
|
6
|
+
import {
|
|
5
7
|
tokenizePrompt
|
|
6
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-F7OO3DHP.js";
|
|
7
9
|
|
|
8
10
|
// src/generation/provenance.ts
|
|
9
11
|
var PROVENANCE_FORMAT = "pixerate.generation-provenance";
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
var _chunkYBMUHIOMcjs = require('./chunk-YBMUHIOM.cjs');
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
|
|
8
|
+
var _chunkN4KP3UQRcjs = require('./chunk-N4KP3UQR.cjs');
|
|
7
9
|
|
|
8
10
|
// src/generation/provenance.ts
|
|
9
11
|
var PROVENANCE_FORMAT = "pixerate.generation-provenance";
|
|
@@ -21,14 +23,14 @@ function pinTemplates(rawPrompt, templates, bindings, maxDepth) {
|
|
|
21
23
|
const pinned = /* @__PURE__ */ new Map();
|
|
22
24
|
const visit = (text, depth) => {
|
|
23
25
|
if (depth > maxDepth) return;
|
|
24
|
-
for (const token of
|
|
26
|
+
for (const token of _chunkN4KP3UQRcjs.tokenizePrompt.call(void 0, text)) {
|
|
25
27
|
if (token.type !== "template" || pinned.has(token.value)) continue;
|
|
26
28
|
const template = byName.get(token.value);
|
|
27
29
|
if (!template) continue;
|
|
28
|
-
const body =
|
|
30
|
+
const body = _chunkYBMUHIOMcjs.getTemplateBody.call(void 0, template, bindings);
|
|
29
31
|
if (body === void 0) continue;
|
|
30
32
|
const bound = bindings[template.name];
|
|
31
|
-
const version = bound && template.versions ? template.versions.find((v) => v.id === bound || v.version === bound) :
|
|
33
|
+
const version = bound && template.versions ? template.versions.find((v) => v.id === bound || v.version === bound) : _chunkYBMUHIOMcjs.getLatestVersion.call(void 0, template);
|
|
32
34
|
const isVersioned = !!_optionalChain([template, 'access', _ => _.versions, 'optionalAccess', _2 => _2.length]) && !!version;
|
|
33
35
|
pinned.set(template.name, {
|
|
34
36
|
name: template.name,
|
|
@@ -55,7 +57,7 @@ function pinnedTemplatesToTemplates(pinned) {
|
|
|
55
57
|
function createProvenance(options) {
|
|
56
58
|
const templates = _nullishCoalesce(options.templates, () => ( []));
|
|
57
59
|
const maxDepth = _nullishCoalesce(options.maxDepth, () => ( 10));
|
|
58
|
-
const resolved =
|
|
60
|
+
const resolved = _chunkYBMUHIOMcjs.resolvePrompt.call(void 0, options.rawPrompt, templates, {
|
|
59
61
|
bindings: options.bindings,
|
|
60
62
|
values: options.values,
|
|
61
63
|
maxDepth
|
|
@@ -130,7 +132,7 @@ function parseProvenance(input) {
|
|
|
130
132
|
};
|
|
131
133
|
}
|
|
132
134
|
function replayProvenancePrompt(provenance) {
|
|
133
|
-
const result =
|
|
135
|
+
const result = _chunkYBMUHIOMcjs.resolvePrompt.call(void 0, provenance.rawPrompt, pinnedTemplatesToTemplates(provenance.templates), {
|
|
134
136
|
bindings: provenance.bindings,
|
|
135
137
|
...provenance.values ? { values: provenance.values } : {}
|
|
136
138
|
});
|
|
@@ -24,9 +24,174 @@ var _chunkG43MNQ4Ccjs = require('./chunk-G43MNQ4C.cjs');
|
|
|
24
24
|
|
|
25
25
|
var _chunk34RQAGWIcjs = require('./chunk-34RQAGWI.cjs');
|
|
26
26
|
|
|
27
|
+
// src/extensions/table/nesting.ts
|
|
28
|
+
var _model = require('@tiptap/pm/model');
|
|
29
|
+
var _state = require('@tiptap/pm/state');
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
var _tables = require('@tiptap/pm/tables');
|
|
35
|
+
var ALLOW_NESTED_TABLES_META = "allowNestedTables";
|
|
36
|
+
var tableNestingPluginKey = new (0, _state.PluginKey)("tableNesting");
|
|
37
|
+
var roleOf = (node) => node.type.spec.tableRole;
|
|
38
|
+
var isTableNode = (node) => roleOf(node) === "table";
|
|
39
|
+
function outermostTableDepth($pos) {
|
|
40
|
+
for (let d = 1; d <= $pos.depth; d++) if (isTableNode($pos.node(d))) return d;
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
function isInTableCell($pos) {
|
|
44
|
+
for (let d = $pos.depth; d > 0; d--) {
|
|
45
|
+
const role = roleOf($pos.node(d));
|
|
46
|
+
if (role === "cell" || role === "header_cell") return true;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
function sliceContainsTable(content) {
|
|
51
|
+
const fragment = content instanceof _model.Slice ? content.content : content;
|
|
52
|
+
let found = false;
|
|
53
|
+
fragment.descendants((node) => {
|
|
54
|
+
if (found) return false;
|
|
55
|
+
if (isTableNode(node)) found = true;
|
|
56
|
+
return !found;
|
|
57
|
+
});
|
|
58
|
+
return found;
|
|
59
|
+
}
|
|
60
|
+
function insertSliceAfterTable(tr, from, to, slice) {
|
|
61
|
+
const $from = tr.doc.resolve(from);
|
|
62
|
+
const depth = outermostTableDepth($from);
|
|
63
|
+
if (depth < 0) return null;
|
|
64
|
+
const tableStart = $from.before(depth);
|
|
65
|
+
const tableEnd = $from.after(depth);
|
|
66
|
+
if (to > from && to < tableEnd) {
|
|
67
|
+
if (tr.selection instanceof _tables.CellSelection && tr.selection.from === from && tr.selection.to === to) {
|
|
68
|
+
tr.deleteSelection();
|
|
69
|
+
} else {
|
|
70
|
+
tr.delete(from, to);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const table = tr.doc.nodeAt(tableStart);
|
|
74
|
+
if (!table) return null;
|
|
75
|
+
const after = tableStart + table.nodeSize;
|
|
76
|
+
const before = tr.doc.content.size;
|
|
77
|
+
tr.replace(after, after, new (0, _model.Slice)(slice.content, 0, 0));
|
|
78
|
+
return after + (tr.doc.content.size - before);
|
|
79
|
+
}
|
|
80
|
+
function handleTablePasteWithoutNesting(view, event, slice) {
|
|
81
|
+
const { state } = view;
|
|
82
|
+
const { selection } = state;
|
|
83
|
+
if (outermostTableDepth(selection.$from) < 0) return false;
|
|
84
|
+
if (selection instanceof _tables.CellSelection || _tables.__pastedCells.call(void 0, slice)) {
|
|
85
|
+
if (_tables.handlePaste.call(void 0, view, event, slice)) return true;
|
|
86
|
+
}
|
|
87
|
+
if (!sliceContainsTable(slice)) return false;
|
|
88
|
+
const tr = state.tr;
|
|
89
|
+
const end = insertSliceAfterTable(tr, selection.from, selection.to, slice);
|
|
90
|
+
if (end === null) return false;
|
|
91
|
+
tr.setSelection(_state.Selection.near(tr.doc.resolve(end), -1));
|
|
92
|
+
view.dispatch(tr.scrollIntoView().setMeta("paste", true).setMeta("uiEvent", "paste"));
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
function changedRanges(transactions, skip2) {
|
|
96
|
+
let ranges = [];
|
|
97
|
+
for (const tr of transactions) {
|
|
98
|
+
const skipped = skip2(tr);
|
|
99
|
+
for (const step of tr.steps) {
|
|
100
|
+
const map = step.getMap();
|
|
101
|
+
ranges = ranges.map(([from, to]) => [map.map(from, 1), map.map(to, -1)]).filter(([from, to]) => to > from);
|
|
102
|
+
if (skipped) continue;
|
|
103
|
+
map.forEach((_oldStart, _oldEnd, newStart, newEnd) => {
|
|
104
|
+
if (newEnd > newStart) ranges.push([newStart, newEnd]);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return ranges;
|
|
109
|
+
}
|
|
110
|
+
function findNestedTables(doc, ranges) {
|
|
111
|
+
const found = /* @__PURE__ */ new Set();
|
|
112
|
+
for (const [from, to] of ranges) {
|
|
113
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
114
|
+
if (!isTableNode(node) || pos < from) return true;
|
|
115
|
+
if (isInTableCell(doc.resolve(pos))) {
|
|
116
|
+
found.add(pos);
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const sorted = [...found].sort((a, b) => a - b);
|
|
123
|
+
const outer = [];
|
|
124
|
+
for (const pos of sorted) {
|
|
125
|
+
const last = outer[outer.length - 1];
|
|
126
|
+
if (last === void 0 || pos >= last + doc.nodeAt(last).nodeSize) outer.push(pos);
|
|
127
|
+
}
|
|
128
|
+
return outer;
|
|
129
|
+
}
|
|
130
|
+
function unnestTables(tr, ranges) {
|
|
131
|
+
let changed = false;
|
|
132
|
+
for (let round = 0; round < 32 && ranges.length; round++) {
|
|
133
|
+
const nested = findNestedTables(tr.doc, ranges);
|
|
134
|
+
if (!nested.length) break;
|
|
135
|
+
const groups = /* @__PURE__ */ new Map();
|
|
136
|
+
for (const pos of nested) {
|
|
137
|
+
const $pos = tr.doc.resolve(pos);
|
|
138
|
+
const outer = $pos.before(outermostTableDepth($pos));
|
|
139
|
+
groups.set(outer, [..._nullishCoalesce(groups.get(outer), () => ( [])), pos]);
|
|
140
|
+
}
|
|
141
|
+
const next = [];
|
|
142
|
+
for (const outer of [...groups.keys()].sort((a, b) => b - a)) {
|
|
143
|
+
const positions = groups.get(outer);
|
|
144
|
+
const nodes = positions.map((pos) => tr.doc.nodeAt(pos));
|
|
145
|
+
for (let i = positions.length - 1; i >= 0; i--) {
|
|
146
|
+
const pos = positions[i];
|
|
147
|
+
const node = nodes[i];
|
|
148
|
+
const $pos = tr.doc.resolve(pos);
|
|
149
|
+
const parent = $pos.parent;
|
|
150
|
+
const filler = parent.childCount === 1 ? _optionalChain([parent, 'access', _2 => _2.type, 'access', _3 => _3.contentMatch, 'access', _4 => _4.defaultType, 'optionalAccess', _5 => _5.createAndFill, 'call', _6 => _6()]) : null;
|
|
151
|
+
if (filler) tr.replaceWith(pos, pos + node.nodeSize, filler);
|
|
152
|
+
else tr.delete(pos, pos + node.nodeSize);
|
|
153
|
+
}
|
|
154
|
+
const table = tr.doc.nodeAt(outer);
|
|
155
|
+
const after = outer + table.nodeSize;
|
|
156
|
+
const fragment = _model.Fragment.fromArray(nodes);
|
|
157
|
+
tr.insert(after, fragment);
|
|
158
|
+
next.push([after, after + fragment.size]);
|
|
159
|
+
changed = true;
|
|
160
|
+
}
|
|
161
|
+
ranges = next;
|
|
162
|
+
}
|
|
163
|
+
return changed;
|
|
164
|
+
}
|
|
165
|
+
function replacesDocument(tr) {
|
|
166
|
+
return tr.steps.some((step, i) => {
|
|
167
|
+
const { from, to } = step;
|
|
168
|
+
return from === 0 && to !== void 0 && to >= tr.docs[i].content.size;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
var skip = (tr) => !tr.docChanged || tr.getMeta(ALLOW_NESTED_TABLES_META) === true || // Undo/redo and remote collaborative changes restore what was there.
|
|
172
|
+
!!tr.getMeta("history$") || !!tr.getMeta("y-sync$") || // Other plugins' housekeeping, e.g. Track Changes putting a deleted
|
|
173
|
+
// (nested) table back so the deletion can be reviewed.
|
|
174
|
+
!!tr.getMeta("appendedTransaction") || replacesDocument(tr);
|
|
175
|
+
function createTableNestingPlugin() {
|
|
176
|
+
return new (0, _state.Plugin)({
|
|
177
|
+
key: tableNestingPluginKey,
|
|
178
|
+
props: {
|
|
179
|
+
handlePaste: (view, event, slice) => handleTablePasteWithoutNesting(view, event, slice)
|
|
180
|
+
},
|
|
181
|
+
appendTransaction(transactions, _oldState, newState) {
|
|
182
|
+
if (transactions.every(skip)) return null;
|
|
183
|
+
const ranges = changedRanges(transactions, skip);
|
|
184
|
+
if (!ranges.length) return null;
|
|
185
|
+
const tr = newState.tr;
|
|
186
|
+
if (!unnestTables(tr, ranges)) return null;
|
|
187
|
+
return tr;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
27
192
|
// src/extensions/comments.ts
|
|
28
193
|
var _core = require('@tiptap/core');
|
|
29
|
-
|
|
194
|
+
|
|
30
195
|
var _view = require('@tiptap/pm/view');
|
|
31
196
|
var commentsPluginKey = new (0, _state.PluginKey)("comments");
|
|
32
197
|
var COMMENT_MARK_NAME = "comment";
|
|
@@ -67,8 +232,8 @@ function getCommentAnchors(doc) {
|
|
|
67
232
|
function getCommentIdsAt(state, pos = state.selection.from) {
|
|
68
233
|
const $pos = state.doc.resolve(pos);
|
|
69
234
|
const marks = [
|
|
70
|
-
..._nullishCoalesce(_optionalChain([$pos, 'access',
|
|
71
|
-
..._nullishCoalesce(_optionalChain([$pos, 'access',
|
|
235
|
+
..._nullishCoalesce(_optionalChain([$pos, 'access', _7 => _7.nodeAfter, 'optionalAccess', _8 => _8.marks]), () => ( [])),
|
|
236
|
+
..._nullishCoalesce(_optionalChain([$pos, 'access', _9 => _9.nodeBefore, 'optionalAccess', _10 => _10.marks]), () => ( []))
|
|
72
237
|
];
|
|
73
238
|
const ids = [];
|
|
74
239
|
marks.forEach((m) => {
|
|
@@ -79,7 +244,7 @@ function getCommentIdsAt(state, pos = state.selection.from) {
|
|
|
79
244
|
return ids;
|
|
80
245
|
}
|
|
81
246
|
function getCommentStore(editor) {
|
|
82
|
-
return _nullishCoalesce(_optionalChain([editor, 'optionalAccess',
|
|
247
|
+
return _nullishCoalesce(_optionalChain([editor, 'optionalAccess', _11 => _11.storage, 'optionalAccess', _12 => _12[COMMENT_MARK_NAME], 'optionalAccess', _13 => _13.store]), () => ( null));
|
|
83
248
|
}
|
|
84
249
|
function resolveAuthor(author) {
|
|
85
250
|
return typeof author === "function" ? author() : author;
|
|
@@ -202,7 +367,7 @@ var Comments = _core.Mark.create({
|
|
|
202
367
|
const decorations = [];
|
|
203
368
|
findCommentRanges(doc).forEach((ranges, id) => {
|
|
204
369
|
const thread = store.getThread(id);
|
|
205
|
-
const resolved = _nullishCoalesce(_optionalChain([thread, 'optionalAccess',
|
|
370
|
+
const resolved = _nullishCoalesce(_optionalChain([thread, 'optionalAccess', _14 => _14.resolved]), () => ( false));
|
|
206
371
|
const active = snapshot.activeThreadId === id;
|
|
207
372
|
const cls = [
|
|
208
373
|
resolved ? options.resolvedClass : options.commentClass,
|
|
@@ -235,7 +400,7 @@ var Comments = _core.Mark.create({
|
|
|
235
400
|
scheduled = false;
|
|
236
401
|
if (destroyed) return;
|
|
237
402
|
sync();
|
|
238
|
-
if (_optionalChain([cache, 'optionalAccess',
|
|
403
|
+
if (_optionalChain([cache, 'optionalAccess', _15 => _15.snapshot]) !== store.getSnapshot()) {
|
|
239
404
|
view.dispatch(
|
|
240
405
|
view.state.tr.setMeta(commentsPluginKey, "refresh").setMeta("addToHistory", false)
|
|
241
406
|
);
|
|
@@ -264,175 +429,10 @@ var Comments = _core.Mark.create({
|
|
|
264
429
|
}
|
|
265
430
|
});
|
|
266
431
|
function getCommentAuthor(editor) {
|
|
267
|
-
const ext = _optionalChain([editor, 'optionalAccess',
|
|
432
|
+
const ext = _optionalChain([editor, 'optionalAccess', _16 => _16.extensionManager, 'optionalAccess', _17 => _17.extensions, 'access', _18 => _18.find, 'call', _19 => _19((e) => e.name === COMMENT_MARK_NAME)]);
|
|
268
433
|
return ext ? resolveAuthor(ext.options.author) : null;
|
|
269
434
|
}
|
|
270
435
|
|
|
271
|
-
// src/extensions/table/nesting.ts
|
|
272
|
-
var _model = require('@tiptap/pm/model');
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
var _tables = require('@tiptap/pm/tables');
|
|
279
|
-
var ALLOW_NESTED_TABLES_META = "allowNestedTables";
|
|
280
|
-
var tableNestingPluginKey = new (0, _state.PluginKey)("tableNesting");
|
|
281
|
-
var roleOf = (node) => node.type.spec.tableRole;
|
|
282
|
-
var isTableNode = (node) => roleOf(node) === "table";
|
|
283
|
-
function outermostTableDepth($pos) {
|
|
284
|
-
for (let d = 1; d <= $pos.depth; d++) if (isTableNode($pos.node(d))) return d;
|
|
285
|
-
return -1;
|
|
286
|
-
}
|
|
287
|
-
function isInTableCell($pos) {
|
|
288
|
-
for (let d = $pos.depth; d > 0; d--) {
|
|
289
|
-
const role = roleOf($pos.node(d));
|
|
290
|
-
if (role === "cell" || role === "header_cell") return true;
|
|
291
|
-
}
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
|
-
function sliceContainsTable(content) {
|
|
295
|
-
const fragment = content instanceof _model.Slice ? content.content : content;
|
|
296
|
-
let found = false;
|
|
297
|
-
fragment.descendants((node) => {
|
|
298
|
-
if (found) return false;
|
|
299
|
-
if (isTableNode(node)) found = true;
|
|
300
|
-
return !found;
|
|
301
|
-
});
|
|
302
|
-
return found;
|
|
303
|
-
}
|
|
304
|
-
function insertSliceAfterTable(tr, from, to, slice) {
|
|
305
|
-
const $from = tr.doc.resolve(from);
|
|
306
|
-
const depth = outermostTableDepth($from);
|
|
307
|
-
if (depth < 0) return null;
|
|
308
|
-
const tableStart = $from.before(depth);
|
|
309
|
-
const tableEnd = $from.after(depth);
|
|
310
|
-
if (to > from && to < tableEnd) {
|
|
311
|
-
if (tr.selection instanceof _tables.CellSelection && tr.selection.from === from && tr.selection.to === to) {
|
|
312
|
-
tr.deleteSelection();
|
|
313
|
-
} else {
|
|
314
|
-
tr.delete(from, to);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
const table = tr.doc.nodeAt(tableStart);
|
|
318
|
-
if (!table) return null;
|
|
319
|
-
const after = tableStart + table.nodeSize;
|
|
320
|
-
const before = tr.doc.content.size;
|
|
321
|
-
tr.replace(after, after, new (0, _model.Slice)(slice.content, 0, 0));
|
|
322
|
-
return after + (tr.doc.content.size - before);
|
|
323
|
-
}
|
|
324
|
-
function handleTablePasteWithoutNesting(view, event, slice) {
|
|
325
|
-
const { state } = view;
|
|
326
|
-
const { selection } = state;
|
|
327
|
-
if (outermostTableDepth(selection.$from) < 0) return false;
|
|
328
|
-
if (selection instanceof _tables.CellSelection || _tables.__pastedCells.call(void 0, slice)) {
|
|
329
|
-
if (_tables.handlePaste.call(void 0, view, event, slice)) return true;
|
|
330
|
-
}
|
|
331
|
-
if (!sliceContainsTable(slice)) return false;
|
|
332
|
-
const tr = state.tr;
|
|
333
|
-
const end = insertSliceAfterTable(tr, selection.from, selection.to, slice);
|
|
334
|
-
if (end === null) return false;
|
|
335
|
-
tr.setSelection(_state.Selection.near(tr.doc.resolve(end), -1));
|
|
336
|
-
view.dispatch(tr.scrollIntoView().setMeta("paste", true).setMeta("uiEvent", "paste"));
|
|
337
|
-
return true;
|
|
338
|
-
}
|
|
339
|
-
function changedRanges(transactions, skip2) {
|
|
340
|
-
let ranges = [];
|
|
341
|
-
for (const tr of transactions) {
|
|
342
|
-
const skipped = skip2(tr);
|
|
343
|
-
for (const step of tr.steps) {
|
|
344
|
-
const map = step.getMap();
|
|
345
|
-
ranges = ranges.map(([from, to]) => [map.map(from, 1), map.map(to, -1)]).filter(([from, to]) => to > from);
|
|
346
|
-
if (skipped) continue;
|
|
347
|
-
map.forEach((_oldStart, _oldEnd, newStart, newEnd) => {
|
|
348
|
-
if (newEnd > newStart) ranges.push([newStart, newEnd]);
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
return ranges;
|
|
353
|
-
}
|
|
354
|
-
function findNestedTables(doc, ranges) {
|
|
355
|
-
const found = /* @__PURE__ */ new Set();
|
|
356
|
-
for (const [from, to] of ranges) {
|
|
357
|
-
doc.nodesBetween(from, to, (node, pos) => {
|
|
358
|
-
if (!isTableNode(node) || pos < from) return true;
|
|
359
|
-
if (isInTableCell(doc.resolve(pos))) {
|
|
360
|
-
found.add(pos);
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
363
|
-
return true;
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
const sorted = [...found].sort((a, b) => a - b);
|
|
367
|
-
const outer = [];
|
|
368
|
-
for (const pos of sorted) {
|
|
369
|
-
const last = outer[outer.length - 1];
|
|
370
|
-
if (last === void 0 || pos >= last + doc.nodeAt(last).nodeSize) outer.push(pos);
|
|
371
|
-
}
|
|
372
|
-
return outer;
|
|
373
|
-
}
|
|
374
|
-
function unnestTables(tr, ranges) {
|
|
375
|
-
let changed = false;
|
|
376
|
-
for (let round = 0; round < 32 && ranges.length; round++) {
|
|
377
|
-
const nested = findNestedTables(tr.doc, ranges);
|
|
378
|
-
if (!nested.length) break;
|
|
379
|
-
const groups = /* @__PURE__ */ new Map();
|
|
380
|
-
for (const pos of nested) {
|
|
381
|
-
const $pos = tr.doc.resolve(pos);
|
|
382
|
-
const outer = $pos.before(outermostTableDepth($pos));
|
|
383
|
-
groups.set(outer, [..._nullishCoalesce(groups.get(outer), () => ( [])), pos]);
|
|
384
|
-
}
|
|
385
|
-
const next = [];
|
|
386
|
-
for (const outer of [...groups.keys()].sort((a, b) => b - a)) {
|
|
387
|
-
const positions = groups.get(outer);
|
|
388
|
-
const nodes = positions.map((pos) => tr.doc.nodeAt(pos));
|
|
389
|
-
for (let i = positions.length - 1; i >= 0; i--) {
|
|
390
|
-
const pos = positions[i];
|
|
391
|
-
const node = nodes[i];
|
|
392
|
-
const $pos = tr.doc.resolve(pos);
|
|
393
|
-
const parent = $pos.parent;
|
|
394
|
-
const filler = parent.childCount === 1 ? _optionalChain([parent, 'access', _15 => _15.type, 'access', _16 => _16.contentMatch, 'access', _17 => _17.defaultType, 'optionalAccess', _18 => _18.createAndFill, 'call', _19 => _19()]) : null;
|
|
395
|
-
if (filler) tr.replaceWith(pos, pos + node.nodeSize, filler);
|
|
396
|
-
else tr.delete(pos, pos + node.nodeSize);
|
|
397
|
-
}
|
|
398
|
-
const table = tr.doc.nodeAt(outer);
|
|
399
|
-
const after = outer + table.nodeSize;
|
|
400
|
-
const fragment = _model.Fragment.fromArray(nodes);
|
|
401
|
-
tr.insert(after, fragment);
|
|
402
|
-
next.push([after, after + fragment.size]);
|
|
403
|
-
changed = true;
|
|
404
|
-
}
|
|
405
|
-
ranges = next;
|
|
406
|
-
}
|
|
407
|
-
return changed;
|
|
408
|
-
}
|
|
409
|
-
function replacesDocument(tr) {
|
|
410
|
-
return tr.steps.some((step, i) => {
|
|
411
|
-
const { from, to } = step;
|
|
412
|
-
return from === 0 && to !== void 0 && to >= tr.docs[i].content.size;
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
var skip = (tr) => !tr.docChanged || tr.getMeta(ALLOW_NESTED_TABLES_META) === true || // Undo/redo and remote collaborative changes restore what was there.
|
|
416
|
-
!!tr.getMeta("history$") || !!tr.getMeta("y-sync$") || // Other plugins' housekeeping, e.g. Track Changes putting a deleted
|
|
417
|
-
// (nested) table back so the deletion can be reviewed.
|
|
418
|
-
!!tr.getMeta("appendedTransaction") || replacesDocument(tr);
|
|
419
|
-
function createTableNestingPlugin() {
|
|
420
|
-
return new (0, _state.Plugin)({
|
|
421
|
-
key: tableNestingPluginKey,
|
|
422
|
-
props: {
|
|
423
|
-
handlePaste: (view, event, slice) => handleTablePasteWithoutNesting(view, event, slice)
|
|
424
|
-
},
|
|
425
|
-
appendTransaction(transactions, _oldState, newState) {
|
|
426
|
-
if (transactions.every(skip)) return null;
|
|
427
|
-
const ranges = changedRanges(transactions, skip);
|
|
428
|
-
if (!ranges.length) return null;
|
|
429
|
-
const tr = newState.tr;
|
|
430
|
-
if (!unnestTables(tr, ranges)) return null;
|
|
431
|
-
return tr;
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
|
|
436
436
|
// src/extensions/find-replace/pattern.ts
|
|
437
437
|
var FIND_PARAGRAPH_MARK = "\r";
|
|
438
438
|
var MAX_FIND_PATTERN_LENGTH = 1024;
|
|
@@ -2541,4 +2541,4 @@ async function typeAgentText(editor, options) {
|
|
|
2541
2541
|
|
|
2542
2542
|
|
|
2543
2543
|
|
|
2544
|
-
exports.
|
|
2544
|
+
exports.ALLOW_NESTED_TABLES_META = ALLOW_NESTED_TABLES_META; exports.tableNestingPluginKey = tableNestingPluginKey; exports.outermostTableDepth = outermostTableDepth; exports.isInTableCell = isInTableCell; exports.sliceContainsTable = sliceContainsTable; exports.insertSliceAfterTable = insertSliceAfterTable; exports.handleTablePasteWithoutNesting = handleTablePasteWithoutNesting; exports.unnestTables = unnestTables; exports.createTableNestingPlugin = createTableNestingPlugin; exports.commentsPluginKey = commentsPluginKey; exports.COMMENT_MARK_NAME = COMMENT_MARK_NAME; exports.findCommentRanges = findCommentRanges; exports.getCommentAnchors = getCommentAnchors; exports.getCommentIdsAt = getCommentIdsAt; exports.getCommentStore = getCommentStore; exports.Comments = Comments; exports.getCommentAuthor = getCommentAuthor; exports.generateStructureId = generateStructureId; exports.presenceStateSpec = presenceStateSpec; exports.arraysEqual = arraysEqual; exports.scrollDomAtPos = scrollDomAtPos; exports.syncInitialContent = syncInitialContent; exports.STRUCTURE_PRIORITY = STRUCTURE_PRIORITY; exports.FIND_PARAGRAPH_MARK = FIND_PARAGRAPH_MARK; exports.MAX_FIND_PATTERN_LENGTH = MAX_FIND_PATTERN_LENGTH; exports.createSearchBudget = createSearchBudget; exports.foldCodePoint = foldCodePoint; exports.compileFindPattern = compileFindPattern; exports.findAllMatches = findAllMatches; exports.parseReplacement = parseReplacement; exports.expandReplacement = expandReplacement; exports.searchDocument = searchDocument; exports.applyReplacements = applyReplacements; exports.normalizeTableCellAlignment = normalizeTableCellAlignment; exports.normalizeTableCellColor = normalizeTableCellColor; exports.isGfmTable = isGfmTable; exports.DEFAULT_TABLE_OPTIONS = DEFAULT_TABLE_OPTIONS; exports.Table = Table; exports.TableRow = TableRow; exports.TableCell = TableCell; exports.TableHeader = TableHeader; exports.createTableExtensions = createTableExtensions; exports.ChartNodeView = ChartNodeView; exports.createChartNodeView = createChartNodeView; exports.chartPluginKey = chartPluginKey; exports.getDocumentCharts = getDocumentCharts; exports.isChartEnabled = isChartEnabled; exports.staticChartSvg = staticChartSvg; exports.Chart = Chart; exports.SPARKLINE_KINDS = SPARKLINE_KINDS; exports.MAX_SPARKLINE_VALUES = MAX_SPARKLINE_VALUES; exports.normalizeSparklineValues = normalizeSparklineValues; exports.sparklineLabel = sparklineLabel; exports.Sparkline = Sparkline; exports.TABLE_ACTIONS = TABLE_ACTIONS; exports.DEFAULT_TABLE_TOOLBAR = DEFAULT_TABLE_TOOLBAR; exports.MAX_TABLE_ROWS = MAX_TABLE_ROWS; exports.MAX_TABLE_COLUMNS = MAX_TABLE_COLUMNS; exports.isTableEnabled = isTableEnabled; exports.isSelectionInTable = isSelectionInTable; exports.shouldShowTableBubbleMenu = shouldShowTableBubbleMenu; exports.getTableActionState = getTableActionState; exports.runTableAction = runTableAction; exports.EMPTY_TABLE_STATE = EMPTY_TABLE_STATE; exports.getTableState = getTableState; exports.createTableStore = createTableStore; exports.DEFAULT_AGENT_CARET_COLOR = DEFAULT_AGENT_CARET_COLOR; exports.DEFAULT_AGENT_CARET_NAME = DEFAULT_AGENT_CARET_NAME; exports.agentCaretPluginKey = agentCaretPluginKey; exports.createAgentCaretPlugin = createAgentCaretPlugin; exports.AgentCaret = AgentCaret; exports.ensureAgentCaret = ensureAgentCaret; exports.setAgentCaret = setAgentCaret; exports.clearAgentCaret = clearAgentCaret; exports.markAgentChanges = markAgentChanges; exports.getAgentCarets = getAgentCarets; exports.replaceWithTextTransaction = replaceWithTextTransaction; exports.typeAgentText = typeAgentText;
|