@pixerate/editor 0.58.0 → 0.60.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 +111 -38
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +30 -2
- package/dist/agent/index.d.ts +30 -2
- package/dist/agent/index.js +96 -23
- package/dist/agent/index.js.map +1 -1
- package/dist/agent-caret-BmYhQF7L.d.cts +106 -0
- package/dist/agent-caret-BmYhQF7L.d.ts +106 -0
- package/dist/animation/index.cjs +9 -3
- package/dist/animation/index.cjs.map +1 -1
- package/dist/animation/index.d.cts +2 -2
- package/dist/animation/index.d.ts +2 -2
- package/dist/animation/index.js +9 -3
- package/dist/animation-editor/index.cjs +535 -124
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +239 -9
- package/dist/animation-editor/index.d.ts +239 -9
- package/dist/animation-editor/index.js +494 -83
- package/dist/animation-editor/index.js.map +1 -1
- package/dist/canvas/index.cjs +35 -29
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +4 -4
- package/dist/canvas/index.d.ts +4 -4
- package/dist/canvas/index.js +9 -3
- package/dist/canvas/index.js.map +1 -1
- package/dist/{chunk-O4ONBPZW.cjs → chunk-2FGRTYJN.cjs} +4 -4
- package/dist/{chunk-O4ONBPZW.cjs.map → chunk-2FGRTYJN.cjs.map} +1 -1
- package/dist/{chunk-XZ4L3R4K.cjs → chunk-2FHLHZAL.cjs} +39 -3
- package/dist/chunk-2FHLHZAL.cjs.map +1 -0
- package/dist/{chunk-PYMV7HLI.js → chunk-3TLL5OID.js} +2 -2
- package/dist/{chunk-LMUDHBWR.js → chunk-4YFMSPBU.js} +2 -2
- package/dist/{chunk-3I6V7PI4.cjs → chunk-7ZSU4MQZ.cjs} +45 -45
- package/dist/{chunk-3I6V7PI4.cjs.map → chunk-7ZSU4MQZ.cjs.map} +1 -1
- package/dist/{chunk-UB2OY7FD.js → chunk-AGR4P4UZ.js} +38 -2
- package/dist/chunk-AGR4P4UZ.js.map +1 -0
- package/dist/{chunk-SHOVAHUB.js → chunk-JK6M6V7G.js} +2 -2
- package/dist/{chunk-WLVZ235X.js → chunk-OK7T2LHK.js} +229 -2
- package/dist/chunk-OK7T2LHK.js.map +1 -0
- package/dist/{chunk-AHCENCU4.cjs → chunk-T4XWVPJK.cjs} +253 -26
- package/dist/chunk-T4XWVPJK.cjs.map +1 -0
- package/dist/{chunk-FKONE6AO.cjs → chunk-YJLCBA7V.cjs} +3 -3
- package/dist/{chunk-FKONE6AO.cjs.map → chunk-YJLCBA7V.cjs.map} +1 -1
- package/dist/{easing-CNGk-W6d.d.ts → easing-lM0Xo9Ni.d.cts} +14 -2
- package/dist/{easing-CNGk-W6d.d.cts → easing-lM0Xo9Ni.d.ts} +14 -2
- package/dist/extensions/index.cjs +27 -3
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +2 -1
- package/dist/extensions/index.d.ts +2 -1
- package/dist/extensions/index.js +26 -2
- package/dist/{index-CTCc3m3C.d.ts → index-B16wbOn_.d.ts} +1 -0
- package/dist/{index-BcHyG0Wq.d.cts → index-BAt14aIU.d.cts} +1 -0
- package/dist/index.cjs +32 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/dist/parameters/index.cjs +2 -2
- package/dist/parameters/index.d.cts +1 -1
- package/dist/parameters/index.d.ts +1 -1
- package/dist/parameters/index.js +1 -1
- package/dist/{player-W-5DX3Go.d.ts → player-DV4Jujdq.d.ts} +1 -1
- package/dist/{player-Dg0FT0UI.d.cts → player-DrcP2xqj.d.cts} +1 -1
- package/dist/vector/index.cjs +472 -472
- package/dist/vector/index.d.cts +1 -1
- package/dist/vector/index.d.ts +1 -1
- package/dist/vector/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-AHCENCU4.cjs.map +0 -1
- package/dist/chunk-UB2OY7FD.js.map +0 -1
- package/dist/chunk-WLVZ235X.js.map +0 -1
- package/dist/chunk-XZ4L3R4K.cjs.map +0 -1
- /package/dist/{chunk-PYMV7HLI.js.map → chunk-3TLL5OID.js.map} +0 -0
- /package/dist/{chunk-LMUDHBWR.js.map → chunk-4YFMSPBU.js.map} +0 -0
- /package/dist/{chunk-SHOVAHUB.js.map → chunk-JK6M6V7G.js.map} +0 -0
|
@@ -15,6 +15,10 @@ var _chunkP2CTDJNFcjs = require('./chunk-P2CTDJNF.cjs');
|
|
|
15
15
|
var _chunkCKRNELPOcjs = require('./chunk-CKRNELPO.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
var _chunk66IMF6ODcjs = require('./chunk-66IMF6OD.cjs');
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
18
22
|
var _chunkIFHKKVXHcjs = require('./chunk-IFHKKVXH.cjs');
|
|
19
23
|
|
|
20
24
|
// src/extensions/table/nesting.ts
|
|
@@ -140,7 +144,7 @@ function unnestTables(tr, ranges) {
|
|
|
140
144
|
const node = nodes[i];
|
|
141
145
|
const $pos = tr.doc.resolve(pos);
|
|
142
146
|
const parent = $pos.parent;
|
|
143
|
-
const filler = parent.childCount === 1 ? _optionalChain([parent, 'access',
|
|
147
|
+
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;
|
|
144
148
|
if (filler) tr.replaceWith(pos, pos + node.nodeSize, filler);
|
|
145
149
|
else tr.delete(pos, pos + node.nodeSize);
|
|
146
150
|
}
|
|
@@ -1058,7 +1062,7 @@ var _extensiontable = require('@tiptap/extension-table'); var _Table = _interopR
|
|
|
1058
1062
|
var _extensiontablerow = require('@tiptap/extension-table-row'); var _TableRow = _interopRequireWildcard(_extensiontablerow);
|
|
1059
1063
|
var _extensiontableheader = require('@tiptap/extension-table-header'); var _TableHeader = _interopRequireWildcard(_extensiontableheader);
|
|
1060
1064
|
var _extensiontablecell = require('@tiptap/extension-table-cell'); var _TableCell = _interopRequireWildcard(_extensiontablecell);
|
|
1061
|
-
var resolveExt = (mod, name) => _optionalChain([mod, 'optionalAccess',
|
|
1065
|
+
var resolveExt = (mod, name) => _optionalChain([mod, 'optionalAccess', _7 => _7[name]]) || _optionalChain([mod, 'optionalAccess', _8 => _8.default, 'optionalAccess', _9 => _9[name]]) || _optionalChain([mod, 'optionalAccess', _10 => _10.default, 'optionalAccess', _11 => _11.default]) || _optionalChain([mod, 'optionalAccess', _12 => _12.default]) || mod;
|
|
1062
1066
|
var BaseTable = resolveExt(_Table, "Table");
|
|
1063
1067
|
var BaseTableRow = resolveExt(_TableRow, "TableRow");
|
|
1064
1068
|
var BaseTableHeader = resolveExt(_TableHeader, "TableHeader");
|
|
@@ -1078,7 +1082,7 @@ function normalizeTableCellColor(value) {
|
|
|
1078
1082
|
var cellAttributes = () => ({
|
|
1079
1083
|
align: {
|
|
1080
1084
|
default: null,
|
|
1081
|
-
parseHTML: (element) => normalizeTableCellAlignment(_optionalChain([element, 'access',
|
|
1085
|
+
parseHTML: (element) => normalizeTableCellAlignment(_optionalChain([element, 'access', _13 => _13.style, 'optionalAccess', _14 => _14.textAlign]) || element.getAttribute("align")),
|
|
1082
1086
|
renderHTML: (attrs) => {
|
|
1083
1087
|
const align = normalizeTableCellAlignment(attrs.align);
|
|
1084
1088
|
return align ? { style: `text-align: ${align}` } : {};
|
|
@@ -1087,7 +1091,7 @@ var cellAttributes = () => ({
|
|
|
1087
1091
|
backgroundColor: {
|
|
1088
1092
|
default: null,
|
|
1089
1093
|
parseHTML: (element) => normalizeTableCellColor(
|
|
1090
|
-
element.getAttribute("data-background-color") || _optionalChain([element, 'access',
|
|
1094
|
+
element.getAttribute("data-background-color") || _optionalChain([element, 'access', _15 => _15.style, 'optionalAccess', _16 => _16.backgroundColor]) || element.getAttribute("bgcolor")
|
|
1091
1095
|
),
|
|
1092
1096
|
renderHTML: (attrs) => {
|
|
1093
1097
|
const color = normalizeTableCellColor(attrs.backgroundColor);
|
|
@@ -1158,18 +1162,18 @@ var Table = BaseTable.extend({
|
|
|
1158
1162
|
return { markdown: { serialize: serializeTableMarkdown } };
|
|
1159
1163
|
},
|
|
1160
1164
|
addProseMirrorPlugins() {
|
|
1161
|
-
return [..._nullishCoalesce(_optionalChain([this, 'access',
|
|
1165
|
+
return [..._nullishCoalesce(_optionalChain([this, 'access', _17 => _17.parent, 'optionalCall', _18 => _18()]), () => ( [])), createTableNestingPlugin()];
|
|
1162
1166
|
}
|
|
1163
1167
|
});
|
|
1164
1168
|
var TableRow = BaseTableRow;
|
|
1165
1169
|
var TableCell = BaseTableCell.extend({
|
|
1166
1170
|
addAttributes() {
|
|
1167
|
-
return { ..._optionalChain([this, 'access',
|
|
1171
|
+
return { ..._optionalChain([this, 'access', _19 => _19.parent, 'optionalCall', _20 => _20()]), ...cellAttributes() };
|
|
1168
1172
|
}
|
|
1169
1173
|
});
|
|
1170
1174
|
var TableHeader = BaseTableHeader.extend({
|
|
1171
1175
|
addAttributes() {
|
|
1172
|
-
return { ..._optionalChain([this, 'access',
|
|
1176
|
+
return { ..._optionalChain([this, 'access', _21 => _21.parent, 'optionalCall', _22 => _22()]), ...cellAttributes() };
|
|
1173
1177
|
}
|
|
1174
1178
|
});
|
|
1175
1179
|
function createTableExtensions(options = {}) {
|
|
@@ -1319,7 +1323,7 @@ var ChartNodeView = (_class = class {
|
|
|
1319
1323
|
destroy() {
|
|
1320
1324
|
this.editor.off("update", this.onEditorUpdate);
|
|
1321
1325
|
this.unsubscribe();
|
|
1322
|
-
_optionalChain([this, 'access',
|
|
1326
|
+
_optionalChain([this, 'access', _23 => _23.renderer, 'optionalAccess', _24 => _24.destroy, 'call', _25 => _25()]);
|
|
1323
1327
|
this.controller.destroy();
|
|
1324
1328
|
}
|
|
1325
1329
|
}, _class);
|
|
@@ -1392,7 +1396,7 @@ function arraysEqual(a, b, eq) {
|
|
|
1392
1396
|
}
|
|
1393
1397
|
function scrollDomAtPos(view, pos, behavior = "smooth") {
|
|
1394
1398
|
try {
|
|
1395
|
-
const dom = _optionalChain([view, 'optionalAccess',
|
|
1399
|
+
const dom = _optionalChain([view, 'optionalAccess', _26 => _26.nodeDOM, 'optionalCall', _27 => _27(pos)]);
|
|
1396
1400
|
if (dom && typeof dom.scrollIntoView === "function") {
|
|
1397
1401
|
dom.scrollIntoView({ block: "start", behavior });
|
|
1398
1402
|
}
|
|
@@ -1407,7 +1411,7 @@ function syncInitialContent(editor, sync) {
|
|
|
1407
1411
|
errorOnInvalidContent: false
|
|
1408
1412
|
});
|
|
1409
1413
|
const tr = sync(_state.EditorState.create({ doc }));
|
|
1410
|
-
if (_optionalChain([tr, 'optionalAccess',
|
|
1414
|
+
if (_optionalChain([tr, 'optionalAccess', _28 => _28.docChanged])) editor.options.content = tr.doc;
|
|
1411
1415
|
} catch (e2) {
|
|
1412
1416
|
}
|
|
1413
1417
|
}
|
|
@@ -1427,7 +1431,7 @@ function getDocumentCharts(doc, typeName = "chart") {
|
|
|
1427
1431
|
return charts;
|
|
1428
1432
|
}
|
|
1429
1433
|
function isChartEnabled(editor) {
|
|
1430
|
-
return !!_optionalChain([editor, 'optionalAccess',
|
|
1434
|
+
return !!_optionalChain([editor, 'optionalAccess', _29 => _29.schema, 'optionalAccess', _30 => _30.nodes, 'optionalAccess', _31 => _31.chart]);
|
|
1431
1435
|
}
|
|
1432
1436
|
function readSpec(value) {
|
|
1433
1437
|
let input = value;
|
|
@@ -1459,7 +1463,7 @@ function syncChartIds(state, typeName, generateId) {
|
|
|
1459
1463
|
tr = _nullishCoalesce(tr, () => ( state.tr));
|
|
1460
1464
|
tr.setNodeMarkup(chart.pos, void 0, { ...chart.node.attrs, id });
|
|
1461
1465
|
}
|
|
1462
|
-
return _nullishCoalesce(_optionalChain([tr, 'optionalAccess',
|
|
1466
|
+
return _nullishCoalesce(_optionalChain([tr, 'optionalAccess', _32 => _32.setMeta, 'call', _33 => _33("addToHistory", false)]), () => ( null));
|
|
1463
1467
|
}
|
|
1464
1468
|
function staticChartSvg(node, options) {
|
|
1465
1469
|
const spec = node.attrs.spec;
|
|
@@ -1534,7 +1538,7 @@ var Chart = _core.Node.create({
|
|
|
1534
1538
|
priority: 60,
|
|
1535
1539
|
getAttrs: (element) => {
|
|
1536
1540
|
const code = element.querySelector("code");
|
|
1537
|
-
const language = _nullishCoalesce(_nullishCoalesce(_optionalChain([code, 'optionalAccess',
|
|
1541
|
+
const language = _nullishCoalesce(_nullishCoalesce(_optionalChain([code, 'optionalAccess', _34 => _34.getAttribute, 'call', _35 => _35("class")]), () => ( element.getAttribute("data-language"))), () => ( ""));
|
|
1538
1542
|
if (!/(?:^|\s)language-mermaid(?:\s|$)/.test(language) && language !== "mermaid") return false;
|
|
1539
1543
|
const result = _chunkTKPPIVW7cjs.chartFromMermaid.call(void 0, _nullishCoalesce((_nullishCoalesce(code, () => ( element))).textContent, () => ( "")));
|
|
1540
1544
|
return result.family ? { spec: result.spec } : false;
|
|
@@ -1554,7 +1558,7 @@ var Chart = _core.Node.create({
|
|
|
1554
1558
|
];
|
|
1555
1559
|
},
|
|
1556
1560
|
renderText({ node }) {
|
|
1557
|
-
return `[Chart: ${_optionalChain([node, 'access',
|
|
1561
|
+
return `[Chart: ${_optionalChain([node, 'access', _36 => _36.attrs, 'access', _37 => _37.spec, 'optionalAccess', _38 => _38.title]) || "untitled"}]`;
|
|
1558
1562
|
},
|
|
1559
1563
|
addStorage() {
|
|
1560
1564
|
return {
|
|
@@ -1856,13 +1860,13 @@ function getTableActionState(editor, action, params = {}) {
|
|
|
1856
1860
|
if (params.align !== void 0 && params.align !== null && !normalizeTableCellAlignment(params.align)) {
|
|
1857
1861
|
return 'Alignment must be "left", "center", "right", "justify" or null.';
|
|
1858
1862
|
}
|
|
1859
|
-
if (!_optionalChain([editor, 'access',
|
|
1863
|
+
if (!_optionalChain([editor, 'access', _39 => _39.schema, 'access', _40 => _40.nodes, 'access', _41 => _41.tableCell, 'optionalAccess', _42 => _42.spec, 'access', _43 => _43.attrs, 'optionalAccess', _44 => _44.align])) return "Cell alignment is not supported by this schema.";
|
|
1860
1864
|
return true;
|
|
1861
1865
|
case "setCellBackground":
|
|
1862
1866
|
if (params.color !== void 0 && params.color !== null && !normalizeTableCellColor(params.color)) {
|
|
1863
1867
|
return "Color must be a CSS color such as #fde68a, rgb(\u2026) or a color name, or null.";
|
|
1864
1868
|
}
|
|
1865
|
-
if (!_optionalChain([editor, 'access',
|
|
1869
|
+
if (!_optionalChain([editor, 'access', _45 => _45.schema, 'access', _46 => _46.nodes, 'access', _47 => _47.tableCell, 'optionalAccess', _48 => _48.spec, 'access', _49 => _49.attrs, 'optionalAccess', _50 => _50.backgroundColor])) return "Cell backgrounds are not supported by this schema.";
|
|
1866
1870
|
return true;
|
|
1867
1871
|
default:
|
|
1868
1872
|
return can(editor, (c) => c[action]()) ? true : "This table action is not available here.";
|
|
@@ -1925,7 +1929,7 @@ function getTableState(editor) {
|
|
|
1925
1929
|
const rect = _tables.selectedRect.call(void 0, state);
|
|
1926
1930
|
const { map, table } = rect;
|
|
1927
1931
|
const cellAt = (row, col) => table.nodeAt(map.map[row * map.width + col]);
|
|
1928
|
-
const allHeaders = (positions) => positions.length > 0 && positions.every((pos) => _optionalChain([table, 'access',
|
|
1932
|
+
const allHeaders = (positions) => positions.length > 0 && positions.every((pos) => _optionalChain([table, 'access', _51 => _51.nodeAt, 'call', _52 => _52(pos), 'optionalAccess', _53 => _53.type, 'access', _54 => _54.name]) === "tableHeader");
|
|
1929
1933
|
const firstRow = map.cellsInRect({ left: 0, right: map.width, top: 0, bottom: 1 });
|
|
1930
1934
|
const firstColumn = map.cellsInRect({ left: 0, right: 1, top: 0, bottom: map.height });
|
|
1931
1935
|
const cell = cellAt(rect.top, rect.left);
|
|
@@ -1939,9 +1943,9 @@ function getTableState(editor) {
|
|
|
1939
1943
|
column: rect.left,
|
|
1940
1944
|
headerRow: allHeaders(firstRow),
|
|
1941
1945
|
headerColumn: allHeaders(firstColumn),
|
|
1942
|
-
headerCell: _optionalChain([cell, 'optionalAccess',
|
|
1943
|
-
cellAlignment: normalizeTableCellAlignment(_optionalChain([cell, 'optionalAccess',
|
|
1944
|
-
cellBackground: normalizeTableCellColor(_optionalChain([cell, 'optionalAccess',
|
|
1946
|
+
headerCell: _optionalChain([cell, 'optionalAccess', _55 => _55.type, 'access', _56 => _56.name]) === "tableHeader",
|
|
1947
|
+
cellAlignment: normalizeTableCellAlignment(_optionalChain([cell, 'optionalAccess', _57 => _57.attrs, 'access', _58 => _58.align])),
|
|
1948
|
+
cellBackground: normalizeTableCellColor(_optionalChain([cell, 'optionalAccess', _59 => _59.attrs, 'access', _60 => _60.backgroundColor]))
|
|
1945
1949
|
};
|
|
1946
1950
|
} catch (e6) {
|
|
1947
1951
|
return { ...base, inTable: true };
|
|
@@ -1961,10 +1965,10 @@ function createTableStore(editor) {
|
|
|
1961
1965
|
listeners.forEach((listener) => listener());
|
|
1962
1966
|
};
|
|
1963
1967
|
const detach = () => {
|
|
1964
|
-
_optionalChain([editor, 'optionalAccess',
|
|
1965
|
-
_optionalChain([editor, 'optionalAccess',
|
|
1966
|
-
_optionalChain([editor, 'optionalAccess',
|
|
1967
|
-
_optionalChain([editor, 'optionalAccess',
|
|
1968
|
+
_optionalChain([editor, 'optionalAccess', _61 => _61.off, 'call', _62 => _62("transaction", update)]);
|
|
1969
|
+
_optionalChain([editor, 'optionalAccess', _63 => _63.off, 'call', _64 => _64("update", update)]);
|
|
1970
|
+
_optionalChain([editor, 'optionalAccess', _65 => _65.off, 'call', _66 => _66("focus", update)]);
|
|
1971
|
+
_optionalChain([editor, 'optionalAccess', _67 => _67.off, 'call', _68 => _68("destroy", update)]);
|
|
1968
1972
|
};
|
|
1969
1973
|
return {
|
|
1970
1974
|
getSnapshot: () => {
|
|
@@ -1999,6 +2003,229 @@ function createTableStore(editor) {
|
|
|
1999
2003
|
};
|
|
2000
2004
|
}
|
|
2001
2005
|
|
|
2006
|
+
// src/extensions/agent-caret.ts
|
|
2007
|
+
|
|
2008
|
+
|
|
2009
|
+
var _view = require('@tiptap/pm/view');
|
|
2010
|
+
var DEFAULT_AGENT_CARET_COLOR = "#8b5cf6";
|
|
2011
|
+
var DEFAULT_AGENT_CARET_NAME = "Agent";
|
|
2012
|
+
var agentCaretPluginKey = new (0, _state.PluginKey)("agentCaret");
|
|
2013
|
+
var clamp = (pos, size) => Math.max(0, Math.min(size, Math.round(pos)));
|
|
2014
|
+
function caretWidget(caret) {
|
|
2015
|
+
return (view) => {
|
|
2016
|
+
const doc = view.dom.ownerDocument;
|
|
2017
|
+
const el = doc.createElement("span");
|
|
2018
|
+
el.className = "pe-agent-caret";
|
|
2019
|
+
el.setAttribute("data-agent-id", caret.id);
|
|
2020
|
+
el.setAttribute("contenteditable", "false");
|
|
2021
|
+
el.setAttribute("aria-hidden", "true");
|
|
2022
|
+
el.style.cssText = `position:relative;margin-left:-1px;margin-right:-1px;border-left:2px solid ${caret.color};word-break:normal;pointer-events:none;`;
|
|
2023
|
+
const label = doc.createElement("span");
|
|
2024
|
+
label.className = "pe-agent-caret-label";
|
|
2025
|
+
label.textContent = caret.name;
|
|
2026
|
+
label.style.cssText = `position:absolute;left:-2px;bottom:100%;background:${caret.color};color:#fff;font:600 11px/1.5 system-ui,sans-serif;padding:0 5px;border-radius:3px 3px 3px 0;white-space:nowrap;user-select:none;pointer-events:none;`;
|
|
2027
|
+
el.append("\u2060", label, "\u2060");
|
|
2028
|
+
return el;
|
|
2029
|
+
};
|
|
2030
|
+
}
|
|
2031
|
+
var tint = (color, percent) => `color-mix(in srgb, ${color} ${percent}%, transparent)`;
|
|
2032
|
+
function buildDecorations(state, carets) {
|
|
2033
|
+
const decorations = [];
|
|
2034
|
+
for (const caret of carets) {
|
|
2035
|
+
for (const range of caret.changed) {
|
|
2036
|
+
decorations.push(
|
|
2037
|
+
_view.Decoration.inline(range.from, range.to, {
|
|
2038
|
+
class: "pe-agent-changed",
|
|
2039
|
+
"data-agent-id": caret.id,
|
|
2040
|
+
style: `background-color:${tint(caret.color, 18)};`
|
|
2041
|
+
})
|
|
2042
|
+
);
|
|
2043
|
+
}
|
|
2044
|
+
const from = Math.min(caret.anchor, caret.head);
|
|
2045
|
+
const to = Math.max(caret.anchor, caret.head);
|
|
2046
|
+
if (from < to) {
|
|
2047
|
+
decorations.push(
|
|
2048
|
+
_view.Decoration.inline(from, to, {
|
|
2049
|
+
class: "pe-agent-selection",
|
|
2050
|
+
"data-agent-id": caret.id,
|
|
2051
|
+
style: `background-color:${tint(caret.color, 28)};`
|
|
2052
|
+
})
|
|
2053
|
+
);
|
|
2054
|
+
}
|
|
2055
|
+
decorations.push(
|
|
2056
|
+
_view.Decoration.widget(caret.head, caretWidget(caret), {
|
|
2057
|
+
key: `agent-caret:${caret.id}:${caret.name}:${caret.color}`,
|
|
2058
|
+
side: 10,
|
|
2059
|
+
ignoreSelection: true
|
|
2060
|
+
})
|
|
2061
|
+
);
|
|
2062
|
+
}
|
|
2063
|
+
return _view.DecorationSet.create(state.doc, decorations);
|
|
2064
|
+
}
|
|
2065
|
+
function createAgentCaretPlugin() {
|
|
2066
|
+
return new (0, _state.Plugin)({
|
|
2067
|
+
key: agentCaretPluginKey,
|
|
2068
|
+
state: {
|
|
2069
|
+
init: (_, state) => ({ carets: [], spans: {}, decorations: _view.DecorationSet.create(state.doc, []) }),
|
|
2070
|
+
apply(tr, value, _old, state) {
|
|
2071
|
+
const meta = tr.getMeta(agentCaretPluginKey);
|
|
2072
|
+
if (!tr.docChanged && !meta) return value;
|
|
2073
|
+
const size = state.doc.content.size;
|
|
2074
|
+
let carets = value.carets;
|
|
2075
|
+
let spans = value.spans;
|
|
2076
|
+
if (tr.docChanged) {
|
|
2077
|
+
const anchorBias = (c) => c.anchor <= c.head ? 1 : -1;
|
|
2078
|
+
carets = carets.map((c) => ({
|
|
2079
|
+
...c,
|
|
2080
|
+
anchor: tr.mapping.map(c.anchor, anchorBias(c)),
|
|
2081
|
+
head: tr.mapping.map(c.head, -anchorBias(c)),
|
|
2082
|
+
changed: c.changed.map((r) => ({ from: tr.mapping.map(r.from, 1), to: tr.mapping.map(r.to, -1) })).filter((r) => r.from < r.to)
|
|
2083
|
+
}));
|
|
2084
|
+
const own = !!meta && "span" in meta;
|
|
2085
|
+
spans = Object.fromEntries(
|
|
2086
|
+
Object.entries(spans).map(([id, s]) => {
|
|
2087
|
+
const from = tr.mapping.map(s.from, 1);
|
|
2088
|
+
return [id, { from, to: Math.max(from, tr.mapping.map(s.to, -1)), foreign: s.foreign || !own }];
|
|
2089
|
+
})
|
|
2090
|
+
);
|
|
2091
|
+
}
|
|
2092
|
+
if (meta && "set" in meta) {
|
|
2093
|
+
const input = meta.set;
|
|
2094
|
+
const prev = carets.find((c) => c.id === input.id);
|
|
2095
|
+
const anchor = clamp(input.from, size);
|
|
2096
|
+
const caret = {
|
|
2097
|
+
id: input.id,
|
|
2098
|
+
name: _nullishCoalesce(_nullishCoalesce(input.name, () => ( _optionalChain([prev, 'optionalAccess', _69 => _69.name]))), () => ( DEFAULT_AGENT_CARET_NAME)),
|
|
2099
|
+
color: _nullishCoalesce(_nullishCoalesce(input.color, () => ( _optionalChain([prev, 'optionalAccess', _70 => _70.color]))), () => ( DEFAULT_AGENT_CARET_COLOR)),
|
|
2100
|
+
anchor,
|
|
2101
|
+
head: input.to === void 0 ? anchor : clamp(input.to, size),
|
|
2102
|
+
changed: _nullishCoalesce(_optionalChain([prev, 'optionalAccess', _71 => _71.changed]), () => ( []))
|
|
2103
|
+
};
|
|
2104
|
+
carets = prev ? carets.map((c) => c.id === input.id ? caret : c) : [...carets, caret];
|
|
2105
|
+
} else if (meta && "clear" in meta) {
|
|
2106
|
+
carets = meta.clear === null ? [] : carets.filter((c) => c.id !== meta.clear);
|
|
2107
|
+
} else if (meta && "changed" in meta) {
|
|
2108
|
+
const { id, ranges } = meta.changed;
|
|
2109
|
+
carets = carets.map(
|
|
2110
|
+
(c) => c.id === id ? { ...c, changed: ranges.map((r) => ({ from: clamp(r.from, size), to: clamp(r.to, size) })).filter((r) => r.from < r.to) } : c
|
|
2111
|
+
);
|
|
2112
|
+
} else if (meta && "span" in meta) {
|
|
2113
|
+
const span = meta.span;
|
|
2114
|
+
spans = { ...spans };
|
|
2115
|
+
if ("end" in span) delete spans[span.id];
|
|
2116
|
+
else spans[span.id] = { from: span.from, to: span.to, foreign: _nullishCoalesce(_optionalChain([spans, 'access', _72 => _72[span.id], 'optionalAccess', _73 => _73.foreign]), () => ( false)) };
|
|
2117
|
+
}
|
|
2118
|
+
return { carets, spans, decorations: buildDecorations(state, carets) };
|
|
2119
|
+
}
|
|
2120
|
+
},
|
|
2121
|
+
props: {
|
|
2122
|
+
decorations: (state) => _optionalChain([agentCaretPluginKey, 'access', _74 => _74.getState, 'call', _75 => _75(state), 'optionalAccess', _76 => _76.decorations])
|
|
2123
|
+
}
|
|
2124
|
+
});
|
|
2125
|
+
}
|
|
2126
|
+
var AgentCaret = _core.Extension.create({
|
|
2127
|
+
name: "agentCaret",
|
|
2128
|
+
addProseMirrorPlugins() {
|
|
2129
|
+
return [createAgentCaretPlugin()];
|
|
2130
|
+
}
|
|
2131
|
+
});
|
|
2132
|
+
function ensureAgentCaret(editor) {
|
|
2133
|
+
if (editor.isDestroyed || agentCaretPluginKey.getState(editor.state)) return;
|
|
2134
|
+
editor.registerPlugin(createAgentCaretPlugin());
|
|
2135
|
+
}
|
|
2136
|
+
function dispatchMeta(editor, meta) {
|
|
2137
|
+
if (editor.isDestroyed) return;
|
|
2138
|
+
ensureAgentCaret(editor);
|
|
2139
|
+
editor.view.dispatch(editor.state.tr.setMeta(agentCaretPluginKey, meta).setMeta("addToHistory", false));
|
|
2140
|
+
}
|
|
2141
|
+
function setAgentCaret(editor, caret) {
|
|
2142
|
+
dispatchMeta(editor, { set: caret });
|
|
2143
|
+
}
|
|
2144
|
+
function clearAgentCaret(editor, id) {
|
|
2145
|
+
if (editor.isDestroyed || !agentCaretPluginKey.getState(editor.state)) return;
|
|
2146
|
+
dispatchMeta(editor, { clear: _nullishCoalesce(id, () => ( null)) });
|
|
2147
|
+
}
|
|
2148
|
+
function markAgentChanges(editor, id, ranges) {
|
|
2149
|
+
if (!ranges.length && !agentCaretPluginKey.getState(editor.state)) return;
|
|
2150
|
+
dispatchMeta(editor, { changed: { id, ranges } });
|
|
2151
|
+
}
|
|
2152
|
+
function getAgentCarets(state) {
|
|
2153
|
+
return _nullishCoalesce(_optionalChain([agentCaretPluginKey, 'access', _77 => _77.getState, 'call', _78 => _78(state), 'optionalAccess', _79 => _79.carets]), () => ( []));
|
|
2154
|
+
}
|
|
2155
|
+
function replaceWithTextTransaction(state, from, to, text) {
|
|
2156
|
+
return /[\r\n]/.test(text) ? state.tr.replace(from, to, _chunk66IMF6ODcjs.plainTextToSlice.call(void 0, text, state.schema)) : text ? state.tr.insertText(text, from, to) : state.tr.delete(from, to);
|
|
2157
|
+
}
|
|
2158
|
+
var NO_HISTORY = (tr) => tr.setMeta("addToHistory", false).setMeta(_chunkIFHKKVXHcjs.TRACK_CHANGES_SKIP_META, true);
|
|
2159
|
+
var cannotAnimate = () => typeof document === "undefined" || document.hidden === true;
|
|
2160
|
+
async function typeAgentText(editor, options) {
|
|
2161
|
+
const { from, to, text, caret, signal } = options;
|
|
2162
|
+
const cps = _nullishCoalesce(options.charsPerSecond, () => ( 60));
|
|
2163
|
+
const chars = Array.from(text);
|
|
2164
|
+
ensureAgentCaret(editor);
|
|
2165
|
+
const show = (tr, anchor, head = anchor) => tr.setMeta(agentCaretPluginKey, { set: { ...caret, from: anchor, to: head } });
|
|
2166
|
+
const commit = (start, end) => {
|
|
2167
|
+
const tr = replaceWithTextTransaction(editor.state, start, end, text);
|
|
2168
|
+
const insertedTo = tr.mapping.map(end, 1);
|
|
2169
|
+
const insertedFrom = Math.min(tr.mapping.map(start, -1), insertedTo);
|
|
2170
|
+
editor.view.dispatch(show(tr, insertedTo).scrollIntoView());
|
|
2171
|
+
if (insertedFrom < insertedTo) markAgentChanges(editor, caret.id, [{ from: insertedFrom, to: insertedTo }]);
|
|
2172
|
+
return { from: insertedFrom, to: insertedTo };
|
|
2173
|
+
};
|
|
2174
|
+
const animate = Number.isFinite(cps) && cps > 0 && chars.length > 0 && (options.wait || !cannotAnimate());
|
|
2175
|
+
if (!animate) return commit(from, to);
|
|
2176
|
+
const wait = _nullishCoalesce(options.wait, () => ( ((ms) => new Promise((resolve) => setTimeout(resolve, ms)))));
|
|
2177
|
+
const duration = Math.min(_nullishCoalesce(options.maxDurationMs, () => ( 1500)), chars.length / cps * 1e3);
|
|
2178
|
+
const frameMs = 1e3 / 30;
|
|
2179
|
+
const frames = Math.max(1, Math.min(chars.length, Math.round(duration / frameMs)));
|
|
2180
|
+
const original = editor.state.doc.slice(from, to);
|
|
2181
|
+
const inverses = [];
|
|
2182
|
+
const span = () => agentCaretPluginKey.getState(editor.state).spans[caret.id];
|
|
2183
|
+
editor.view.dispatch(NO_HISTORY(editor.state.tr.setMeta(agentCaretPluginKey, { span: { id: caret.id, from, to } })));
|
|
2184
|
+
editor.view.dispatch(NO_HISTORY(show(editor.state.tr, from, to)));
|
|
2185
|
+
const rollback = () => {
|
|
2186
|
+
const s = span();
|
|
2187
|
+
const tr = editor.state.tr;
|
|
2188
|
+
if (!s.foreign) inverses.slice().reverse().forEach((step) => tr.step(step));
|
|
2189
|
+
else tr.replace(s.from, s.to, original);
|
|
2190
|
+
tr.setMeta(agentCaretPluginKey, { span: { id: caret.id, end: true } });
|
|
2191
|
+
editor.view.dispatch(NO_HISTORY(tr));
|
|
2192
|
+
return { from: s.from, to: s.from + original.size };
|
|
2193
|
+
};
|
|
2194
|
+
try {
|
|
2195
|
+
if (from < to) await wait(_nullishCoalesce(options.selectMs, () => ( 250)));
|
|
2196
|
+
for (let i = 1; i <= frames; i++) {
|
|
2197
|
+
if (_optionalChain([signal, 'optionalAccess', _80 => _80.aborted])) throw new Error("Typing was cancelled; the document is unchanged.");
|
|
2198
|
+
if (editor.isDestroyed) throw new Error("The editor was closed while the agent was typing.");
|
|
2199
|
+
const s = span();
|
|
2200
|
+
const prefix = chars.slice(0, Math.round(chars.length * i / frames)).join("");
|
|
2201
|
+
const tr = replaceWithTextTransaction(editor.state, s.from, s.to, prefix);
|
|
2202
|
+
tr.steps.forEach((step, k) => inverses.push(step.invert(tr.docs[k])));
|
|
2203
|
+
const end = tr.mapping.map(s.to, 1);
|
|
2204
|
+
tr.setMeta(agentCaretPluginKey, { span: { id: caret.id, from: Math.min(tr.mapping.map(s.from, -1), end), to: end } });
|
|
2205
|
+
editor.view.dispatch(NO_HISTORY(tr));
|
|
2206
|
+
editor.view.dispatch(NO_HISTORY(show(editor.state.tr, end)));
|
|
2207
|
+
if (i < frames) await wait(duration / frames);
|
|
2208
|
+
}
|
|
2209
|
+
} catch (error) {
|
|
2210
|
+
if (!editor.isDestroyed) rollback();
|
|
2211
|
+
throw error;
|
|
2212
|
+
}
|
|
2213
|
+
const restored = rollback();
|
|
2214
|
+
return commit(restored.from, restored.to);
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
|
|
2218
|
+
|
|
2219
|
+
|
|
2220
|
+
|
|
2221
|
+
|
|
2222
|
+
|
|
2223
|
+
|
|
2224
|
+
|
|
2225
|
+
|
|
2226
|
+
|
|
2227
|
+
|
|
2228
|
+
|
|
2002
2229
|
|
|
2003
2230
|
|
|
2004
2231
|
|
|
@@ -2058,5 +2285,5 @@ function createTableStore(editor) {
|
|
|
2058
2285
|
|
|
2059
2286
|
|
|
2060
2287
|
|
|
2061
|
-
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.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;
|
|
2062
|
-
//# sourceMappingURL=chunk-
|
|
2288
|
+
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.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;
|
|
2289
|
+
//# sourceMappingURL=chunk-T4XWVPJK.cjs.map
|