@pixerate/editor 0.47.0 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/agent/index.cjs +246 -29
  2. package/dist/agent/index.cjs.map +1 -1
  3. package/dist/agent/index.d.cts +18 -6
  4. package/dist/agent/index.d.ts +18 -6
  5. package/dist/agent/index.js +226 -9
  6. package/dist/agent/index.js.map +1 -1
  7. package/dist/{builtins-xs7rK6ys.d.cts → builtins-1kqwLUnb.d.cts} +1 -1
  8. package/dist/{builtins-D2nMtw2W.d.ts → builtins-BKYlHH1s.d.ts} +1 -1
  9. package/dist/chart/index.cjs +214 -3541
  10. package/dist/chart/index.cjs.map +1 -1
  11. package/dist/chart/index.d.cts +4 -494
  12. package/dist/chart/index.d.ts +4 -494
  13. package/dist/chart/index.js +135 -3462
  14. package/dist/chart/index.js.map +1 -1
  15. package/dist/{chunk-5VXI5GED.js → chunk-2CJ3LPYQ.js} +3 -3
  16. package/dist/{chunk-ZFBBVGCI.js → chunk-EKYHKQPG.js} +243 -243
  17. package/dist/{chunk-ZFBBVGCI.js.map → chunk-EKYHKQPG.js.map} +1 -1
  18. package/dist/chunk-HXUL3LS7.js +113 -0
  19. package/dist/chunk-HXUL3LS7.js.map +1 -0
  20. package/dist/{chunk-REAGGLXS.js → chunk-JQ3BB3E6.js} +2 -2
  21. package/dist/chunk-LTUM52X6.js +4074 -0
  22. package/dist/chunk-LTUM52X6.js.map +1 -0
  23. package/dist/{chunk-J3R2OWOE.cjs → chunk-MUCYWI6W.cjs} +608 -15
  24. package/dist/chunk-MUCYWI6W.cjs.map +1 -0
  25. package/dist/chunk-PIMCHMZE.cjs +521 -0
  26. package/dist/chunk-PIMCHMZE.cjs.map +1 -0
  27. package/dist/{chunk-TK2XZK6Z.js → chunk-PKBWLEL7.js} +594 -1
  28. package/dist/chunk-PKBWLEL7.js.map +1 -0
  29. package/dist/chunk-PRSJJZBS.cjs +4074 -0
  30. package/dist/chunk-PRSJJZBS.cjs.map +1 -0
  31. package/dist/chunk-U6IZKC7B.cjs +113 -0
  32. package/dist/chunk-U6IZKC7B.cjs.map +1 -0
  33. package/dist/{chunk-SQC26VQV.cjs → chunk-UN33YOXW.cjs} +191 -191
  34. package/dist/{chunk-SQC26VQV.cjs.map → chunk-UN33YOXW.cjs.map} +1 -1
  35. package/dist/{chunk-PQFAHT5O.js → chunk-VKPEPWKZ.js} +27 -94
  36. package/dist/chunk-VKPEPWKZ.js.map +1 -0
  37. package/dist/{chunk-H4PICYNL.cjs → chunk-WXEHCVJQ.cjs} +113 -180
  38. package/dist/chunk-WXEHCVJQ.cjs.map +1 -0
  39. package/dist/{chunk-LYGEEDNR.cjs → chunk-XP5IUZUO.cjs} +242 -242
  40. package/dist/chunk-XP5IUZUO.cjs.map +1 -0
  41. package/dist/{chunk-C3NWJE3K.js → chunk-XUUD43OV.js} +11 -672
  42. package/dist/chunk-XUUD43OV.js.map +1 -0
  43. package/dist/{chunk-BBRK6MOI.cjs → chunk-YU4WQE5M.cjs} +100 -100
  44. package/dist/{chunk-BBRK6MOI.cjs.map → chunk-YU4WQE5M.cjs.map} +1 -1
  45. package/dist/commands/index.d.cts +1 -1
  46. package/dist/commands/index.d.ts +1 -1
  47. package/dist/controller-ChjCCMLl.d.cts +822 -0
  48. package/dist/controller-DtbEo3om.d.ts +822 -0
  49. package/dist/extensions/index.cjs +32 -4
  50. package/dist/extensions/index.cjs.map +1 -1
  51. package/dist/extensions/index.d.cts +4 -2
  52. package/dist/extensions/index.d.ts +4 -2
  53. package/dist/extensions/index.js +31 -3
  54. package/dist/{index-QrqMmZ75.d.cts → index-DoHqT1mq.d.cts} +203 -7
  55. package/dist/{index-CSUCQYAH.d.ts → index-YLZ0fKqE.d.ts} +203 -7
  56. package/dist/index.cjs +37 -12
  57. package/dist/index.cjs.map +1 -1
  58. package/dist/index.d.cts +9 -7
  59. package/dist/index.d.ts +9 -7
  60. package/dist/index.js +31 -6
  61. package/dist/index.js.map +1 -1
  62. package/dist/spreadsheet/index.cjs +4 -4
  63. package/dist/spreadsheet/index.js +3 -3
  64. package/package.json +1 -1
  65. package/dist/chunk-C3NWJE3K.js.map +0 -1
  66. package/dist/chunk-H4PICYNL.cjs.map +0 -1
  67. package/dist/chunk-J3R2OWOE.cjs.map +0 -1
  68. package/dist/chunk-LYGEEDNR.cjs.map +0 -1
  69. package/dist/chunk-NEOO6QJD.cjs +0 -1182
  70. package/dist/chunk-NEOO6QJD.cjs.map +0 -1
  71. package/dist/chunk-PQFAHT5O.js.map +0 -1
  72. package/dist/chunk-TK2XZK6Z.js.map +0 -1
  73. package/dist/types-BVqWm3d1.d.cts +0 -320
  74. package/dist/types-BVqWm3d1.d.ts +0 -320
  75. /package/dist/{chunk-5VXI5GED.js.map → chunk-2CJ3LPYQ.js.map} +0 -0
  76. /package/dist/{chunk-REAGGLXS.js.map → chunk-JQ3BB3E6.js.map} +0 -0
@@ -7,25 +7,35 @@ import {
7
7
  } from "./chunk-MR2764X2.js";
8
8
  import {
9
9
  CHART_OOXML_NS,
10
- chartDataToTable,
11
10
  chartFromOoxml
12
- } from "./chunk-C3NWJE3K.js";
11
+ } from "./chunk-XUUD43OV.js";
13
12
  import {
13
+ Chart,
14
14
  MAX_TABLE_COLUMNS,
15
15
  MAX_TABLE_ROWS,
16
+ STRUCTURE_PRIORITY,
17
+ Sparkline,
16
18
  TABLE_ACTIONS,
17
19
  applyReplacements,
20
+ arraysEqual,
18
21
  compileFindPattern,
19
22
  createTableExtensions,
23
+ generateStructureId,
20
24
  getTableActionState,
21
25
  getTableState,
22
26
  handleTablePasteWithoutNesting,
23
27
  insertSliceAfterTable,
24
28
  outermostTableDepth,
29
+ presenceStateSpec,
25
30
  runTableAction,
31
+ scrollDomAtPos,
26
32
  searchDocument,
27
- sliceContainsTable
28
- } from "./chunk-TK2XZK6Z.js";
33
+ sliceContainsTable,
34
+ syncInitialContent
35
+ } from "./chunk-PKBWLEL7.js";
36
+ import {
37
+ chartDataToTable
38
+ } from "./chunk-LTUM52X6.js";
29
39
  import {
30
40
  compareDocuments
31
41
  } from "./chunk-QJSOZFCZ.js";
@@ -2470,10 +2480,12 @@ async function loadCharts(zip, Parser, root, rels, options) {
2470
2480
  }
2471
2481
  return charts;
2472
2482
  }
2473
- function chartTableHtml(chart) {
2483
+ function chartBlockHtml(chart) {
2474
2484
  const [head, ...rows] = chartDataToTable(chart.spec);
2475
2485
  const cell = (v, tag) => `<${tag}><p>${escapeHtml(v === null || v === void 0 ? "" : String(v))}</p></${tag}>`;
2476
- return `<table><tbody><tr>${head.map((h) => cell(h, "th")).join("")}</tr>${rows.map((r) => `<tr>${r.map((v, i) => cell(v, i ? "td" : "th")).join("")}</tr>`).join("")}</tbody></table>`;
2486
+ const table = `<table><tbody><tr>${head.map((h) => cell(h, "th")).join("")}</tr>${rows.map((r) => `<tr>${r.map((v, i) => cell(v, i ? "td" : "th")).join("")}</tr>`).join("")}</tbody></table>`;
2487
+ const caption = `<p>${escapeHtml(`[Chart: ${chart.title || "untitled"}]`)}</p>`;
2488
+ return `<div data-type="chart" data-chart-id="${escapeHtml(chart.id)}" data-chart="${escapeHtml(JSON.stringify(chart.spec))}">${caption}${table}</div>`;
2477
2489
  }
2478
2490
  async function loadImages(zip, root, rels, options) {
2479
2491
  const images = /* @__PURE__ */ new Map();
@@ -2943,7 +2955,7 @@ function renderSegments(segments, code = false) {
2943
2955
  if (seg.kind === "text") inner += escapeHtml(seg.text);
2944
2956
  else if (seg.kind === "br") inner += code ? "\n" : "<br>";
2945
2957
  else if (seg.kind === "img") inner += code ? "" : `<img src="${escapeHtml(seg.src)}" alt="${escapeHtml(seg.alt)}">`;
2946
- else if (seg.kind === "chart") inner += escapeHtml(`[Chart: ${seg.chart.title || "untitled"}]`);
2958
+ else if (seg.kind === "chart") inner += code ? escapeHtml(`[Chart: ${seg.chart.title || "untitled"}]`) : "";
2947
2959
  else inner += `<sup>${seg.n}</sup>`;
2948
2960
  }
2949
2961
  const format = segments[i].format;
@@ -3334,8 +3346,8 @@ function renderBlocks(container, ctx, part, topLevel = false) {
3334
3346
  const mappedStyle = styleId ? ctx.styleIds.get(styleId) : void 0;
3335
3347
  const styleAttr = !heading && !list && mappedStyle && mappedStyle !== NORMAL_STYLE_ID ? ` data-style="${escapeHtml(mappedStyle)}"` : "";
3336
3348
  const changeAttr = topLevel && !list && ctx.tracked === "marks" ? blockChangeAttr(pPr, ctx) : "";
3337
- const tables = renderer.charts.map(chartTableHtml).join("");
3338
- const blockHtml = (heading ? `<h${heading}${changeAttr}>${inner}</h${heading}>` : `<p${styleAttr}${changeAttr}>${inner}</p>`) + tables;
3349
+ const charts = renderer.charts.map(chartBlockHtml).join("");
3350
+ const blockHtml = (charts && !inner && !heading ? "" : heading ? `<h${heading}${changeAttr}>${inner}</h${heading}>` : `<p${styleAttr}${changeAttr}>${inner}</p>`) + charts;
3339
3351
  if (!list) {
3340
3352
  closeAll();
3341
3353
  html += blockHtml;
@@ -4133,90 +4145,6 @@ import {
4133
4145
  PluginKey as PluginKey7,
4134
4146
  TextSelection as TextSelection2
4135
4147
  } from "@tiptap/pm/state";
4136
-
4137
- // src/extensions/document-structure/utils.ts
4138
- import { createDocument } from "@tiptap/core";
4139
- import { EditorState } from "@tiptap/pm/state";
4140
- import { ReplaceAroundStep, ReplaceStep } from "@tiptap/pm/transform";
4141
- var idCounter = 0;
4142
- function generateStructureId(prefix) {
4143
- idCounter = (idCounter + 1) % 1296;
4144
- const random = Math.random().toString(36).slice(2, 8).padEnd(6, "0");
4145
- return `${prefix}-${random}${idCounter.toString(36).padStart(2, "0")}`;
4146
- }
4147
- function transactionsInsert(transactions, typeNames) {
4148
- for (const tr of transactions) {
4149
- for (const step of tr.steps) {
4150
- if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) {
4151
- const mark = step.mark;
4152
- if (mark && typeNames.includes(mark.type.name)) return true;
4153
- continue;
4154
- }
4155
- let found = false;
4156
- step.slice.content.descendants((node) => {
4157
- if (found) return false;
4158
- if (typeNames.includes(node.type.name) || node.marks.some((m) => typeNames.includes(m.type.name))) {
4159
- found = true;
4160
- }
4161
- return !found;
4162
- });
4163
- if (found) return true;
4164
- }
4165
- }
4166
- return false;
4167
- }
4168
- function docContains(doc, typeNames) {
4169
- let found = false;
4170
- doc.descendants((node) => {
4171
- if (found) return false;
4172
- if (typeNames.includes(node.type.name) || node.marks.some((m) => typeNames.includes(m.type.name))) {
4173
- found = true;
4174
- }
4175
- return !found;
4176
- });
4177
- return found;
4178
- }
4179
- function presenceStateSpec(typeNames) {
4180
- return {
4181
- init: (_config, state) => docContains(state.doc, typeNames),
4182
- apply: (tr, present, _oldState, newState) => {
4183
- if (!tr.docChanged) return present;
4184
- if (!present && !transactionsInsert([tr], typeNames)) return false;
4185
- return docContains(newState.doc, typeNames);
4186
- }
4187
- };
4188
- }
4189
- function arraysEqual(a, b, eq) {
4190
- if (a.length !== b.length) return false;
4191
- for (let i = 0; i < a.length; i++) {
4192
- if (!eq(a[i], b[i])) return false;
4193
- }
4194
- return true;
4195
- }
4196
- function scrollDomAtPos(view, pos, behavior = "smooth") {
4197
- try {
4198
- const dom = view?.nodeDOM?.(pos);
4199
- if (dom && typeof dom.scrollIntoView === "function") {
4200
- dom.scrollIntoView({ block: "start", behavior });
4201
- }
4202
- } catch {
4203
- }
4204
- }
4205
- function syncInitialContent(editor, sync) {
4206
- const { content } = editor.options;
4207
- if (content == null || content === "") return;
4208
- try {
4209
- const doc = createDocument(content, editor.schema, editor.options.parseOptions, {
4210
- errorOnInvalidContent: false
4211
- });
4212
- const tr = sync(EditorState.create({ doc }));
4213
- if (tr?.docChanged) editor.options.content = tr.doc;
4214
- } catch {
4215
- }
4216
- }
4217
- var STRUCTURE_PRIORITY = 45;
4218
-
4219
- // src/extensions/document-structure/outline.ts
4220
4148
  var outlinePluginKey = new PluginKey7("outline");
4221
4149
  var outlineIdPluginKey = new PluginKey7("outlineIds");
4222
4150
  var sameHeading = (a, b) => a.id === b.id && a.level === b.level && a.text === b.text && a.pos === b.pos && a.depth === b.depth;
@@ -6492,6 +6420,11 @@ function createRichTextPreset(options = {}) {
6492
6420
  if (options.findReplace) {
6493
6421
  extensions2.push(FindReplace.configure(optionObject(options.findReplace)));
6494
6422
  }
6423
+ if (options.chart) {
6424
+ const { sparkline = true, ...chartOptions } = optionObject(options.chart);
6425
+ extensions2.push(Chart.configure(chartOptions));
6426
+ if (sparkline) extensions2.push(Sparkline.configure(optionObject(sparkline)));
6427
+ }
6495
6428
  if (options.paragraphStyles) {
6496
6429
  extensions2.push(ParagraphStyles.configure(optionObject(options.paragraphStyles)));
6497
6430
  }
@@ -6820,4 +6753,4 @@ export {
6820
6753
  validateFindPattern,
6821
6754
  createTableCommands
6822
6755
  };
6823
- //# sourceMappingURL=chunk-PQFAHT5O.js.map
6756
+ //# sourceMappingURL=chunk-VKPEPWKZ.js.map