@gantfdt/semiword 1.1.2 → 1.2.1

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 (39) hide show
  1. package/dist-lib/{FlowchartEditor-LT6T7ZQV.mjs → FlowchartEditor-OSHXJZQC.mjs} +3 -3
  2. package/dist-lib/{FlowchartEditor-LT6T7ZQV.mjs.map → FlowchartEditor-OSHXJZQC.mjs.map} +1 -1
  3. package/dist-lib/{MindmapEditor-TMXT2VG3.mjs → MindmapEditor-LHYQNYU2.mjs} +3 -3
  4. package/dist-lib/{MindmapEditor-TMXT2VG3.mjs.map → MindmapEditor-LHYQNYU2.mjs.map} +1 -1
  5. package/dist-lib/{WhiteboardEditor-FSYK6RVN.mjs → WhiteboardEditor-ZNZ7DSSC.mjs} +9 -457
  6. package/dist-lib/WhiteboardEditor-ZNZ7DSSC.mjs.map +1 -0
  7. package/dist-lib/ai.mjs +6 -6
  8. package/dist-lib/{chunk-JUWUIWRJ.mjs → chunk-3S2IK47C.mjs} +4 -4
  9. package/dist-lib/{chunk-JUWUIWRJ.mjs.map → chunk-3S2IK47C.mjs.map} +1 -1
  10. package/dist-lib/{chunk-2NQHWRMX.mjs → chunk-7SGGGLSR.mjs} +7 -7
  11. package/dist-lib/{chunk-2NQHWRMX.mjs.map → chunk-7SGGGLSR.mjs.map} +1 -1
  12. package/dist-lib/{chunk-YE3O5CVM.mjs → chunk-7SGW66XT.mjs} +166 -30
  13. package/dist-lib/chunk-7SGW66XT.mjs.map +1 -0
  14. package/dist-lib/{chunk-IQZHLLFT.mjs → chunk-ADBRQOSQ.mjs} +4 -4
  15. package/dist-lib/{chunk-IQZHLLFT.mjs.map → chunk-ADBRQOSQ.mjs.map} +1 -1
  16. package/dist-lib/{chunk-UNGEXPJP.mjs → chunk-FGUTLPFA.mjs} +6 -6
  17. package/dist-lib/{chunk-UNGEXPJP.mjs.map → chunk-FGUTLPFA.mjs.map} +1 -1
  18. package/dist-lib/{chunk-V4AKDECS.mjs → chunk-NRXQ5SSE.mjs} +15 -9
  19. package/dist-lib/chunk-NRXQ5SSE.mjs.map +1 -0
  20. package/dist-lib/{chunk-WT7ZJINB.mjs → chunk-Q72ADACC.mjs} +31 -4
  21. package/dist-lib/chunk-Q72ADACC.mjs.map +1 -0
  22. package/dist-lib/{chunk-YLBAMBKK.mjs → chunk-UB5DIRWL.mjs} +4 -4
  23. package/dist-lib/{chunk-YLBAMBKK.mjs.map → chunk-UB5DIRWL.mjs.map} +1 -1
  24. package/dist-lib/designer.mjs +7 -7
  25. package/dist-lib/editor.d.mts +3 -3
  26. package/dist-lib/editor.mjs +7 -7
  27. package/dist-lib/gant-ai.mjs +6 -6
  28. package/dist-lib/index.d.mts +2 -2
  29. package/dist-lib/index.mjs +7 -7
  30. package/dist-lib/io.mjs +3 -3
  31. package/dist-lib/sdk.mjs +4 -4
  32. package/dist-lib/storage.d.mts +3 -3
  33. package/dist-lib/{types-D7kCE5Mu.d.mts → types-D43MTtwD.d.mts} +4 -0
  34. package/dist-lib/{useDocumentPersistence-CDUT0u5S.d.mts → useDocumentPersistence-0s-GS72-.d.mts} +1 -1
  35. package/package.json +4 -4
  36. package/dist-lib/WhiteboardEditor-FSYK6RVN.mjs.map +0 -1
  37. package/dist-lib/chunk-V4AKDECS.mjs.map +0 -1
  38. package/dist-lib/chunk-WT7ZJINB.mjs.map +0 -1
  39. package/dist-lib/chunk-YE3O5CVM.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { createStyles, useBlockStyles, Button, IconEdit, IconDelete, IconVideo, IconAttachment, createGraphicBlockView, createGraphicBlockNode, IconUndo, IconRedo, IconParagraph, IconQuote, IconCode, IconDivider, IconBulletList, IconOrderedList, IconTaskList, IconBold, IconItalic, IconStrikethrough, IconUnderline, IconTextColor, IconAlignLeft, IconAlignCenter, IconAlignRight, IconClearFormat, IconFormatPainter, IconBackgroundColor, IconTable, IconImage, IconFlowchart, IconWhiteboard, IconMindmap, IconMention, Tooltip, IconLink, Modal as Modal$1, Input, DatePicker } from './chunk-WT7ZJINB.mjs';
1
+ import { createStyles, useBlockStyles, Button, IconEdit, IconDelete, IconVideo, IconAttachment, createGraphicBlockView, createGraphicBlockNode, IconUndo, IconRedo, IconParagraph, IconQuote, IconCode, IconDivider, IconBulletList, IconOrderedList, IconTaskList, IconBold, IconItalic, IconStrikethrough, IconUnderline, IconTextColor, IconAlignLeft, IconAlignCenter, IconAlignRight, IconClearFormat, IconFormatPainter, IconBackgroundColor, IconTable, IconImage, IconFlowchart, IconWhiteboard, IconMindmap, IconMention, Tooltip, IconLink, Modal as Modal$1, Input, DatePicker } from './chunk-Q72ADACC.mjs';
2
2
  import { sanitizeSvg, DATA_MEDIA_URI_PATTERN } from './chunk-7D6NMYFG.mjs';
3
3
  import { readTemplateBlockMeta, renderTemplateBlockMeta, parseTemplateBlockMeta, getTemplateBlockRegistry, effectivePin, createTemplateController, getRegisteredTemplateBlockExtensions, createIntegrityExtension } from './chunk-EOUNN3NA.mjs';
4
4
  import { tr } from './chunk-W627LLF4.mjs';
@@ -429,28 +429,39 @@ function pickFile(accept) {
429
429
  input.style.left = "-9999px";
430
430
  document.body.appendChild(input);
431
431
  let settled = false;
432
- let handleFocus = null;
433
- const finish = (file) => {
434
- if (settled) return;
435
- settled = true;
436
- if (handleFocus) {
437
- window.removeEventListener("focus", handleFocus);
438
- }
432
+ let fallbackTimer = null;
433
+ function dispose() {
434
+ if (fallbackTimer) clearTimeout(fallbackTimer);
435
+ window.removeEventListener("focus", handleFocus);
436
+ input.removeEventListener("cancel", handleCancel);
439
437
  input.onchange = null;
440
438
  input.remove();
439
+ }
440
+ function finish(file) {
441
+ if (settled) return;
442
+ settled = true;
443
+ dispose();
441
444
  resolve(file);
442
- };
445
+ }
446
+ function handleCancel() {
447
+ finish(null);
448
+ }
449
+ function handleFocus() {
450
+ if (settled) return;
451
+ if (fallbackTimer) clearTimeout(fallbackTimer);
452
+ fallbackTimer = setTimeout(() => {
453
+ if (settled || !document.hasFocus()) return;
454
+ const files = input.files;
455
+ if (!files || files.length === 0) finish(null);
456
+ }, 500);
457
+ }
443
458
  input.onchange = (e) => {
444
459
  finish(e.target.files?.[0] ?? null);
445
460
  };
446
- handleFocus = () => {
447
- setTimeout(() => {
448
- if (!settled && (!input.files || input.files.length === 0)) {
449
- finish(null);
450
- }
451
- }, 200);
452
- };
453
- window.addEventListener("focus", handleFocus);
461
+ input.addEventListener("cancel", handleCancel);
462
+ if (!("oncancel" in input)) {
463
+ window.addEventListener("focus", handleFocus);
464
+ }
454
465
  input.click();
455
466
  });
456
467
  }
@@ -1401,7 +1412,10 @@ var headingPlugin = {
1401
1412
  group: "format",
1402
1413
  order: 10,
1403
1414
  label: tr("\u6807\u9898"),
1404
- icon: /* @__PURE__ */ jsx(IconParagraph, {}),
1415
+ // 未命中任何标题级别时(如空段落未聚焦)默认展示「正文」
1416
+ fallbackLabel: tr("\u6B63\u6587"),
1417
+ // 固定文字列宽度:正文 / H1-H6 切换时按钮宽度保持一致
1418
+ triggerLabelWidth: 2,
1405
1419
  options: [
1406
1420
  {
1407
1421
  label: tr("\u6B63\u6587"),
@@ -2472,7 +2486,7 @@ function createMarkApply(attach) {
2472
2486
  if (typeof from !== "number" || typeof to !== "number" || from > to) return false;
2473
2487
  const rawParams = args[1];
2474
2488
  const params = typeof rawParams === "object" && rawParams !== null ? rawParams : void 0;
2475
- const chain = attach(editor.chain().setTextSelection({ from, to }), { from, to }, params);
2489
+ const chain = attach(editor.chain().setTextSelection({ from, to }), { from, to }, params, editor);
2476
2490
  return chain === false ? false : chain.run();
2477
2491
  };
2478
2492
  }
@@ -2576,6 +2590,17 @@ var textFormatPlugin = {
2576
2590
  }
2577
2591
  ]
2578
2592
  };
2593
+
2594
+ // src/editor/plugins/utils/textStyleAttrs.ts
2595
+ function getTextStyleAttrs(editor) {
2596
+ const attrs = editor.getAttributes("textStyle");
2597
+ return {
2598
+ color: attrs.color ?? null,
2599
+ gradient: attrs.gradient ?? null,
2600
+ fontFamily: attrs.fontFamily ?? null,
2601
+ fontSize: attrs.fontSize ?? null
2602
+ };
2603
+ }
2579
2604
  var TextStyleGradient = Extension.create({
2580
2605
  name: "textStyleGradient",
2581
2606
  addGlobalAttributes() {
@@ -2619,13 +2644,13 @@ var textColorPlugin = {
2619
2644
  },
2620
2645
  onColorSelect: (editor, color, options) => {
2621
2646
  const chain = options?.focus === false ? editor.chain() : editor.chain().focus();
2622
- chain.setMark("textStyle", { color, gradient: null }).run();
2647
+ chain.setMark("textStyle", { ...getTextStyleAttrs(editor), color, gradient: null }).run();
2623
2648
  },
2624
2649
  onGradientSelect: (editor, gradient) => {
2625
- editor.chain().focus().setMark("textStyle", { color: null, gradient }).run();
2650
+ editor.chain().focus().setMark("textStyle", { ...getTextStyleAttrs(editor), color: null, gradient }).run();
2626
2651
  },
2627
2652
  onClear: (editor) => {
2628
- editor.chain().focus().setMark("textStyle", { color: null, gradient: null }).removeEmptyTextStyle().run();
2653
+ editor.chain().focus().setMark("textStyle", { ...getTextStyleAttrs(editor), color: null, gradient: null }).removeEmptyTextStyle().run();
2629
2654
  }
2630
2655
  }
2631
2656
  ],
@@ -2646,10 +2671,10 @@ var textColorPlugin = {
2646
2671
  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
2672
  }
2648
2673
  ],
2649
- apply: createMarkApply((chain, _range, params) => {
2674
+ apply: createMarkApply((chain, _range, params, editor) => {
2650
2675
  const color = params?.color;
2651
2676
  if (typeof color !== "string" || !color.trim()) return false;
2652
- return chain.setMark("textStyle", { color, gradient: null });
2677
+ return chain.setMark("textStyle", { ...getTextStyleAttrs(editor), color, gradient: null });
2653
2678
  })
2654
2679
  },
2655
2680
  {
@@ -2660,11 +2685,120 @@ var textColorPlugin = {
2660
2685
  "\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
2686
  ),
2662
2687
  apply: createMarkApply(
2663
- (chain) => chain.setMark("textStyle", { color: null, gradient: null }).removeEmptyTextStyle()
2688
+ (chain, _range, _params, editor) => chain.setMark("textStyle", { ...getTextStyleAttrs(editor), color: null, gradient: null }).removeEmptyTextStyle()
2664
2689
  )
2665
2690
  }
2666
2691
  ]
2667
2692
  };
2693
+ var TextStyleFontFamily = Extension.create({
2694
+ name: "textStyleFontFamily",
2695
+ addGlobalAttributes() {
2696
+ return [
2697
+ {
2698
+ types: ["textStyle"],
2699
+ attributes: {
2700
+ fontFamily: {
2701
+ default: null,
2702
+ parseHTML: (element) => element.style.fontFamily?.replace(/['"]+/g, "") || null,
2703
+ renderHTML: (attributes) => {
2704
+ const family = attributes.fontFamily;
2705
+ if (!family) return {};
2706
+ return { style: `font-family: ${/[\s,]/.test(family) ? `'${family}'` : family}` };
2707
+ }
2708
+ }
2709
+ }
2710
+ }
2711
+ ];
2712
+ }
2713
+ });
2714
+ var FONT_FAMILIES = [
2715
+ { label: tr("\u5B8B\u4F53"), value: "SimSun" },
2716
+ { label: tr("\u5FAE\u8F6F\u96C5\u9ED1"), value: "Microsoft YaHei" },
2717
+ { label: tr("\u9ED1\u4F53"), value: "SimHei" },
2718
+ { label: tr("\u6977\u4F53"), value: "KaiTi" },
2719
+ { label: tr("\u4EFF\u5B8B"), value: "FangSong" },
2720
+ { label: tr("Arial"), value: "Arial" }
2721
+ ];
2722
+ var fontFamilyPlugin = {
2723
+ name: "font-family",
2724
+ category: "format",
2725
+ dependencies: ["text-color"],
2726
+ defaultEnabled: true,
2727
+ tiptapExtensions: () => [TextStyleFontFamily],
2728
+ toolbarItems: () => [
2729
+ {
2730
+ id: "font-family",
2731
+ type: "dropdown",
2732
+ group: "format",
2733
+ order: 11,
2734
+ label: tr("\u5B57\u4F53"),
2735
+ // 固定宽度容纳四字字体名,切换字体时按钮宽度不跳动
2736
+ triggerLabelWidth: 4.2,
2737
+ options: [
2738
+ {
2739
+ label: tr("\u9ED8\u8BA4"),
2740
+ onClick: (editor) => editor.chain().focus().setMark("textStyle", { ...getTextStyleAttrs(editor), fontFamily: null }).removeEmptyTextStyle().run()
2741
+ },
2742
+ ...FONT_FAMILIES.map(({ label, value }) => ({
2743
+ label,
2744
+ isActive: (editor) => editor.isActive("textStyle", { fontFamily: value }),
2745
+ onClick: (editor) => editor.chain().focus().setMark("textStyle", { ...getTextStyleAttrs(editor), fontFamily: value }).run()
2746
+ }))
2747
+ ]
2748
+ }
2749
+ ]
2750
+ };
2751
+ var TextStyleFontSize = Extension.create({
2752
+ name: "textStyleFontSize",
2753
+ addGlobalAttributes() {
2754
+ return [
2755
+ {
2756
+ types: ["textStyle"],
2757
+ attributes: {
2758
+ fontSize: {
2759
+ default: null,
2760
+ parseHTML: (element) => element.style.fontSize || null,
2761
+ renderHTML: (attributes) => {
2762
+ const size = attributes.fontSize;
2763
+ if (!size) return {};
2764
+ return { style: `font-size: ${size}` };
2765
+ }
2766
+ }
2767
+ }
2768
+ }
2769
+ ];
2770
+ }
2771
+ });
2772
+ var FONT_SIZES = ["12px", "14px", "16px", "18px", "20px", "24px", "30px", "36px", "48px"];
2773
+ var fontSizePlugin = {
2774
+ name: "font-size",
2775
+ category: "format",
2776
+ dependencies: ["text-color"],
2777
+ defaultEnabled: true,
2778
+ tiptapExtensions: () => [TextStyleFontSize],
2779
+ toolbarItems: () => [
2780
+ {
2781
+ id: "font-size",
2782
+ type: "dropdown",
2783
+ group: "format",
2784
+ order: 12,
2785
+ label: tr("\u5B57\u53F7"),
2786
+ // 固定宽度容纳 "48px",切换字号时按钮宽度不跳动
2787
+ triggerLabelWidth: 2.5,
2788
+ options: [
2789
+ {
2790
+ label: tr("\u9ED8\u8BA4"),
2791
+ onClick: (editor) => editor.chain().focus().setMark("textStyle", { ...getTextStyleAttrs(editor), fontSize: null }).removeEmptyTextStyle().run()
2792
+ },
2793
+ ...FONT_SIZES.map((size) => ({
2794
+ label: size,
2795
+ isActive: (editor) => editor.isActive("textStyle", { fontSize: size }),
2796
+ onClick: (editor) => editor.chain().focus().setMark("textStyle", { ...getTextStyleAttrs(editor), fontSize: size }).run()
2797
+ }))
2798
+ ]
2799
+ }
2800
+ ]
2801
+ };
2668
2802
  var textAlignPlugin = {
2669
2803
  name: "text-align",
2670
2804
  category: "format",
@@ -5397,7 +5531,7 @@ var FlowchartView = createGraphicBlockView({
5397
5531
  loadingText: () => tr("\u52A0\u8F7D\u6D41\u7A0B\u56FE\u7F16\u8F91\u5668\u2026"),
5398
5532
  alt: "flowchart",
5399
5533
  // x6 画布较重,仅在进入编辑态时懒加载,不拖累编辑器初始包体
5400
- editorLoader: () => import('./FlowchartEditor-LT6T7ZQV.mjs')
5534
+ editorLoader: () => import('./FlowchartEditor-OSHXJZQC.mjs')
5401
5535
  });
5402
5536
  var FlowchartView_default = FlowchartView;
5403
5537
  var FlowchartBlock = createGraphicBlockNode({
@@ -5466,7 +5600,7 @@ var WhiteboardView = createGraphicBlockView({
5466
5600
  placeholderText: () => tr("\u70B9\u51FB\u7F16\u8F91\u753B\u677F"),
5467
5601
  loadingText: () => tr("\u52A0\u8F7D\u753B\u677F\u7F16\u8F91\u5668\u2026"),
5468
5602
  // Excalidraw 体积较大,仅在进入编辑态时懒加载
5469
- editorLoader: () => import('./WhiteboardEditor-FSYK6RVN.mjs')
5603
+ editorLoader: () => import('./WhiteboardEditor-ZNZ7DSSC.mjs')
5470
5604
  });
5471
5605
  var WhiteboardView_default = WhiteboardView;
5472
5606
  var WhiteboardBlock = createGraphicBlockNode({
@@ -5513,7 +5647,7 @@ var MindmapView = createGraphicBlockView({
5513
5647
  placeholderText: () => tr("\u70B9\u51FB\u7F16\u8F91\u601D\u7EF4\u5BFC\u56FE"),
5514
5648
  loadingText: () => tr("\u52A0\u8F7D\u601D\u7EF4\u5BFC\u56FE\u7F16\u8F91\u5668\u2026"),
5515
5649
  // simple-mind-map 体积较大,仅在进入编辑态时懒加载
5516
- editorLoader: () => import('./MindmapEditor-TMXT2VG3.mjs')
5650
+ editorLoader: () => import('./MindmapEditor-LHYQNYU2.mjs')
5517
5651
  });
5518
5652
  var MindmapView_default = MindmapView;
5519
5653
  var MindmapBlock = createGraphicBlockNode({
@@ -6583,6 +6717,8 @@ var BUILTIN_PLUGINS = [
6583
6717
  // format - 文本格式
6584
6718
  textFormatPlugin,
6585
6719
  textColorPlugin,
6720
+ fontFamilyPlugin,
6721
+ fontSizePlugin,
6586
6722
  textAlignPlugin,
6587
6723
  clearFormatPlugin,
6588
6724
  formatPainterPlugin,
@@ -7295,5 +7431,5 @@ function fixedTableCss({ token, pa, borderRadius, mode, sel: s }) {
7295
7431
  }
7296
7432
 
7297
7433
  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
7434
+ //# sourceMappingURL=chunk-7SGW66XT.mjs.map
7435
+ //# sourceMappingURL=chunk-7SGW66XT.mjs.map