@superdoc-dev/mcp 0.8.0-next.5 → 0.8.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 (2) hide show
  1. package/dist/index.js +517 -51
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -51891,7 +51891,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
51891
51891
  emptyOptions2 = {};
51892
51892
  });
51893
51893
 
51894
- // ../../packages/superdoc/dist/chunks/SuperConverter-yBMSqEiB.es.js
51894
+ // ../../packages/superdoc/dist/chunks/SuperConverter-k7GHkV-c.es.js
51895
51895
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
51896
51896
  const fieldValue = extension$1.config[field];
51897
51897
  if (typeof fieldValue === "function")
@@ -80560,6 +80560,33 @@ function _getReferencedTableStyles(tableStyleReference, params) {
80560
80560
  ...styleProps
80561
80561
  };
80562
80562
  }
80563
+ function buildFieldResultRuns(params, outputMarks) {
80564
+ const { node: node2 } = params;
80565
+ const contentNodes = (node2.content ?? []).flatMap((child) => exportSchemaToJson({
80566
+ ...params,
80567
+ node: child
80568
+ }));
80569
+ if (contentNodes.length > 0)
80570
+ return contentNodes;
80571
+ const resolvedText = node2.attrs?.resolvedText;
80572
+ if (typeof resolvedText !== "string" || resolvedText.length === 0)
80573
+ return [];
80574
+ const textAttributes = /^\s|\s$/.test(resolvedText) ? { "xml:space": "preserve" } : undefined;
80575
+ return [{
80576
+ name: "w:r",
80577
+ elements: [{
80578
+ name: "w:rPr",
80579
+ elements: outputMarks
80580
+ }, {
80581
+ name: "w:t",
80582
+ attributes: textAttributes,
80583
+ elements: [{
80584
+ text: resolvedText,
80585
+ type: "text"
80586
+ }]
80587
+ }]
80588
+ }];
80589
+ }
80563
80590
  function parseTarget(instruction) {
80564
80591
  if (!instruction)
80565
80592
  return "";
@@ -80613,7 +80640,19 @@ function parseCitationSourceIds(instruction) {
80613
80640
  function extractResolvedText$1(content$2) {
80614
80641
  if (!Array.isArray(content$2))
80615
80642
  return "";
80616
- return content$2.filter((n) => n.type === "text").map((n) => n.text || "").join("");
80643
+ let out = "";
80644
+ const walk = (nodes) => {
80645
+ for (const node2 of nodes) {
80646
+ if (!node2)
80647
+ continue;
80648
+ if (node2.type === "text")
80649
+ out += node2.text || "";
80650
+ else if (Array.isArray(node2.content))
80651
+ walk(node2.content);
80652
+ }
80653
+ };
80654
+ walk(content$2);
80655
+ return out;
80617
80656
  }
80618
80657
  function parseTaInstruction(instruction) {
80619
80658
  let longCitation = "";
@@ -102766,10 +102805,7 @@ var isRegExp = (value) => {
102766
102805
  }, decode$20 = (params) => {
102767
102806
  const { node: node2 } = params;
102768
102807
  const outputMarks = processOutputMarks(node2.attrs?.marksAsAttrs || []);
102769
- const contentNodes = (node2.content ?? []).flatMap((n) => exportSchemaToJson({
102770
- ...params,
102771
- node: n
102772
- }));
102808
+ const contentNodes = buildFieldResultRuns(params, outputMarks);
102773
102809
  const instructionElements = buildInstructionElements(node2.attrs?.instruction, node2.attrs?.instructionTokens);
102774
102810
  return [
102775
102811
  {
@@ -102834,10 +102870,7 @@ var isRegExp = (value) => {
102834
102870
  }, decode$19 = (params) => {
102835
102871
  const { node: node2 } = params;
102836
102872
  const outputMarks = processOutputMarks(node2.attrs?.marksAsAttrs || []);
102837
- const contentNodes = (node2.content ?? []).flatMap((n) => exportSchemaToJson({
102838
- ...params,
102839
- node: n
102840
- }));
102873
+ const contentNodes = buildFieldResultRuns(params, outputMarks);
102841
102874
  const instructionElements = buildInstructionElements(node2.attrs?.instruction, node2.attrs?.instructionTokens);
102842
102875
  return [
102843
102876
  {
@@ -105977,7 +106010,7 @@ var isRegExp = (value) => {
105977
106010
  state.kern = kernNode.attributes["w:val"];
105978
106011
  }
105979
106012
  }, SuperConverter;
105980
- var init_SuperConverter_yBMSqEiB_es = __esm(() => {
106013
+ var init_SuperConverter_k7GHkV_c_es = __esm(() => {
105981
106014
  init_rolldown_runtime_Bg48TavK_es();
105982
106015
  init_jszip_C49i9kUs_es();
105983
106016
  init_xml_js_CqGKpaft_es();
@@ -144157,7 +144190,7 @@ var init_SuperConverter_yBMSqEiB_es = __esm(() => {
144157
144190
  };
144158
144191
  });
144159
144192
 
144160
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DOHBUV3P.es.js
144193
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-dycevpY9.es.js
144161
144194
  function parseSizeUnit(val = "0") {
144162
144195
  const length = val.toString() || "0";
144163
144196
  const value = Number.parseFloat(length);
@@ -154182,8 +154215,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
154182
154215
  }
154183
154216
  };
154184
154217
  };
154185
- var init_create_headless_toolbar_DOHBUV3P_es = __esm(() => {
154186
- init_SuperConverter_yBMSqEiB_es();
154218
+ var init_create_headless_toolbar_dycevpY9_es = __esm(() => {
154219
+ init_SuperConverter_k7GHkV_c_es();
154187
154220
  init_uuid_qzgm05fK_es();
154188
154221
  init_constants_DrU4EASo_es();
154189
154222
  init_dist_B8HfvhaK_es();
@@ -208909,7 +208942,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
208909
208942
  init_remark_gfm_BhnWr3yf_es();
208910
208943
  });
208911
208944
 
208912
- // ../../packages/superdoc/dist/chunks/src-Cccxf1lk.es.js
208945
+ // ../../packages/superdoc/dist/chunks/src-D6w3M9Bh.es.js
208913
208946
  function deleteProps(obj, propOrProps) {
208914
208947
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
208915
208948
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -210796,6 +210829,86 @@ function backfillCapability(metaMap, ydoc) {
210796
210829
  function createReplacer(data) {
210797
210830
  return ({ part }) => replacePartData(part, data);
210798
210831
  }
210832
+ function normalizeYjsFragmentForSchema(fragment) {
210833
+ if (!isTraversableYjsXml(fragment))
210834
+ return false;
210835
+ let changed = false;
210836
+ const normalize4 = () => {
210837
+ changed = stripSchemaAtomChildren(fragment) || changed;
210838
+ };
210839
+ if (fragment.doc)
210840
+ fragment.doc.transact(normalize4, NORMALIZE_YJS_FRAGMENT_ORIGIN);
210841
+ else
210842
+ normalize4();
210843
+ return changed;
210844
+ }
210845
+ function normalizeYjsFragmentEventsForSchema(events, fallbackFragment) {
210846
+ if (!Array.isArray(events) || events.length === 0)
210847
+ return normalizeYjsFragmentForSchema(fallbackFragment);
210848
+ if (events.some((event) => event?.transaction?.origin === NORMALIZE_YJS_FRAGMENT_ORIGIN))
210849
+ return false;
210850
+ let changed = false;
210851
+ const normalize4 = () => {
210852
+ const visited = /* @__PURE__ */ new Set;
210853
+ for (const event of events) {
210854
+ const target = findNormalizableEventTarget(event?.target);
210855
+ if (!isTraversableYjsXml(target) || visited.has(target))
210856
+ continue;
210857
+ visited.add(target);
210858
+ changed = stripSchemaAtomChildren(target) || changed;
210859
+ }
210860
+ };
210861
+ const doc$12 = fallbackFragment?.doc || findEventDoc(events);
210862
+ if (doc$12)
210863
+ doc$12.transact(normalize4, NORMALIZE_YJS_FRAGMENT_ORIGIN);
210864
+ else
210865
+ normalize4();
210866
+ return changed;
210867
+ }
210868
+ function stripSchemaAtomChildren(parent) {
210869
+ if (!isTraversableYjsXml(parent))
210870
+ return false;
210871
+ if (parent instanceof YXmlElement && SCHEMA_ATOM_NODE_NAMES.has(parent.nodeName)) {
210872
+ if (parent.length === 0)
210873
+ return false;
210874
+ parent.delete(0, parent.length);
210875
+ return true;
210876
+ }
210877
+ let changed = false;
210878
+ for (const child of parent.toArray()) {
210879
+ if (!(child instanceof YXmlElement))
210880
+ continue;
210881
+ if (SCHEMA_ATOM_NODE_NAMES.has(child.nodeName)) {
210882
+ if (child.length > 0) {
210883
+ child.delete(0, child.length);
210884
+ changed = true;
210885
+ }
210886
+ continue;
210887
+ }
210888
+ changed = stripSchemaAtomChildren(child) || changed;
210889
+ }
210890
+ return changed;
210891
+ }
210892
+ function findNormalizableEventTarget(target) {
210893
+ let current = target;
210894
+ while (current) {
210895
+ if (current instanceof YXmlElement && SCHEMA_ATOM_NODE_NAMES.has(current.nodeName))
210896
+ return current;
210897
+ current = current.parent;
210898
+ }
210899
+ return target;
210900
+ }
210901
+ function findEventDoc(events) {
210902
+ for (const event of events) {
210903
+ const doc$12 = event?.target?.doc;
210904
+ if (doc$12)
210905
+ return doc$12;
210906
+ }
210907
+ return null;
210908
+ }
210909
+ function isTraversableYjsXml(value) {
210910
+ return Boolean(value && typeof value.toArray === "function");
210911
+ }
210799
210912
  function getEditorSurfaceElement(editor) {
210800
210913
  if (!editor)
210801
210914
  return null;
@@ -211298,13 +211411,8 @@ function splitBlockPatch(state, dispatch, editor) {
211298
211411
  atStart = $from.start(d) == $from.pos - ($from.depth - d);
211299
211412
  deflt = defaultBlockAt($from.node(d - 1).contentMatchAt($from.indexAfter(d - 1)));
211300
211413
  const sourceParagraphStyleId = node2.attrs?.paragraphProperties?.styleId;
211301
- paragraphAttrs = {
211302
- ...node2.attrs,
211303
- sdBlockId: null,
211304
- sdBlockRev: null,
211305
- paraId: null,
211306
- textId: null
211307
- };
211414
+ const extensionAttrs = editor?.extensionService?.attributes ?? [];
211415
+ paragraphAttrs = Attribute2.getSplittedAttributes(extensionAttrs, node2.type.name, node2.attrs);
211308
211416
  paragraphAttrs = clearInheritedLinkedStyleId(paragraphAttrs, editor, { emptyParagraph: atEnd });
211309
211417
  if (atEnd && $from.parent.type.name === "run") {
211310
211418
  if (!isLinkedParagraphStyleId(editor, sourceParagraphStyleId))
@@ -232316,10 +232424,7 @@ function tablesSplitAdapter(editor, input2, options) {
232316
232424
  const rEnd = tr.mapping.slice(mapFrom).map(rowPositions[i4] + tableNode.child(i4).nodeSize);
232317
232425
  tr.delete(rp, rEnd);
232318
232426
  }
232319
- const newTableAttrs = { ...tableNode.attrs };
232320
- delete newTableAttrs.sdBlockId;
232321
- delete newTableAttrs.paraId;
232322
- delete newTableAttrs.textId;
232427
+ const newTableAttrs = Attribute2.getSplittedAttributes(editor.extensionService?.attributes ?? [], tableNode.type.name, tableNode.attrs);
232323
232428
  const newTable = schema.nodes.table.create(newTableAttrs, secondTableRows);
232324
232429
  const separatorParagraph = createSeparatorParagraph(schema);
232325
232430
  if (!separatorParagraph)
@@ -268725,7 +268830,7 @@ var Node$13 = class Node$14 {
268725
268830
  let $pos = doc$12.resolve(this.pos);
268726
268831
  return GapCursor.valid($pos) ? new GapCursor($pos) : Selection.near($pos);
268727
268832
  }
268728
- }, handleKeyDown2, Gapcursor, PARTS_MAP_KEY = "parts", META_MAP_KEY = "meta", META_PARTS_SCHEMA_VERSION_KEY = "partsSchemaVersion", META_PARTS_MIGRATION_KEY = "partsMigration", META_PARTS_LAST_HYDRATED_AT_KEY = "partsLastHydratedAt", META_PARTS_FALLBACK_MODE_KEY = "partsFallbackMode", META_PARTS_CAPABILITY_KEY = "partsCapability", SOURCE_COLLAB_REMOTE_PARTS = "collab:remote:parts", SOURCE_COLLAB_REMOTE_PREFIX = "collab:remote:", EXCLUDED_PART_IDS, CRITICAL_PART_IDS, isApplyingRemoteParts = false, headlessBindingStateByEditor, headlessCleanupRegisteredEditors, META_BODY_SECT_PR_KEY = "bodySectPr", BODY_SECT_PR_SYNC_META_KEY = "bodySectPrSync", collaborationCleanupByEditor, registerHeadlessBindingCleanup = (editor, cleanup) => {
268833
+ }, handleKeyDown2, Gapcursor, PARTS_MAP_KEY = "parts", META_MAP_KEY = "meta", META_PARTS_SCHEMA_VERSION_KEY = "partsSchemaVersion", META_PARTS_MIGRATION_KEY = "partsMigration", META_PARTS_LAST_HYDRATED_AT_KEY = "partsLastHydratedAt", META_PARTS_FALLBACK_MODE_KEY = "partsFallbackMode", META_PARTS_CAPABILITY_KEY = "partsCapability", SOURCE_COLLAB_REMOTE_PARTS = "collab:remote:parts", SOURCE_COLLAB_REMOTE_PREFIX = "collab:remote:", EXCLUDED_PART_IDS, CRITICAL_PART_IDS, isApplyingRemoteParts = false, SCHEMA_ATOM_NODE_NAMES, NORMALIZE_YJS_FRAGMENT_ORIGIN, headlessBindingStateByEditor, headlessCleanupRegisteredEditors, META_BODY_SECT_PR_KEY = "bodySectPr", BODY_SECT_PR_SYNC_META_KEY = "bodySectPrSync", collaborationCleanupByEditor, registerHeadlessBindingCleanup = (editor, cleanup) => {
268729
268834
  if (!cleanup || headlessCleanupRegisteredEditors.has(editor))
268730
268835
  return;
268731
268836
  headlessCleanupRegisteredEditors.add(editor);
@@ -268809,6 +268914,7 @@ var Node$13 = class Node$14 {
268809
268914
  if (!cleanup)
268810
268915
  return;
268811
268916
  cleanup.syncListenerCleanup?.();
268917
+ cleanup.fragmentNormalizeCleanup?.();
268812
268918
  cleanup.mediaMap?.unobserve?.(cleanup.mediaMapObserver);
268813
268919
  cleanup.metaMap?.unobserve?.(cleanup.metaMapObserver);
268814
268920
  cleanup.partSyncHandle?.destroy();
@@ -268819,12 +268925,23 @@ var Node$13 = class Node$14 {
268819
268925
  collaborationCleanupByEditor.delete(editor);
268820
268926
  }, createSyncPlugin = (ydoc, editor) => {
268821
268927
  const fragment = ydoc.getXmlFragment("supereditor");
268928
+ normalizeYjsFragmentForSchema(fragment);
268822
268929
  const onFirstRender = () => {
268823
268930
  if (!editor.options.isNewFile)
268824
268931
  return;
268825
268932
  initializeMetaMap(ydoc, editor);
268826
268933
  };
268827
268934
  return [ySyncPlugin(fragment, { onFirstRender }), fragment];
268935
+ }, registerYjsFragmentNormalizer = (fragment) => {
268936
+ if (!fragment || typeof fragment.observeDeep !== "function" || typeof fragment.unobserveDeep !== "function")
268937
+ return () => {};
268938
+ const normalize4 = (events) => {
268939
+ normalizeYjsFragmentEventsForSchema(events, fragment);
268940
+ };
268941
+ fragment.observeDeep(normalize4);
268942
+ return () => {
268943
+ fragment.unobserveDeep(normalize4);
268944
+ };
268828
268945
  }, initializeMetaMap = (ydoc, editor) => {
268829
268946
  seedPartsFromEditor(editor, ydoc);
268830
268947
  const mediaMap = ydoc.getMap("media");
@@ -297376,13 +297493,13 @@ menclose::after {
297376
297493
  return;
297377
297494
  console.log(...args$1);
297378
297495
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions;
297379
- var init_src_Cccxf1lk_es = __esm(() => {
297496
+ var init_src_D6w3M9Bh_es = __esm(() => {
297380
297497
  init_rolldown_runtime_Bg48TavK_es();
297381
- init_SuperConverter_yBMSqEiB_es();
297498
+ init_SuperConverter_k7GHkV_c_es();
297382
297499
  init_jszip_C49i9kUs_es();
297383
297500
  init_xml_js_CqGKpaft_es();
297384
297501
  init_uuid_qzgm05fK_es();
297385
- init_create_headless_toolbar_DOHBUV3P_es();
297502
+ init_create_headless_toolbar_dycevpY9_es();
297386
297503
  init_constants_DrU4EASo_es();
297387
297504
  init_dist_B8HfvhaK_es();
297388
297505
  init_unified_Dsuw2be5_es();
@@ -298604,6 +298721,8 @@ ${err.toString()}`);
298604
298721
  "word/_rels/document.xml.rels",
298605
298722
  "[Content_Types].xml"
298606
298723
  ]);
298724
+ SCHEMA_ATOM_NODE_NAMES = new Set(["crossReference", "citation"]);
298725
+ NORMALIZE_YJS_FRAGMENT_ORIGIN = Symbol.for("superdoc/yjs-fragment-normalize");
298607
298726
  new PluginKey("collaboration");
298608
298727
  headlessBindingStateByEditor = /* @__PURE__ */ new WeakMap;
298609
298728
  headlessCleanupRegisteredEditors = /* @__PURE__ */ new WeakSet;
@@ -298631,6 +298750,7 @@ ${err.toString()}`);
298631
298750
  const syncListenerCleanup = initSyncListener(this.options.ydoc, this.editor, this);
298632
298751
  const [syncPlugin, fragment] = createSyncPlugin(this.options.ydoc, this.editor);
298633
298752
  this.options.fragment = fragment;
298753
+ const fragmentNormalizeCleanup = registerYjsFragmentNormalizer(fragment);
298634
298754
  const mediaMap = this.options.ydoc.getMap("media");
298635
298755
  const mediaMapObserver = (event) => {
298636
298756
  event.changes.keys.forEach((_$1, key2) => {
@@ -298645,6 +298765,7 @@ ${err.toString()}`);
298645
298765
  syncListenerCleanup,
298646
298766
  mediaMap,
298647
298767
  mediaMapObserver,
298768
+ fragmentNormalizeCleanup,
298648
298769
  metaMap: null,
298649
298770
  metaMapObserver: null,
298650
298771
  partSyncHandle: null,
@@ -300263,8 +300384,14 @@ ${err.toString()}`);
300263
300384
  },
300264
300385
  addAttributes() {
300265
300386
  return {
300266
- paraId: { rendered: false },
300267
- textId: { rendered: false },
300387
+ paraId: {
300388
+ rendered: false,
300389
+ keepOnSplit: false
300390
+ },
300391
+ textId: {
300392
+ rendered: false,
300393
+ keepOnSplit: false
300394
+ },
300268
300395
  rsidR: { rendered: false },
300269
300396
  rsidRDefault: { rendered: false },
300270
300397
  rsidP: { rendered: false },
@@ -321421,6 +321548,7 @@ function print() { __p += __j.call(arguments, '') }
321421
321548
  }
321422
321549
  #telemetry = null;
321423
321550
  #documentOpenTracked = false;
321551
+ #constructorFragment = null;
321424
321552
  constructor(options) {
321425
321553
  super();
321426
321554
  this.extensionStorage = {};
@@ -321526,6 +321654,7 @@ function print() { __p += __j.call(arguments, '') }
321526
321654
  resolvedOptions.element = null;
321527
321655
  resolvedOptions.selector = null;
321528
321656
  }
321657
+ this.#constructorFragment = resolvedOptions.fragment ?? null;
321529
321658
  this.#checkHeadless(resolvedOptions);
321530
321659
  this.setOptions(resolvedOptions);
321531
321660
  this.#renderer = resolvedOptions.renderer ?? (domAvailable ? new ProseMirrorRenderer : null);
@@ -321647,6 +321776,7 @@ function print() { __p += __j.call(arguments, '') }
321647
321776
  try {
321648
321777
  const resolvedMode = options?.mode ?? this.options.mode ?? "docx";
321649
321778
  const explicitIsNewFile = options?.isNewFile;
321779
+ const hasOpenFragment = Object.prototype.hasOwnProperty.call(options ?? {}, "fragment");
321650
321780
  const resolvedOptions = {
321651
321781
  ...this.options,
321652
321782
  mode: resolvedMode,
@@ -321655,7 +321785,8 @@ function print() { __p += __j.call(arguments, '') }
321655
321785
  documentMode: options?.documentMode ?? this.options.documentMode ?? "editing",
321656
321786
  html: options?.html,
321657
321787
  markdown: options?.markdown,
321658
- jsonOverride: options?.json ?? null
321788
+ jsonOverride: options?.json ?? null,
321789
+ fragment: hasOpenFragment ? options?.fragment ?? null : this.options.fragment ?? this.#constructorFragment
321659
321790
  };
321660
321791
  const loadOptions = options?.password ? { password: options.password } : undefined;
321661
321792
  if (typeof source === "string")
@@ -321789,6 +321920,7 @@ function print() { __p += __j.call(arguments, '') }
321789
321920
  this.options.initialState = null;
321790
321921
  this.options.content = "";
321791
321922
  this.options.fileSource = null;
321923
+ this.options.fragment = null;
321792
321924
  this._state = undefined;
321793
321925
  }
321794
321926
  #initProtectionState() {
@@ -322493,8 +322625,10 @@ function print() { __p += __j.call(arguments, '') }
322493
322625
  });
322494
322626
  else if (this.options.jsonOverride)
322495
322627
  doc$12 = this.schema.nodeFromJSON(this.options.jsonOverride);
322496
- if (fragment)
322628
+ if (fragment) {
322629
+ normalizeYjsFragmentForSchema(fragment);
322497
322630
  doc$12 = yXmlFragmentToProseMirrorRootNode(fragment, this.schema);
322631
+ }
322498
322632
  }
322499
322633
  else if (mode === "text" || mode === "html")
322500
322634
  if (loadFromSchema && hasJsonContent(content3))
@@ -323060,12 +323194,13 @@ function print() { __p += __j.call(arguments, '') }
323060
323194
  isHeadless: !(config3?.element != null || config3?.selector != null),
323061
323195
  ...config3
323062
323196
  };
323063
- const { html: html3, markdown, json: json2, isCommentsEnabled, suppressDefaultDocxStyles, documentMode, content: content3, mediaFiles, fonts, isNewFile, password, ...editorConfig } = resolvedConfig;
323197
+ const { html: html3, markdown, json: json2, fragment, isCommentsEnabled, suppressDefaultDocxStyles, documentMode, content: content3, mediaFiles, fonts, isNewFile, password, ...editorConfig } = resolvedConfig;
323064
323198
  const openOptions = {
323065
323199
  mode: resolvedConfig.mode,
323066
323200
  html: html3,
323067
323201
  markdown,
323068
323202
  json: json2,
323203
+ fragment,
323069
323204
  isCommentsEnabled,
323070
323205
  suppressDefaultDocxStyles,
323071
323206
  documentMode,
@@ -335179,11 +335314,11 @@ function print() { __p += __j.call(arguments, '') }
335179
335314
  ];
335180
335315
  });
335181
335316
 
335182
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-Dv5eUJtx.es.js
335317
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-BLDU9pTd.es.js
335183
335318
  var MOD_ALIASES, ALT_ALIASES, CTRL_ALIASES, SHIFT_ALIASES, BUILTIN_CONTEXT_MENU_GROUPS, BUILTIN_GROUP_ORDER, RESERVED_PROXY_PROPERTY_NAMES, ALL_TOOLBAR_COMMAND_IDS, EMPTY_ACTIVE_IDS;
335184
- var init_create_super_doc_ui_Dv5eUJtx_es = __esm(() => {
335185
- init_SuperConverter_yBMSqEiB_es();
335186
- init_create_headless_toolbar_DOHBUV3P_es();
335319
+ var init_create_super_doc_ui_BLDU9pTd_es = __esm(() => {
335320
+ init_SuperConverter_k7GHkV_c_es();
335321
+ init_create_headless_toolbar_dycevpY9_es();
335187
335322
  MOD_ALIASES = new Set([
335188
335323
  "Mod",
335189
335324
  "Meta",
@@ -335225,16 +335360,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
335225
335360
 
335226
335361
  // ../../packages/superdoc/dist/super-editor.es.js
335227
335362
  var init_super_editor_es = __esm(() => {
335228
- init_src_Cccxf1lk_es();
335229
- init_SuperConverter_yBMSqEiB_es();
335363
+ init_src_D6w3M9Bh_es();
335364
+ init_SuperConverter_k7GHkV_c_es();
335230
335365
  init_jszip_C49i9kUs_es();
335231
335366
  init_xml_js_CqGKpaft_es();
335232
- init_create_headless_toolbar_DOHBUV3P_es();
335367
+ init_create_headless_toolbar_dycevpY9_es();
335233
335368
  init_constants_DrU4EASo_es();
335234
335369
  init_dist_B8HfvhaK_es();
335235
335370
  init_unified_Dsuw2be5_es();
335236
335371
  init_DocxZipper_CZMPWpOp_es();
335237
- init_create_super_doc_ui_Dv5eUJtx_es();
335372
+ init_create_super_doc_ui_BLDU9pTd_es();
335238
335373
  init_ui_C5PAS9hY_es();
335239
335374
  init_eventemitter3_BnGqBE_Q_es();
335240
335375
  init_errors_CNaD6vcg_es();
@@ -393842,6 +393977,28 @@ function chainableEditorState2(transaction, state) {
393842
393977
  }
393843
393978
  };
393844
393979
  }
393980
+
393981
+ // ../../packages/super-editor/src/editors/v1/core/helpers/getNodeType.js
393982
+ function getNodeType2(nameOrType, schema) {
393983
+ if (typeof nameOrType === "string") {
393984
+ if (!schema.nodes[nameOrType]) {
393985
+ throw Error(`There is no node type named '${nameOrType}' in schema.`);
393986
+ }
393987
+ return schema.nodes[nameOrType];
393988
+ }
393989
+ return nameOrType;
393990
+ }
393991
+
393992
+ // ../../packages/super-editor/src/editors/v1/core/helpers/getMarkType.js
393993
+ function getMarkType2(nameOrType, schema) {
393994
+ if (typeof nameOrType === "string") {
393995
+ if (!schema.marks[nameOrType]) {
393996
+ throw Error(`There is no mark type named '${nameOrType}' in schema.`);
393997
+ }
393998
+ return schema.marks[nameOrType];
393999
+ }
394000
+ return nameOrType;
394001
+ }
393845
394002
  // ../../packages/super-editor/src/editors/v1/core/helpers/findParentNodeClosestToPos.js
393846
394003
  var findParentNodeClosestToPos2 = ($pos, predicate) => {
393847
394004
  for (let i4 = $pos.depth;i4 > 0; i4--) {
@@ -393900,6 +394057,16 @@ var init_isMarkActive = __esm(() => {
393900
394057
  var init_getMarksBetween = __esm(() => {
393901
394058
  init_getMarkRange();
393902
394059
  });
394060
+
394061
+ // ../../packages/super-editor/src/editors/v1/core/helpers/getSchemaTypeNameByName.js
394062
+ function getSchemaTypeNameByName2(name, schema) {
394063
+ if (schema.nodes[name])
394064
+ return "node";
394065
+ if (schema.marks[name])
394066
+ return "mark";
394067
+ return null;
394068
+ }
394069
+
393903
394070
  // ../../packages/super-editor/src/editors/v1/core/helpers/isNodeActive.js
393904
394071
  var init_isNodeActive = __esm(() => {
393905
394072
  init_objectIncludes();
@@ -421796,8 +421963,34 @@ var buildInstructionElements2 = (instruction, instructionTokens) => {
421796
421963
  ];
421797
421964
  };
421798
421965
 
421966
+ // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/sd/shared/build-field-result-runs.js
421967
+ function buildFieldResultRuns2(params3, outputMarks) {
421968
+ const { node: node4 } = params3;
421969
+ const contentNodes = (node4.content ?? []).flatMap((child) => exportSchemaToJson2({ ...params3, node: child }));
421970
+ if (contentNodes.length > 0)
421971
+ return contentNodes;
421972
+ const resolvedText = node4.attrs?.resolvedText;
421973
+ if (typeof resolvedText !== "string" || resolvedText.length === 0)
421974
+ return [];
421975
+ const textAttributes = /^\s|\s$/.test(resolvedText) ? { "xml:space": "preserve" } : undefined;
421976
+ return [
421977
+ {
421978
+ name: "w:r",
421979
+ elements: [
421980
+ { name: "w:rPr", elements: outputMarks },
421981
+ { name: "w:t", attributes: textAttributes, elements: [{ text: resolvedText, type: "text" }] }
421982
+ ]
421983
+ }
421984
+ ];
421985
+ }
421986
+ var init_build_field_result_runs = __esm(() => {
421987
+ init_exporter();
421988
+ });
421989
+
421799
421990
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/sd/shared/index.js
421800
- var init_shared = () => {};
421991
+ var init_shared = __esm(() => {
421992
+ init_build_field_result_runs();
421993
+ });
421801
421994
 
421802
421995
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/sd/crossReference/crossReference-translator.js
421803
421996
  function parseTarget3(instruction) {
@@ -421862,7 +422055,7 @@ var XML_NODE_NAME27 = "sd:crossReference", SD_NODE_NAME21 = "crossReference", en
421862
422055
  }, decode68 = (params3) => {
421863
422056
  const { node: node4 } = params3;
421864
422057
  const outputMarks = processOutputMarks2(node4.attrs?.marksAsAttrs || []);
421865
- const contentNodes = (node4.content ?? []).flatMap((n) => exportSchemaToJson2({ ...params3, node: n }));
422058
+ const contentNodes = buildFieldResultRuns2(params3, outputMarks);
421866
422059
  const instructionElements = buildInstructionElements2(node4.attrs?.instruction, node4.attrs?.instructionTokens);
421867
422060
  return [
421868
422061
  {
@@ -421925,7 +422118,20 @@ function parseCitationSourceIds2(instruction) {
421925
422118
  function extractResolvedText3(content4) {
421926
422119
  if (!Array.isArray(content4))
421927
422120
  return "";
421928
- return content4.filter((n) => n.type === "text").map((n) => n.text || "").join("");
422121
+ let out = "";
422122
+ const walk = (nodes) => {
422123
+ for (const node4 of nodes) {
422124
+ if (!node4)
422125
+ continue;
422126
+ if (node4.type === "text") {
422127
+ out += node4.text || "";
422128
+ } else if (Array.isArray(node4.content)) {
422129
+ walk(node4.content);
422130
+ }
422131
+ }
422132
+ };
422133
+ walk(content4);
422134
+ return out;
421929
422135
  }
421930
422136
  var XML_NODE_NAME28 = "sd:citation", SD_NODE_NAME22 = "citation", encode65 = (params3) => {
421931
422137
  const { nodes = [], nodeListHandler } = params3 || {};
@@ -421950,7 +422156,7 @@ var XML_NODE_NAME28 = "sd:citation", SD_NODE_NAME22 = "citation", encode65 = (pa
421950
422156
  }, decode69 = (params3) => {
421951
422157
  const { node: node4 } = params3;
421952
422158
  const outputMarks = processOutputMarks2(node4.attrs?.marksAsAttrs || []);
421953
- const contentNodes = (node4.content ?? []).flatMap((n) => exportSchemaToJson2({ ...params3, node: n }));
422159
+ const contentNodes = buildFieldResultRuns2(params3, outputMarks);
421954
422160
  const instructionElements = buildInstructionElements2(node4.attrs?.instruction, node4.attrs?.instructionTokens);
421955
422161
  return [
421956
422162
  {
@@ -432538,6 +432744,19 @@ function normalizeRunProperties2(runProperties) {
432538
432744
  }
432539
432745
 
432540
432746
  // ../../packages/super-editor/src/editors/v1/core/helpers/getMarksFromSelection.js
432747
+ function getMarksFromSelection2(state, editor) {
432748
+ return getSelectionFormattingState2(state, editor).resolvedMarks;
432749
+ }
432750
+ function getSelectionFormattingState2(state, editor) {
432751
+ const { from: from4, to, empty: empty6 } = state.selection;
432752
+ if (empty6) {
432753
+ return getFormattingStateAtPos2(state, state.selection.$head.pos, editor, {
432754
+ storedMarks: state.storedMarks ?? null,
432755
+ includeCursorMarksWithStoredMarks: true
432756
+ });
432757
+ }
432758
+ return getFormattingStateForRange2(state, from4, to, editor);
432759
+ }
432541
432760
  function getFormattingStateAtPos2(state, pos, editor, options = {}) {
432542
432761
  const {
432543
432762
  storedMarks = null,
@@ -432594,6 +432813,37 @@ function getFormattingStateAtPos2(state, pos, editor, options = {}) {
432594
432813
  styleRunProperties
432595
432814
  };
432596
432815
  }
432816
+ function getFormattingStateForRange2(state, from4, to, editor) {
432817
+ const segments = [];
432818
+ const seen = new Set;
432819
+ state.doc.nodesBetween(from4, to, (node4, pos) => {
432820
+ if (!node4.isText || node4.text?.length === 0)
432821
+ return;
432822
+ const segmentPos = pos + 1;
432823
+ if (seen.has(segmentPos))
432824
+ return;
432825
+ seen.add(segmentPos);
432826
+ segments.push(getFormattingStateAtPos2(state, segmentPos, editor));
432827
+ });
432828
+ if (segments.length === 0) {
432829
+ return getFormattingStateAtPos2(state, from4, editor);
432830
+ }
432831
+ return aggregateFormattingSegments2(state, editor, segments);
432832
+ }
432833
+ function aggregateFormattingSegments2(state, editor, segments) {
432834
+ const resolvedRunProperties = intersectRunProperties2(segments.map((segment) => segment.resolvedRunProperties));
432835
+ const inlineRunProperties = intersectRunProperties2(segments.map((segment) => segment.inlineRunProperties));
432836
+ const styleRunProperties = intersectRunProperties2(segments.map((segment) => segment.styleRunProperties));
432837
+ const resolvedMarks = createMarksFromRunProperties2(state, resolvedRunProperties, editor);
432838
+ const inlineMarks = createMarksFromRunProperties2(state, inlineRunProperties, editor);
432839
+ return {
432840
+ resolvedMarks: mergeResolvedMarksWithInlineFallback2(resolvedMarks, inlineMarks),
432841
+ inlineMarks,
432842
+ resolvedRunProperties,
432843
+ inlineRunProperties,
432844
+ styleRunProperties
432845
+ };
432846
+ }
432597
432847
  function mergeResolvedMarksWithInlineFallback2(resolvedMarks, inlineMarks) {
432598
432848
  if (!resolvedMarks.length)
432599
432849
  return inlineMarks;
@@ -432603,6 +432853,20 @@ function mergeResolvedMarksWithInlineFallback2(resolvedMarks, inlineMarks) {
432603
432853
  const missingInlineMarks = inlineMarks.filter((mark2) => !resolvedMarkNames.has(mark2.type.name));
432604
432854
  return [...resolvedMarks, ...missingInlineMarks];
432605
432855
  }
432856
+ function intersectRunProperties2(runPropertiesList) {
432857
+ const filtered = runPropertiesList.filter((props) => props && typeof props === "object");
432858
+ if (filtered.length === 0)
432859
+ return null;
432860
+ const first2 = filtered[0];
432861
+ const intersection3 = {};
432862
+ Object.keys(first2).forEach((key2) => {
432863
+ const serialized = JSON.stringify(first2[key2]);
432864
+ if (filtered.every((props) => JSON.stringify(props[key2]) === serialized)) {
432865
+ intersection3[key2] = first2[key2];
432866
+ }
432867
+ });
432868
+ return Object.keys(intersection3).length ? intersection3 : null;
432869
+ }
432606
432870
  function getInheritedRunProperties2($pos, editor, inlineRunProperties) {
432607
432871
  if (!editor) {
432608
432872
  return {
@@ -449330,6 +449594,210 @@ function generateDocxHexId2() {
449330
449594
  }
449331
449595
  var DOCX_HEX_ID_LENGTH2 = 8;
449332
449596
 
449597
+ // ../../packages/super-editor/src/editors/v1/core/Attribute.ts
449598
+ class Attribute4 {
449599
+ static getAttributesFromExtensions(extensions) {
449600
+ const extensionAttributes = [];
449601
+ const defaultAttribute = {
449602
+ default: null,
449603
+ rendered: true,
449604
+ renderDOM: null,
449605
+ parseDOM: null,
449606
+ keepOnSplit: true
449607
+ };
449608
+ const globalAttributes = this.#getGlobalAttributes(extensions, defaultAttribute);
449609
+ const nodeAndMarksAttributes = this.#getNodeAndMarksAttributes(extensions, defaultAttribute);
449610
+ extensionAttributes.push(...globalAttributes, ...nodeAndMarksAttributes);
449611
+ return extensionAttributes;
449612
+ }
449613
+ static #getGlobalAttributes(extensions, defaultAttribute) {
449614
+ const extensionAttributes = [];
449615
+ const collectAttribute = (globalAttr) => {
449616
+ for (const type of globalAttr.types) {
449617
+ const entries = Object.entries(globalAttr.attributes);
449618
+ for (const [name, attribute] of entries) {
449619
+ extensionAttributes.push({
449620
+ type,
449621
+ name,
449622
+ attribute: {
449623
+ ...defaultAttribute,
449624
+ ...attribute
449625
+ }
449626
+ });
449627
+ }
449628
+ }
449629
+ };
449630
+ for (const extension3 of extensions) {
449631
+ const context = {
449632
+ name: extension3.name,
449633
+ options: extension3.options,
449634
+ storage: extension3.storage
449635
+ };
449636
+ const addGlobalAttributes = getExtensionConfigField2(extension3, "addGlobalAttributes", context);
449637
+ if (!addGlobalAttributes)
449638
+ continue;
449639
+ const globalAttributes = addGlobalAttributes();
449640
+ for (const globalAttr of globalAttributes) {
449641
+ collectAttribute(globalAttr);
449642
+ }
449643
+ }
449644
+ return extensionAttributes;
449645
+ }
449646
+ static #getNodeAndMarksAttributes(extensions, defaultAttribute) {
449647
+ const extensionAttributes = [];
449648
+ const nodeAndMarkExtensions = extensions.filter((e) => {
449649
+ return e.type === "node" || e.type === "mark";
449650
+ });
449651
+ for (const extension3 of nodeAndMarkExtensions) {
449652
+ const context = {
449653
+ name: extension3.name,
449654
+ options: extension3.options,
449655
+ storage: extension3.storage
449656
+ };
449657
+ const addAttributes = getExtensionConfigField2(extension3, "addAttributes", context);
449658
+ if (!addAttributes)
449659
+ continue;
449660
+ const attributes = addAttributes();
449661
+ for (const [name, attribute] of Object.entries(attributes)) {
449662
+ const merged = {
449663
+ ...defaultAttribute,
449664
+ ...attribute
449665
+ };
449666
+ if (typeof merged.default === "function") {
449667
+ merged.default = merged.default();
449668
+ }
449669
+ extensionAttributes.push({
449670
+ type: extension3.name,
449671
+ name,
449672
+ attribute: merged
449673
+ });
449674
+ }
449675
+ }
449676
+ return extensionAttributes;
449677
+ }
449678
+ static insertExtensionAttrsToParseRule(parseRule, extensionAttrs) {
449679
+ if ("style" in parseRule) {
449680
+ return parseRule;
449681
+ }
449682
+ return {
449683
+ ...parseRule,
449684
+ getAttrs: (node4) => {
449685
+ const oldAttrs = parseRule.getAttrs ? parseRule.getAttrs(node4) : parseRule.attrs;
449686
+ if (oldAttrs === false)
449687
+ return false;
449688
+ const parseFromString = (value) => {
449689
+ if (typeof value !== "string")
449690
+ return value;
449691
+ if (value.match(/^[+-]?(\d*\.)?\d+$/))
449692
+ return Number(value);
449693
+ if (value === "true")
449694
+ return true;
449695
+ if (value === "false")
449696
+ return false;
449697
+ return value;
449698
+ };
449699
+ let newAttrs = {};
449700
+ for (const item of extensionAttrs) {
449701
+ const value = item.attribute.parseDOM ? item.attribute.parseDOM(node4) : parseFromString(node4.getAttribute(item.name));
449702
+ if (value === null || value === undefined)
449703
+ continue;
449704
+ newAttrs = {
449705
+ ...newAttrs,
449706
+ [item.name]: value
449707
+ };
449708
+ }
449709
+ return { ...oldAttrs, ...newAttrs };
449710
+ }
449711
+ };
449712
+ }
449713
+ static getAttributesToRender(nodeOrMark, extensionAttrs) {
449714
+ const attributes = extensionAttrs.filter((item) => item.attribute.rendered).map((item) => {
449715
+ if (!item.attribute.renderDOM) {
449716
+ return { [item.name]: nodeOrMark.attrs[item.name] };
449717
+ }
449718
+ return item.attribute.renderDOM(nodeOrMark.attrs) || {};
449719
+ });
449720
+ let mergedAttrs = {};
449721
+ for (const attribute of attributes) {
449722
+ mergedAttrs = this.mergeAttributes(mergedAttrs, attribute);
449723
+ }
449724
+ return mergedAttrs;
449725
+ }
449726
+ static mergeAttributes(...objects) {
449727
+ const items = objects.filter((item) => !!item);
449728
+ let attrs = {};
449729
+ for (const item of items) {
449730
+ const mergedAttributes = { ...attrs };
449731
+ for (const [key2, value] of Object.entries(item)) {
449732
+ const exists = mergedAttributes[key2];
449733
+ if (!exists) {
449734
+ mergedAttributes[key2] = value;
449735
+ continue;
449736
+ }
449737
+ if (key2 === "class") {
449738
+ const valueStr = typeof value === "string" ? value : String(value);
449739
+ const existingStr = typeof mergedAttributes[key2] === "string" ? mergedAttributes[key2] : String(mergedAttributes[key2] || "");
449740
+ const valueClasses = valueStr ? valueStr.split(" ") : [];
449741
+ const existingClasses = existingStr ? existingStr.split(" ") : [];
449742
+ const insertClasses = valueClasses.filter((value2) => !existingClasses.includes(value2));
449743
+ mergedAttributes[key2] = [...existingClasses, ...insertClasses].join(" ");
449744
+ } else if (key2 === "style") {
449745
+ mergedAttributes[key2] = [mergedAttributes[key2], value].join("; ");
449746
+ } else {
449747
+ mergedAttributes[key2] = value;
449748
+ }
449749
+ }
449750
+ attrs = mergedAttributes;
449751
+ }
449752
+ return attrs;
449753
+ }
449754
+ static getSplittedAttributes(extensionAttrs, typeName, attributes) {
449755
+ const entries = Object.entries(attributes).filter(([name]) => {
449756
+ const extensionAttr = extensionAttrs.find((item) => {
449757
+ return item.type === typeName && item.name === name;
449758
+ });
449759
+ if (!extensionAttr)
449760
+ return false;
449761
+ return extensionAttr.attribute.keepOnSplit;
449762
+ });
449763
+ return Object.fromEntries(entries);
449764
+ }
449765
+ static getMarkAttributes(state, typeOrName) {
449766
+ const type = getMarkType2(typeOrName, state.schema);
449767
+ const marks = getMarksFromSelection2(state);
449768
+ const mark2 = marks.find((markItem) => markItem.type.name === type.name);
449769
+ if (!mark2)
449770
+ return {};
449771
+ return { ...mark2.attrs };
449772
+ }
449773
+ static getNodeAttributes(state, typeOrName) {
449774
+ const type = getNodeType2(typeOrName, state.schema);
449775
+ const { from: from4, to } = state.selection;
449776
+ const nodes = [];
449777
+ state.doc.nodesBetween(from4, to, (node5) => {
449778
+ nodes.push(node5);
449779
+ });
449780
+ const node4 = nodes.reverse().find((nodeItem) => nodeItem.type.name === type.name);
449781
+ if (!node4)
449782
+ return {};
449783
+ return { ...node4.attrs };
449784
+ }
449785
+ static getAttributes(state, typeOrName) {
449786
+ const schemaType = getSchemaTypeNameByName2(typeof typeOrName === "string" ? typeOrName : typeOrName.name, state.schema);
449787
+ if (schemaType === "node") {
449788
+ return this.getNodeAttributes(state, typeOrName);
449789
+ }
449790
+ if (schemaType === "mark") {
449791
+ return this.getMarkAttributes(state, typeOrName);
449792
+ }
449793
+ return {};
449794
+ }
449795
+ }
449796
+ var init_Attribute = __esm(() => {
449797
+ init_getExtensionConfigField();
449798
+ init_getMarksFromSelection();
449799
+ });
449800
+
449333
449801
  // ../../packages/super-editor/src/editors/v1/extensions/table/tableHelpers/border-utils.js
449334
449802
  function cloneBorders2(borders, sides) {
449335
449803
  if (!borders || typeof borders !== "object")
@@ -450836,10 +451304,7 @@ function tablesSplitAdapter2(editor, input2, options) {
450836
451304
  const rEnd = tr.mapping.slice(mapFrom).map(rowPositions[i5] + tableNode.child(i5).nodeSize);
450837
451305
  tr.delete(rp, rEnd);
450838
451306
  }
450839
- const newTableAttrs = { ...tableNode.attrs };
450840
- delete newTableAttrs.sdBlockId;
450841
- delete newTableAttrs.paraId;
450842
- delete newTableAttrs.textId;
451307
+ const newTableAttrs = Attribute4.getSplittedAttributes(editor.extensionService?.attributes ?? [], tableNode.type.name, tableNode.attrs);
450843
451308
  const newTable = schema.nodes.table.create(newTableAttrs, secondTableRows);
450844
451309
  const separatorParagraph = createSeparatorParagraph2(schema);
450845
451310
  if (!separatorParagraph) {
@@ -452669,6 +453134,7 @@ var init_tables_adapter = __esm(() => {
452669
453134
  init_errors4();
452670
453135
  init_node_address_resolver();
452671
453136
  init_ooxml();
453137
+ init_Attribute();
452672
453138
  init_document_settings();
452673
453139
  init_mutate_part();
452674
453140
  init_table_attr_sync();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/mcp",
3
- "version": "0.8.0-next.5",
3
+ "version": "0.8.0-next.7",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -19,9 +19,9 @@
19
19
  "@types/bun": "^1.3.8",
20
20
  "@types/node": "22.19.2",
21
21
  "typescript": "^5.9.2",
22
- "superdoc": "1.35.0",
22
+ "@superdoc/document-api": "0.0.1",
23
23
  "@superdoc/super-editor": "0.0.1",
24
- "@superdoc/document-api": "0.0.1"
24
+ "superdoc": "1.35.0"
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public"