@superdoc-dev/cli 0.11.0-next.12 → 0.11.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 +239 -74
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -158229,7 +158229,7 @@ var init_SuperConverter_BLUJyRB9_es = __esm(() => {
158229
158229
  };
158230
158230
  });
158231
158231
 
158232
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DCioTQPP.es.js
158232
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-CmoOhFUt.es.js
158233
158233
  function parseSizeUnit(val = "0") {
158234
158234
  const length3 = val.toString() || "0";
158235
158235
  const value = Number.parseFloat(length3);
@@ -160220,6 +160220,11 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
160220
160220
  }, hasNegatedFormattingMark = (formatting, markName) => {
160221
160221
  const rawActiveMark = formatting.find((mark) => mark.name === markName);
160222
160222
  return rawActiveMark ? isNegatedMark(rawActiveMark.name, rawActiveMark.attrs) : false;
160223
+ }, isFormatCommandsStorage = (value) => {
160224
+ return typeof value === "object" && value !== null && "storedStyle" in value;
160225
+ }, hasStoredCopyFormat = (context) => {
160226
+ const formatCommands = resolveStateEditor(context)?.storage?.formatCommands;
160227
+ return isFormatCommandsStorage(formatCommands) && Boolean(formatCommands.storedStyle);
160223
160228
  }, createBoldStateDeriver = () => ({ context }) => {
160224
160229
  const stateEditor = resolveStateEditor(context);
160225
160230
  const formatting = stateEditor ? getActiveFormatting(stateEditor) : [];
@@ -160271,6 +160276,11 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
160271
160276
  active: !hasNegatedFormattingMark(formatting, "strike") && formatting.some((mark) => mark.name === "strike"),
160272
160277
  disabled: false
160273
160278
  };
160279
+ }, createCopyFormatStateDeriver = () => ({ context }) => {
160280
+ return {
160281
+ active: hasStoredCopyFormat(context),
160282
+ disabled: isCommandDisabled(context)
160283
+ };
160274
160284
  }, createFontSizeStateDeriver = () => ({ context }) => {
160275
160285
  const stateEditor = resolveStateEditor(context);
160276
160286
  const formatting = stateEditor ? getActiveFormatting(stateEditor) : [];
@@ -160831,7 +160841,7 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
160831
160841
  "copy-format": {
160832
160842
  id: "copy-format",
160833
160843
  directCommandName: "copyFormat",
160834
- state: createDisabledStateDeriver()
160844
+ state: createCopyFormatStateDeriver()
160835
160845
  },
160836
160846
  "track-changes-accept-selection": {
160837
160847
  id: "track-changes-accept-selection",
@@ -160990,7 +161000,7 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
160990
161000
  }
160991
161001
  };
160992
161002
  };
160993
- var init_create_headless_toolbar_DCioTQPP_es = __esm(() => {
161003
+ var init_create_headless_toolbar_CmoOhFUt_es = __esm(() => {
160994
161004
  init_SuperConverter_BLUJyRB9_es();
160995
161005
  init_constants_DrU4EASo_es();
160996
161006
  init_dist_B8HfvhaK_es();
@@ -209702,7 +209712,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
209702
209712
  init_remark_gfm_BhnWr3yf_es();
209703
209713
  });
209704
209714
 
209705
- // ../../packages/superdoc/dist/chunks/src-CLqPyVCp.es.js
209715
+ // ../../packages/superdoc/dist/chunks/src-Cxh53Lmk.es.js
209706
209716
  function deleteProps(obj, propOrProps) {
209707
209717
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
209708
209718
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -210640,6 +210650,165 @@ function isStyleTokenEnabled(val) {
210640
210650
  }
210641
210651
  return !!val;
210642
210652
  }
210653
+ function getSelectionRange(state) {
210654
+ const { from: from$1, to } = state.selection;
210655
+ return {
210656
+ from: from$1,
210657
+ to
210658
+ };
210659
+ }
210660
+ function isSameSelection(selection, otherSelection) {
210661
+ if (!selection || !otherSelection)
210662
+ return false;
210663
+ return selection.from === otherSelection.from && selection.to === otherSelection.to;
210664
+ }
210665
+ function clearFormatPainterStorage(storage) {
210666
+ storage.releaseCleanup?.();
210667
+ storage.storedStyle = null;
210668
+ storage.sourceSelection = null;
210669
+ storage.persistent = false;
210670
+ storage.lastCopyFormatClickAt = 0;
210671
+ storage.releaseCleanup = null;
210672
+ storage.pointerSelecting = false;
210673
+ storage.keyboardSelecting = false;
210674
+ }
210675
+ function armFormatPainterRelease({ storage, editor }) {
210676
+ if (storage.releaseCleanup)
210677
+ return;
210678
+ if (typeof document === "undefined" || !document?.addEventListener)
210679
+ return;
210680
+ const pointerDownEventName = typeof PointerEvent === "undefined" ? "mousedown" : "pointerdown";
210681
+ const pointerUpEventName = typeof PointerEvent === "undefined" ? "mouseup" : "pointerup";
210682
+ const isToolbarEvent = (event) => event?.target?.closest?.(FORMAT_PAINTER_UI_SELECTOR);
210683
+ const applyIfTargetSelected = () => {
210684
+ if (!storage.storedStyle)
210685
+ return;
210686
+ const selection = editor.state.selection;
210687
+ const currentSelection = getSelectionRange(editor.state);
210688
+ if (selection.empty || isSameSelection(currentSelection, storage.sourceSelection))
210689
+ return;
210690
+ editor.commands.applyStoredFormat();
210691
+ };
210692
+ const handlePointerDown = (event) => {
210693
+ if (isToolbarEvent(event)) {
210694
+ storage.pointerSelecting = false;
210695
+ return;
210696
+ }
210697
+ storage.pointerSelecting = true;
210698
+ };
210699
+ const handleRelease = (event) => {
210700
+ if (isToolbarEvent(event)) {
210701
+ storage.pointerSelecting = false;
210702
+ return;
210703
+ }
210704
+ storage.pointerSelecting = false;
210705
+ applyIfTargetSelected();
210706
+ };
210707
+ const handleKeyDown$1 = (event) => {
210708
+ if (isToolbarEvent(event))
210709
+ return;
210710
+ if (isFormatPainterSelectionKey(event))
210711
+ storage.keyboardSelecting = true;
210712
+ };
210713
+ const handleKeyUp = () => {
210714
+ if (!storage.keyboardSelecting)
210715
+ return;
210716
+ storage.keyboardSelecting = false;
210717
+ applyIfTargetSelected();
210718
+ };
210719
+ document.addEventListener(pointerDownEventName, handlePointerDown, true);
210720
+ document.addEventListener(pointerUpEventName, handleRelease, true);
210721
+ document.addEventListener("keydown", handleKeyDown$1, true);
210722
+ document.addEventListener("keyup", handleKeyUp, true);
210723
+ storage.releaseCleanup = () => {
210724
+ document.removeEventListener(pointerDownEventName, handlePointerDown, true);
210725
+ document.removeEventListener(pointerUpEventName, handleRelease, true);
210726
+ document.removeEventListener("keydown", handleKeyDown$1, true);
210727
+ document.removeEventListener("keyup", handleKeyUp, true);
210728
+ };
210729
+ }
210730
+ function isFormatPainterSelectionKey(event) {
210731
+ if (!event?.shiftKey)
210732
+ return false;
210733
+ return [
210734
+ "ArrowLeft",
210735
+ "ArrowRight",
210736
+ "ArrowUp",
210737
+ "ArrowDown",
210738
+ "Home",
210739
+ "End",
210740
+ "PageUp",
210741
+ "PageDown"
210742
+ ].includes(event.key);
210743
+ }
210744
+ function applyStoredFormat({ chain, storage }) {
210745
+ if (!storage.storedStyle)
210746
+ return false;
210747
+ const shouldStayActive = storage.persistent;
210748
+ try {
210749
+ if (!storage.storedStyle.length) {
210750
+ if (!shouldStayActive)
210751
+ clearFormatPainterStorage(storage);
210752
+ return chain().clearFormat().run();
210753
+ }
210754
+ const storedMarks = storage.storedStyle;
210755
+ const processedMarks = [];
210756
+ storedMarks.forEach((mark2) => {
210757
+ const { type, attrs } = mark2;
210758
+ const { name } = type;
210759
+ if (name === "textStyle")
210760
+ Object.keys(attrs).forEach((key2) => {
210761
+ if (!attrs[key2])
210762
+ return;
210763
+ const attributes = {};
210764
+ attributes[key2] = attrs[key2];
210765
+ processedMarks.push({
210766
+ name: key2,
210767
+ attrs: attributes
210768
+ });
210769
+ });
210770
+ else
210771
+ processedMarks.push({
210772
+ name,
210773
+ attrs
210774
+ });
210775
+ });
210776
+ const marksToCommands = {
210777
+ bold: ["setBold", "unsetBold"],
210778
+ italic: ["setItalic", "unsetItalic"],
210779
+ underline: ["setUnderline", "unsetUnderline"],
210780
+ color: [
210781
+ "setColor",
210782
+ "setColor",
210783
+ null
210784
+ ],
210785
+ fontSize: ["setFontSize", "unsetFontSize"],
210786
+ fontFamily: ["setFontFamily", "unsetFontFamily"]
210787
+ };
210788
+ let result = chain();
210789
+ Object.keys(marksToCommands).forEach((key2) => {
210790
+ const [setCommand, unsetCommand, defaultParam] = marksToCommands[key2];
210791
+ const markToApply = processedMarks.find((mark2) => mark2.name === key2);
210792
+ const hasEmptyAttrs = markToApply?.attrs && markToApply?.attrs[key2];
210793
+ let cmd = {};
210794
+ if (!markToApply && !hasEmptyAttrs)
210795
+ cmd = {
210796
+ command: unsetCommand,
210797
+ argument: defaultParam
210798
+ };
210799
+ else
210800
+ cmd = {
210801
+ command: setCommand,
210802
+ argument: markToApply.attrs[key2] || defaultParam
210803
+ };
210804
+ result = result[cmd.command](cmd.argument);
210805
+ });
210806
+ return result;
210807
+ } finally {
210808
+ if (!shouldStayActive)
210809
+ clearFormatPainterStorage(storage);
210810
+ }
210811
+ }
210643
210812
  function dropCursor(options = {}) {
210644
210813
  return new Plugin({ view(editorView) {
210645
210814
  return new DropCursorView(editorView, options);
@@ -275747,7 +275916,7 @@ var Node$13 = class Node$14 {
275747
275916
  if (styleOn)
275748
275917
  return cmdChain.setMark(markName, negationAttrs, { extendEmptyMarkRange }).run();
275749
275918
  return cmdChain.setMark(markName, {}, { extendEmptyMarkRange }).run();
275750
- }, FormatCommands, DropCursorView = class {
275919
+ }, 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 {
275751
275920
  constructor(editorView, options) {
275752
275921
  var _a;
275753
275922
  this.editorView = editorView;
@@ -304479,13 +304648,13 @@ menclose::after {
304479
304648
  return;
304480
304649
  console.log(...args$1);
304481
304650
  }, 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;
304482
- var init_src_CLqPyVCp_es = __esm(() => {
304651
+ var init_src_Cxh53Lmk_es = __esm(() => {
304483
304652
  init_rolldown_runtime_Bg48TavK_es();
304484
304653
  init_SuperConverter_BLUJyRB9_es();
304485
304654
  init_jszip_C49i9kUs_es();
304486
304655
  init_xml_js_CqGKpaft_es();
304487
304656
  init_uuid_qzgm05fK_es();
304488
- init_create_headless_toolbar_DCioTQPP_es();
304657
+ init_create_headless_toolbar_CmoOhFUt_es();
304489
304658
  init_constants_DrU4EASo_es();
304490
304659
  init_dist_B8HfvhaK_es();
304491
304660
  init_unified_Dsuw2be5_es();
@@ -305505,7 +305674,15 @@ ${err.toString()}`);
305505
305674
  return {};
305506
305675
  },
305507
305676
  addStorage() {
305508
- return { storedStyle: null };
305677
+ return {
305678
+ storedStyle: null,
305679
+ sourceSelection: null,
305680
+ persistent: false,
305681
+ lastCopyFormatClickAt: 0,
305682
+ releaseCleanup: null,
305683
+ pointerSelecting: false,
305684
+ keyboardSelecting: false
305685
+ };
305509
305686
  },
305510
305687
  addCommands() {
305511
305688
  return {
@@ -305520,72 +305697,60 @@ ${err.toString()}`);
305520
305697
  return chain().clearNodes().run();
305521
305698
  },
305522
305699
  copyFormat: () => ({ chain }) => {
305700
+ const currentSelection = getSelectionRange(this.editor.state);
305523
305701
  if (!this.storage.storedStyle) {
305524
305702
  const marks = getMarksFromSelection(this.editor.state, this.editor);
305525
305703
  this.storage.storedStyle = marks;
305704
+ this.storage.sourceSelection = currentSelection;
305705
+ this.storage.persistent = false;
305706
+ this.storage.lastCopyFormatClickAt = Date.now();
305707
+ armFormatPainterRelease({
305708
+ storage: this.storage,
305709
+ editor: this.editor
305710
+ });
305526
305711
  return true;
305527
305712
  }
305528
- if (!this.storage.storedStyle.length) {
305529
- this.storage.storedStyle = null;
305530
- return chain().clearFormat().run();
305531
- }
305532
- const storedMarks = this.storage.storedStyle;
305533
- const processedMarks = [];
305534
- storedMarks.forEach((mark2) => {
305535
- const { type, attrs } = mark2;
305536
- const { name } = type;
305537
- if (name === "textStyle")
305538
- Object.keys(attrs).forEach((key2) => {
305539
- if (!attrs[key2])
305540
- return;
305541
- const attributes = {};
305542
- attributes[key2] = attrs[key2];
305543
- processedMarks.push({
305544
- name: key2,
305545
- attrs: attributes
305546
- });
305547
- });
305548
- else
305549
- processedMarks.push({
305550
- name,
305551
- attrs
305552
- });
305713
+ if (this.storage.persistent) {
305714
+ clearFormatPainterStorage(this.storage);
305715
+ return true;
305716
+ }
305717
+ const clickedSourceAgain = isSameSelection(currentSelection, this.storage.sourceSelection);
305718
+ if (clickedSourceAgain && Date.now() - this.storage.lastCopyFormatClickAt <= FORMAT_PAINTER_DOUBLE_CLICK_MS && !this.storage.persistent) {
305719
+ this.storage.persistent = true;
305720
+ this.storage.lastCopyFormatClickAt = 0;
305721
+ return true;
305722
+ }
305723
+ if (clickedSourceAgain) {
305724
+ clearFormatPainterStorage(this.storage);
305725
+ return true;
305726
+ }
305727
+ return applyStoredFormat({
305728
+ chain,
305729
+ storage: this.storage
305553
305730
  });
305554
- const marksToCommands = {
305555
- bold: ["setBold", "unsetBold"],
305556
- italic: ["setItalic", "unsetItalic"],
305557
- underline: ["setUnderline", "unsetUnderline"],
305558
- color: [
305559
- "setColor",
305560
- "setColor",
305561
- null
305562
- ],
305563
- fontSize: ["setFontSize", "unsetFontSize"],
305564
- fontFamily: ["setFontFamily", "unsetFontFamily"]
305565
- };
305566
- let result = chain();
305567
- Object.keys(marksToCommands).forEach((key2) => {
305568
- const [setCommand, unsetCommand, defaultParam] = marksToCommands[key2];
305569
- const markToApply = processedMarks.find((mark2) => mark2.name === key2);
305570
- const hasEmptyAttrs = markToApply?.attrs && markToApply?.attrs[key2];
305571
- let cmd = {};
305572
- if (!markToApply && !hasEmptyAttrs)
305573
- cmd = {
305574
- command: unsetCommand,
305575
- argument: defaultParam
305576
- };
305577
- else
305578
- cmd = {
305579
- command: setCommand,
305580
- argument: markToApply.attrs[key2] || defaultParam
305581
- };
305582
- result = result[cmd.command](cmd.argument);
305731
+ },
305732
+ applyStoredFormat: () => ({ chain }) => {
305733
+ return applyStoredFormat({
305734
+ chain,
305735
+ storage: this.storage
305583
305736
  });
305584
- this.storage.storedStyle = null;
305585
- return result;
305586
305737
  }
305587
305738
  };
305588
305739
  },
305740
+ onSelectionUpdate({ editor }) {
305741
+ const { storedStyle, sourceSelection } = this.storage;
305742
+ if (!storedStyle)
305743
+ return;
305744
+ const currentSelection = getSelectionRange(editor.state);
305745
+ if (editor.state.selection.empty || isSameSelection(currentSelection, sourceSelection))
305746
+ return;
305747
+ if (this.storage.pointerSelecting || this.storage.keyboardSelecting)
305748
+ return;
305749
+ editor.commands.applyStoredFormat();
305750
+ },
305751
+ onDestroy() {
305752
+ clearFormatPainterStorage(this.storage);
305753
+ },
305589
305754
  addShortcuts() {
305590
305755
  return { "Mod-Alt-c": () => this.editor.commands.clearFormat() };
305591
305756
  }
@@ -342649,11 +342814,11 @@ function print() { __p += __j.call(arguments, '') }
342649
342814
  ];
342650
342815
  });
342651
342816
 
342652
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-6HZGNd4y.es.js
342817
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-DZLpw5_x.es.js
342653
342818
  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;
342654
- var init_create_super_doc_ui_6HZGNd4y_es = __esm(() => {
342819
+ var init_create_super_doc_ui_DZLpw5_x_es = __esm(() => {
342655
342820
  init_SuperConverter_BLUJyRB9_es();
342656
- init_create_headless_toolbar_DCioTQPP_es();
342821
+ init_create_headless_toolbar_CmoOhFUt_es();
342657
342822
  MOD_ALIASES = new Set([
342658
342823
  "Mod",
342659
342824
  "Meta",
@@ -342695,16 +342860,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
342695
342860
 
342696
342861
  // ../../packages/superdoc/dist/super-editor.es.js
342697
342862
  var init_super_editor_es = __esm(() => {
342698
- init_src_CLqPyVCp_es();
342863
+ init_src_Cxh53Lmk_es();
342699
342864
  init_SuperConverter_BLUJyRB9_es();
342700
342865
  init_jszip_C49i9kUs_es();
342701
342866
  init_xml_js_CqGKpaft_es();
342702
- init_create_headless_toolbar_DCioTQPP_es();
342867
+ init_create_headless_toolbar_CmoOhFUt_es();
342703
342868
  init_constants_DrU4EASo_es();
342704
342869
  init_dist_B8HfvhaK_es();
342705
342870
  init_unified_Dsuw2be5_es();
342706
342871
  init_DocxZipper_DoY5OEjc_es();
342707
- init_create_super_doc_ui_6HZGNd4y_es();
342872
+ init_create_super_doc_ui_DZLpw5_x_es();
342708
342873
  init_ui_C5PAS9hY_es();
342709
342874
  init_eventemitter3_BnGqBE_Q_es();
342710
342875
  init_errors_CNaD6vcg_es();
@@ -354857,10 +355022,10 @@ var init_MouseEvent = __esm(() => {
354857
355022
  });
354858
355023
 
354859
355024
  // ../../node_modules/.pnpm/happy-dom@20.4.0/node_modules/happy-dom/lib/event/events/PointerEvent.js
354860
- var PointerEvent;
355025
+ var PointerEvent2;
354861
355026
  var init_PointerEvent = __esm(() => {
354862
355027
  init_MouseEvent();
354863
- PointerEvent = class PointerEvent extends MouseEvent2 {
355028
+ PointerEvent2 = class PointerEvent2 extends MouseEvent2 {
354864
355029
  pointerId;
354865
355030
  width;
354866
355031
  height;
@@ -365067,7 +365232,7 @@ var init_HTMLElement = __esm(() => {
365067
365232
  this.setAttribute("popover", value2);
365068
365233
  }
365069
365234
  click() {
365070
- this.dispatchEvent(new PointerEvent("click", {
365235
+ this.dispatchEvent(new PointerEvent2("click", {
365071
365236
  bubbles: true,
365072
365237
  composed: true,
365073
365238
  cancelable: true
@@ -388426,7 +388591,7 @@ var init_BrowserWindow = __esm(() => {
388426
388591
  KeyboardEvent = KeyboardEvent2;
388427
388592
  MessageEvent = MessageEvent2;
388428
388593
  MouseEvent = MouseEvent2;
388429
- PointerEvent = PointerEvent;
388594
+ PointerEvent = PointerEvent2;
388430
388595
  FocusEvent = FocusEvent;
388431
388596
  WheelEvent = WheelEvent;
388432
388597
  InputEvent = InputEvent2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.11.0-next.12",
3
+ "version": "0.11.0-next.14",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -34,11 +34,11 @@
34
34
  "access": "public"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@superdoc-dev/cli-darwin-arm64": "0.11.0-next.12",
38
- "@superdoc-dev/cli-darwin-x64": "0.11.0-next.12",
39
- "@superdoc-dev/cli-linux-arm64": "0.11.0-next.12",
40
- "@superdoc-dev/cli-windows-x64": "0.11.0-next.12",
41
- "@superdoc-dev/cli-linux-x64": "0.11.0-next.12"
37
+ "@superdoc-dev/cli-darwin-arm64": "0.11.0-next.14",
38
+ "@superdoc-dev/cli-darwin-x64": "0.11.0-next.14",
39
+ "@superdoc-dev/cli-linux-x64": "0.11.0-next.14",
40
+ "@superdoc-dev/cli-linux-arm64": "0.11.0-next.14",
41
+ "@superdoc-dev/cli-windows-x64": "0.11.0-next.14"
42
42
  },
43
43
  "scripts": {
44
44
  "predev": "node scripts/ensure-superdoc-build.js",