@pixerate/editor 0.43.0 → 0.45.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/README.md +27 -2
- package/THIRD_PARTY_NOTICES.md +4 -0
- package/dist/agent/index.cjs +548 -45
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +47 -17
- package/dist/agent/index.d.ts +47 -17
- package/dist/agent/index.js +536 -33
- package/dist/agent/index.js.map +1 -1
- package/dist/{builtins-BLud97fC.d.cts → builtins-CZW-aYKS.d.cts} +1 -1
- package/dist/{builtins-D0BDyAgw.d.ts → builtins-DghNQbT-.d.ts} +1 -1
- package/dist/{chunk-I6BZB5ZH.cjs → chunk-EFDCLENW.cjs} +73 -6
- package/dist/chunk-EFDCLENW.cjs.map +1 -0
- package/dist/chunk-HHQ4XJWT.js +826 -0
- package/dist/chunk-HHQ4XJWT.js.map +1 -0
- package/dist/chunk-J3R2OWOE.cjs +1465 -0
- package/dist/chunk-J3R2OWOE.cjs.map +1 -0
- package/dist/chunk-K2LVZ4FA.cjs +826 -0
- package/dist/chunk-K2LVZ4FA.cjs.map +1 -0
- package/dist/{chunk-6MDQKHRH.cjs → chunk-N4MLNJPO.cjs} +21 -899
- package/dist/chunk-N4MLNJPO.cjs.map +1 -0
- package/dist/chunk-PQM5W7ZN.js +168 -0
- package/dist/chunk-PQM5W7ZN.js.map +1 -0
- package/dist/{chunk-DDADOHJW.js → chunk-Q25ZS4F7.js} +5 -883
- package/dist/chunk-Q25ZS4F7.js.map +1 -0
- package/dist/chunk-TK2XZK6Z.js +1465 -0
- package/dist/chunk-TK2XZK6Z.js.map +1 -0
- package/dist/commands/index.cjs +3 -2
- package/dist/commands/index.cjs.map +1 -1
- package/dist/commands/index.d.cts +5 -5
- package/dist/commands/index.d.ts +5 -5
- package/dist/commands/index.js +2 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/extensions/index.cjs +4 -4
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +3 -3
- package/dist/extensions/index.d.ts +3 -3
- package/dist/extensions/index.js +12 -12
- package/dist/generation/index.cjs +2 -2
- package/dist/generation/index.d.cts +4 -4
- package/dist/generation/index.d.ts +4 -4
- package/dist/generation/index.js +1 -1
- package/dist/image-editor/index.cjs +24 -24
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +2 -2
- package/dist/image-editor/index.d.ts +2 -2
- package/dist/image-editor/index.js +24 -24
- package/dist/image-editor/index.js.map +1 -1
- package/dist/{index-C6gaQRH0.d.cts → index-CfOQf70b.d.cts} +1 -1
- package/dist/{index-DXAv_R08.d.ts → index-jwJ_onWf.d.ts} +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +12 -12
- package/dist/parameters/index.d.cts +2 -2
- package/dist/parameters/index.d.ts +2 -2
- package/dist/{registry-DnzpgY27.d.cts → registry-B4l-lYts.d.cts} +1 -1
- package/dist/{registry-DhVUZioj.d.ts → registry-BfVD-vVg.d.ts} +1 -1
- package/dist/{registry-BDe-vlv3.d.ts → registry-CSlH4iUn.d.ts} +1 -1
- package/dist/{registry-D0GADKc7.d.cts → registry-vz6HOiiy.d.cts} +1 -1
- package/dist/{schema-DYDGdYL9.d.cts → schema-Di0CS6Pe.d.cts} +26 -2
- package/dist/{schema-DYDGdYL9.d.ts → schema-Di0CS6Pe.d.ts} +26 -2
- package/dist/tools/index.cjs +37 -3
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.cts +871 -11
- package/dist/tools/index.d.ts +871 -11
- package/dist/tools/index.js +36 -2
- package/dist/vector/index.cjs +1982 -301
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +624 -154
- package/dist/vector/index.d.ts +624 -154
- package/dist/vector/index.js +1755 -74
- package/dist/vector/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-36BLROHV.js +0 -438
- package/dist/chunk-36BLROHV.js.map +0 -1
- package/dist/chunk-5H2OPMXZ.js +0 -586
- package/dist/chunk-5H2OPMXZ.js.map +0 -1
- package/dist/chunk-6MDQKHRH.cjs.map +0 -1
- package/dist/chunk-D6S5M7HV.js +0 -101
- package/dist/chunk-D6S5M7HV.js.map +0 -1
- package/dist/chunk-DDADOHJW.js.map +0 -1
- package/dist/chunk-I6BZB5ZH.cjs.map +0 -1
- package/dist/chunk-MC2LQN5S.cjs +0 -586
- package/dist/chunk-MC2LQN5S.cjs.map +0 -1
- package/dist/chunk-V7CC7RZ6.cjs +0 -438
- package/dist/chunk-V7CC7RZ6.cjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/chunk-I6BZB5ZH.cjs","../src/tools/schema.ts"],"names":[],"mappings":"AAAA;ACiCA,SAAS,MAAA,CAAO,KAAA,EAA8C;AAC7D,EAAA,GAAA,CAAI,MAAA,IAAU,IAAA,EAAM,OAAO,MAAA;AAC3B,EAAA,GAAA,CAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG,OAAO,OAAA;AACjC,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU,QAAA,EAAU,OAAO,MAAA,CAAO,SAAA,CAAU,KAAK,EAAA,EAAI,UAAA,EAAY,QAAA;AAC5E,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU,SAAA,GAAY,OAAO,MAAA,IAAU,UAAA,GAAa,OAAO,MAAA,IAAU,QAAA,EAAU;AACzF,IAAA,OAAO,OAAO,KAAA;AAAA,EACf;AACA,EAAA,OAAO,WAAA;AACR;AAEA,SAAS,WAAA,CAAY,KAAA,EAAgB,IAAA,EAA+B;AACnE,EAAA,MAAM,OAAA,EAAS,MAAA,CAAO,KAAK,CAAA;AAC3B,EAAA,GAAA,CAAI,KAAA,IAAS,QAAA,EAAU,OAAO,OAAA,IAAW,SAAA,GAAY,OA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A,EAAA,GAAa,KAAA,CAAM,OAAA,EAAS,MAAA,CAAO,QAAA,EAAU;AACpE,MAAA,MAAA,CAAO,IAAA,CAAK,EAAE,IAAA,EAAM,EAAA,EAAI,OAAA,EAAS,CAAA,mBAAA,EAAsB,MAAA,CAAO,QAAQ,CAAA,OAAA,EAAU,CAAC,CAAA;AAAA,IAClF;AACA,IAAA,GAAA,CAAI,MAAA,CAAO,SAAA,IAAa,KAAA,EAAA,GAAa,KAAA,CAAM,OAAA,EAAS,MAAA,CAAO,QAAA,EAAU;AACpE,MAAA,MAAA,CAAO,IAAA,CAAK,EAAE,IAAA,EAAM,EAAA,EAAI,OAAA,EAAS,CAAA,kBAAA,EAAqB,MAAA,CAAO,QAAQ,CAAA,OAAA,EAAU,CAAC,CAAA;AAAA,IACjF;AACA,IAAA,GAAA,CAAI,MAAA,CAAO,KAAA,EAAO;AACjB,MAAA,KAAA,CAAM,OAAA,CAAQ,CAAC,IAAA,EAAM,KAAA,EAAA,GAAU;AAC9B,QAAA,MAAA,CAAO,IAAA,CAAK,GAAG,kBAAA,CAAmB,IAAA,EAAM,MAAA,CAAO,KAAA,EAAO,CAAA,EAAA;AACtD,MAAA;AACF,IAAA;AACD,EAAA;AAEgC,EAAA;AACnB,IAAA;AAC6B,IAAA;AACZ,MAAA;AACoB,QAAA;AAChD,MAAA;AACD,IAAA;AACyC,IAAA;AACO,IAAA;AACtB,MAAA;AACF,MAAA;AACiC,QAAA;AACN,MAAA;AACF,QAAA;AACE,MAAA;AACD,QAAA;AACjD,MAAA;AACD,IAAA;AACD,EAAA;AAEO,EAAA;AACR;AD/C+D;AACA;AACA;AACA","file":"/home/runner/work/editor/editor/packages/core/dist/chunk-I6BZB5ZH.cjs","sourcesContent":[null,"/**\n * JSON-Schema-lite: the subset of JSON Schema used by MCP tool `inputSchema`s,\n * plus a small validator for tool-call arguments. Unknown keywords are ignored.\n */\nexport type JsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';\n\nexport interface JsonSchema {\n\ttype?: JsonSchemaType | readonly JsonSchemaType[];\n\tdescription?: string;\n\ttitle?: string;\n\tenum?: readonly unknown[];\n\tconst?: unknown;\n\tdefault?: unknown;\n\tproperties?: { readonly [key: string]: JsonSchema };\n\trequired?: readonly string[];\n\tadditionalProperties?: boolean | JsonSchema;\n\titems?: JsonSchema;\n\tminItems?: number;\n\tmaxItems?: number;\n\tminimum?: number;\n\tmaximum?: number;\n\tminLength?: number;\n\tmaxLength?: number;\n\tpattern?: string;\n\t[keyword: string]: unknown;\n}\n\nexport interface SchemaValidationError {\n\t/** JSON-pointer-like path to the offending value, e.g. `/node/id` (`\"\"` is the root). */\n\tpath: string;\n\tmessage: string;\n}\n\nfunction typeOf(value: unknown): JsonSchemaType | 'undefined' {\n\tif (value === null) return 'null';\n\tif (Array.isArray(value)) return 'array';\n\tif (typeof value === 'number') return Number.isInteger(value) ? 'integer' : 'number';\n\tif (typeof value === 'string' || typeof value === 'boolean' || typeof value === 'object') {\n\t\treturn typeof value as JsonSchemaType;\n\t}\n\treturn 'undefined';\n}\n\nfunction matchesType(value: unknown, type: JsonSchemaType): boolean {\n\tconst actual = typeOf(value);\n\tif (type === 'number') return actual === 'number' || actual === 'integer';\n\treturn actual === type;\n}\n\nconst isEqual = (a: unknown, b: unknown) => a === b || JSON.stringify(a) === JSON.stringify(b);\n\n/**\n * Validates `value` against `schema` and returns every error found (an empty\n * array means valid). Supports `type` (incl. arrays of types), `enum`, `const`,\n * `properties`, `required`, `additionalProperties`, `items`, `minItems`,\n * `maxItems`, `minimum`, `maximum`, `minLength`, `maxLength` and `pattern`.\n */\nexport function validateJsonSchema(value: unknown, schema: JsonSchema | undefined, path = ''): SchemaValidationError[] {\n\tif (!schema || typeof schema !== 'object') return [];\n\tconst errors: SchemaValidationError[] = [];\n\tconst at = path || '/';\n\n\tif (schema.type !== undefined) {\n\t\tconst types = (Array.isArray(schema.type) ? schema.type : [schema.type]) as JsonSchemaType[];\n\t\tif (!types.some((t) => matchesType(value, t))) {\n\t\t\terrors.push({ path: at, message: `Expected ${types.join(' | ')}, got ${typeOf(value)}.` });\n\t\t\treturn errors;\n\t\t}\n\t}\n\tif (schema.const !== undefined && !isEqual(value, schema.const)) {\n\t\terrors.push({ path: at, message: `Expected ${JSON.stringify(schema.const)}.` });\n\t}\n\tif (schema.enum && !schema.enum.some((option) => isEqual(value, option))) {\n\t\terrors.push({\n\t\t\tpath: at,\n\t\t\tmessage: `Expected one of ${schema.enum.map((o) => JSON.stringify(o)).join(', ')}, got ${JSON.stringify(value)}.`\n\t\t});\n\t}\n\n\tif (typeof value === 'string') {\n\t\tif (schema.minLength !== undefined && value.length < schema.minLength) {\n\t\t\terrors.push({ path: at, message: `Must be at least ${schema.minLength} characters.` });\n\t\t}\n\t\tif (schema.maxLength !== undefined && value.length > schema.maxLength) {\n\t\t\terrors.push({ path: at, message: `Must be at most ${schema.maxLength} characters.` });\n\t\t}\n\t\tif (schema.pattern !== undefined) {\n\t\t\tlet regex: RegExp | null = null;\n\t\t\ttry {\n\t\t\t\tregex = new RegExp(schema.pattern, 'u');\n\t\t\t} catch {\n\t\t\t\t// An invalid pattern in the schema is not the caller's fault.\n\t\t\t}\n\t\t\tif (regex && !regex.test(value)) {\n\t\t\t\terrors.push({ path: at, message: `Must match pattern ${schema.pattern}.` });\n\t\t\t}\n\t\t}\n\t}\n\n\tif (typeof value === 'number') {\n\t\tif (schema.minimum !== undefined && value < schema.minimum) {\n\t\t\terrors.push({ path: at, message: `Must be >= ${schema.minimum}.` });\n\t\t}\n\t\tif (schema.maximum !== undefined && value > schema.maximum) {\n\t\t\terrors.push({ path: at, message: `Must be <= ${schema.maximum}.` });\n\t\t}\n\t}\n\n\tif (Array.isArray(value)) {\n\t\tif (schema.minItems !== undefined && value.length < schema.minItems) {\n\t\t\terrors.push({ path: at, message: `Must have at least ${schema.minItems} items.` });\n\t\t}\n\t\tif (schema.maxItems !== undefined && value.length > schema.maxItems) {\n\t\t\terrors.push({ path: at, message: `Must have at most ${schema.maxItems} items.` });\n\t\t}\n\t\tif (schema.items) {\n\t\t\tvalue.forEach((item, index) => {\n\t\t\t\terrors.push(...validateJsonSchema(item, schema.items, `${path}/${index}`));\n\t\t\t});\n\t\t}\n\t}\n\n\tif (typeOf(value) === 'object') {\n\t\tconst obj = value as Record<string, unknown>;\n\t\tfor (const key of schema.required ?? []) {\n\t\t\tif (obj[key] === undefined) {\n\t\t\t\terrors.push({ path: `${path}/${key}`, message: `Missing required property \"${key}\".` });\n\t\t\t}\n\t\t}\n\t\tconst properties = schema.properties ?? {};\n\t\tfor (const [key, child] of Object.entries(obj)) {\n\t\t\tif (child === undefined) continue;\n\t\t\tif (key in properties) {\n\t\t\t\terrors.push(...validateJsonSchema(child, properties[key], `${path}/${key}`));\n\t\t\t} else if (schema.additionalProperties === false) {\n\t\t\t\terrors.push({ path: `${path}/${key}`, message: `Unknown property \"${key}\".` });\n\t\t\t} else if (typeof schema.additionalProperties === 'object') {\n\t\t\t\terrors.push(...validateJsonSchema(child, schema.additionalProperties, `${path}/${key}`));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn errors;\n}\n"]}
|
package/dist/chunk-MC2LQN5S.cjs
DELETED
|
@@ -1,586 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
-
|
|
3
|
-
var _chunkIFHKKVXHcjs = require('./chunk-IFHKKVXH.cjs');
|
|
4
|
-
|
|
5
|
-
// src/extensions/table/nesting.ts
|
|
6
|
-
var _model = require('@tiptap/pm/model');
|
|
7
|
-
var _state = require('@tiptap/pm/state');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _tables = require('@tiptap/pm/tables');
|
|
13
|
-
var ALLOW_NESTED_TABLES_META = "allowNestedTables";
|
|
14
|
-
var tableNestingPluginKey = new (0, _state.PluginKey)("tableNesting");
|
|
15
|
-
var roleOf = (node) => node.type.spec.tableRole;
|
|
16
|
-
var isTableNode = (node) => roleOf(node) === "table";
|
|
17
|
-
function outermostTableDepth($pos) {
|
|
18
|
-
for (let d = 1; d <= $pos.depth; d++) if (isTableNode($pos.node(d))) return d;
|
|
19
|
-
return -1;
|
|
20
|
-
}
|
|
21
|
-
function isInTableCell($pos) {
|
|
22
|
-
for (let d = $pos.depth; d > 0; d--) {
|
|
23
|
-
const role = roleOf($pos.node(d));
|
|
24
|
-
if (role === "cell" || role === "header_cell") return true;
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
function sliceContainsTable(content) {
|
|
29
|
-
const fragment = content instanceof _model.Slice ? content.content : content;
|
|
30
|
-
let found = false;
|
|
31
|
-
fragment.descendants((node) => {
|
|
32
|
-
if (found) return false;
|
|
33
|
-
if (isTableNode(node)) found = true;
|
|
34
|
-
return !found;
|
|
35
|
-
});
|
|
36
|
-
return found;
|
|
37
|
-
}
|
|
38
|
-
function insertSliceAfterTable(tr, from, to, slice) {
|
|
39
|
-
const $from = tr.doc.resolve(from);
|
|
40
|
-
const depth = outermostTableDepth($from);
|
|
41
|
-
if (depth < 0) return null;
|
|
42
|
-
const tableStart = $from.before(depth);
|
|
43
|
-
const tableEnd = $from.after(depth);
|
|
44
|
-
if (to > from && to < tableEnd) {
|
|
45
|
-
if (tr.selection instanceof _tables.CellSelection && tr.selection.from === from && tr.selection.to === to) {
|
|
46
|
-
tr.deleteSelection();
|
|
47
|
-
} else {
|
|
48
|
-
tr.delete(from, to);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const table = tr.doc.nodeAt(tableStart);
|
|
52
|
-
if (!table) return null;
|
|
53
|
-
const after = tableStart + table.nodeSize;
|
|
54
|
-
const before = tr.doc.content.size;
|
|
55
|
-
tr.replace(after, after, new (0, _model.Slice)(slice.content, 0, 0));
|
|
56
|
-
return after + (tr.doc.content.size - before);
|
|
57
|
-
}
|
|
58
|
-
function handleTablePasteWithoutNesting(view, event, slice) {
|
|
59
|
-
const { state } = view;
|
|
60
|
-
const { selection } = state;
|
|
61
|
-
if (outermostTableDepth(selection.$from) < 0) return false;
|
|
62
|
-
if (selection instanceof _tables.CellSelection || _tables.__pastedCells.call(void 0, slice)) {
|
|
63
|
-
if (_tables.handlePaste.call(void 0, view, event, slice)) return true;
|
|
64
|
-
}
|
|
65
|
-
if (!sliceContainsTable(slice)) return false;
|
|
66
|
-
const tr = state.tr;
|
|
67
|
-
const end = insertSliceAfterTable(tr, selection.from, selection.to, slice);
|
|
68
|
-
if (end === null) return false;
|
|
69
|
-
tr.setSelection(_state.Selection.near(tr.doc.resolve(end), -1));
|
|
70
|
-
view.dispatch(tr.scrollIntoView().setMeta("paste", true).setMeta("uiEvent", "paste"));
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
function changedRanges(transactions, skip2) {
|
|
74
|
-
let ranges = [];
|
|
75
|
-
for (const tr of transactions) {
|
|
76
|
-
const skipped = skip2(tr);
|
|
77
|
-
for (const step of tr.steps) {
|
|
78
|
-
const map = step.getMap();
|
|
79
|
-
ranges = ranges.map(([from, to]) => [map.map(from, 1), map.map(to, -1)]).filter(([from, to]) => to > from);
|
|
80
|
-
if (skipped) continue;
|
|
81
|
-
map.forEach((_oldStart, _oldEnd, newStart, newEnd) => {
|
|
82
|
-
if (newEnd > newStart) ranges.push([newStart, newEnd]);
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return ranges;
|
|
87
|
-
}
|
|
88
|
-
function findNestedTables(doc, ranges) {
|
|
89
|
-
const found = /* @__PURE__ */ new Set();
|
|
90
|
-
for (const [from, to] of ranges) {
|
|
91
|
-
doc.nodesBetween(from, to, (node, pos) => {
|
|
92
|
-
if (!isTableNode(node) || pos < from) return true;
|
|
93
|
-
if (isInTableCell(doc.resolve(pos))) {
|
|
94
|
-
found.add(pos);
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
return true;
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
const sorted = [...found].sort((a, b) => a - b);
|
|
101
|
-
const outer = [];
|
|
102
|
-
for (const pos of sorted) {
|
|
103
|
-
const last = outer[outer.length - 1];
|
|
104
|
-
if (last === void 0 || pos >= last + doc.nodeAt(last).nodeSize) outer.push(pos);
|
|
105
|
-
}
|
|
106
|
-
return outer;
|
|
107
|
-
}
|
|
108
|
-
function unnestTables(tr, ranges) {
|
|
109
|
-
let changed = false;
|
|
110
|
-
for (let round = 0; round < 32 && ranges.length; round++) {
|
|
111
|
-
const nested = findNestedTables(tr.doc, ranges);
|
|
112
|
-
if (!nested.length) break;
|
|
113
|
-
const groups = /* @__PURE__ */ new Map();
|
|
114
|
-
for (const pos of nested) {
|
|
115
|
-
const $pos = tr.doc.resolve(pos);
|
|
116
|
-
const outer = $pos.before(outermostTableDepth($pos));
|
|
117
|
-
groups.set(outer, [..._nullishCoalesce(groups.get(outer), () => ( [])), pos]);
|
|
118
|
-
}
|
|
119
|
-
const next = [];
|
|
120
|
-
for (const outer of [...groups.keys()].sort((a, b) => b - a)) {
|
|
121
|
-
const positions = groups.get(outer);
|
|
122
|
-
const nodes = positions.map((pos) => tr.doc.nodeAt(pos));
|
|
123
|
-
for (let i = positions.length - 1; i >= 0; i--) {
|
|
124
|
-
const pos = positions[i];
|
|
125
|
-
const node = nodes[i];
|
|
126
|
-
const $pos = tr.doc.resolve(pos);
|
|
127
|
-
const parent = $pos.parent;
|
|
128
|
-
const filler = parent.childCount === 1 ? _optionalChain([parent, 'access', _ => _.type, 'access', _2 => _2.contentMatch, 'access', _3 => _3.defaultType, 'optionalAccess', _4 => _4.createAndFill, 'call', _5 => _5()]) : null;
|
|
129
|
-
if (filler) tr.replaceWith(pos, pos + node.nodeSize, filler);
|
|
130
|
-
else tr.delete(pos, pos + node.nodeSize);
|
|
131
|
-
}
|
|
132
|
-
const table = tr.doc.nodeAt(outer);
|
|
133
|
-
const after = outer + table.nodeSize;
|
|
134
|
-
const fragment = _model.Fragment.fromArray(nodes);
|
|
135
|
-
tr.insert(after, fragment);
|
|
136
|
-
next.push([after, after + fragment.size]);
|
|
137
|
-
changed = true;
|
|
138
|
-
}
|
|
139
|
-
ranges = next;
|
|
140
|
-
}
|
|
141
|
-
return changed;
|
|
142
|
-
}
|
|
143
|
-
function replacesDocument(tr) {
|
|
144
|
-
return tr.steps.some((step, i) => {
|
|
145
|
-
const { from, to } = step;
|
|
146
|
-
return from === 0 && to !== void 0 && to >= tr.docs[i].content.size;
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
var skip = (tr) => !tr.docChanged || tr.getMeta(ALLOW_NESTED_TABLES_META) === true || // Undo/redo and remote collaborative changes restore what was there.
|
|
150
|
-
!!tr.getMeta("history$") || !!tr.getMeta("y-sync$") || // Other plugins' housekeeping, e.g. Track Changes putting a deleted
|
|
151
|
-
// (nested) table back so the deletion can be reviewed.
|
|
152
|
-
!!tr.getMeta("appendedTransaction") || replacesDocument(tr);
|
|
153
|
-
function createTableNestingPlugin() {
|
|
154
|
-
return new (0, _state.Plugin)({
|
|
155
|
-
key: tableNestingPluginKey,
|
|
156
|
-
props: {
|
|
157
|
-
handlePaste: (view, event, slice) => handleTablePasteWithoutNesting(view, event, slice)
|
|
158
|
-
},
|
|
159
|
-
appendTransaction(transactions, _oldState, newState) {
|
|
160
|
-
if (transactions.every(skip)) return null;
|
|
161
|
-
const ranges = changedRanges(transactions, skip);
|
|
162
|
-
if (!ranges.length) return null;
|
|
163
|
-
const tr = newState.tr;
|
|
164
|
-
if (!unnestTables(tr, ranges)) return null;
|
|
165
|
-
return tr;
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// src/extensions/table/extension.ts
|
|
171
|
-
var _core = require('@tiptap/core');
|
|
172
|
-
|
|
173
|
-
var _extensiontable = require('@tiptap/extension-table'); var _Table = _interopRequireWildcard(_extensiontable);
|
|
174
|
-
var _extensiontablerow = require('@tiptap/extension-table-row'); var _TableRow = _interopRequireWildcard(_extensiontablerow);
|
|
175
|
-
var _extensiontableheader = require('@tiptap/extension-table-header'); var _TableHeader = _interopRequireWildcard(_extensiontableheader);
|
|
176
|
-
var _extensiontablecell = require('@tiptap/extension-table-cell'); var _TableCell = _interopRequireWildcard(_extensiontablecell);
|
|
177
|
-
var resolveExt = (mod, name) => _optionalChain([mod, 'optionalAccess', _6 => _6[name]]) || _optionalChain([mod, 'optionalAccess', _7 => _7.default, 'optionalAccess', _8 => _8[name]]) || _optionalChain([mod, 'optionalAccess', _9 => _9.default, 'optionalAccess', _10 => _10.default]) || _optionalChain([mod, 'optionalAccess', _11 => _11.default]) || mod;
|
|
178
|
-
var BaseTable = resolveExt(_Table, "Table");
|
|
179
|
-
var BaseTableRow = resolveExt(_TableRow, "TableRow");
|
|
180
|
-
var BaseTableHeader = resolveExt(_TableHeader, "TableHeader");
|
|
181
|
-
var BaseTableCell = resolveExt(_TableCell, "TableCell");
|
|
182
|
-
var ALIGNMENTS = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]);
|
|
183
|
-
function normalizeTableCellAlignment(value) {
|
|
184
|
-
const v = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
185
|
-
return ALIGNMENTS.has(v) ? v : null;
|
|
186
|
-
}
|
|
187
|
-
var COLOR_REGEX = /^(?:#[0-9a-f]{3,8}|(?:rgb|rgba|hsl|hsla)\(\s*[-0-9.%\s,/deg]+\)|[a-z]{3,20})$/i;
|
|
188
|
-
function normalizeTableCellColor(value) {
|
|
189
|
-
const v = typeof value === "string" ? value.trim() : "";
|
|
190
|
-
if (!v || v.length > 64 || !COLOR_REGEX.test(v)) return null;
|
|
191
|
-
if (/^(?:inherit|initial|unset|revert|transparent)$/i.test(v)) return null;
|
|
192
|
-
return v;
|
|
193
|
-
}
|
|
194
|
-
var cellAttributes = () => ({
|
|
195
|
-
align: {
|
|
196
|
-
default: null,
|
|
197
|
-
parseHTML: (element) => normalizeTableCellAlignment(_optionalChain([element, 'access', _12 => _12.style, 'optionalAccess', _13 => _13.textAlign]) || element.getAttribute("align")),
|
|
198
|
-
renderHTML: (attrs) => {
|
|
199
|
-
const align = normalizeTableCellAlignment(attrs.align);
|
|
200
|
-
return align ? { style: `text-align: ${align}` } : {};
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
backgroundColor: {
|
|
204
|
-
default: null,
|
|
205
|
-
parseHTML: (element) => normalizeTableCellColor(
|
|
206
|
-
element.getAttribute("data-background-color") || _optionalChain([element, 'access', _14 => _14.style, 'optionalAccess', _15 => _15.backgroundColor]) || element.getAttribute("bgcolor")
|
|
207
|
-
),
|
|
208
|
-
renderHTML: (attrs) => {
|
|
209
|
-
const color = normalizeTableCellColor(attrs.backgroundColor);
|
|
210
|
-
return color ? { style: `background-color: ${color}`, "data-background-color": color } : {};
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
var children = (node) => {
|
|
215
|
-
const list = [];
|
|
216
|
-
node.forEach((child) => list.push(child));
|
|
217
|
-
return list;
|
|
218
|
-
};
|
|
219
|
-
var hasSpan = (cell) => (_nullishCoalesce(cell.attrs.colspan, () => ( 1))) > 1 || (_nullishCoalesce(cell.attrs.rowspan, () => ( 1))) > 1;
|
|
220
|
-
function isGfmTable(node) {
|
|
221
|
-
const rows = children(node);
|
|
222
|
-
if (rows.length === 0) return false;
|
|
223
|
-
const width = rows[0].childCount;
|
|
224
|
-
return rows.every(
|
|
225
|
-
(row, r) => row.childCount === width && children(row).every(
|
|
226
|
-
(cell) => (r === 0 ? cell.type.name === "tableHeader" : cell.type.name === "tableCell") && !hasSpan(cell) && cell.childCount === 1 && cell.firstChild.type.name === "paragraph"
|
|
227
|
-
)
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
var DELIMITERS = { left: ":---", center: ":---:", right: "---:" };
|
|
231
|
-
function serializeTableMarkdown(state, node) {
|
|
232
|
-
if (!isGfmTable(node)) {
|
|
233
|
-
const html = _core.getHTMLFromFragment.call(void 0, _model.Fragment.from(node), node.type.schema);
|
|
234
|
-
state.write(html.replace(/\n{2,}/g, "\n"));
|
|
235
|
-
state.closeBlock(node);
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
const previous = state.inTable;
|
|
239
|
-
state.inTable = true;
|
|
240
|
-
children(node).forEach((row, r) => {
|
|
241
|
-
if (r) state.ensureNewLine();
|
|
242
|
-
state.write("| ");
|
|
243
|
-
children(row).forEach((cell, c) => {
|
|
244
|
-
if (c) state.write(" | ");
|
|
245
|
-
const paragraph = cell.firstChild;
|
|
246
|
-
const start = state.out.length;
|
|
247
|
-
if (paragraph.childCount) state.renderInline(paragraph);
|
|
248
|
-
const text = state.out.slice(start);
|
|
249
|
-
state.out = state.out.slice(0, start) + text.replace(/\n/g, " ").replace(/\|/g, "\\|");
|
|
250
|
-
});
|
|
251
|
-
state.write(" |");
|
|
252
|
-
if (r === 0) {
|
|
253
|
-
const delimiter = children(row).map((cell) => _nullishCoalesce(DELIMITERS[cell.attrs.align], () => ( "---")));
|
|
254
|
-
state.ensureNewLine();
|
|
255
|
-
state.write(`| ${delimiter.join(" | ")} |`);
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
state.inTable = previous;
|
|
259
|
-
state.closeBlock(node);
|
|
260
|
-
}
|
|
261
|
-
var DEFAULT_TABLE_OPTIONS = {
|
|
262
|
-
resizable: true,
|
|
263
|
-
handleWidth: 5,
|
|
264
|
-
cellMinWidth: 25,
|
|
265
|
-
lastColumnResizable: true,
|
|
266
|
-
allowTableNodeSelection: true,
|
|
267
|
-
HTMLAttributes: { class: "pixerate-table" },
|
|
268
|
-
cellHTMLAttributes: {},
|
|
269
|
-
headerHTMLAttributes: {},
|
|
270
|
-
rowHTMLAttributes: {}
|
|
271
|
-
};
|
|
272
|
-
var Table = BaseTable.extend({
|
|
273
|
-
addStorage() {
|
|
274
|
-
return { markdown: { serialize: serializeTableMarkdown } };
|
|
275
|
-
},
|
|
276
|
-
addProseMirrorPlugins() {
|
|
277
|
-
return [..._nullishCoalesce(_optionalChain([this, 'access', _16 => _16.parent, 'optionalCall', _17 => _17()]), () => ( [])), createTableNestingPlugin()];
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
var TableRow = BaseTableRow;
|
|
281
|
-
var TableCell = BaseTableCell.extend({
|
|
282
|
-
addAttributes() {
|
|
283
|
-
return { ..._optionalChain([this, 'access', _18 => _18.parent, 'optionalCall', _19 => _19()]), ...cellAttributes() };
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
var TableHeader = BaseTableHeader.extend({
|
|
287
|
-
addAttributes() {
|
|
288
|
-
return { ..._optionalChain([this, 'access', _20 => _20.parent, 'optionalCall', _21 => _21()]), ...cellAttributes() };
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
function createTableExtensions(options = {}) {
|
|
292
|
-
const o = { ...DEFAULT_TABLE_OPTIONS, ...options };
|
|
293
|
-
return [
|
|
294
|
-
Table.configure({
|
|
295
|
-
resizable: o.resizable,
|
|
296
|
-
handleWidth: o.handleWidth,
|
|
297
|
-
cellMinWidth: o.cellMinWidth,
|
|
298
|
-
lastColumnResizable: o.lastColumnResizable,
|
|
299
|
-
allowTableNodeSelection: o.allowTableNodeSelection,
|
|
300
|
-
HTMLAttributes: o.HTMLAttributes
|
|
301
|
-
}),
|
|
302
|
-
TableRow.configure({ HTMLAttributes: o.rowHTMLAttributes }),
|
|
303
|
-
TableHeader.configure({ HTMLAttributes: o.headerHTMLAttributes }),
|
|
304
|
-
TableCell.configure({ HTMLAttributes: o.cellHTMLAttributes })
|
|
305
|
-
];
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// src/extensions/table/actions.ts
|
|
309
|
-
|
|
310
|
-
var TABLE_ACTIONS = [
|
|
311
|
-
{ action: "insertTable", label: "Insert Table", description: "Inserts a table (rows, cols, withHeaderRow) at the cursor.", keywords: ["table", "grid", "new"] },
|
|
312
|
-
{ action: "addRowBefore", label: "Insert Row Above", description: "Adds a row above the current row.", keywords: ["row", "add", "above"] },
|
|
313
|
-
{ action: "addRowAfter", label: "Insert Row Below", description: "Adds a row below the current row.", keywords: ["row", "add", "below"] },
|
|
314
|
-
{ action: "deleteRow", label: "Delete Row", description: "Deletes the selected rows.", keywords: ["row", "remove"] },
|
|
315
|
-
{ action: "addColumnBefore", label: "Insert Column Left", description: "Adds a column left of the current column.", keywords: ["column", "add", "left", "before"] },
|
|
316
|
-
{ action: "addColumnAfter", label: "Insert Column Right", description: "Adds a column right of the current column.", keywords: ["column", "add", "right", "after"] },
|
|
317
|
-
{ action: "deleteColumn", label: "Delete Column", description: "Deletes the selected columns.", keywords: ["column", "remove"] },
|
|
318
|
-
{ action: "deleteTable", label: "Delete Table", description: "Deletes the table around the cursor.", keywords: ["table", "remove"] },
|
|
319
|
-
{ action: "mergeCells", label: "Merge Cells", description: "Merges the selected cells into one.", keywords: ["combine", "join", "span"] },
|
|
320
|
-
{ action: "splitCell", label: "Split Cell", description: "Splits a merged cell back into single cells.", keywords: ["unmerge", "span"] },
|
|
321
|
-
{ action: "toggleHeaderRow", label: "Toggle Header Row", description: "Turns the first row into header cells, or back.", keywords: ["header", "row", "th"] },
|
|
322
|
-
{ action: "toggleHeaderColumn", label: "Toggle Header Column", description: "Turns the first column into header cells, or back.", keywords: ["header", "column", "th"] },
|
|
323
|
-
{ action: "toggleHeaderCell", label: "Toggle Header Cell", description: "Turns the selected cells into header cells, or back.", keywords: ["header", "cell", "th"] },
|
|
324
|
-
{ action: "goToNextCell", label: "Next Cell", description: "Moves the cursor to the next cell.", keywords: ["tab", "navigate"] },
|
|
325
|
-
{ action: "goToPreviousCell", label: "Previous Cell", description: "Moves the cursor to the previous cell.", keywords: ["shift tab", "navigate"] },
|
|
326
|
-
{ action: "setCellAlignment", label: "Align Cells\u2026", description: "Sets the horizontal alignment (align: left | center | right | justify | null) of the selected cells.", keywords: ["align", "left", "center", "right"] },
|
|
327
|
-
{ action: "setCellBackground", label: "Cell Background\u2026", description: "Sets the background color (color: CSS color or null) of the selected cells.", keywords: ["shading", "fill", "color"] }
|
|
328
|
-
];
|
|
329
|
-
var DEFAULT_TABLE_TOOLBAR = [
|
|
330
|
-
{ id: "addRowBefore", action: "addRowBefore", label: "+ Row \u2191", title: "Insert row above", group: "rows" },
|
|
331
|
-
{ id: "addRowAfter", action: "addRowAfter", label: "+ Row \u2193", title: "Insert row below", group: "rows" },
|
|
332
|
-
{ id: "deleteRow", action: "deleteRow", label: "\u2212 Row", title: "Delete row", group: "rows" },
|
|
333
|
-
{ id: "addColumnBefore", action: "addColumnBefore", label: "+ Col \u2190", title: "Insert column left", group: "columns" },
|
|
334
|
-
{ id: "addColumnAfter", action: "addColumnAfter", label: "+ Col \u2192", title: "Insert column right", group: "columns" },
|
|
335
|
-
{ id: "deleteColumn", action: "deleteColumn", label: "\u2212 Col", title: "Delete column", group: "columns" },
|
|
336
|
-
{ id: "mergeCells", action: "mergeCells", label: "Merge", title: "Merge cells", group: "cells" },
|
|
337
|
-
{ id: "splitCell", action: "splitCell", label: "Split", title: "Split cell", group: "cells" },
|
|
338
|
-
{ id: "toggleHeaderRow", action: "toggleHeaderRow", label: "Header row", title: "Toggle header row", group: "headers", active: (s) => s.headerRow },
|
|
339
|
-
{ id: "toggleHeaderColumn", action: "toggleHeaderColumn", label: "Header col", title: "Toggle header column", group: "headers", active: (s) => s.headerColumn },
|
|
340
|
-
{ id: "toggleHeaderCell", action: "toggleHeaderCell", label: "Header cell", title: "Toggle header cell", group: "headers", active: (s) => s.headerCell },
|
|
341
|
-
{ id: "alignLeft", action: "setCellAlignment", params: { align: "left" }, label: "Left", title: "Align cell left", group: "align", active: (s) => s.cellAlignment === "left" },
|
|
342
|
-
{ id: "alignCenter", action: "setCellAlignment", params: { align: "center" }, label: "Center", title: "Align cell center", group: "align", active: (s) => s.cellAlignment === "center" },
|
|
343
|
-
{ id: "alignRight", action: "setCellAlignment", params: { align: "right" }, label: "Right", title: "Align cell right", group: "align", active: (s) => s.cellAlignment === "right" },
|
|
344
|
-
{ id: "deleteTable", action: "deleteTable", label: "Delete table", title: "Delete table", group: "table" }
|
|
345
|
-
];
|
|
346
|
-
var MAX_TABLE_ROWS = 100;
|
|
347
|
-
var MAX_TABLE_COLUMNS = 50;
|
|
348
|
-
var live = (editor) => !!editor && !editor.isDestroyed;
|
|
349
|
-
function isTableEnabled(editor) {
|
|
350
|
-
return live(editor) && !!editor.schema.nodes.table && !!editor.schema.nodes.tableRow;
|
|
351
|
-
}
|
|
352
|
-
function isSelectionInTable(state) {
|
|
353
|
-
if (!state.schema.nodes.table) return false;
|
|
354
|
-
return state.selection instanceof _tables.CellSelection || _tables.isInTable.call(void 0, state);
|
|
355
|
-
}
|
|
356
|
-
function shouldShowTableBubbleMenu({ editor, state }) {
|
|
357
|
-
return editor.isEditable && isSelectionInTable(state);
|
|
358
|
-
}
|
|
359
|
-
var isInt = (value, min, max) => typeof value === "number" && Number.isInteger(value) && value >= min && value <= max;
|
|
360
|
-
var can = (editor, run) => {
|
|
361
|
-
try {
|
|
362
|
-
return !!run(editor.can().chain()).run();
|
|
363
|
-
} catch (e) {
|
|
364
|
-
return false;
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
function getTableActionState(editor, action, params = {}) {
|
|
368
|
-
if (!live(editor)) return "The editor is not available.";
|
|
369
|
-
if (!isTableEnabled(editor)) return "Tables are not enabled in this editor.";
|
|
370
|
-
if (!editor.isEditable) return "The editor is read-only.";
|
|
371
|
-
const state = editor.state;
|
|
372
|
-
const inTable = isSelectionInTable(state);
|
|
373
|
-
if (action === "insertTable") {
|
|
374
|
-
if (inTable) return "Tables cannot be nested: move the cursor out of the table first.";
|
|
375
|
-
if (params.rows !== void 0 && !isInt(params.rows, 1, MAX_TABLE_ROWS)) {
|
|
376
|
-
return `Rows must be a whole number from 1 to ${MAX_TABLE_ROWS}.`;
|
|
377
|
-
}
|
|
378
|
-
if (params.cols !== void 0 && !isInt(params.cols, 1, MAX_TABLE_COLUMNS)) {
|
|
379
|
-
return `Columns must be a whole number from 1 to ${MAX_TABLE_COLUMNS}.`;
|
|
380
|
-
}
|
|
381
|
-
return can(editor, (c) => c.insertTable({ rows: 1, cols: 1 })) ? true : "A table cannot be inserted here.";
|
|
382
|
-
}
|
|
383
|
-
if (!inTable) return "Place the cursor in a table first.";
|
|
384
|
-
switch (action) {
|
|
385
|
-
case "mergeCells":
|
|
386
|
-
case "splitCell": {
|
|
387
|
-
if (_chunkIFHKKVXHcjs.isTrackChangesEnabled.call(void 0, editor)) {
|
|
388
|
-
return `${action === "mergeCells" ? "Merging" : "Splitting"} cells cannot be tracked: turn off Track Changes first.`;
|
|
389
|
-
}
|
|
390
|
-
if (action === "mergeCells") {
|
|
391
|
-
return can(editor, (c) => c.mergeCells()) ? true : "Select two or more adjacent cells to merge.";
|
|
392
|
-
}
|
|
393
|
-
return can(editor, (c) => c.splitCell()) ? true : "Only a merged cell can be split.";
|
|
394
|
-
}
|
|
395
|
-
case "deleteRow":
|
|
396
|
-
case "deleteColumn": {
|
|
397
|
-
const rect = _tables.selectedRect.call(void 0, state);
|
|
398
|
-
const all = action === "deleteRow" ? rect.top === 0 && rect.bottom === rect.map.height : rect.left === 0 && rect.right === rect.map.width;
|
|
399
|
-
const what = action === "deleteRow" ? "rows" : "columns";
|
|
400
|
-
if (all || !can(editor, (c) => c[action]())) return `These are all the ${what}: delete the table instead.`;
|
|
401
|
-
return true;
|
|
402
|
-
}
|
|
403
|
-
case "goToNextCell":
|
|
404
|
-
return can(editor, (c) => c.goToNextCell()) ? true : "This is the last cell.";
|
|
405
|
-
case "goToPreviousCell":
|
|
406
|
-
return can(editor, (c) => c.goToPreviousCell()) ? true : "This is the first cell.";
|
|
407
|
-
case "setCellAlignment":
|
|
408
|
-
if (params.align !== void 0 && params.align !== null && !normalizeTableCellAlignment(params.align)) {
|
|
409
|
-
return 'Alignment must be "left", "center", "right", "justify" or null.';
|
|
410
|
-
}
|
|
411
|
-
if (!_optionalChain([editor, 'access', _22 => _22.schema, 'access', _23 => _23.nodes, 'access', _24 => _24.tableCell, 'optionalAccess', _25 => _25.spec, 'access', _26 => _26.attrs, 'optionalAccess', _27 => _27.align])) return "Cell alignment is not supported by this schema.";
|
|
412
|
-
return true;
|
|
413
|
-
case "setCellBackground":
|
|
414
|
-
if (params.color !== void 0 && params.color !== null && !normalizeTableCellColor(params.color)) {
|
|
415
|
-
return "Color must be a CSS color such as #fde68a, rgb(\u2026) or a color name, or null.";
|
|
416
|
-
}
|
|
417
|
-
if (!_optionalChain([editor, 'access', _28 => _28.schema, 'access', _29 => _29.nodes, 'access', _30 => _30.tableCell, 'optionalAccess', _31 => _31.spec, 'access', _32 => _32.attrs, 'optionalAccess', _33 => _33.backgroundColor])) return "Cell backgrounds are not supported by this schema.";
|
|
418
|
-
return true;
|
|
419
|
-
default:
|
|
420
|
-
return can(editor, (c) => c[action]()) ? true : "This table action is not available here.";
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
function runTableAction(editor, action, params = {}, options = {}) {
|
|
424
|
-
if (getTableActionState(editor, action, params) !== true) return false;
|
|
425
|
-
const ed = editor;
|
|
426
|
-
let chain = ed.chain();
|
|
427
|
-
if (options.focus) chain = chain.focus();
|
|
428
|
-
switch (action) {
|
|
429
|
-
case "insertTable":
|
|
430
|
-
chain = chain.insertTable({
|
|
431
|
-
rows: _nullishCoalesce(params.rows, () => ( 3)),
|
|
432
|
-
cols: _nullishCoalesce(params.cols, () => ( 3)),
|
|
433
|
-
withHeaderRow: _nullishCoalesce(params.withHeaderRow, () => ( true))
|
|
434
|
-
});
|
|
435
|
-
break;
|
|
436
|
-
case "setCellAlignment":
|
|
437
|
-
chain = chain.setCellAttribute("align", normalizeTableCellAlignment(params.align));
|
|
438
|
-
break;
|
|
439
|
-
case "setCellBackground":
|
|
440
|
-
chain = chain.setCellAttribute("backgroundColor", normalizeTableCellColor(params.color));
|
|
441
|
-
break;
|
|
442
|
-
default:
|
|
443
|
-
chain = chain[action]();
|
|
444
|
-
}
|
|
445
|
-
return !!chain.run();
|
|
446
|
-
}
|
|
447
|
-
var NO_ACTIONS = Object.fromEntries(
|
|
448
|
-
TABLE_ACTIONS.map(({ action }) => [action, { enabled: false, reason: "The editor is not available." }])
|
|
449
|
-
);
|
|
450
|
-
var EMPTY_TABLE_STATE = Object.freeze({
|
|
451
|
-
enabled: false,
|
|
452
|
-
inTable: false,
|
|
453
|
-
cellSelection: false,
|
|
454
|
-
rows: 0,
|
|
455
|
-
columns: 0,
|
|
456
|
-
row: -1,
|
|
457
|
-
column: -1,
|
|
458
|
-
headerRow: false,
|
|
459
|
-
headerColumn: false,
|
|
460
|
-
headerCell: false,
|
|
461
|
-
cellAlignment: null,
|
|
462
|
-
cellBackground: null,
|
|
463
|
-
actions: NO_ACTIONS
|
|
464
|
-
});
|
|
465
|
-
function getTableState(editor) {
|
|
466
|
-
if (!live(editor)) return EMPTY_TABLE_STATE;
|
|
467
|
-
const actions = Object.fromEntries(
|
|
468
|
-
TABLE_ACTIONS.map(({ action }) => {
|
|
469
|
-
const result = getTableActionState(editor, action);
|
|
470
|
-
return [action, result === true ? { enabled: true } : { enabled: false, reason: result }];
|
|
471
|
-
})
|
|
472
|
-
);
|
|
473
|
-
const state = editor.state;
|
|
474
|
-
const base = { ...EMPTY_TABLE_STATE, enabled: isTableEnabled(editor), actions };
|
|
475
|
-
if (!base.enabled || !isSelectionInTable(state)) return base;
|
|
476
|
-
try {
|
|
477
|
-
const rect = _tables.selectedRect.call(void 0, state);
|
|
478
|
-
const { map, table } = rect;
|
|
479
|
-
const cellAt = (row, col) => table.nodeAt(map.map[row * map.width + col]);
|
|
480
|
-
const allHeaders = (positions) => positions.length > 0 && positions.every((pos) => _optionalChain([table, 'access', _34 => _34.nodeAt, 'call', _35 => _35(pos), 'optionalAccess', _36 => _36.type, 'access', _37 => _37.name]) === "tableHeader");
|
|
481
|
-
const firstRow = map.cellsInRect({ left: 0, right: map.width, top: 0, bottom: 1 });
|
|
482
|
-
const firstColumn = map.cellsInRect({ left: 0, right: 1, top: 0, bottom: map.height });
|
|
483
|
-
const cell = cellAt(rect.top, rect.left);
|
|
484
|
-
return {
|
|
485
|
-
...base,
|
|
486
|
-
inTable: true,
|
|
487
|
-
cellSelection: state.selection instanceof _tables.CellSelection,
|
|
488
|
-
rows: map.height,
|
|
489
|
-
columns: map.width,
|
|
490
|
-
row: rect.top,
|
|
491
|
-
column: rect.left,
|
|
492
|
-
headerRow: allHeaders(firstRow),
|
|
493
|
-
headerColumn: allHeaders(firstColumn),
|
|
494
|
-
headerCell: _optionalChain([cell, 'optionalAccess', _38 => _38.type, 'access', _39 => _39.name]) === "tableHeader",
|
|
495
|
-
cellAlignment: normalizeTableCellAlignment(_optionalChain([cell, 'optionalAccess', _40 => _40.attrs, 'access', _41 => _41.align])),
|
|
496
|
-
cellBackground: normalizeTableCellColor(_optionalChain([cell, 'optionalAccess', _42 => _42.attrs, 'access', _43 => _43.backgroundColor]))
|
|
497
|
-
};
|
|
498
|
-
} catch (e2) {
|
|
499
|
-
return { ...base, inTable: true };
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
var stateKey = (state) => JSON.stringify(state);
|
|
503
|
-
function createTableStore(editor) {
|
|
504
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
505
|
-
let snapshot = getTableState(editor);
|
|
506
|
-
let key = stateKey(snapshot);
|
|
507
|
-
const update = () => {
|
|
508
|
-
const next = getTableState(editor);
|
|
509
|
-
const nextKey = stateKey(next);
|
|
510
|
-
if (nextKey === key) return;
|
|
511
|
-
snapshot = next;
|
|
512
|
-
key = nextKey;
|
|
513
|
-
listeners.forEach((listener) => listener());
|
|
514
|
-
};
|
|
515
|
-
const detach = () => {
|
|
516
|
-
_optionalChain([editor, 'optionalAccess', _44 => _44.off, 'call', _45 => _45("transaction", update)]);
|
|
517
|
-
_optionalChain([editor, 'optionalAccess', _46 => _46.off, 'call', _47 => _47("update", update)]);
|
|
518
|
-
_optionalChain([editor, 'optionalAccess', _48 => _48.off, 'call', _49 => _49("focus", update)]);
|
|
519
|
-
_optionalChain([editor, 'optionalAccess', _50 => _50.off, 'call', _51 => _51("destroy", update)]);
|
|
520
|
-
};
|
|
521
|
-
return {
|
|
522
|
-
getSnapshot: () => {
|
|
523
|
-
if (!listeners.size) {
|
|
524
|
-
const next = getTableState(editor);
|
|
525
|
-
const nextKey = stateKey(next);
|
|
526
|
-
if (nextKey !== key) {
|
|
527
|
-
snapshot = next;
|
|
528
|
-
key = nextKey;
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
return snapshot;
|
|
532
|
-
},
|
|
533
|
-
subscribe(listener) {
|
|
534
|
-
if (!listeners.size && editor) {
|
|
535
|
-
update();
|
|
536
|
-
editor.on("transaction", update);
|
|
537
|
-
editor.on("update", update);
|
|
538
|
-
editor.on("focus", update);
|
|
539
|
-
editor.on("destroy", update);
|
|
540
|
-
}
|
|
541
|
-
listeners.add(listener);
|
|
542
|
-
return () => {
|
|
543
|
-
listeners.delete(listener);
|
|
544
|
-
if (!listeners.size) detach();
|
|
545
|
-
};
|
|
546
|
-
},
|
|
547
|
-
destroy() {
|
|
548
|
-
detach();
|
|
549
|
-
listeners.clear();
|
|
550
|
-
}
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
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.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.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;
|
|
586
|
-
//# sourceMappingURL=chunk-MC2LQN5S.cjs.map
|