@superdoc-dev/mcp 0.8.0-next.6 → 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 +310 -20
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -208942,7 +208942,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
208942
208942
  init_remark_gfm_BhnWr3yf_es();
208943
208943
  });
208944
208944
 
208945
- // ../../packages/superdoc/dist/chunks/src-AnmYYbEU.es.js
208945
+ // ../../packages/superdoc/dist/chunks/src-D6w3M9Bh.es.js
208946
208946
  function deleteProps(obj, propOrProps) {
208947
208947
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
208948
208948
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -211411,13 +211411,8 @@ function splitBlockPatch(state, dispatch, editor) {
211411
211411
  atStart = $from.start(d) == $from.pos - ($from.depth - d);
211412
211412
  deflt = defaultBlockAt($from.node(d - 1).contentMatchAt($from.indexAfter(d - 1)));
211413
211413
  const sourceParagraphStyleId = node2.attrs?.paragraphProperties?.styleId;
211414
- paragraphAttrs = {
211415
- ...node2.attrs,
211416
- sdBlockId: null,
211417
- sdBlockRev: null,
211418
- paraId: null,
211419
- textId: null
211420
- };
211414
+ const extensionAttrs = editor?.extensionService?.attributes ?? [];
211415
+ paragraphAttrs = Attribute2.getSplittedAttributes(extensionAttrs, node2.type.name, node2.attrs);
211421
211416
  paragraphAttrs = clearInheritedLinkedStyleId(paragraphAttrs, editor, { emptyParagraph: atEnd });
211422
211417
  if (atEnd && $from.parent.type.name === "run") {
211423
211418
  if (!isLinkedParagraphStyleId(editor, sourceParagraphStyleId))
@@ -232429,10 +232424,7 @@ function tablesSplitAdapter(editor, input2, options) {
232429
232424
  const rEnd = tr.mapping.slice(mapFrom).map(rowPositions[i4] + tableNode.child(i4).nodeSize);
232430
232425
  tr.delete(rp, rEnd);
232431
232426
  }
232432
- const newTableAttrs = { ...tableNode.attrs };
232433
- delete newTableAttrs.sdBlockId;
232434
- delete newTableAttrs.paraId;
232435
- delete newTableAttrs.textId;
232427
+ const newTableAttrs = Attribute2.getSplittedAttributes(editor.extensionService?.attributes ?? [], tableNode.type.name, tableNode.attrs);
232436
232428
  const newTable = schema.nodes.table.create(newTableAttrs, secondTableRows);
232437
232429
  const separatorParagraph = createSeparatorParagraph(schema);
232438
232430
  if (!separatorParagraph)
@@ -297501,7 +297493,7 @@ menclose::after {
297501
297493
  return;
297502
297494
  console.log(...args$1);
297503
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;
297504
- var init_src_AnmYYbEU_es = __esm(() => {
297496
+ var init_src_D6w3M9Bh_es = __esm(() => {
297505
297497
  init_rolldown_runtime_Bg48TavK_es();
297506
297498
  init_SuperConverter_k7GHkV_c_es();
297507
297499
  init_jszip_C49i9kUs_es();
@@ -300392,8 +300384,14 @@ ${err.toString()}`);
300392
300384
  },
300393
300385
  addAttributes() {
300394
300386
  return {
300395
- paraId: { rendered: false },
300396
- textId: { rendered: false },
300387
+ paraId: {
300388
+ rendered: false,
300389
+ keepOnSplit: false
300390
+ },
300391
+ textId: {
300392
+ rendered: false,
300393
+ keepOnSplit: false
300394
+ },
300397
300395
  rsidR: { rendered: false },
300398
300396
  rsidRDefault: { rendered: false },
300399
300397
  rsidP: { rendered: false },
@@ -335362,7 +335360,7 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
335362
335360
 
335363
335361
  // ../../packages/superdoc/dist/super-editor.es.js
335364
335362
  var init_super_editor_es = __esm(() => {
335365
- init_src_AnmYYbEU_es();
335363
+ init_src_D6w3M9Bh_es();
335366
335364
  init_SuperConverter_k7GHkV_c_es();
335367
335365
  init_jszip_C49i9kUs_es();
335368
335366
  init_xml_js_CqGKpaft_es();
@@ -393979,6 +393977,28 @@ function chainableEditorState2(transaction, state) {
393979
393977
  }
393980
393978
  };
393981
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
+ }
393982
394002
  // ../../packages/super-editor/src/editors/v1/core/helpers/findParentNodeClosestToPos.js
393983
394003
  var findParentNodeClosestToPos2 = ($pos, predicate) => {
393984
394004
  for (let i4 = $pos.depth;i4 > 0; i4--) {
@@ -394037,6 +394057,16 @@ var init_isMarkActive = __esm(() => {
394037
394057
  var init_getMarksBetween = __esm(() => {
394038
394058
  init_getMarkRange();
394039
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
+
394040
394070
  // ../../packages/super-editor/src/editors/v1/core/helpers/isNodeActive.js
394041
394071
  var init_isNodeActive = __esm(() => {
394042
394072
  init_objectIncludes();
@@ -432714,6 +432744,19 @@ function normalizeRunProperties2(runProperties) {
432714
432744
  }
432715
432745
 
432716
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
+ }
432717
432760
  function getFormattingStateAtPos2(state, pos, editor, options = {}) {
432718
432761
  const {
432719
432762
  storedMarks = null,
@@ -432770,6 +432813,37 @@ function getFormattingStateAtPos2(state, pos, editor, options = {}) {
432770
432813
  styleRunProperties
432771
432814
  };
432772
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
+ }
432773
432847
  function mergeResolvedMarksWithInlineFallback2(resolvedMarks, inlineMarks) {
432774
432848
  if (!resolvedMarks.length)
432775
432849
  return inlineMarks;
@@ -432779,6 +432853,20 @@ function mergeResolvedMarksWithInlineFallback2(resolvedMarks, inlineMarks) {
432779
432853
  const missingInlineMarks = inlineMarks.filter((mark2) => !resolvedMarkNames.has(mark2.type.name));
432780
432854
  return [...resolvedMarks, ...missingInlineMarks];
432781
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
+ }
432782
432870
  function getInheritedRunProperties2($pos, editor, inlineRunProperties) {
432783
432871
  if (!editor) {
432784
432872
  return {
@@ -449506,6 +449594,210 @@ function generateDocxHexId2() {
449506
449594
  }
449507
449595
  var DOCX_HEX_ID_LENGTH2 = 8;
449508
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
+
449509
449801
  // ../../packages/super-editor/src/editors/v1/extensions/table/tableHelpers/border-utils.js
449510
449802
  function cloneBorders2(borders, sides) {
449511
449803
  if (!borders || typeof borders !== "object")
@@ -451012,10 +451304,7 @@ function tablesSplitAdapter2(editor, input2, options) {
451012
451304
  const rEnd = tr.mapping.slice(mapFrom).map(rowPositions[i5] + tableNode.child(i5).nodeSize);
451013
451305
  tr.delete(rp, rEnd);
451014
451306
  }
451015
- const newTableAttrs = { ...tableNode.attrs };
451016
- delete newTableAttrs.sdBlockId;
451017
- delete newTableAttrs.paraId;
451018
- delete newTableAttrs.textId;
451307
+ const newTableAttrs = Attribute4.getSplittedAttributes(editor.extensionService?.attributes ?? [], tableNode.type.name, tableNode.attrs);
451019
451308
  const newTable = schema.nodes.table.create(newTableAttrs, secondTableRows);
451020
451309
  const separatorParagraph = createSeparatorParagraph2(schema);
451021
451310
  if (!separatorParagraph) {
@@ -452845,6 +453134,7 @@ var init_tables_adapter = __esm(() => {
452845
453134
  init_errors4();
452846
453135
  init_node_address_resolver();
452847
453136
  init_ooxml();
453137
+ init_Attribute();
452848
453138
  init_document_settings();
452849
453139
  init_mutate_part();
452850
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.6",
3
+ "version": "0.8.0-next.7",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"