@jvs-milkdown/crepe 1.2.33 → 1.2.35

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.
package/lib/esm/index.js CHANGED
@@ -5,7 +5,7 @@ import { languages } from '@codemirror/language-data';
5
5
  import { oneDark } from '@codemirror/theme-one-dark';
6
6
  import { createSlice } from '@jvs-milkdown/kit/ctx';
7
7
  import { $ctx, $nodeSchema, $view, $remark, $markAttr, $markSchema, $command, $prose, $useKeymap, getMarkdown, $inputRule } from '@jvs-milkdown/kit/utils';
8
- import { defineComponent, shallowRef, ref, computed, h, createApp, watchEffect, watch, onUnmounted, Fragment, reactive, onMounted, onBeforeUnmount, nextTick } from 'vue';
8
+ import { defineComponent, shallowRef, ref, computed, h, createApp, watchEffect, watch, onUnmounted, Fragment as Fragment$1, reactive, onMounted, onBeforeUnmount, nextTick } from 'vue';
9
9
  import { Icon } from '@jvs-milkdown/kit/component';
10
10
  import { blockConfig, block, BlockProvider } from '@jvs-milkdown/kit/plugin/block';
11
11
  import { commandsCtx, editorViewCtx, schemaCtx, editorCtx, EditorStatus, rootCtx, parserCtx, editorViewOptionsCtx, Editor, defaultValueCtx } from '@jvs-milkdown/kit/core';
@@ -3898,7 +3898,7 @@ function getBlockKey(node) {
3898
3898
  }
3899
3899
  }
3900
3900
 
3901
- keepAlive(h, Fragment);
3901
+ keepAlive(h, Fragment$1);
3902
3902
  const BlockHandle = defineComponent({
3903
3903
  props: {
3904
3904
  onAdd: {
@@ -3946,7 +3946,7 @@ const BlockHandle = defineComponent({
3946
3946
  const addButton = ref();
3947
3947
  const menuButton = ref();
3948
3948
  return () => {
3949
- return /* @__PURE__ */ h(Fragment, null, /* @__PURE__ */ h(
3949
+ return /* @__PURE__ */ h(Fragment$1, null, /* @__PURE__ */ h(
3950
3950
  "div",
3951
3951
  {
3952
3952
  ref: addButton,
@@ -5509,7 +5509,7 @@ const activeIconMap = {
5509
5509
  [dividerIcon]: dividerIconActive
5510
5510
  // [highLineCodeIcon]: highLineCodeIconActive,
5511
5511
  };
5512
- keepAlive(h, Fragment);
5512
+ keepAlive(h, Fragment$1);
5513
5513
  const formatPainterStates = /* @__PURE__ */ new WeakMap();
5514
5514
  const formatPainterHandlers = /* @__PURE__ */ new WeakMap();
5515
5515
  const formatPainterIgnoreNext = /* @__PURE__ */ new WeakMap();
@@ -5835,8 +5835,7 @@ const Toolbar = defineComponent({
5835
5835
  siblingsWidth += s.offsetWidth;
5836
5836
  }
5837
5837
  }
5838
- const gapCount = Math.max(0, siblings.length);
5839
- containerWidth = parent.clientWidth - siblingsWidth - gapCount * 12;
5838
+ containerWidth = parent.clientWidth - siblingsWidth - 12;
5840
5839
  } else {
5841
5840
  containerWidth = container.clientWidth;
5842
5841
  }
@@ -6863,7 +6862,7 @@ const Toolbar = defineComponent({
6863
6862
  if (groupIndex < nonHeadingGroups.length - 1 && group.items.length > 0) {
6864
6863
  sectionIdx++;
6865
6864
  }
6866
- return /* @__PURE__ */ h(Fragment, { key: group.key }, items, groupIndex < nonHeadingGroups.length - 1 && group.items.length > 0 ? /* @__PURE__ */ h(
6865
+ return /* @__PURE__ */ h(Fragment$1, { key: group.key }, items, groupIndex < nonHeadingGroups.length - 1 && group.items.length > 0 ? /* @__PURE__ */ h(
6867
6866
  "div",
6868
6867
  {
6869
6868
  class: "divider",
@@ -7068,7 +7067,7 @@ const Toolbar = defineComponent({
7068
7067
  () => setIndent(-1),
7069
7068
  currentAlignIndent.value.indent <= 0
7070
7069
  ),
7071
- canMerge.value || canSplit.value ? /* @__PURE__ */ h(Fragment, null, /* @__PURE__ */ h(
7070
+ canMerge.value || canSplit.value ? /* @__PURE__ */ h(Fragment$1, null, /* @__PURE__ */ h(
7072
7071
  "div",
7073
7072
  {
7074
7073
  style: {
@@ -8635,241 +8634,214 @@ const FixedToolbarComponent = defineComponent({
8635
8634
  const isFull = computed(() => maxWidth.value === "none");
8636
8635
  if (!viewState.fixedToolbarVisible) {
8637
8636
  return /* @__PURE__ */ h(
8638
- "div",
8637
+ "button",
8639
8638
  {
8639
+ type: "button",
8640
+ class: "fixed-toolbar-expand-btn",
8641
+ title: "\u5C55\u5F00\u5DE5\u5177\u680F",
8642
+ onClick: (e) => {
8643
+ e.preventDefault();
8644
+ e.stopPropagation();
8645
+ viewState.fixedToolbarVisible = true;
8646
+ },
8640
8647
  style: {
8641
- position: "relative",
8642
- width: "100%",
8643
- height: "100%",
8648
+ position: "absolute",
8649
+ top: "0",
8650
+ right: "40px",
8644
8651
  display: "flex",
8645
8652
  alignItems: "center",
8646
- justifyContent: "center"
8653
+ justifyContent: "center",
8654
+ width: "28px",
8655
+ height: "24px",
8656
+ border: "1px solid var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 85%))",
8657
+ borderTop: "none",
8658
+ background: "var(--crepe-color-surface, #ffffff)",
8659
+ cursor: "pointer",
8660
+ borderRadius: "0 0 6px 6px",
8661
+ boxShadow: "0 4px 8px rgba(0, 0, 0, 0.06)",
8662
+ color: "var(--crepe-color-on-surface, #363b4c)",
8663
+ pointerEvents: "auto",
8664
+ zIndex: 200
8647
8665
  }
8648
8666
  },
8667
+ /* @__PURE__ */ h(
8668
+ "span",
8669
+ {
8670
+ style: { display: "inline-flex", alignItems: "center" },
8671
+ innerHTML: chevronDownIcon
8672
+ }
8673
+ )
8674
+ );
8675
+ }
8676
+ return /* @__PURE__ */ h(Fragment, null, /* @__PURE__ */ h(
8677
+ "div",
8678
+ {
8679
+ style: {
8680
+ position: "relative",
8681
+ display: "flex",
8682
+ alignItems: "center",
8683
+ justifyContent: "flex-start",
8684
+ width: "100%",
8685
+ maxWidth: isFull.value ? "100%" : maxWidth.value,
8686
+ margin: isFull.value ? "0" : "0 auto",
8687
+ padding: "0px 10px",
8688
+ gap: "0px",
8689
+ minWidth: "0",
8690
+ overflow: "hidden"
8691
+ }
8692
+ },
8693
+ ((_d = props.config) == null ? void 0 : _d.showMenuBar) !== false && [
8694
+ /* @__PURE__ */ h(MenuBar, { ctx: props.ctx, config: props.config }),
8695
+ /* @__PURE__ */ h(
8696
+ "div",
8697
+ {
8698
+ style: {
8699
+ width: "1px",
8700
+ minWidth: "1px",
8701
+ height: "20px",
8702
+ backgroundColor: "var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 80%))"
8703
+ }
8704
+ }
8705
+ )
8706
+ ],
8707
+ ((_e = props.config) == null ? void 0 : _e.showHistory) !== false && [
8649
8708
  /* @__PURE__ */ h(
8650
8709
  "button",
8651
8710
  {
8652
8711
  type: "button",
8653
- class: "fixed-toolbar-expand-btn",
8654
- title: "\u5C55\u5F00\u5DE5\u5177\u680F",
8712
+ class: ["toolbar-item", !canUndo && "disabled"],
8713
+ disabled: !canUndo,
8714
+ title: "\u64A4\u9500",
8715
+ onPointerdown: (e) => {
8716
+ e.preventDefault();
8717
+ e.stopPropagation();
8718
+ },
8655
8719
  onClick: (e) => {
8656
8720
  e.preventDefault();
8657
8721
  e.stopPropagation();
8658
- viewState.fixedToolbarVisible = true;
8722
+ if (canUndo) {
8723
+ props.ctx.get(commandsCtx).call("Undo");
8724
+ }
8659
8725
  },
8660
8726
  style: {
8661
- position: "absolute",
8662
- top: "0",
8663
- right: "40px",
8664
8727
  display: "flex",
8665
8728
  alignItems: "center",
8666
8729
  justifyContent: "center",
8667
- width: "28px",
8668
- height: "24px",
8669
- border: "1px solid var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 85%))",
8670
- borderTop: "none",
8671
- background: "var(--crepe-color-surface, #ffffff)",
8672
- cursor: "pointer",
8673
- borderRadius: "0 0 6px 6px",
8674
- boxShadow: "0 4px 8px rgba(0, 0, 0, 0.06)",
8675
- color: "var(--crepe-color-on-surface, #363b4c)",
8676
- pointerEvents: "auto",
8677
- zIndex: 200
8730
+ border: "none",
8731
+ background: "transparent",
8732
+ cursor: canUndo ? "pointer" : "default",
8733
+ padding: "6px",
8734
+ borderRadius: "4px",
8735
+ color: canUndo ? "#363b4c" : "#c0c4cc",
8736
+ "--toolbar-icon-color": canUndo ? "#363b4c" : "#c0c4cc"
8678
8737
  }
8679
8738
  },
8680
8739
  /* @__PURE__ */ h(
8681
8740
  "span",
8682
8741
  {
8683
8742
  style: { display: "inline-flex", alignItems: "center" },
8684
- innerHTML: chevronDownIcon
8685
- }
8686
- )
8687
- )
8688
- );
8689
- }
8690
- return /* @__PURE__ */ h(
8691
- "div",
8692
- {
8693
- style: {
8694
- position: "relative",
8695
- width: "100%",
8696
- height: "100%",
8697
- display: "flex",
8698
- alignItems: "center",
8699
- justifyContent: "center"
8700
- }
8701
- },
8702
- /* @__PURE__ */ h(
8703
- "div",
8704
- {
8705
- style: {
8706
- position: "relative",
8707
- display: "flex",
8708
- alignItems: "center",
8709
- justifyContent: "flex-start",
8710
- width: "100%",
8711
- maxWidth: isFull.value ? "100%" : maxWidth.value,
8712
- margin: isFull.value ? "0" : "0 auto",
8713
- // paddingRight: '40px',
8714
- gap: "0px",
8715
- minWidth: "0",
8716
- overflow: "hidden"
8717
- }
8718
- },
8719
- ((_d = props.config) == null ? void 0 : _d.showMenuBar) !== false && [
8720
- /* @__PURE__ */ h(MenuBar, { ctx: props.ctx, config: props.config }),
8721
- /* @__PURE__ */ h(
8722
- "div",
8723
- {
8724
- style: {
8725
- width: "1px",
8726
- minWidth: "1px",
8727
- height: "20px",
8728
- backgroundColor: "var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 80%))"
8729
- }
8743
+ innerHTML: undoIcon
8730
8744
  }
8731
8745
  )
8732
- ],
8733
- ((_e = props.config) == null ? void 0 : _e.showHistory) !== false && [
8734
- /* @__PURE__ */ h(
8735
- "button",
8736
- {
8737
- type: "button",
8738
- class: ["toolbar-item", !canUndo && "disabled"],
8739
- disabled: !canUndo,
8740
- title: "\u64A4\u9500",
8741
- onPointerdown: (e) => {
8742
- e.preventDefault();
8743
- e.stopPropagation();
8744
- },
8745
- onClick: (e) => {
8746
- e.preventDefault();
8747
- e.stopPropagation();
8748
- if (canUndo) {
8749
- props.ctx.get(commandsCtx).call("Undo");
8750
- }
8751
- },
8752
- style: {
8753
- display: "flex",
8754
- alignItems: "center",
8755
- justifyContent: "center",
8756
- border: "none",
8757
- background: "transparent",
8758
- cursor: canUndo ? "pointer" : "default",
8759
- padding: "6px",
8760
- borderRadius: "4px",
8761
- color: canUndo ? "#363b4c" : "#c0c4cc",
8762
- "--toolbar-icon-color": canUndo ? "#363b4c" : "#c0c4cc"
8763
- }
8746
+ ),
8747
+ /* @__PURE__ */ h(
8748
+ "button",
8749
+ {
8750
+ type: "button",
8751
+ class: ["toolbar-item", !canRedo && "disabled"],
8752
+ disabled: !canRedo,
8753
+ title: "\u6062\u590D",
8754
+ onPointerdown: (e) => {
8755
+ e.preventDefault();
8756
+ e.stopPropagation();
8764
8757
  },
8765
- /* @__PURE__ */ h(
8766
- "span",
8767
- {
8768
- style: { display: "inline-flex", alignItems: "center" },
8769
- innerHTML: undoIcon
8770
- }
8771
- )
8772
- ),
8773
- /* @__PURE__ */ h(
8774
- "button",
8775
- {
8776
- type: "button",
8777
- class: ["toolbar-item", !canRedo && "disabled"],
8778
- disabled: !canRedo,
8779
- title: "\u6062\u590D",
8780
- onPointerdown: (e) => {
8781
- e.preventDefault();
8782
- e.stopPropagation();
8783
- },
8784
- onClick: (e) => {
8785
- e.preventDefault();
8786
- e.stopPropagation();
8787
- if (canRedo) {
8788
- props.ctx.get(commandsCtx).call("Redo");
8789
- }
8790
- },
8791
- style: {
8792
- display: "flex",
8793
- alignItems: "center",
8794
- justifyContent: "center",
8795
- border: "none",
8796
- background: "transparent",
8797
- cursor: canRedo ? "pointer" : "default",
8798
- padding: "6px",
8799
- borderRadius: "4px",
8800
- color: canRedo ? "#363b4c" : "#c0c4cc",
8801
- "--toolbar-icon-color": canRedo ? "#363b4c" : "#c0c4cc"
8758
+ onClick: (e) => {
8759
+ e.preventDefault();
8760
+ e.stopPropagation();
8761
+ if (canRedo) {
8762
+ props.ctx.get(commandsCtx).call("Redo");
8802
8763
  }
8803
8764
  },
8804
- /* @__PURE__ */ h(
8805
- "span",
8806
- {
8807
- style: { display: "inline-flex", alignItems: "center" },
8808
- innerHTML: redoIcon
8809
- }
8810
- )
8811
- ),
8765
+ style: {
8766
+ display: "flex",
8767
+ alignItems: "center",
8768
+ justifyContent: "center",
8769
+ border: "none",
8770
+ background: "transparent",
8771
+ cursor: canRedo ? "pointer" : "default",
8772
+ padding: "6px",
8773
+ borderRadius: "4px",
8774
+ color: canRedo ? "#363b4c" : "#c0c4cc",
8775
+ "--toolbar-icon-color": canRedo ? "#363b4c" : "#c0c4cc"
8776
+ }
8777
+ },
8812
8778
  /* @__PURE__ */ h(
8813
- "div",
8779
+ "span",
8814
8780
  {
8815
- style: {
8816
- width: "1px",
8817
- minWidth: "1px",
8818
- height: "20px",
8819
- backgroundColor: "var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 80%))"
8820
- }
8781
+ style: { display: "inline-flex", alignItems: "center" },
8782
+ innerHTML: redoIcon
8821
8783
  }
8822
8784
  )
8823
- ],
8785
+ ),
8824
8786
  /* @__PURE__ */ h(
8825
- Toolbar,
8787
+ "div",
8826
8788
  {
8827
- ctx: props.ctx,
8828
- hide: props.hide,
8829
- show: props.show,
8830
- state: props.state,
8831
- config: props.config,
8832
- isFixed: true
8789
+ style: {
8790
+ width: "1px",
8791
+ minWidth: "1px",
8792
+ height: "20px",
8793
+ backgroundColor: "var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 80%))"
8794
+ }
8833
8795
  }
8834
- ),
8835
- showShortcuts.value && /* @__PURE__ */ h(ShortcutHelpModal, { ctx: props.ctx, visible: showShortcuts })
8796
+ )
8797
+ ],
8798
+ /* @__PURE__ */ h(
8799
+ Toolbar,
8800
+ {
8801
+ ctx: props.ctx,
8802
+ hide: props.hide,
8803
+ show: props.show,
8804
+ state: props.state,
8805
+ config: props.config,
8806
+ isFixed: true
8807
+ }
8836
8808
  ),
8809
+ showShortcuts.value && /* @__PURE__ */ h(ShortcutHelpModal, { ctx: props.ctx, visible: showShortcuts })
8810
+ ), /* @__PURE__ */ h(
8811
+ "button",
8812
+ {
8813
+ type: "button",
8814
+ class: "toolbar-item collapse-btn",
8815
+ title: "\u6298\u53E0\u5DE5\u5177\u680F",
8816
+ onClick: (e) => {
8817
+ e.preventDefault();
8818
+ e.stopPropagation();
8819
+ viewState.fixedToolbarVisible = false;
8820
+ },
8821
+ style: {
8822
+ position: "absolute",
8823
+ top: "6px",
8824
+ right: "40px",
8825
+ margin: "0",
8826
+ display: "flex",
8827
+ alignItems: "center",
8828
+ justifyContent: "center",
8829
+ pointerEvents: "auto",
8830
+ zIndex: 200
8831
+ }
8832
+ },
8837
8833
  /* @__PURE__ */ h(
8838
- "button",
8834
+ "span",
8839
8835
  {
8840
- type: "button",
8841
- class: "toolbar-item collapse-btn",
8842
- title: "\u6298\u53E0\u5DE5\u5177\u680F",
8843
- onClick: (e) => {
8844
- e.preventDefault();
8845
- e.stopPropagation();
8846
- viewState.fixedToolbarVisible = false;
8847
- },
8848
8836
  style: {
8849
- position: "absolute",
8850
- top: "6px",
8851
- right: "40px",
8852
- margin: "0",
8853
- display: "flex",
8837
+ display: "inline-flex",
8854
8838
  alignItems: "center",
8855
- justifyContent: "center",
8856
- pointerEvents: "auto",
8857
- zIndex: 200
8858
- }
8859
- },
8860
- /* @__PURE__ */ h(
8861
- "span",
8862
- {
8863
- style: {
8864
- display: "inline-flex",
8865
- alignItems: "center",
8866
- transform: "rotate(180deg)"
8867
- },
8868
- innerHTML: chevronDownIcon
8869
- }
8870
- )
8839
+ transform: "rotate(180deg)"
8840
+ },
8841
+ innerHTML: chevronDownIcon
8842
+ }
8871
8843
  )
8872
- );
8844
+ ));
8873
8845
  };
8874
8846
  }
8875
8847
  });