@gantfdt/semiword 1.1.2 → 1.2.0

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 (29) hide show
  1. package/dist-lib/ai.mjs +5 -5
  2. package/dist-lib/{chunk-YE3O5CVM.mjs → chunk-6JRQONYS.mjs} +135 -10
  3. package/dist-lib/chunk-6JRQONYS.mjs.map +1 -0
  4. package/dist-lib/{chunk-JUWUIWRJ.mjs → chunk-76EFOMJ3.mjs} +3 -3
  5. package/dist-lib/{chunk-JUWUIWRJ.mjs.map → chunk-76EFOMJ3.mjs.map} +1 -1
  6. package/dist-lib/{chunk-YLBAMBKK.mjs → chunk-ERWBH53C.mjs} +3 -3
  7. package/dist-lib/{chunk-YLBAMBKK.mjs.map → chunk-ERWBH53C.mjs.map} +1 -1
  8. package/dist-lib/{chunk-IQZHLLFT.mjs → chunk-G7P3OSVI.mjs} +3 -3
  9. package/dist-lib/{chunk-IQZHLLFT.mjs.map → chunk-G7P3OSVI.mjs.map} +1 -1
  10. package/dist-lib/{chunk-V4AKDECS.mjs → chunk-INIR3SZ3.mjs} +14 -8
  11. package/dist-lib/chunk-INIR3SZ3.mjs.map +1 -0
  12. package/dist-lib/{chunk-UNGEXPJP.mjs → chunk-MEI6FU7P.mjs} +5 -5
  13. package/dist-lib/{chunk-UNGEXPJP.mjs.map → chunk-MEI6FU7P.mjs.map} +1 -1
  14. package/dist-lib/{chunk-2NQHWRMX.mjs → chunk-YMND7XVN.mjs} +6 -6
  15. package/dist-lib/{chunk-2NQHWRMX.mjs.map → chunk-YMND7XVN.mjs.map} +1 -1
  16. package/dist-lib/designer.mjs +6 -6
  17. package/dist-lib/editor.d.mts +3 -3
  18. package/dist-lib/editor.mjs +6 -6
  19. package/dist-lib/gant-ai.mjs +5 -5
  20. package/dist-lib/index.d.mts +2 -2
  21. package/dist-lib/index.mjs +6 -6
  22. package/dist-lib/io.mjs +2 -2
  23. package/dist-lib/sdk.mjs +3 -3
  24. package/dist-lib/storage.d.mts +3 -3
  25. package/dist-lib/{types-D7kCE5Mu.d.mts → types-D43MTtwD.d.mts} +4 -0
  26. package/dist-lib/{useDocumentPersistence-CDUT0u5S.d.mts → useDocumentPersistence-0s-GS72-.d.mts} +1 -1
  27. package/package.json +1 -1
  28. package/dist-lib/chunk-V4AKDECS.mjs.map +0 -1
  29. package/dist-lib/chunk-YE3O5CVM.mjs.map +0 -1
package/dist-lib/ai.mjs CHANGED
@@ -1,10 +1,10 @@
1
- export { createDesignerCopilotTools, createEditorCopilotTools } from './chunk-UNGEXPJP.mjs';
1
+ export { createDesignerCopilotTools, createEditorCopilotTools } from './chunk-MEI6FU7P.mjs';
2
2
  export { SemiWordToolStatus } from './chunk-FOIP7DEC.mjs';
3
- import './chunk-JUWUIWRJ.mjs';
4
- import './chunk-IQZHLLFT.mjs';
3
+ import './chunk-76EFOMJ3.mjs';
4
+ import './chunk-G7P3OSVI.mjs';
5
5
  import './chunk-NPPS63UI.mjs';
6
- import './chunk-YLBAMBKK.mjs';
7
- import './chunk-YE3O5CVM.mjs';
6
+ import './chunk-ERWBH53C.mjs';
7
+ import './chunk-6JRQONYS.mjs';
8
8
  import './chunk-WT7ZJINB.mjs';
9
9
  import './chunk-7D6NMYFG.mjs';
10
10
  import './chunk-EOUNN3NA.mjs';
@@ -1401,7 +1401,10 @@ var headingPlugin = {
1401
1401
  group: "format",
1402
1402
  order: 10,
1403
1403
  label: tr("\u6807\u9898"),
1404
- icon: /* @__PURE__ */ jsx(IconParagraph, {}),
1404
+ // 未命中任何标题级别时(如空段落未聚焦)默认展示「正文」
1405
+ fallbackLabel: tr("\u6B63\u6587"),
1406
+ // 固定文字列宽度:正文 / H1-H6 切换时按钮宽度保持一致
1407
+ triggerLabelWidth: 2,
1405
1408
  options: [
1406
1409
  {
1407
1410
  label: tr("\u6B63\u6587"),
@@ -2472,7 +2475,7 @@ function createMarkApply(attach) {
2472
2475
  if (typeof from !== "number" || typeof to !== "number" || from > to) return false;
2473
2476
  const rawParams = args[1];
2474
2477
  const params = typeof rawParams === "object" && rawParams !== null ? rawParams : void 0;
2475
- const chain = attach(editor.chain().setTextSelection({ from, to }), { from, to }, params);
2478
+ const chain = attach(editor.chain().setTextSelection({ from, to }), { from, to }, params, editor);
2476
2479
  return chain === false ? false : chain.run();
2477
2480
  };
2478
2481
  }
@@ -2576,6 +2579,17 @@ var textFormatPlugin = {
2576
2579
  }
2577
2580
  ]
2578
2581
  };
2582
+
2583
+ // src/editor/plugins/utils/textStyleAttrs.ts
2584
+ function getTextStyleAttrs(editor) {
2585
+ const attrs = editor.getAttributes("textStyle");
2586
+ return {
2587
+ color: attrs.color ?? null,
2588
+ gradient: attrs.gradient ?? null,
2589
+ fontFamily: attrs.fontFamily ?? null,
2590
+ fontSize: attrs.fontSize ?? null
2591
+ };
2592
+ }
2579
2593
  var TextStyleGradient = Extension.create({
2580
2594
  name: "textStyleGradient",
2581
2595
  addGlobalAttributes() {
@@ -2619,13 +2633,13 @@ var textColorPlugin = {
2619
2633
  },
2620
2634
  onColorSelect: (editor, color, options) => {
2621
2635
  const chain = options?.focus === false ? editor.chain() : editor.chain().focus();
2622
- chain.setMark("textStyle", { color, gradient: null }).run();
2636
+ chain.setMark("textStyle", { ...getTextStyleAttrs(editor), color, gradient: null }).run();
2623
2637
  },
2624
2638
  onGradientSelect: (editor, gradient) => {
2625
- editor.chain().focus().setMark("textStyle", { color: null, gradient }).run();
2639
+ editor.chain().focus().setMark("textStyle", { ...getTextStyleAttrs(editor), color: null, gradient }).run();
2626
2640
  },
2627
2641
  onClear: (editor) => {
2628
- editor.chain().focus().setMark("textStyle", { color: null, gradient: null }).removeEmptyTextStyle().run();
2642
+ editor.chain().focus().setMark("textStyle", { ...getTextStyleAttrs(editor), color: null, gradient: null }).removeEmptyTextStyle().run();
2629
2643
  }
2630
2644
  }
2631
2645
  ],
@@ -2646,10 +2660,10 @@ var textColorPlugin = {
2646
2660
  description: tr("CSS \u989C\u8272\u503C\uFF08#ff0000 / red / rgb(255,0,0) \u7B49\u4EFB\u4E00 CSS \u5408\u6CD5\u989C\u8272\u5199\u6CD5\uFF09")
2647
2661
  }
2648
2662
  ],
2649
- apply: createMarkApply((chain, _range, params) => {
2663
+ apply: createMarkApply((chain, _range, params, editor) => {
2650
2664
  const color = params?.color;
2651
2665
  if (typeof color !== "string" || !color.trim()) return false;
2652
- return chain.setMark("textStyle", { color, gradient: null });
2666
+ return chain.setMark("textStyle", { ...getTextStyleAttrs(editor), color, gradient: null });
2653
2667
  })
2654
2668
  },
2655
2669
  {
@@ -2660,11 +2674,120 @@ var textColorPlugin = {
2660
2674
  "\u6E05\u9664\u951A\u6587\u672C\u7684\u6587\u5B57\u989C\u8272\u4E0E\u6E10\u53D8\uFF08\u6062\u590D\u9ED8\u8BA4\u8272\uFF0C\u6587\u5B57\u4FDD\u7559\uFF09\u3002\u65E0\u53C2\u6570\u3002\u628A\u7EA2\u5B57/\u5F69\u8272\u5B57/\u6E10\u53D8\u5B57\u6062\u590D\u9ED8\u8BA4\u7528\u672C\u6761\u76EE\u3002"
2661
2675
  ),
2662
2676
  apply: createMarkApply(
2663
- (chain) => chain.setMark("textStyle", { color: null, gradient: null }).removeEmptyTextStyle()
2677
+ (chain, _range, _params, editor) => chain.setMark("textStyle", { ...getTextStyleAttrs(editor), color: null, gradient: null }).removeEmptyTextStyle()
2664
2678
  )
2665
2679
  }
2666
2680
  ]
2667
2681
  };
2682
+ var TextStyleFontFamily = Extension.create({
2683
+ name: "textStyleFontFamily",
2684
+ addGlobalAttributes() {
2685
+ return [
2686
+ {
2687
+ types: ["textStyle"],
2688
+ attributes: {
2689
+ fontFamily: {
2690
+ default: null,
2691
+ parseHTML: (element) => element.style.fontFamily?.replace(/['"]+/g, "") || null,
2692
+ renderHTML: (attributes) => {
2693
+ const family = attributes.fontFamily;
2694
+ if (!family) return {};
2695
+ return { style: `font-family: ${/[\s,]/.test(family) ? `'${family}'` : family}` };
2696
+ }
2697
+ }
2698
+ }
2699
+ }
2700
+ ];
2701
+ }
2702
+ });
2703
+ var FONT_FAMILIES = [
2704
+ { label: tr("\u5B8B\u4F53"), value: "SimSun" },
2705
+ { label: tr("\u5FAE\u8F6F\u96C5\u9ED1"), value: "Microsoft YaHei" },
2706
+ { label: tr("\u9ED1\u4F53"), value: "SimHei" },
2707
+ { label: tr("\u6977\u4F53"), value: "KaiTi" },
2708
+ { label: tr("\u4EFF\u5B8B"), value: "FangSong" },
2709
+ { label: tr("Arial"), value: "Arial" }
2710
+ ];
2711
+ var fontFamilyPlugin = {
2712
+ name: "font-family",
2713
+ category: "format",
2714
+ dependencies: ["text-color"],
2715
+ defaultEnabled: true,
2716
+ tiptapExtensions: () => [TextStyleFontFamily],
2717
+ toolbarItems: () => [
2718
+ {
2719
+ id: "font-family",
2720
+ type: "dropdown",
2721
+ group: "format",
2722
+ order: 11,
2723
+ label: tr("\u5B57\u4F53"),
2724
+ // 固定宽度容纳四字字体名,切换字体时按钮宽度不跳动
2725
+ triggerLabelWidth: 4.2,
2726
+ options: [
2727
+ {
2728
+ label: tr("\u9ED8\u8BA4"),
2729
+ onClick: (editor) => editor.chain().focus().setMark("textStyle", { ...getTextStyleAttrs(editor), fontFamily: null }).removeEmptyTextStyle().run()
2730
+ },
2731
+ ...FONT_FAMILIES.map(({ label, value }) => ({
2732
+ label,
2733
+ isActive: (editor) => editor.isActive("textStyle", { fontFamily: value }),
2734
+ onClick: (editor) => editor.chain().focus().setMark("textStyle", { ...getTextStyleAttrs(editor), fontFamily: value }).run()
2735
+ }))
2736
+ ]
2737
+ }
2738
+ ]
2739
+ };
2740
+ var TextStyleFontSize = Extension.create({
2741
+ name: "textStyleFontSize",
2742
+ addGlobalAttributes() {
2743
+ return [
2744
+ {
2745
+ types: ["textStyle"],
2746
+ attributes: {
2747
+ fontSize: {
2748
+ default: null,
2749
+ parseHTML: (element) => element.style.fontSize || null,
2750
+ renderHTML: (attributes) => {
2751
+ const size = attributes.fontSize;
2752
+ if (!size) return {};
2753
+ return { style: `font-size: ${size}` };
2754
+ }
2755
+ }
2756
+ }
2757
+ }
2758
+ ];
2759
+ }
2760
+ });
2761
+ var FONT_SIZES = ["12px", "14px", "16px", "18px", "20px", "24px", "30px", "36px", "48px"];
2762
+ var fontSizePlugin = {
2763
+ name: "font-size",
2764
+ category: "format",
2765
+ dependencies: ["text-color"],
2766
+ defaultEnabled: true,
2767
+ tiptapExtensions: () => [TextStyleFontSize],
2768
+ toolbarItems: () => [
2769
+ {
2770
+ id: "font-size",
2771
+ type: "dropdown",
2772
+ group: "format",
2773
+ order: 12,
2774
+ label: tr("\u5B57\u53F7"),
2775
+ // 固定宽度容纳 "48px",切换字号时按钮宽度不跳动
2776
+ triggerLabelWidth: 2.5,
2777
+ options: [
2778
+ {
2779
+ label: tr("\u9ED8\u8BA4"),
2780
+ onClick: (editor) => editor.chain().focus().setMark("textStyle", { ...getTextStyleAttrs(editor), fontSize: null }).removeEmptyTextStyle().run()
2781
+ },
2782
+ ...FONT_SIZES.map((size) => ({
2783
+ label: size,
2784
+ isActive: (editor) => editor.isActive("textStyle", { fontSize: size }),
2785
+ onClick: (editor) => editor.chain().focus().setMark("textStyle", { ...getTextStyleAttrs(editor), fontSize: size }).run()
2786
+ }))
2787
+ ]
2788
+ }
2789
+ ]
2790
+ };
2668
2791
  var textAlignPlugin = {
2669
2792
  name: "text-align",
2670
2793
  category: "format",
@@ -6583,6 +6706,8 @@ var BUILTIN_PLUGINS = [
6583
6706
  // format - 文本格式
6584
6707
  textFormatPlugin,
6585
6708
  textColorPlugin,
6709
+ fontFamilyPlugin,
6710
+ fontSizePlugin,
6586
6711
  textAlignPlugin,
6587
6712
  clearFormatPlugin,
6588
6713
  formatPainterPlugin,
@@ -7295,5 +7420,5 @@ function fixedTableCss({ token, pa, borderRadius, mode, sel: s }) {
7295
7420
  }
7296
7421
 
7297
7422
  export { BUILTIN_PLUGINS, DEFAULT_TOOLBAR_GROUP_ORDER, FIXED_CELL_BG, HIGHLIGHT_THEME_CSS, MINIMAL_PLUGINS, PluginRegistry, codeBlockCss, configureEditorFeedback, configureEditorLocale, createCssScope, downloadFile, escapeHtml, findAncestor, fixedTableCss, getDefaultPlaceholder, glassSurfaceCss, headerControlForCol, isPlainObject, isSafeCssColor, lowlight, normalizeFixedTableBackgroundColor, outlinePlugin, parseFormula, pickFile, readFileAsText, readFixedCellControl, resolveCellControl, sanitizeJsonContent, showConfirmModal, showMessage, tableCss, templateCss, templatePlugin, typographyCss, validateFormula };
7298
- //# sourceMappingURL=chunk-YE3O5CVM.mjs.map
7299
- //# sourceMappingURL=chunk-YE3O5CVM.mjs.map
7423
+ //# sourceMappingURL=chunk-6JRQONYS.mjs.map
7424
+ //# sourceMappingURL=chunk-6JRQONYS.mjs.map