@superdoc-dev/mcp 0.8.0-next.6 → 0.8.0-next.8

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 +311 -23
  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-CYTyP_ze.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))
@@ -213136,12 +213131,10 @@ function createListBoundaryNavigationPlugin() {
213136
213131
  const paragraph2 = getParagraphContext$1(selection.$from);
213137
213132
  if (!paragraph2 || !isListParagraph(paragraph2.node))
213138
213133
  return false;
213139
- if (isRtlParagraph$1(paragraph2.node))
213140
- return false;
213141
213134
  const bounds = getParagraphTextBounds2(paragraph2.node, paragraph2.start);
213142
213135
  if (!bounds)
213143
213136
  return false;
213144
- const direction = event.key === "ArrowLeft" ? -1 : 1;
213137
+ const direction = isRtlParagraph$1(paragraph2.node) ? event.key === "ArrowRight" ? -1 : 1 : event.key === "ArrowLeft" ? -1 : 1;
213145
213138
  const atLeftBoundary = direction < 0 && selection.from <= bounds.first;
213146
213139
  const atRightBoundary = direction > 0 && selection.from >= bounds.last;
213147
213140
  if (!atLeftBoundary && !atRightBoundary)
@@ -232429,10 +232422,7 @@ function tablesSplitAdapter(editor, input2, options) {
232429
232422
  const rEnd = tr.mapping.slice(mapFrom).map(rowPositions[i4] + tableNode.child(i4).nodeSize);
232430
232423
  tr.delete(rp, rEnd);
232431
232424
  }
232432
- const newTableAttrs = { ...tableNode.attrs };
232433
- delete newTableAttrs.sdBlockId;
232434
- delete newTableAttrs.paraId;
232435
- delete newTableAttrs.textId;
232425
+ const newTableAttrs = Attribute2.getSplittedAttributes(editor.extensionService?.attributes ?? [], tableNode.type.name, tableNode.attrs);
232436
232426
  const newTable = schema.nodes.table.create(newTableAttrs, secondTableRows);
232437
232427
  const separatorParagraph = createSeparatorParagraph(schema);
232438
232428
  if (!separatorParagraph)
@@ -297501,7 +297491,7 @@ menclose::after {
297501
297491
  return;
297502
297492
  console.log(...args$1);
297503
297493
  }, 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(() => {
297494
+ var init_src_CYTyP_ze_es = __esm(() => {
297505
297495
  init_rolldown_runtime_Bg48TavK_es();
297506
297496
  init_SuperConverter_k7GHkV_c_es();
297507
297497
  init_jszip_C49i9kUs_es();
@@ -300392,8 +300382,14 @@ ${err.toString()}`);
300392
300382
  },
300393
300383
  addAttributes() {
300394
300384
  return {
300395
- paraId: { rendered: false },
300396
- textId: { rendered: false },
300385
+ paraId: {
300386
+ rendered: false,
300387
+ keepOnSplit: false
300388
+ },
300389
+ textId: {
300390
+ rendered: false,
300391
+ keepOnSplit: false
300392
+ },
300397
300393
  rsidR: { rendered: false },
300398
300394
  rsidRDefault: { rendered: false },
300399
300395
  rsidP: { rendered: false },
@@ -335362,7 +335358,7 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
335362
335358
 
335363
335359
  // ../../packages/superdoc/dist/super-editor.es.js
335364
335360
  var init_super_editor_es = __esm(() => {
335365
- init_src_AnmYYbEU_es();
335361
+ init_src_CYTyP_ze_es();
335366
335362
  init_SuperConverter_k7GHkV_c_es();
335367
335363
  init_jszip_C49i9kUs_es();
335368
335364
  init_xml_js_CqGKpaft_es();
@@ -393979,6 +393975,28 @@ function chainableEditorState2(transaction, state) {
393979
393975
  }
393980
393976
  };
393981
393977
  }
393978
+
393979
+ // ../../packages/super-editor/src/editors/v1/core/helpers/getNodeType.js
393980
+ function getNodeType2(nameOrType, schema) {
393981
+ if (typeof nameOrType === "string") {
393982
+ if (!schema.nodes[nameOrType]) {
393983
+ throw Error(`There is no node type named '${nameOrType}' in schema.`);
393984
+ }
393985
+ return schema.nodes[nameOrType];
393986
+ }
393987
+ return nameOrType;
393988
+ }
393989
+
393990
+ // ../../packages/super-editor/src/editors/v1/core/helpers/getMarkType.js
393991
+ function getMarkType2(nameOrType, schema) {
393992
+ if (typeof nameOrType === "string") {
393993
+ if (!schema.marks[nameOrType]) {
393994
+ throw Error(`There is no mark type named '${nameOrType}' in schema.`);
393995
+ }
393996
+ return schema.marks[nameOrType];
393997
+ }
393998
+ return nameOrType;
393999
+ }
393982
394000
  // ../../packages/super-editor/src/editors/v1/core/helpers/findParentNodeClosestToPos.js
393983
394001
  var findParentNodeClosestToPos2 = ($pos, predicate) => {
393984
394002
  for (let i4 = $pos.depth;i4 > 0; i4--) {
@@ -394037,6 +394055,16 @@ var init_isMarkActive = __esm(() => {
394037
394055
  var init_getMarksBetween = __esm(() => {
394038
394056
  init_getMarkRange();
394039
394057
  });
394058
+
394059
+ // ../../packages/super-editor/src/editors/v1/core/helpers/getSchemaTypeNameByName.js
394060
+ function getSchemaTypeNameByName2(name, schema) {
394061
+ if (schema.nodes[name])
394062
+ return "node";
394063
+ if (schema.marks[name])
394064
+ return "mark";
394065
+ return null;
394066
+ }
394067
+
394040
394068
  // ../../packages/super-editor/src/editors/v1/core/helpers/isNodeActive.js
394041
394069
  var init_isNodeActive = __esm(() => {
394042
394070
  init_objectIncludes();
@@ -432714,6 +432742,19 @@ function normalizeRunProperties2(runProperties) {
432714
432742
  }
432715
432743
 
432716
432744
  // ../../packages/super-editor/src/editors/v1/core/helpers/getMarksFromSelection.js
432745
+ function getMarksFromSelection2(state, editor) {
432746
+ return getSelectionFormattingState2(state, editor).resolvedMarks;
432747
+ }
432748
+ function getSelectionFormattingState2(state, editor) {
432749
+ const { from: from4, to, empty: empty6 } = state.selection;
432750
+ if (empty6) {
432751
+ return getFormattingStateAtPos2(state, state.selection.$head.pos, editor, {
432752
+ storedMarks: state.storedMarks ?? null,
432753
+ includeCursorMarksWithStoredMarks: true
432754
+ });
432755
+ }
432756
+ return getFormattingStateForRange2(state, from4, to, editor);
432757
+ }
432717
432758
  function getFormattingStateAtPos2(state, pos, editor, options = {}) {
432718
432759
  const {
432719
432760
  storedMarks = null,
@@ -432770,6 +432811,37 @@ function getFormattingStateAtPos2(state, pos, editor, options = {}) {
432770
432811
  styleRunProperties
432771
432812
  };
432772
432813
  }
432814
+ function getFormattingStateForRange2(state, from4, to, editor) {
432815
+ const segments = [];
432816
+ const seen = new Set;
432817
+ state.doc.nodesBetween(from4, to, (node4, pos) => {
432818
+ if (!node4.isText || node4.text?.length === 0)
432819
+ return;
432820
+ const segmentPos = pos + 1;
432821
+ if (seen.has(segmentPos))
432822
+ return;
432823
+ seen.add(segmentPos);
432824
+ segments.push(getFormattingStateAtPos2(state, segmentPos, editor));
432825
+ });
432826
+ if (segments.length === 0) {
432827
+ return getFormattingStateAtPos2(state, from4, editor);
432828
+ }
432829
+ return aggregateFormattingSegments2(state, editor, segments);
432830
+ }
432831
+ function aggregateFormattingSegments2(state, editor, segments) {
432832
+ const resolvedRunProperties = intersectRunProperties2(segments.map((segment) => segment.resolvedRunProperties));
432833
+ const inlineRunProperties = intersectRunProperties2(segments.map((segment) => segment.inlineRunProperties));
432834
+ const styleRunProperties = intersectRunProperties2(segments.map((segment) => segment.styleRunProperties));
432835
+ const resolvedMarks = createMarksFromRunProperties2(state, resolvedRunProperties, editor);
432836
+ const inlineMarks = createMarksFromRunProperties2(state, inlineRunProperties, editor);
432837
+ return {
432838
+ resolvedMarks: mergeResolvedMarksWithInlineFallback2(resolvedMarks, inlineMarks),
432839
+ inlineMarks,
432840
+ resolvedRunProperties,
432841
+ inlineRunProperties,
432842
+ styleRunProperties
432843
+ };
432844
+ }
432773
432845
  function mergeResolvedMarksWithInlineFallback2(resolvedMarks, inlineMarks) {
432774
432846
  if (!resolvedMarks.length)
432775
432847
  return inlineMarks;
@@ -432779,6 +432851,20 @@ function mergeResolvedMarksWithInlineFallback2(resolvedMarks, inlineMarks) {
432779
432851
  const missingInlineMarks = inlineMarks.filter((mark2) => !resolvedMarkNames.has(mark2.type.name));
432780
432852
  return [...resolvedMarks, ...missingInlineMarks];
432781
432853
  }
432854
+ function intersectRunProperties2(runPropertiesList) {
432855
+ const filtered = runPropertiesList.filter((props) => props && typeof props === "object");
432856
+ if (filtered.length === 0)
432857
+ return null;
432858
+ const first2 = filtered[0];
432859
+ const intersection3 = {};
432860
+ Object.keys(first2).forEach((key2) => {
432861
+ const serialized = JSON.stringify(first2[key2]);
432862
+ if (filtered.every((props) => JSON.stringify(props[key2]) === serialized)) {
432863
+ intersection3[key2] = first2[key2];
432864
+ }
432865
+ });
432866
+ return Object.keys(intersection3).length ? intersection3 : null;
432867
+ }
432782
432868
  function getInheritedRunProperties2($pos, editor, inlineRunProperties) {
432783
432869
  if (!editor) {
432784
432870
  return {
@@ -449506,6 +449592,210 @@ function generateDocxHexId2() {
449506
449592
  }
449507
449593
  var DOCX_HEX_ID_LENGTH2 = 8;
449508
449594
 
449595
+ // ../../packages/super-editor/src/editors/v1/core/Attribute.ts
449596
+ class Attribute4 {
449597
+ static getAttributesFromExtensions(extensions) {
449598
+ const extensionAttributes = [];
449599
+ const defaultAttribute = {
449600
+ default: null,
449601
+ rendered: true,
449602
+ renderDOM: null,
449603
+ parseDOM: null,
449604
+ keepOnSplit: true
449605
+ };
449606
+ const globalAttributes = this.#getGlobalAttributes(extensions, defaultAttribute);
449607
+ const nodeAndMarksAttributes = this.#getNodeAndMarksAttributes(extensions, defaultAttribute);
449608
+ extensionAttributes.push(...globalAttributes, ...nodeAndMarksAttributes);
449609
+ return extensionAttributes;
449610
+ }
449611
+ static #getGlobalAttributes(extensions, defaultAttribute) {
449612
+ const extensionAttributes = [];
449613
+ const collectAttribute = (globalAttr) => {
449614
+ for (const type of globalAttr.types) {
449615
+ const entries = Object.entries(globalAttr.attributes);
449616
+ for (const [name, attribute] of entries) {
449617
+ extensionAttributes.push({
449618
+ type,
449619
+ name,
449620
+ attribute: {
449621
+ ...defaultAttribute,
449622
+ ...attribute
449623
+ }
449624
+ });
449625
+ }
449626
+ }
449627
+ };
449628
+ for (const extension3 of extensions) {
449629
+ const context = {
449630
+ name: extension3.name,
449631
+ options: extension3.options,
449632
+ storage: extension3.storage
449633
+ };
449634
+ const addGlobalAttributes = getExtensionConfigField2(extension3, "addGlobalAttributes", context);
449635
+ if (!addGlobalAttributes)
449636
+ continue;
449637
+ const globalAttributes = addGlobalAttributes();
449638
+ for (const globalAttr of globalAttributes) {
449639
+ collectAttribute(globalAttr);
449640
+ }
449641
+ }
449642
+ return extensionAttributes;
449643
+ }
449644
+ static #getNodeAndMarksAttributes(extensions, defaultAttribute) {
449645
+ const extensionAttributes = [];
449646
+ const nodeAndMarkExtensions = extensions.filter((e) => {
449647
+ return e.type === "node" || e.type === "mark";
449648
+ });
449649
+ for (const extension3 of nodeAndMarkExtensions) {
449650
+ const context = {
449651
+ name: extension3.name,
449652
+ options: extension3.options,
449653
+ storage: extension3.storage
449654
+ };
449655
+ const addAttributes = getExtensionConfigField2(extension3, "addAttributes", context);
449656
+ if (!addAttributes)
449657
+ continue;
449658
+ const attributes = addAttributes();
449659
+ for (const [name, attribute] of Object.entries(attributes)) {
449660
+ const merged = {
449661
+ ...defaultAttribute,
449662
+ ...attribute
449663
+ };
449664
+ if (typeof merged.default === "function") {
449665
+ merged.default = merged.default();
449666
+ }
449667
+ extensionAttributes.push({
449668
+ type: extension3.name,
449669
+ name,
449670
+ attribute: merged
449671
+ });
449672
+ }
449673
+ }
449674
+ return extensionAttributes;
449675
+ }
449676
+ static insertExtensionAttrsToParseRule(parseRule, extensionAttrs) {
449677
+ if ("style" in parseRule) {
449678
+ return parseRule;
449679
+ }
449680
+ return {
449681
+ ...parseRule,
449682
+ getAttrs: (node4) => {
449683
+ const oldAttrs = parseRule.getAttrs ? parseRule.getAttrs(node4) : parseRule.attrs;
449684
+ if (oldAttrs === false)
449685
+ return false;
449686
+ const parseFromString = (value) => {
449687
+ if (typeof value !== "string")
449688
+ return value;
449689
+ if (value.match(/^[+-]?(\d*\.)?\d+$/))
449690
+ return Number(value);
449691
+ if (value === "true")
449692
+ return true;
449693
+ if (value === "false")
449694
+ return false;
449695
+ return value;
449696
+ };
449697
+ let newAttrs = {};
449698
+ for (const item of extensionAttrs) {
449699
+ const value = item.attribute.parseDOM ? item.attribute.parseDOM(node4) : parseFromString(node4.getAttribute(item.name));
449700
+ if (value === null || value === undefined)
449701
+ continue;
449702
+ newAttrs = {
449703
+ ...newAttrs,
449704
+ [item.name]: value
449705
+ };
449706
+ }
449707
+ return { ...oldAttrs, ...newAttrs };
449708
+ }
449709
+ };
449710
+ }
449711
+ static getAttributesToRender(nodeOrMark, extensionAttrs) {
449712
+ const attributes = extensionAttrs.filter((item) => item.attribute.rendered).map((item) => {
449713
+ if (!item.attribute.renderDOM) {
449714
+ return { [item.name]: nodeOrMark.attrs[item.name] };
449715
+ }
449716
+ return item.attribute.renderDOM(nodeOrMark.attrs) || {};
449717
+ });
449718
+ let mergedAttrs = {};
449719
+ for (const attribute of attributes) {
449720
+ mergedAttrs = this.mergeAttributes(mergedAttrs, attribute);
449721
+ }
449722
+ return mergedAttrs;
449723
+ }
449724
+ static mergeAttributes(...objects) {
449725
+ const items = objects.filter((item) => !!item);
449726
+ let attrs = {};
449727
+ for (const item of items) {
449728
+ const mergedAttributes = { ...attrs };
449729
+ for (const [key2, value] of Object.entries(item)) {
449730
+ const exists = mergedAttributes[key2];
449731
+ if (!exists) {
449732
+ mergedAttributes[key2] = value;
449733
+ continue;
449734
+ }
449735
+ if (key2 === "class") {
449736
+ const valueStr = typeof value === "string" ? value : String(value);
449737
+ const existingStr = typeof mergedAttributes[key2] === "string" ? mergedAttributes[key2] : String(mergedAttributes[key2] || "");
449738
+ const valueClasses = valueStr ? valueStr.split(" ") : [];
449739
+ const existingClasses = existingStr ? existingStr.split(" ") : [];
449740
+ const insertClasses = valueClasses.filter((value2) => !existingClasses.includes(value2));
449741
+ mergedAttributes[key2] = [...existingClasses, ...insertClasses].join(" ");
449742
+ } else if (key2 === "style") {
449743
+ mergedAttributes[key2] = [mergedAttributes[key2], value].join("; ");
449744
+ } else {
449745
+ mergedAttributes[key2] = value;
449746
+ }
449747
+ }
449748
+ attrs = mergedAttributes;
449749
+ }
449750
+ return attrs;
449751
+ }
449752
+ static getSplittedAttributes(extensionAttrs, typeName, attributes) {
449753
+ const entries = Object.entries(attributes).filter(([name]) => {
449754
+ const extensionAttr = extensionAttrs.find((item) => {
449755
+ return item.type === typeName && item.name === name;
449756
+ });
449757
+ if (!extensionAttr)
449758
+ return false;
449759
+ return extensionAttr.attribute.keepOnSplit;
449760
+ });
449761
+ return Object.fromEntries(entries);
449762
+ }
449763
+ static getMarkAttributes(state, typeOrName) {
449764
+ const type = getMarkType2(typeOrName, state.schema);
449765
+ const marks = getMarksFromSelection2(state);
449766
+ const mark2 = marks.find((markItem) => markItem.type.name === type.name);
449767
+ if (!mark2)
449768
+ return {};
449769
+ return { ...mark2.attrs };
449770
+ }
449771
+ static getNodeAttributes(state, typeOrName) {
449772
+ const type = getNodeType2(typeOrName, state.schema);
449773
+ const { from: from4, to } = state.selection;
449774
+ const nodes = [];
449775
+ state.doc.nodesBetween(from4, to, (node5) => {
449776
+ nodes.push(node5);
449777
+ });
449778
+ const node4 = nodes.reverse().find((nodeItem) => nodeItem.type.name === type.name);
449779
+ if (!node4)
449780
+ return {};
449781
+ return { ...node4.attrs };
449782
+ }
449783
+ static getAttributes(state, typeOrName) {
449784
+ const schemaType = getSchemaTypeNameByName2(typeof typeOrName === "string" ? typeOrName : typeOrName.name, state.schema);
449785
+ if (schemaType === "node") {
449786
+ return this.getNodeAttributes(state, typeOrName);
449787
+ }
449788
+ if (schemaType === "mark") {
449789
+ return this.getMarkAttributes(state, typeOrName);
449790
+ }
449791
+ return {};
449792
+ }
449793
+ }
449794
+ var init_Attribute = __esm(() => {
449795
+ init_getExtensionConfigField();
449796
+ init_getMarksFromSelection();
449797
+ });
449798
+
449509
449799
  // ../../packages/super-editor/src/editors/v1/extensions/table/tableHelpers/border-utils.js
449510
449800
  function cloneBorders2(borders, sides) {
449511
449801
  if (!borders || typeof borders !== "object")
@@ -451012,10 +451302,7 @@ function tablesSplitAdapter2(editor, input2, options) {
451012
451302
  const rEnd = tr.mapping.slice(mapFrom).map(rowPositions[i5] + tableNode.child(i5).nodeSize);
451013
451303
  tr.delete(rp, rEnd);
451014
451304
  }
451015
- const newTableAttrs = { ...tableNode.attrs };
451016
- delete newTableAttrs.sdBlockId;
451017
- delete newTableAttrs.paraId;
451018
- delete newTableAttrs.textId;
451305
+ const newTableAttrs = Attribute4.getSplittedAttributes(editor.extensionService?.attributes ?? [], tableNode.type.name, tableNode.attrs);
451019
451306
  const newTable = schema.nodes.table.create(newTableAttrs, secondTableRows);
451020
451307
  const separatorParagraph = createSeparatorParagraph2(schema);
451021
451308
  if (!separatorParagraph) {
@@ -452845,6 +453132,7 @@ var init_tables_adapter = __esm(() => {
452845
453132
  init_errors4();
452846
453133
  init_node_address_resolver();
452847
453134
  init_ooxml();
453135
+ init_Attribute();
452848
453136
  init_document_settings();
452849
453137
  init_mutate_part();
452850
453138
  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.8",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"