@harbour-enterprises/superdoc 0.25.0-next.5 → 0.25.0-next.7

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 (24) hide show
  1. package/dist/chunks/{PdfViewer-8kRpbCwn.cjs → PdfViewer-B2IOirxr.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-DVToyLl3.es.js → PdfViewer-lMsL6l5A.es.js} +1 -1
  3. package/dist/chunks/{index-STsumey2.es.js → index-DOLVGSYC.es.js} +2 -2
  4. package/dist/chunks/{index-DisCF1vr.cjs → index-aoNHRlnl.cjs} +2 -2
  5. package/dist/chunks/{super-editor.es-QqtfiJGc.cjs → super-editor.es-B2cypcnX.cjs} +218 -2
  6. package/dist/chunks/{super-editor.es-rBPknGqQ.es.js → super-editor.es-CHq5MqBc.es.js} +218 -2
  7. package/dist/super-editor/ai-writer.es.js +1 -1
  8. package/dist/super-editor/chunks/{editor-BOoGDORN.js → editor-CEZNgaJQ.js} +216 -0
  9. package/dist/super-editor/chunks/{toolbar-DPI_cCm_.js → toolbar-C6e42Zol.js} +1 -1
  10. package/dist/super-editor/editor.es.js +1 -1
  11. package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content-commands.d.ts +25 -0
  12. package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTablesById.d.ts +10 -0
  13. package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/index.d.ts +1 -0
  14. package/dist/super-editor/super-editor/src/extensions/table/table.d.ts +84 -0
  15. package/dist/super-editor/super-editor/src/extensions/table/tableHelpers/appendRows.d.ts +139 -0
  16. package/dist/super-editor/super-editor.es.js +5 -5
  17. package/dist/super-editor/toolbar.es.js +2 -2
  18. package/dist/super-editor.cjs +1 -1
  19. package/dist/super-editor.es.js +1 -1
  20. package/dist/superdoc.cjs +2 -2
  21. package/dist/superdoc.es.js +2 -2
  22. package/dist/superdoc.umd.js +218 -2
  23. package/dist/superdoc.umd.js.map +1 -1
  24. package/package.json +1 -1
@@ -63466,10 +63466,27 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63466
63466
  const result = findChildren$5(state2.doc, (node) => node.type.name === "structuredContentBlock");
63467
63467
  return result;
63468
63468
  }
63469
+ function getStructuredContentTablesById(id, state2) {
63470
+ if (!id || !state2) return [];
63471
+ const blocks = getStructuredContentTagsById(id, state2).filter(
63472
+ ({ node }) => node.type.name === "structuredContentBlock"
63473
+ );
63474
+ if (!blocks.length) return [];
63475
+ const { pos: blockPos, node: blockNode } = blocks[0];
63476
+ const tablesInBlock = [];
63477
+ blockNode.descendants((child, relPos) => {
63478
+ if (child.type.name === "table") {
63479
+ const absPos = blockPos + 1 + relPos;
63480
+ tablesInBlock.push({ node: child, pos: absPos });
63481
+ }
63482
+ });
63483
+ return tablesInBlock;
63484
+ }
63469
63485
  const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
63470
63486
  __proto__: null,
63471
63487
  getStructuredContentBlockTags,
63472
63488
  getStructuredContentInlineTags,
63489
+ getStructuredContentTablesById,
63473
63490
  getStructuredContentTags,
63474
63491
  getStructuredContentTagsById
63475
63492
  }, Symbol.toStringTag, { value: "Module" }));
@@ -63666,6 +63683,36 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63666
63683
  tr.replaceWith(posFrom, posTo, content);
63667
63684
  }
63668
63685
  return true;
63686
+ },
63687
+ /**
63688
+ * Append multiple rows to the end of a table inside a structured content block.
63689
+ * Each inner array represents the cell values for one new row.
63690
+ * @category Command
63691
+ * @param {StructuredContentTableAppendRowsOptions} options - Append configuration
63692
+ * @example
63693
+ * editor.commands.appendRowsToStructuredContentTable({
63694
+ * id: 'block-123',
63695
+ * tableIndex: 0,
63696
+ * rows: [['A', 'B'], ['C', 'D']],
63697
+ * copyRowStyle: true,
63698
+ * });
63699
+ */
63700
+ appendRowsToStructuredContentTable: ({ id, tableIndex = 0, rows = [], copyRowStyle = false }) => ({ state: state2, commands: commands2, dispatch }) => {
63701
+ const normalized = normalizeRowsInput(rows);
63702
+ if (!normalized.length) return true;
63703
+ const tables = getStructuredContentTablesById(id, state2);
63704
+ if (!tables.length || tableIndex < 0 || tableIndex >= tables.length) return true;
63705
+ const { node: tableNode, pos: tablePos } = tables[tableIndex];
63706
+ if (dispatch) {
63707
+ return commands2.appendRowsWithContent({ tablePos, tableNode, valueRows: normalized, copyRowStyle });
63708
+ }
63709
+ return commands2.appendRowsWithContent({
63710
+ tablePos,
63711
+ tableNode,
63712
+ valueRows: normalized,
63713
+ copyRowStyle,
63714
+ dispatch: false
63715
+ });
63669
63716
  }
63670
63717
  };
63671
63718
  },
@@ -63675,6 +63722,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63675
63722
  };
63676
63723
  }
63677
63724
  });
63725
+ const normalizeRowsInput = (rowsOrValues) => {
63726
+ if (!Array.isArray(rowsOrValues) || !rowsOrValues.length) {
63727
+ return [];
63728
+ }
63729
+ if (Array.isArray(rowsOrValues[0])) {
63730
+ return rowsOrValues;
63731
+ }
63732
+ return [rowsOrValues];
63733
+ };
63678
63734
  class DocumentSectionView {
63679
63735
  constructor(node, getPos, decorations, editor) {
63680
63736
  __privateAdd$1(this, _DocumentSectionView_instances);
@@ -69427,6 +69483,107 @@ Please report this to https://github.com/markedjs/marked.`, e) {
69427
69483
  }
69428
69484
  return null;
69429
69485
  }
69486
+ function resolveTable(tr, tablePos, tableNode) {
69487
+ if (tableNode && tableNode.type && tableNode.type.name === "table") {
69488
+ return tableNode;
69489
+ }
69490
+ if (typeof tablePos === "number") {
69491
+ const current = tr.doc.nodeAt(tablePos);
69492
+ if (current && current.type.name === "table") {
69493
+ return current;
69494
+ }
69495
+ }
69496
+ return null;
69497
+ }
69498
+ function pickTemplateRowForAppend(tableNode, schema) {
69499
+ const RowType = schema.nodes.tableRow;
69500
+ const rows = [];
69501
+ tableNode.descendants((child) => {
69502
+ if (child.type === RowType) rows.push(child);
69503
+ });
69504
+ if (!rows.length) return null;
69505
+ for (let i2 = rows.length - 1; i2 >= 0; i2--) {
69506
+ const r2 = rows[i2];
69507
+ const hasBodyCell = r2.content?.content?.some((c2) => c2.type.name === "tableCell");
69508
+ if (hasBodyCell) return r2;
69509
+ }
69510
+ return rows[rows.length - 1];
69511
+ }
69512
+ function extractRowTemplateFormatting(cellNode, schema) {
69513
+ const ParagraphType = schema.nodes.paragraph;
69514
+ let blockType = ParagraphType;
69515
+ let blockAttrs = null;
69516
+ let textMarks = [];
69517
+ const blocks = cellNode?.content?.content || [];
69518
+ for (const block of blocks) {
69519
+ const isParagraphish = block.type === ParagraphType || block.type.name === "heading";
69520
+ if (isParagraphish) {
69521
+ blockType = block.type || ParagraphType;
69522
+ blockAttrs = block.attrs || null;
69523
+ }
69524
+ let foundText = null;
69525
+ block.descendants?.((n) => {
69526
+ if (!foundText && n.isText) foundText = n;
69527
+ });
69528
+ if (foundText) {
69529
+ textMarks = foundText.marks ? Array.from(foundText.marks) : [];
69530
+ break;
69531
+ }
69532
+ }
69533
+ if (!blockType || !blockType.validContent) blockType = ParagraphType;
69534
+ return { blockType, blockAttrs, textMarks };
69535
+ }
69536
+ function buildFormattedCellBlock(schema, value, { blockType, blockAttrs, textMarks }, copyRowStyle = false) {
69537
+ const text = typeof value === "string" ? value : value == null ? "" : String(value);
69538
+ const marks = copyRowStyle ? textMarks || [] : [];
69539
+ const textNode = schema.text(text, marks);
69540
+ const type2 = blockType || schema.nodes.paragraph;
69541
+ return type2.createAndFill(blockAttrs || null, textNode);
69542
+ }
69543
+ function buildRowFromTemplateRow({ schema, tableNode, templateRow, values, copyRowStyle = false }) {
69544
+ const RowType = schema.nodes.tableRow;
69545
+ const CellType = schema.nodes.tableCell;
69546
+ const HeaderType = schema.nodes.tableHeader;
69547
+ const map2 = TableMap.get(tableNode);
69548
+ const totalColumns = map2.width;
69549
+ const byColumns = Array.isArray(values) && values.length === totalColumns;
69550
+ const newCells = [];
69551
+ let columnCursor = 0;
69552
+ templateRow.content.content.forEach((cellNode, cellIndex) => {
69553
+ const isHeaderCell = cellNode.type === HeaderType;
69554
+ const targetCellType = isHeaderCell ? CellType : cellNode.type;
69555
+ const attrs = { ...cellNode.attrs };
69556
+ const formatting = extractRowTemplateFormatting(cellNode, schema);
69557
+ let cellValue = "";
69558
+ if (byColumns) {
69559
+ const span = Math.max(1, attrs.colspan || 1);
69560
+ cellValue = values[columnCursor] ?? "";
69561
+ columnCursor += span;
69562
+ } else {
69563
+ cellValue = Array.isArray(values) ? values[cellIndex] ?? "" : "";
69564
+ }
69565
+ const content = buildFormattedCellBlock(schema, cellValue, formatting, copyRowStyle);
69566
+ const newCell = targetCellType.createAndFill(attrs, content);
69567
+ if (newCell) newCells.push(newCell);
69568
+ });
69569
+ return RowType.createAndFill(null, newCells);
69570
+ }
69571
+ function insertRowsAtTableEnd({ tr, tablePos, tableNode, rows }) {
69572
+ if (!rows || !rows.length) return;
69573
+ const RowTypeName = "tableRow";
69574
+ let lastRowRelPos = 0;
69575
+ let lastRowNode = null;
69576
+ tableNode.descendants((child, relPos) => {
69577
+ if (child.type.name === RowTypeName) {
69578
+ lastRowRelPos = relPos;
69579
+ lastRowNode = child;
69580
+ }
69581
+ });
69582
+ if (!lastRowNode) return;
69583
+ const lastRowAbsEnd = tablePos + 1 + lastRowRelPos + lastRowNode.nodeSize;
69584
+ const frag = Fragment.fromArray(rows);
69585
+ tr.insert(lastRowAbsEnd, frag);
69586
+ }
69430
69587
  const Table = Node$1.create({
69431
69588
  name: "table",
69432
69589
  content: "tableRow+",
@@ -69586,6 +69743,47 @@ Please report this to https://github.com/markedjs/marked.`, e) {
69586
69743
  },
69587
69744
  addCommands() {
69588
69745
  return {
69746
+ /**
69747
+ * Append multiple rows to the end of a table in a single transaction.
69748
+ * @category Command
69749
+ * @param {appendRowsWithContentOptions} options - Append configuration
69750
+ * @example
69751
+ * editor.commands.appendRowsWithContent({ tablePos, valueRows: [['A','B'], ['C','D']], copyRowStyle: true })
69752
+ */
69753
+ appendRowsWithContent: ({ tablePos, tableNode, valueRows = [], copyRowStyle = false }) => ({ editor, chain }) => {
69754
+ if (typeof tablePos !== "number" && !tableNode || !Array.isArray(valueRows) || !valueRows.length) {
69755
+ return false;
69756
+ }
69757
+ return chain().command(({ tr, dispatch }) => {
69758
+ const workingTable = resolveTable(tr, tablePos, tableNode);
69759
+ if (!workingTable) return false;
69760
+ const templateRow = pickTemplateRowForAppend(workingTable, editor.schema);
69761
+ if (!templateRow) return false;
69762
+ const newRows = valueRows.map(
69763
+ (vals) => buildRowFromTemplateRow({
69764
+ schema: editor.schema,
69765
+ tableNode: workingTable,
69766
+ templateRow,
69767
+ values: vals,
69768
+ copyRowStyle
69769
+ })
69770
+ ).filter(Boolean);
69771
+ if (!newRows.length) return false;
69772
+ let resolvedTablePos = tablePos;
69773
+ if (typeof resolvedTablePos !== "number" && workingTable) {
69774
+ const tables = editor.getNodesOfType("table");
69775
+ const match = workingTable ? tables.find((t) => t.node.eq(workingTable)) : tables[0];
69776
+ resolvedTablePos = match?.pos ?? null;
69777
+ }
69778
+ if (typeof resolvedTablePos !== "number") {
69779
+ return false;
69780
+ }
69781
+ if (dispatch) {
69782
+ insertRowsAtTableEnd({ tr, tablePos, tableNode: workingTable, rows: newRows });
69783
+ }
69784
+ return true;
69785
+ }).run();
69786
+ },
69589
69787
  /**
69590
69788
  * Insert a new table into the document
69591
69789
  * @category Command
@@ -75232,6 +75430,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75232
75430
  const { from: from2, to } = state2.selection;
75233
75431
  return commands2.acceptTrackedChangesBetween(from2, to);
75234
75432
  },
75433
+ acceptTrackedChangeFromToolbar: () => ({ state: state2, commands: commands2 }) => {
75434
+ const commentsPluginState = CommentsPluginKey.getState(state2);
75435
+ const activeThreadId = commentsPluginState?.activeThreadId;
75436
+ if (activeThreadId && commentsPluginState?.trackedChanges?.[activeThreadId]) {
75437
+ return commands2.acceptTrackedChangeById(activeThreadId);
75438
+ } else {
75439
+ return commands2.acceptTrackedChangeBySelection();
75440
+ }
75441
+ },
75235
75442
  acceptTrackedChangeById: (id) => ({ state: state2, tr, commands: commands2 }) => {
75236
75443
  const toResolve = getChangesByIdToResolve(state2, id) || [];
75237
75444
  return toResolve.map(({ from: from2, to }) => {
@@ -75260,6 +75467,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75260
75467
  const { from: from2, to } = state2.selection;
75261
75468
  return commands2.rejectTrackedChangesBetween(from2, to);
75262
75469
  },
75470
+ rejectTrackedChangeFromToolbar: () => ({ state: state2, commands: commands2 }) => {
75471
+ const commentsPluginState = CommentsPluginKey.getState(state2);
75472
+ const activeThreadId = commentsPluginState?.activeThreadId;
75473
+ if (activeThreadId && commentsPluginState?.trackedChanges?.[activeThreadId]) {
75474
+ return commands2.rejectTrackedChangeById(activeThreadId);
75475
+ } else {
75476
+ return commands2.rejectTrackedChangeOnSelection();
75477
+ }
75478
+ },
75263
75479
  rejectAllTrackedChanges: () => ({ state: state2, commands: commands2 }) => {
75264
75480
  const from2 = 0, to = state2.doc.content.size;
75265
75481
  return commands2.rejectTrackedChangesBetween(from2, to);
@@ -93662,7 +93878,7 @@ ${style2}
93662
93878
  disabled: false,
93663
93879
  name: "acceptTrackedChangeBySelection",
93664
93880
  tooltip: toolbarTexts2.trackChangesAccept,
93665
- command: "acceptTrackedChangeBySelection",
93881
+ command: "acceptTrackedChangeFromToolbar",
93666
93882
  icon: toolbarIcons2.trackChangesAccept,
93667
93883
  group: "left",
93668
93884
  attributes: {
@@ -93674,7 +93890,7 @@ ${style2}
93674
93890
  disabled: false,
93675
93891
  name: "rejectTrackedChangeOnSelection",
93676
93892
  tooltip: toolbarTexts2.trackChangesReject,
93677
- command: "rejectTrackedChangeOnSelection",
93893
+ command: "rejectTrackedChangeFromToolbar",
93678
93894
  icon: toolbarIcons2.trackChangesReject,
93679
93895
  group: "left",
93680
93896
  attributes: {