@superdoc-dev/mcp 0.6.0-next.12 → 0.6.0-next.14

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 +235 -70
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -143800,7 +143800,7 @@ var init_SuperConverter_BLUJyRB9_es = __esm(() => {
143800
143800
  };
143801
143801
  });
143802
143802
 
143803
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DCioTQPP.es.js
143803
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-CmoOhFUt.es.js
143804
143804
  function parseSizeUnit(val = "0") {
143805
143805
  const length = val.toString() || "0";
143806
143806
  const value = Number.parseFloat(length);
@@ -145791,6 +145791,11 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
145791
145791
  }, hasNegatedFormattingMark = (formatting, markName) => {
145792
145792
  const rawActiveMark = formatting.find((mark) => mark.name === markName);
145793
145793
  return rawActiveMark ? isNegatedMark(rawActiveMark.name, rawActiveMark.attrs) : false;
145794
+ }, isFormatCommandsStorage = (value) => {
145795
+ return typeof value === "object" && value !== null && "storedStyle" in value;
145796
+ }, hasStoredCopyFormat = (context) => {
145797
+ const formatCommands = resolveStateEditor(context)?.storage?.formatCommands;
145798
+ return isFormatCommandsStorage(formatCommands) && Boolean(formatCommands.storedStyle);
145794
145799
  }, createBoldStateDeriver = () => ({ context }) => {
145795
145800
  const stateEditor = resolveStateEditor(context);
145796
145801
  const formatting = stateEditor ? getActiveFormatting(stateEditor) : [];
@@ -145842,6 +145847,11 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
145842
145847
  active: !hasNegatedFormattingMark(formatting, "strike") && formatting.some((mark) => mark.name === "strike"),
145843
145848
  disabled: false
145844
145849
  };
145850
+ }, createCopyFormatStateDeriver = () => ({ context }) => {
145851
+ return {
145852
+ active: hasStoredCopyFormat(context),
145853
+ disabled: isCommandDisabled(context)
145854
+ };
145845
145855
  }, createFontSizeStateDeriver = () => ({ context }) => {
145846
145856
  const stateEditor = resolveStateEditor(context);
145847
145857
  const formatting = stateEditor ? getActiveFormatting(stateEditor) : [];
@@ -146402,7 +146412,7 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
146402
146412
  "copy-format": {
146403
146413
  id: "copy-format",
146404
146414
  directCommandName: "copyFormat",
146405
- state: createDisabledStateDeriver()
146415
+ state: createCopyFormatStateDeriver()
146406
146416
  },
146407
146417
  "track-changes-accept-selection": {
146408
146418
  id: "track-changes-accept-selection",
@@ -146561,7 +146571,7 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
146561
146571
  }
146562
146572
  };
146563
146573
  };
146564
- var init_create_headless_toolbar_DCioTQPP_es = __esm(() => {
146574
+ var init_create_headless_toolbar_CmoOhFUt_es = __esm(() => {
146565
146575
  init_SuperConverter_BLUJyRB9_es();
146566
146576
  init_constants_DrU4EASo_es();
146567
146577
  init_dist_B8HfvhaK_es();
@@ -200794,7 +200804,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
200794
200804
  init_remark_gfm_BhnWr3yf_es();
200795
200805
  });
200796
200806
 
200797
- // ../../packages/superdoc/dist/chunks/src-CLqPyVCp.es.js
200807
+ // ../../packages/superdoc/dist/chunks/src-Cxh53Lmk.es.js
200798
200808
  function deleteProps(obj, propOrProps) {
200799
200809
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
200800
200810
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -201732,6 +201742,165 @@ function isStyleTokenEnabled(val) {
201732
201742
  }
201733
201743
  return !!val;
201734
201744
  }
201745
+ function getSelectionRange(state) {
201746
+ const { from: from$1, to } = state.selection;
201747
+ return {
201748
+ from: from$1,
201749
+ to
201750
+ };
201751
+ }
201752
+ function isSameSelection(selection, otherSelection) {
201753
+ if (!selection || !otherSelection)
201754
+ return false;
201755
+ return selection.from === otherSelection.from && selection.to === otherSelection.to;
201756
+ }
201757
+ function clearFormatPainterStorage(storage) {
201758
+ storage.releaseCleanup?.();
201759
+ storage.storedStyle = null;
201760
+ storage.sourceSelection = null;
201761
+ storage.persistent = false;
201762
+ storage.lastCopyFormatClickAt = 0;
201763
+ storage.releaseCleanup = null;
201764
+ storage.pointerSelecting = false;
201765
+ storage.keyboardSelecting = false;
201766
+ }
201767
+ function armFormatPainterRelease({ storage, editor }) {
201768
+ if (storage.releaseCleanup)
201769
+ return;
201770
+ if (typeof document === "undefined" || !document?.addEventListener)
201771
+ return;
201772
+ const pointerDownEventName = typeof PointerEvent === "undefined" ? "mousedown" : "pointerdown";
201773
+ const pointerUpEventName = typeof PointerEvent === "undefined" ? "mouseup" : "pointerup";
201774
+ const isToolbarEvent = (event) => event?.target?.closest?.(FORMAT_PAINTER_UI_SELECTOR);
201775
+ const applyIfTargetSelected = () => {
201776
+ if (!storage.storedStyle)
201777
+ return;
201778
+ const selection = editor.state.selection;
201779
+ const currentSelection = getSelectionRange(editor.state);
201780
+ if (selection.empty || isSameSelection(currentSelection, storage.sourceSelection))
201781
+ return;
201782
+ editor.commands.applyStoredFormat();
201783
+ };
201784
+ const handlePointerDown = (event) => {
201785
+ if (isToolbarEvent(event)) {
201786
+ storage.pointerSelecting = false;
201787
+ return;
201788
+ }
201789
+ storage.pointerSelecting = true;
201790
+ };
201791
+ const handleRelease = (event) => {
201792
+ if (isToolbarEvent(event)) {
201793
+ storage.pointerSelecting = false;
201794
+ return;
201795
+ }
201796
+ storage.pointerSelecting = false;
201797
+ applyIfTargetSelected();
201798
+ };
201799
+ const handleKeyDown$1 = (event) => {
201800
+ if (isToolbarEvent(event))
201801
+ return;
201802
+ if (isFormatPainterSelectionKey(event))
201803
+ storage.keyboardSelecting = true;
201804
+ };
201805
+ const handleKeyUp = () => {
201806
+ if (!storage.keyboardSelecting)
201807
+ return;
201808
+ storage.keyboardSelecting = false;
201809
+ applyIfTargetSelected();
201810
+ };
201811
+ document.addEventListener(pointerDownEventName, handlePointerDown, true);
201812
+ document.addEventListener(pointerUpEventName, handleRelease, true);
201813
+ document.addEventListener("keydown", handleKeyDown$1, true);
201814
+ document.addEventListener("keyup", handleKeyUp, true);
201815
+ storage.releaseCleanup = () => {
201816
+ document.removeEventListener(pointerDownEventName, handlePointerDown, true);
201817
+ document.removeEventListener(pointerUpEventName, handleRelease, true);
201818
+ document.removeEventListener("keydown", handleKeyDown$1, true);
201819
+ document.removeEventListener("keyup", handleKeyUp, true);
201820
+ };
201821
+ }
201822
+ function isFormatPainterSelectionKey(event) {
201823
+ if (!event?.shiftKey)
201824
+ return false;
201825
+ return [
201826
+ "ArrowLeft",
201827
+ "ArrowRight",
201828
+ "ArrowUp",
201829
+ "ArrowDown",
201830
+ "Home",
201831
+ "End",
201832
+ "PageUp",
201833
+ "PageDown"
201834
+ ].includes(event.key);
201835
+ }
201836
+ function applyStoredFormat({ chain, storage }) {
201837
+ if (!storage.storedStyle)
201838
+ return false;
201839
+ const shouldStayActive = storage.persistent;
201840
+ try {
201841
+ if (!storage.storedStyle.length) {
201842
+ if (!shouldStayActive)
201843
+ clearFormatPainterStorage(storage);
201844
+ return chain().clearFormat().run();
201845
+ }
201846
+ const storedMarks = storage.storedStyle;
201847
+ const processedMarks = [];
201848
+ storedMarks.forEach((mark2) => {
201849
+ const { type, attrs } = mark2;
201850
+ const { name } = type;
201851
+ if (name === "textStyle")
201852
+ Object.keys(attrs).forEach((key2) => {
201853
+ if (!attrs[key2])
201854
+ return;
201855
+ const attributes = {};
201856
+ attributes[key2] = attrs[key2];
201857
+ processedMarks.push({
201858
+ name: key2,
201859
+ attrs: attributes
201860
+ });
201861
+ });
201862
+ else
201863
+ processedMarks.push({
201864
+ name,
201865
+ attrs
201866
+ });
201867
+ });
201868
+ const marksToCommands = {
201869
+ bold: ["setBold", "unsetBold"],
201870
+ italic: ["setItalic", "unsetItalic"],
201871
+ underline: ["setUnderline", "unsetUnderline"],
201872
+ color: [
201873
+ "setColor",
201874
+ "setColor",
201875
+ null
201876
+ ],
201877
+ fontSize: ["setFontSize", "unsetFontSize"],
201878
+ fontFamily: ["setFontFamily", "unsetFontFamily"]
201879
+ };
201880
+ let result = chain();
201881
+ Object.keys(marksToCommands).forEach((key2) => {
201882
+ const [setCommand, unsetCommand, defaultParam] = marksToCommands[key2];
201883
+ const markToApply = processedMarks.find((mark2) => mark2.name === key2);
201884
+ const hasEmptyAttrs = markToApply?.attrs && markToApply?.attrs[key2];
201885
+ let cmd = {};
201886
+ if (!markToApply && !hasEmptyAttrs)
201887
+ cmd = {
201888
+ command: unsetCommand,
201889
+ argument: defaultParam
201890
+ };
201891
+ else
201892
+ cmd = {
201893
+ command: setCommand,
201894
+ argument: markToApply.attrs[key2] || defaultParam
201895
+ };
201896
+ result = result[cmd.command](cmd.argument);
201897
+ });
201898
+ return result;
201899
+ } finally {
201900
+ if (!shouldStayActive)
201901
+ clearFormatPainterStorage(storage);
201902
+ }
201903
+ }
201735
201904
  function dropCursor(options = {}) {
201736
201905
  return new Plugin({ view(editorView) {
201737
201906
  return new DropCursorView(editorView, options);
@@ -266839,7 +267008,7 @@ var Node$13 = class Node$14 {
266839
267008
  if (styleOn)
266840
267009
  return cmdChain.setMark(markName, negationAttrs, { extendEmptyMarkRange }).run();
266841
267010
  return cmdChain.setMark(markName, {}, { extendEmptyMarkRange }).run();
266842
- }, FormatCommands, DropCursorView = class {
267011
+ }, FORMAT_PAINTER_DOUBLE_CLICK_MS = 500, FORMAT_PAINTER_UI_SELECTOR = "[data-editor-ui-surface], .toolbar-dropdown-menu, .sd-toolbar-dropdown-menu, .sd-tooltip-content", FormatCommands, DropCursorView = class {
266843
267012
  constructor(editorView, options) {
266844
267013
  var _a2;
266845
267014
  this.editorView = editorView;
@@ -295571,13 +295740,13 @@ menclose::after {
295571
295740
  return;
295572
295741
  console.log(...args$1);
295573
295742
  }, 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;
295574
- var init_src_CLqPyVCp_es = __esm(() => {
295743
+ var init_src_Cxh53Lmk_es = __esm(() => {
295575
295744
  init_rolldown_runtime_Bg48TavK_es();
295576
295745
  init_SuperConverter_BLUJyRB9_es();
295577
295746
  init_jszip_C49i9kUs_es();
295578
295747
  init_xml_js_CqGKpaft_es();
295579
295748
  init_uuid_qzgm05fK_es();
295580
- init_create_headless_toolbar_DCioTQPP_es();
295749
+ init_create_headless_toolbar_CmoOhFUt_es();
295581
295750
  init_constants_DrU4EASo_es();
295582
295751
  init_dist_B8HfvhaK_es();
295583
295752
  init_unified_Dsuw2be5_es();
@@ -296597,7 +296766,15 @@ ${err.toString()}`);
296597
296766
  return {};
296598
296767
  },
296599
296768
  addStorage() {
296600
- return { storedStyle: null };
296769
+ return {
296770
+ storedStyle: null,
296771
+ sourceSelection: null,
296772
+ persistent: false,
296773
+ lastCopyFormatClickAt: 0,
296774
+ releaseCleanup: null,
296775
+ pointerSelecting: false,
296776
+ keyboardSelecting: false
296777
+ };
296601
296778
  },
296602
296779
  addCommands() {
296603
296780
  return {
@@ -296612,72 +296789,60 @@ ${err.toString()}`);
296612
296789
  return chain().clearNodes().run();
296613
296790
  },
296614
296791
  copyFormat: () => ({ chain }) => {
296792
+ const currentSelection = getSelectionRange(this.editor.state);
296615
296793
  if (!this.storage.storedStyle) {
296616
296794
  const marks = getMarksFromSelection(this.editor.state, this.editor);
296617
296795
  this.storage.storedStyle = marks;
296796
+ this.storage.sourceSelection = currentSelection;
296797
+ this.storage.persistent = false;
296798
+ this.storage.lastCopyFormatClickAt = Date.now();
296799
+ armFormatPainterRelease({
296800
+ storage: this.storage,
296801
+ editor: this.editor
296802
+ });
296618
296803
  return true;
296619
296804
  }
296620
- if (!this.storage.storedStyle.length) {
296621
- this.storage.storedStyle = null;
296622
- return chain().clearFormat().run();
296623
- }
296624
- const storedMarks = this.storage.storedStyle;
296625
- const processedMarks = [];
296626
- storedMarks.forEach((mark2) => {
296627
- const { type, attrs } = mark2;
296628
- const { name } = type;
296629
- if (name === "textStyle")
296630
- Object.keys(attrs).forEach((key2) => {
296631
- if (!attrs[key2])
296632
- return;
296633
- const attributes = {};
296634
- attributes[key2] = attrs[key2];
296635
- processedMarks.push({
296636
- name: key2,
296637
- attrs: attributes
296638
- });
296639
- });
296640
- else
296641
- processedMarks.push({
296642
- name,
296643
- attrs
296644
- });
296805
+ if (this.storage.persistent) {
296806
+ clearFormatPainterStorage(this.storage);
296807
+ return true;
296808
+ }
296809
+ const clickedSourceAgain = isSameSelection(currentSelection, this.storage.sourceSelection);
296810
+ if (clickedSourceAgain && Date.now() - this.storage.lastCopyFormatClickAt <= FORMAT_PAINTER_DOUBLE_CLICK_MS && !this.storage.persistent) {
296811
+ this.storage.persistent = true;
296812
+ this.storage.lastCopyFormatClickAt = 0;
296813
+ return true;
296814
+ }
296815
+ if (clickedSourceAgain) {
296816
+ clearFormatPainterStorage(this.storage);
296817
+ return true;
296818
+ }
296819
+ return applyStoredFormat({
296820
+ chain,
296821
+ storage: this.storage
296645
296822
  });
296646
- const marksToCommands = {
296647
- bold: ["setBold", "unsetBold"],
296648
- italic: ["setItalic", "unsetItalic"],
296649
- underline: ["setUnderline", "unsetUnderline"],
296650
- color: [
296651
- "setColor",
296652
- "setColor",
296653
- null
296654
- ],
296655
- fontSize: ["setFontSize", "unsetFontSize"],
296656
- fontFamily: ["setFontFamily", "unsetFontFamily"]
296657
- };
296658
- let result = chain();
296659
- Object.keys(marksToCommands).forEach((key2) => {
296660
- const [setCommand, unsetCommand, defaultParam] = marksToCommands[key2];
296661
- const markToApply = processedMarks.find((mark2) => mark2.name === key2);
296662
- const hasEmptyAttrs = markToApply?.attrs && markToApply?.attrs[key2];
296663
- let cmd = {};
296664
- if (!markToApply && !hasEmptyAttrs)
296665
- cmd = {
296666
- command: unsetCommand,
296667
- argument: defaultParam
296668
- };
296669
- else
296670
- cmd = {
296671
- command: setCommand,
296672
- argument: markToApply.attrs[key2] || defaultParam
296673
- };
296674
- result = result[cmd.command](cmd.argument);
296823
+ },
296824
+ applyStoredFormat: () => ({ chain }) => {
296825
+ return applyStoredFormat({
296826
+ chain,
296827
+ storage: this.storage
296675
296828
  });
296676
- this.storage.storedStyle = null;
296677
- return result;
296678
296829
  }
296679
296830
  };
296680
296831
  },
296832
+ onSelectionUpdate({ editor }) {
296833
+ const { storedStyle, sourceSelection } = this.storage;
296834
+ if (!storedStyle)
296835
+ return;
296836
+ const currentSelection = getSelectionRange(editor.state);
296837
+ if (editor.state.selection.empty || isSameSelection(currentSelection, sourceSelection))
296838
+ return;
296839
+ if (this.storage.pointerSelecting || this.storage.keyboardSelecting)
296840
+ return;
296841
+ editor.commands.applyStoredFormat();
296842
+ },
296843
+ onDestroy() {
296844
+ clearFormatPainterStorage(this.storage);
296845
+ },
296681
296846
  addShortcuts() {
296682
296847
  return { "Mod-Alt-c": () => this.editor.commands.clearFormat() };
296683
296848
  }
@@ -333741,11 +333906,11 @@ function print() { __p += __j.call(arguments, '') }
333741
333906
  ];
333742
333907
  });
333743
333908
 
333744
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-6HZGNd4y.es.js
333909
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-DZLpw5_x.es.js
333745
333910
  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;
333746
- var init_create_super_doc_ui_6HZGNd4y_es = __esm(() => {
333911
+ var init_create_super_doc_ui_DZLpw5_x_es = __esm(() => {
333747
333912
  init_SuperConverter_BLUJyRB9_es();
333748
- init_create_headless_toolbar_DCioTQPP_es();
333913
+ init_create_headless_toolbar_CmoOhFUt_es();
333749
333914
  MOD_ALIASES = new Set([
333750
333915
  "Mod",
333751
333916
  "Meta",
@@ -333787,16 +333952,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
333787
333952
 
333788
333953
  // ../../packages/superdoc/dist/super-editor.es.js
333789
333954
  var init_super_editor_es = __esm(() => {
333790
- init_src_CLqPyVCp_es();
333955
+ init_src_Cxh53Lmk_es();
333791
333956
  init_SuperConverter_BLUJyRB9_es();
333792
333957
  init_jszip_C49i9kUs_es();
333793
333958
  init_xml_js_CqGKpaft_es();
333794
- init_create_headless_toolbar_DCioTQPP_es();
333959
+ init_create_headless_toolbar_CmoOhFUt_es();
333795
333960
  init_constants_DrU4EASo_es();
333796
333961
  init_dist_B8HfvhaK_es();
333797
333962
  init_unified_Dsuw2be5_es();
333798
333963
  init_DocxZipper_DoY5OEjc_es();
333799
- init_create_super_doc_ui_6HZGNd4y_es();
333964
+ init_create_super_doc_ui_DZLpw5_x_es();
333800
333965
  init_ui_C5PAS9hY_es();
333801
333966
  init_eventemitter3_BnGqBE_Q_es();
333802
333967
  init_errors_CNaD6vcg_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/mcp",
3
- "version": "0.6.0-next.12",
3
+ "version": "0.6.0-next.14",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"