@a200888213/gbdocx 0.5.2 → 0.6.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 (80) hide show
  1. package/README.md +215 -207
  2. package/index.html +3 -2
  3. package/package.json +48 -48
  4. package/serve.mjs +3 -2
  5. package/src/app/file-io.js +122 -122
  6. package/src/app/main.js +9 -9
  7. package/src/app/word/catalog.js +52 -52
  8. package/src/app/word/comments.js +112 -112
  9. package/src/app/word/doc.js +113 -113
  10. package/src/app/word/edit.js +72 -72
  11. package/src/app/word/file.js +30 -1
  12. package/src/app/word/hf.js +76 -76
  13. package/src/app/word/layout.js +155 -155
  14. package/src/app/word/notes.js +110 -110
  15. package/src/app/word/shared.js +22 -22
  16. package/src/app/word/view.js +6 -2
  17. package/src/app/word-app.js +486 -469
  18. package/src/app/word-sheets.js +101 -101
  19. package/src/kernel/docx/codec/blocks.js +123 -123
  20. package/src/kernel/docx/codec/carry.js +129 -129
  21. package/src/kernel/docx/codec/comments.js +25 -25
  22. package/src/kernel/docx/codec/docx.js +198 -198
  23. package/src/kernel/docx/codec/docxStyles.js +177 -177
  24. package/src/kernel/docx/codec/fonts.js +195 -195
  25. package/src/kernel/docx/codec/helpers.js +161 -161
  26. package/src/kernel/docx/codec/hfHtml.js +152 -152
  27. package/src/kernel/docx/codec/html.js +739 -739
  28. package/src/kernel/docx/codec/losses.js +420 -420
  29. package/src/kernel/docx/codec/markdown.js +170 -170
  30. package/src/kernel/docx/codec/parts.js +249 -249
  31. package/src/kernel/docx/codec/read.js +603 -603
  32. package/src/kernel/docx/codec/render.js +1156 -1156
  33. package/src/kernel/docx/codec/roundtrip.js +236 -236
  34. package/src/kernel/docx/codec/write.js +833 -833
  35. package/src/kernel/docx/comments.js +14 -14
  36. package/src/kernel/docx/pageGeometry.js +123 -123
  37. package/src/kernel/docx/pagination.js +481 -481
  38. package/src/kernel/docx/watermark.js +45 -45
  39. package/src/kernel/editor/constants.js +8 -8
  40. package/src/kernel/editor/engine/blocks.js +594 -594
  41. package/src/kernel/editor/engine/blocksEnter.js +109 -109
  42. package/src/kernel/editor/engine/blocksInsert.js +254 -254
  43. package/src/kernel/editor/engine/blocksStructure.js +226 -226
  44. package/src/kernel/editor/engine/commands.js +181 -181
  45. package/src/kernel/editor/engine/dom.js +646 -646
  46. package/src/kernel/editor/engine/history.js +149 -149
  47. package/src/kernel/editor/engine/inline.js +656 -656
  48. package/src/kernel/editor/engine/input.js +554 -554
  49. package/src/kernel/editor/engine/interaction.js +137 -137
  50. package/src/kernel/editor/engine/pointer.js +39 -39
  51. package/src/kernel/editor/engine/revision.js +138 -138
  52. package/src/kernel/editor/engine/schema.js +417 -417
  53. package/src/kernel/editor/engine/selection.js +119 -119
  54. package/src/kernel/editor/engine/state.js +118 -118
  55. package/src/kernel/editor/engine/tableClip.js +154 -154
  56. package/src/kernel/editor/engine/tableGrid.js +55 -55
  57. package/src/kernel/editor/engine/tableInteraction.js +388 -388
  58. package/src/kernel/editor/engine/tableMenu.js +250 -250
  59. package/src/kernel/editor/engine/tableOps.js +174 -174
  60. package/src/kernel/editor/engine/tables.js +732 -732
  61. package/src/kernel/editor/overlayGeometry.js +20 -20
  62. package/src/kernel/editor/utils.js +48 -48
  63. package/src/kernel/keyboard.js +114 -114
  64. package/src/kernel/textStyles.js +84 -84
  65. package/src/kernel/util/imageFile.js +91 -91
  66. package/src/kernel/util/shortcutKey.js +33 -33
  67. package/src/surface/editor-surface.js +600 -600
  68. package/src/ui/color-panel.js +69 -69
  69. package/src/ui/context-menu.js +133 -133
  70. package/src/ui/find-bar.js +151 -151
  71. package/src/ui/icons.js +137 -135
  72. package/src/ui/menubar.js +28 -28
  73. package/src/ui/panels.js +115 -115
  74. package/src/ui/prompt.js +89 -89
  75. package/src/ui/ribbon.js +485 -485
  76. package/src/ui/special-chars.js +39 -39
  77. package/src/ui/statusbar.js +81 -81
  78. package/src/ui/toolbar.js +32 -32
  79. package/styles/editor-content.css +440 -440
  80. package/styles/tokens.css +154 -154
@@ -1,20 +1,20 @@
1
- // [文件] web·editor-kernel·overlayGeometry —— 编辑面浮件坐标基准:把 getBoundingClientRect 的视觉坐标折算回滚动容器的局部坐标
2
- // [通用:工具] overlayOrigin —— 浮件坐标基准(视觉 → 局部,缩放感知)【强制通道】
3
- // [坑] 屏幕缩放(Word 应用挂在 .word-editor 的 CSS zoom 上)会让「视觉差值」≠「局部 left/top」:
4
- // 局部 px × 缩放 = 视觉 px,直接把视觉差值当 left/top 用,非 100% 缩放时浮件会整体偏移。
5
- // 故基准点与缩放系数都从一枚探针现量——探针挂在滚动容器 padding box 原点、局部宽恒 PROBE_WIDTH,
6
- // 它随内容滚动,故原点、滚动量、缩放三件事一次量全(不必碰 scrollLeft / clientLeft 的缩放口径)。
7
-
8
- /** 探针的局部宽度(px):量到的视觉宽度 ÷ 此值 = 所在子树的缩放系数 */
9
- export const PROBE_WIDTH = 100;
10
-
11
- /**
12
- * 浮件坐标基准
13
- * @param {HTMLElement|null} probe 探针元素(挂在滚动容器 padding box 原点、局部宽 = PROBE_WIDTH)
14
- * @returns {{x:number, y:number, z:number}} x/y = 局部 (0,0) 的视觉坐标;z = 缩放系数
15
- */
16
- export function overlayOrigin(probe) {
17
- const rect = probe?.getBoundingClientRect?.();
18
- if (!rect) return { x: 0, y: 0, z: 1 };
19
- return { x: rect.left, y: rect.top, z: rect.width > 0 ? rect.width / PROBE_WIDTH : 1 };
20
- }
1
+ // [文件] web·editor-kernel·overlayGeometry —— 编辑面浮件坐标基准:把 getBoundingClientRect 的视觉坐标折算回滚动容器的局部坐标
2
+ // [通用:工具] overlayOrigin —— 浮件坐标基准(视觉 → 局部,缩放感知)【强制通道】
3
+ // [坑] 屏幕缩放(Word 应用挂在 .word-editor 的 CSS zoom 上)会让「视觉差值」≠「局部 left/top」:
4
+ // 局部 px × 缩放 = 视觉 px,直接把视觉差值当 left/top 用,非 100% 缩放时浮件会整体偏移。
5
+ // 故基准点与缩放系数都从一枚探针现量——探针挂在滚动容器 padding box 原点、局部宽恒 PROBE_WIDTH,
6
+ // 它随内容滚动,故原点、滚动量、缩放三件事一次量全(不必碰 scrollLeft / clientLeft 的缩放口径)。
7
+
8
+ /** 探针的局部宽度(px):量到的视觉宽度 ÷ 此值 = 所在子树的缩放系数 */
9
+ export const PROBE_WIDTH = 100;
10
+
11
+ /**
12
+ * 浮件坐标基准
13
+ * @param {HTMLElement|null} probe 探针元素(挂在滚动容器 padding box 原点、局部宽 = PROBE_WIDTH)
14
+ * @returns {{x:number, y:number, z:number}} x/y = 局部 (0,0) 的视觉坐标;z = 缩放系数
15
+ */
16
+ export function overlayOrigin(probe) {
17
+ const rect = probe?.getBoundingClientRect?.();
18
+ if (!rect) return { x: 0, y: 0, z: 1 };
19
+ return { x: rect.left, y: rect.top, z: rect.width > 0 ? rect.width / PROBE_WIDTH : 1 };
20
+ }
@@ -1,49 +1,49 @@
1
- // [文件] web·editor-kernel·utils —— 编辑器浮层定位工具(颜色归一口径见 guabiutils 的 normalizeColor)
2
- // 无状态、不依赖 Vue 与编辑器实例,便于单独推理与复用。
3
-
4
- import { clampFloatPosition } from 'guabiutils';
5
-
6
- const PLACEMENT_GAP = 6;
7
- const VIEWPORT_PADDING = 8;
8
-
9
- /**
10
- * 浮层定位:强制通道 clampFloatPosition 的编辑器口径适配(锚点矩形 + 面板实测尺寸 → fixed 坐标 + 展开侧限高)
11
- * @param {{left:number,top:number,right:number,bottom:number}} anchor 锚点矩形(点锚传零宽高)
12
- * @param {{width:number,height:number}} panel 浮层自身尺寸(渲染后实测,禁止估算)
13
- * @param {{placement?:string, gap?:number}} options placement: bottom-start|bottom|top|top-start|right-start|left-start
14
- * @returns {{left:number, top:number, maxHeight:number}} maxHeight 必须下发给面板,越界走面板内部滚动
15
- */
16
- export function computePopupPosition(anchor, panel, options = {}) {
17
- const { placement = 'bottom-start', gap = PLACEMENT_GAP } = options;
18
- const { left, top, maxHeight } = clampFloatPosition({
19
- anchor,
20
- size: panel,
21
- prefer: placement,
22
- gap,
23
- margin: VIEWPORT_PADDING,
24
- arrowSize: 0,
25
- });
26
- return { left: Math.round(left), top: Math.round(top), maxHeight: Math.round(maxHeight) };
27
- }
28
-
29
- /** 从任意对象安全取 DOMRect(元素不存在时返回 null) */
30
- export function rectOf(el) {
31
- if (!el || typeof el.getBoundingClientRect !== 'function') return null;
32
- return el.getBoundingClientRect();
33
- }
34
-
35
- /**
36
- * 浮层 inline 定位样式(坐标 + 展开侧限高)
37
- * [坑] 锚点或面板尺寸量不到时 pos.maxHeight 仍是初始 0,原样下发会把它压成零高——
38
- * 浮层「点了没反应」就是这么来的,所以只在量到真实限高时才下发
39
- * @param {{left:number, top:number, maxHeight?:number}} pos
40
- * @param {Object} [extra] 面板私有变量(如列数)
41
- */
42
- export function panelStyleOf(pos, extra = {}) {
43
- return {
44
- left: `${pos.left}px`,
45
- top: `${pos.top}px`,
46
- ...(pos.maxHeight > 0 ? { maxHeight: `${pos.maxHeight}px` } : {}),
47
- ...extra,
48
- };
1
+ // [文件] web·editor-kernel·utils —— 编辑器浮层定位工具(颜色归一口径见 guabiutils 的 normalizeColor)
2
+ // 无状态、不依赖 Vue 与编辑器实例,便于单独推理与复用。
3
+
4
+ import { clampFloatPosition } from 'guabiutils';
5
+
6
+ const PLACEMENT_GAP = 6;
7
+ const VIEWPORT_PADDING = 8;
8
+
9
+ /**
10
+ * 浮层定位:强制通道 clampFloatPosition 的编辑器口径适配(锚点矩形 + 面板实测尺寸 → fixed 坐标 + 展开侧限高)
11
+ * @param {{left:number,top:number,right:number,bottom:number}} anchor 锚点矩形(点锚传零宽高)
12
+ * @param {{width:number,height:number}} panel 浮层自身尺寸(渲染后实测,禁止估算)
13
+ * @param {{placement?:string, gap?:number}} options placement: bottom-start|bottom|top|top-start|right-start|left-start
14
+ * @returns {{left:number, top:number, maxHeight:number}} maxHeight 必须下发给面板,越界走面板内部滚动
15
+ */
16
+ export function computePopupPosition(anchor, panel, options = {}) {
17
+ const { placement = 'bottom-start', gap = PLACEMENT_GAP } = options;
18
+ const { left, top, maxHeight } = clampFloatPosition({
19
+ anchor,
20
+ size: panel,
21
+ prefer: placement,
22
+ gap,
23
+ margin: VIEWPORT_PADDING,
24
+ arrowSize: 0,
25
+ });
26
+ return { left: Math.round(left), top: Math.round(top), maxHeight: Math.round(maxHeight) };
27
+ }
28
+
29
+ /** 从任意对象安全取 DOMRect(元素不存在时返回 null) */
30
+ export function rectOf(el) {
31
+ if (!el || typeof el.getBoundingClientRect !== 'function') return null;
32
+ return el.getBoundingClientRect();
33
+ }
34
+
35
+ /**
36
+ * 浮层 inline 定位样式(坐标 + 展开侧限高)
37
+ * [坑] 锚点或面板尺寸量不到时 pos.maxHeight 仍是初始 0,原样下发会把它压成零高——
38
+ * 浮层「点了没反应」就是这么来的,所以只在量到真实限高时才下发
39
+ * @param {{left:number, top:number, maxHeight?:number}} pos
40
+ * @param {Object} [extra] 面板私有变量(如列数)
41
+ */
42
+ export function panelStyleOf(pos, extra = {}) {
43
+ return {
44
+ left: `${pos.left}px`,
45
+ top: `${pos.top}px`,
46
+ ...(pos.maxHeight > 0 ? { maxHeight: `${pos.maxHeight}px` } : {}),
47
+ ...extra,
48
+ };
49
49
  }
@@ -1,114 +1,114 @@
1
- // [文件] gbdocx·keyboard —— 全局键盘事件总线(唯一 document 监听 + 优先级分发)与 useKeyboard 注册
2
- // 说明:移植自 guabi 的 keyboardBus/useKeyboard,去掉 Vue 作用域与窗口归属门控(单窗口应用不需要),
3
- // 保留优先级排序、active 门控与「return true / stopPropagation 即消费」的语义。
4
-
5
- /** 优先级档位:数值大者先执行,同档按注册先后 */
6
- export const KEY_PRIORITY = {
7
- CAPTURE: 1000,
8
- FLOAT: 800,
9
- WINDOW: 600,
10
- APPLET: 400,
11
- GLOBAL: 200,
12
- };
13
-
14
- /** 归一键盘事件键名(小写);非真实按键事件返回空串 */
15
- export const eventKey = (e) => (typeof e?.key === 'string' ? e.key.toLowerCase() : '');
16
-
17
- const NON_TEXT_INPUT_TYPES = new Set(['button', 'submit', 'reset', 'checkbox', 'radio', 'range', 'color', 'file']);
18
-
19
- /** 焦点元素是否处于「文本输入态」(文本域 / 文本输入框 / 可编辑区 / 下拉) */
20
- export function isTypingTarget(el) {
21
- if (!el || !document.documentElement.contains(el)) return false;
22
- if (el.isContentEditable) return true;
23
- const tag = el.tagName;
24
- if (tag === 'TEXTAREA' || tag === 'SELECT') return true;
25
- if (tag === 'INPUT') return !NON_TEXT_INPUT_TYPES.has(String(el.type || 'text').toLowerCase());
26
- return false;
27
- }
28
-
29
- const registry = { keydown: { capture: [], bubble: [] }, keyup: { capture: [], bubble: [] } };
30
- let sorted = true;
31
- let bound = false;
32
- let seq = 0;
33
-
34
- function sortRegistry() {
35
- for (const type of ['keydown', 'keyup']) {
36
- for (const phase of ['capture', 'bubble']) {
37
- registry[type][phase].sort((a, b) => b.priority - a.priority || a.seq - b.seq);
38
- }
39
- }
40
- sorted = true;
41
- }
42
-
43
- function dispatch(type, phase, e) {
44
- const list = registry[type][phase];
45
- if (!list.length) return;
46
- if (!eventKey(e)) return;
47
- if (!sorted) sortRegistry();
48
- for (const item of list.slice()) {
49
- if (item.active && !item.active(e)) continue;
50
- const consumed = item.handler(e) === true;
51
- if (consumed || e.cancelBubble === true) return;
52
- }
53
- }
54
-
55
- const onDownCapture = (e) => dispatch('keydown', 'capture', e);
56
- const onDownBubble = (e) => dispatch('keydown', 'bubble', e);
57
- const onUpCapture = (e) => dispatch('keyup', 'capture', e);
58
- const onUpBubble = (e) => dispatch('keyup', 'bubble', e);
59
-
60
- function bind() {
61
- document.addEventListener('keydown', onDownCapture, true);
62
- document.addEventListener('keydown', onDownBubble);
63
- document.addEventListener('keyup', onUpCapture, true);
64
- document.addEventListener('keyup', onUpBubble);
65
- bound = true;
66
- }
67
-
68
- function unbind() {
69
- document.removeEventListener('keydown', onDownCapture, true);
70
- document.removeEventListener('keydown', onDownBubble);
71
- document.removeEventListener('keyup', onUpCapture, true);
72
- document.removeEventListener('keyup', onUpBubble);
73
- bound = false;
74
- }
75
-
76
- function syncBound() {
77
- const need =
78
- registry.keydown.capture.length || registry.keydown.bubble.length ||
79
- registry.keyup.capture.length || registry.keyup.bubble.length;
80
- if (need && !bound) bind();
81
- else if (!need && bound) unbind();
82
- }
83
-
84
- function subscribe(type, handler, { priority = KEY_PRIORITY.GLOBAL, phase = 'capture', active } = {}) {
85
- if (typeof handler !== 'function') return () => {};
86
- const item = { seq: ++seq, priority, active, handler };
87
- const list = registry[type][phase === 'bubble' ? 'bubble' : 'capture'];
88
- list.push(item);
89
- sorted = false;
90
- syncBound();
91
- return () => {
92
- const i = list.indexOf(item);
93
- if (i >= 0) list.splice(i, 1);
94
- syncBound();
95
- };
96
- }
97
-
98
- export const onKeydown = (handler, opts) => subscribe('keydown', handler, opts);
99
- export const onKeyup = (handler, opts) => subscribe('keyup', handler, opts);
100
-
101
- /**
102
- * 注册键盘处理器(同 guabi useKeyboard 的调用形态,去掉作用域门控)
103
- * @param {{keydown?:Function, keyup?:Function}} handlers
104
- * @param {{priority?:number, phase?:'capture'|'bubble', active?:Function}} [opts]
105
- * @returns {() => void} 注销函数
106
- */
107
- export function useKeyboard(handlers, opts = {}) {
108
- const offs = [];
109
- if (typeof handlers?.keydown === 'function') offs.push(onKeydown(handlers.keydown, opts));
110
- if (typeof handlers?.keyup === 'function') offs.push(onKeyup(handlers.keyup, opts));
111
- return () => {
112
- while (offs.length) offs.pop()();
113
- };
114
- }
1
+ // [文件] gbdocx·keyboard —— 全局键盘事件总线(唯一 document 监听 + 优先级分发)与 useKeyboard 注册
2
+ // 说明:移植自 guabi 的 keyboardBus/useKeyboard,去掉 Vue 作用域与窗口归属门控(单窗口应用不需要),
3
+ // 保留优先级排序、active 门控与「return true / stopPropagation 即消费」的语义。
4
+
5
+ /** 优先级档位:数值大者先执行,同档按注册先后 */
6
+ export const KEY_PRIORITY = {
7
+ CAPTURE: 1000,
8
+ FLOAT: 800,
9
+ WINDOW: 600,
10
+ APPLET: 400,
11
+ GLOBAL: 200,
12
+ };
13
+
14
+ /** 归一键盘事件键名(小写);非真实按键事件返回空串 */
15
+ export const eventKey = (e) => (typeof e?.key === 'string' ? e.key.toLowerCase() : '');
16
+
17
+ const NON_TEXT_INPUT_TYPES = new Set(['button', 'submit', 'reset', 'checkbox', 'radio', 'range', 'color', 'file']);
18
+
19
+ /** 焦点元素是否处于「文本输入态」(文本域 / 文本输入框 / 可编辑区 / 下拉) */
20
+ export function isTypingTarget(el) {
21
+ if (!el || !document.documentElement.contains(el)) return false;
22
+ if (el.isContentEditable) return true;
23
+ const tag = el.tagName;
24
+ if (tag === 'TEXTAREA' || tag === 'SELECT') return true;
25
+ if (tag === 'INPUT') return !NON_TEXT_INPUT_TYPES.has(String(el.type || 'text').toLowerCase());
26
+ return false;
27
+ }
28
+
29
+ const registry = { keydown: { capture: [], bubble: [] }, keyup: { capture: [], bubble: [] } };
30
+ let sorted = true;
31
+ let bound = false;
32
+ let seq = 0;
33
+
34
+ function sortRegistry() {
35
+ for (const type of ['keydown', 'keyup']) {
36
+ for (const phase of ['capture', 'bubble']) {
37
+ registry[type][phase].sort((a, b) => b.priority - a.priority || a.seq - b.seq);
38
+ }
39
+ }
40
+ sorted = true;
41
+ }
42
+
43
+ function dispatch(type, phase, e) {
44
+ const list = registry[type][phase];
45
+ if (!list.length) return;
46
+ if (!eventKey(e)) return;
47
+ if (!sorted) sortRegistry();
48
+ for (const item of list.slice()) {
49
+ if (item.active && !item.active(e)) continue;
50
+ const consumed = item.handler(e) === true;
51
+ if (consumed || e.cancelBubble === true) return;
52
+ }
53
+ }
54
+
55
+ const onDownCapture = (e) => dispatch('keydown', 'capture', e);
56
+ const onDownBubble = (e) => dispatch('keydown', 'bubble', e);
57
+ const onUpCapture = (e) => dispatch('keyup', 'capture', e);
58
+ const onUpBubble = (e) => dispatch('keyup', 'bubble', e);
59
+
60
+ function bind() {
61
+ document.addEventListener('keydown', onDownCapture, true);
62
+ document.addEventListener('keydown', onDownBubble);
63
+ document.addEventListener('keyup', onUpCapture, true);
64
+ document.addEventListener('keyup', onUpBubble);
65
+ bound = true;
66
+ }
67
+
68
+ function unbind() {
69
+ document.removeEventListener('keydown', onDownCapture, true);
70
+ document.removeEventListener('keydown', onDownBubble);
71
+ document.removeEventListener('keyup', onUpCapture, true);
72
+ document.removeEventListener('keyup', onUpBubble);
73
+ bound = false;
74
+ }
75
+
76
+ function syncBound() {
77
+ const need =
78
+ registry.keydown.capture.length || registry.keydown.bubble.length ||
79
+ registry.keyup.capture.length || registry.keyup.bubble.length;
80
+ if (need && !bound) bind();
81
+ else if (!need && bound) unbind();
82
+ }
83
+
84
+ function subscribe(type, handler, { priority = KEY_PRIORITY.GLOBAL, phase = 'capture', active } = {}) {
85
+ if (typeof handler !== 'function') return () => {};
86
+ const item = { seq: ++seq, priority, active, handler };
87
+ const list = registry[type][phase === 'bubble' ? 'bubble' : 'capture'];
88
+ list.push(item);
89
+ sorted = false;
90
+ syncBound();
91
+ return () => {
92
+ const i = list.indexOf(item);
93
+ if (i >= 0) list.splice(i, 1);
94
+ syncBound();
95
+ };
96
+ }
97
+
98
+ export const onKeydown = (handler, opts) => subscribe('keydown', handler, opts);
99
+ export const onKeyup = (handler, opts) => subscribe('keyup', handler, opts);
100
+
101
+ /**
102
+ * 注册键盘处理器(同 guabi useKeyboard 的调用形态,去掉作用域门控)
103
+ * @param {{keydown?:Function, keyup?:Function}} handlers
104
+ * @param {{priority?:number, phase?:'capture'|'bubble', active?:Function}} [opts]
105
+ * @returns {() => void} 注销函数
106
+ */
107
+ export function useKeyboard(handlers, opts = {}) {
108
+ const offs = [];
109
+ if (typeof handlers?.keydown === 'function') offs.push(onKeydown(handlers.keydown, opts));
110
+ if (typeof handlers?.keyup === 'function') offs.push(onKeyup(handlers.keyup, opts));
111
+ return () => {
112
+ while (offs.length) offs.pop()();
113
+ };
114
+ }
@@ -1,84 +1,84 @@
1
- // [文件] web·core·文字样式常量 —— 字号/字体/调色板/对齐/字体效果/组合色的单一来源(富文本编辑器与演示文稿工具条共用,禁各域再建第二张表)
2
- // [通用:常量] textStyles —— FONT_SIZES / FONT_FAMILIES / TEXT_COLORS / BG_COLORS / ALIGN_OPTIONS / FONT_EFFECTS / COMBO_STYLES / RECENT_STYLE_LIMIT
3
-
4
- /** 字号预设(px,12~72) */
5
- export const FONT_SIZES = [12, 13, 14, 15, 16, 18, 20, 24, 28, 32, 36, 42, 48, 54, 62, 72];
6
-
7
- /** 字体(系统字体 + Web 安全字体;内网不回源加载,命中本机字体即生效) */
8
- export const FONT_FAMILIES = [
9
- { label: '微软雅黑', value: 'Microsoft YaHei, "微软雅黑"' },
10
- { label: '苹方', value: 'PingFang SC, "苹方-简"' },
11
- { label: '宋体', value: 'SimSun, "宋体", serif' },
12
- { label: '黑体', value: 'SimHei, "黑体", sans-serif' },
13
- { label: '楷体', value: 'KaiTi, "楷体", serif' },
14
- { label: '仿宋', value: 'FangSong, "仿宋", serif' },
15
- { label: '思源黑体', value: '"Noto Sans SC", "Source Han Sans SC", sans-serif' },
16
- { label: '思源宋体', value: '"Noto Serif SC", "Source Han Serif SC", serif' },
17
- { label: 'Arial', value: 'Arial, Helvetica, sans-serif' },
18
- { label: 'Helvetica', value: '"Helvetica Neue", Helvetica, sans-serif' },
19
- { label: 'Inter', value: 'Inter, -apple-system, sans-serif' },
20
- { label: 'Roboto', value: 'Roboto, "Segoe UI", sans-serif' },
21
- { label: 'Times New Roman', value: '"Times New Roman", Times, serif' },
22
- { label: 'Georgia', value: 'Georgia, "Times New Roman", serif' },
23
- { label: 'Courier New', value: '"Courier New", Courier, monospace' },
24
- { label: 'Consolas', value: 'Consolas, "Courier New", monospace' },
25
- { label: 'Monaco', value: 'Monaco, Consolas, monospace' },
26
- ];
27
-
28
- /** 对齐方式(互斥高亮) */
29
- export const ALIGN_OPTIONS = [
30
- { value: 'left', title: '左对齐', icon: 'alignLeft' },
31
- { value: 'center', title: '居中', icon: 'alignCenter' },
32
- { value: 'right', title: '右对齐', icon: 'alignRight' },
33
- { value: 'justify', title: '两端对齐', icon: 'alignJustify' },
34
- ];
35
-
36
- /** 文字色调色板(淡→深,两行:灰阶 + 彩色) */
37
- export const TEXT_COLORS = [
38
- '#000000', '#434343', '#666666', '#999999', '#b7b7b7', '#cccccc', '#d9d9d9', '#efefef', '#f3f3f3', '#ffffff',
39
- '#980000', '#ff0000', '#ff9900', '#bf9000', '#38761d', '#00ff00', '#00ffff', '#4a86e8', '#0000ff', '#9900ff',
40
- '#cc4125', '#e06666', '#f6b26b', '#ffd966', '#93c47d', '#76a5af', '#6d9eeb', '#8e7cc3', '#c27ba0', '#ff00ff',
41
- ];
42
-
43
- /** 背景色(高亮)调色板:每组由浅到深,共 6 列 */
44
- export const BG_COLORS = [
45
- '#ffffff', '#f2f3f5', '#e7e9eb', '#d4d5d9', '#c9c7c6', '#a8adb3',
46
- '#fde9e9', '#fddede', '#ffd4d4', '#fbc1c1', '#f8b0b0', '#f5a3a3',
47
- '#fff3d6', '#ffe9b3', '#ffdf8f', '#ffd25e', '#ffc233', '#ffb500',
48
- '#fffbd0', '#fdf2bc', '#fbea93', '#f8e35e', '#f5dc33', '#f5d500',
49
- '#e8fad4', '#d3f2b3', '#b9ec8e', '#a5e266', '#8fd354', '#71b823',
50
- '#d6f5f5', '#b3e9e9', '#8fdcdc', '#66cccc', '#4db8b8', '#339999',
51
- '#dae8fc', '#d0e4f7', '#b4d6f5', '#9cc2f0', '#7db3ea', '#5698e0',
52
- ];
53
-
54
- /**
55
- * 字体效果(互斥布尔样式;key 即内核标记键,value 是落到内联 style 的 CSS 值)
56
- * 空心 = -webkit-text-stroke 描边 + 透明填充;阴影 = 多层 text-shadow。
57
- */
58
- export const FONT_EFFECTS = [
59
- {
60
- key: 'textStroke',
61
- label: '空心',
62
- value: '0.2px currentColor',
63
- preview: { WebkitTextStroke: '0.2px currentColor', WebkitTextFillColor: 'transparent' },
64
- },
65
- {
66
- key: 'textShadow',
67
- label: '阴影',
68
- value: '1px 1px var(--gbd-dt-border-strong), 2px 2px var(--gbd-dt-border-strong)',
69
- preview: { textShadow: '1px 1px var(--gbd-dt-border-strong), 2px 2px var(--gbd-dt-border-strong)' },
70
- },
71
- ];
72
-
73
- /** 组合色(前景 + 背景一体应用);取值同调色板的 hex */
74
- export const COMBO_STYLES = [
75
- { color: '#000000', backgroundColor: '#fde9e9' },
76
- { color: '#980000', backgroundColor: '#ffd4d4' },
77
- { color: '#bf9000', backgroundColor: '#fff3d6' },
78
- { color: '#38761d', backgroundColor: '#e8fad4' },
79
- { color: '#4a86e8', backgroundColor: '#dae8fc' },
80
- { color: '#9900ff', backgroundColor: '#e7e9eb' },
81
- ];
82
-
83
- /** 「最近使用的外观」保留条数 */
84
- export const RECENT_STYLE_LIMIT = 14;
1
+ // [文件] web·core·文字样式常量 —— 字号/字体/调色板/对齐/字体效果/组合色的单一来源(富文本编辑器与演示文稿工具条共用,禁各域再建第二张表)
2
+ // [通用:常量] textStyles —— FONT_SIZES / FONT_FAMILIES / TEXT_COLORS / BG_COLORS / ALIGN_OPTIONS / FONT_EFFECTS / COMBO_STYLES / RECENT_STYLE_LIMIT
3
+
4
+ /** 字号预设(px,12~72) */
5
+ export const FONT_SIZES = [12, 13, 14, 15, 16, 18, 20, 24, 28, 32, 36, 42, 48, 54, 62, 72];
6
+
7
+ /** 字体(系统字体 + Web 安全字体;内网不回源加载,命中本机字体即生效) */
8
+ export const FONT_FAMILIES = [
9
+ { label: '微软雅黑', value: 'Microsoft YaHei, "微软雅黑"' },
10
+ { label: '苹方', value: 'PingFang SC, "苹方-简"' },
11
+ { label: '宋体', value: 'SimSun, "宋体", serif' },
12
+ { label: '黑体', value: 'SimHei, "黑体", sans-serif' },
13
+ { label: '楷体', value: 'KaiTi, "楷体", serif' },
14
+ { label: '仿宋', value: 'FangSong, "仿宋", serif' },
15
+ { label: '思源黑体', value: '"Noto Sans SC", "Source Han Sans SC", sans-serif' },
16
+ { label: '思源宋体', value: '"Noto Serif SC", "Source Han Serif SC", serif' },
17
+ { label: 'Arial', value: 'Arial, Helvetica, sans-serif' },
18
+ { label: 'Helvetica', value: '"Helvetica Neue", Helvetica, sans-serif' },
19
+ { label: 'Inter', value: 'Inter, -apple-system, sans-serif' },
20
+ { label: 'Roboto', value: 'Roboto, "Segoe UI", sans-serif' },
21
+ { label: 'Times New Roman', value: '"Times New Roman", Times, serif' },
22
+ { label: 'Georgia', value: 'Georgia, "Times New Roman", serif' },
23
+ { label: 'Courier New', value: '"Courier New", Courier, monospace' },
24
+ { label: 'Consolas', value: 'Consolas, "Courier New", monospace' },
25
+ { label: 'Monaco', value: 'Monaco, Consolas, monospace' },
26
+ ];
27
+
28
+ /** 对齐方式(互斥高亮) */
29
+ export const ALIGN_OPTIONS = [
30
+ { value: 'left', title: '左对齐', icon: 'alignLeft' },
31
+ { value: 'center', title: '居中', icon: 'alignCenter' },
32
+ { value: 'right', title: '右对齐', icon: 'alignRight' },
33
+ { value: 'justify', title: '两端对齐', icon: 'alignJustify' },
34
+ ];
35
+
36
+ /** 文字色调色板(淡→深,两行:灰阶 + 彩色) */
37
+ export const TEXT_COLORS = [
38
+ '#000000', '#434343', '#666666', '#999999', '#b7b7b7', '#cccccc', '#d9d9d9', '#efefef', '#f3f3f3', '#ffffff',
39
+ '#980000', '#ff0000', '#ff9900', '#bf9000', '#38761d', '#00ff00', '#00ffff', '#4a86e8', '#0000ff', '#9900ff',
40
+ '#cc4125', '#e06666', '#f6b26b', '#ffd966', '#93c47d', '#76a5af', '#6d9eeb', '#8e7cc3', '#c27ba0', '#ff00ff',
41
+ ];
42
+
43
+ /** 背景色(高亮)调色板:每组由浅到深,共 6 列 */
44
+ export const BG_COLORS = [
45
+ '#ffffff', '#f2f3f5', '#e7e9eb', '#d4d5d9', '#c9c7c6', '#a8adb3',
46
+ '#fde9e9', '#fddede', '#ffd4d4', '#fbc1c1', '#f8b0b0', '#f5a3a3',
47
+ '#fff3d6', '#ffe9b3', '#ffdf8f', '#ffd25e', '#ffc233', '#ffb500',
48
+ '#fffbd0', '#fdf2bc', '#fbea93', '#f8e35e', '#f5dc33', '#f5d500',
49
+ '#e8fad4', '#d3f2b3', '#b9ec8e', '#a5e266', '#8fd354', '#71b823',
50
+ '#d6f5f5', '#b3e9e9', '#8fdcdc', '#66cccc', '#4db8b8', '#339999',
51
+ '#dae8fc', '#d0e4f7', '#b4d6f5', '#9cc2f0', '#7db3ea', '#5698e0',
52
+ ];
53
+
54
+ /**
55
+ * 字体效果(互斥布尔样式;key 即内核标记键,value 是落到内联 style 的 CSS 值)
56
+ * 空心 = -webkit-text-stroke 描边 + 透明填充;阴影 = 多层 text-shadow。
57
+ */
58
+ export const FONT_EFFECTS = [
59
+ {
60
+ key: 'textStroke',
61
+ label: '空心',
62
+ value: '0.2px currentColor',
63
+ preview: { WebkitTextStroke: '0.2px currentColor', WebkitTextFillColor: 'transparent' },
64
+ },
65
+ {
66
+ key: 'textShadow',
67
+ label: '阴影',
68
+ value: '1px 1px var(--gbd-dt-border-strong), 2px 2px var(--gbd-dt-border-strong)',
69
+ preview: { textShadow: '1px 1px var(--gbd-dt-border-strong), 2px 2px var(--gbd-dt-border-strong)' },
70
+ },
71
+ ];
72
+
73
+ /** 组合色(前景 + 背景一体应用);取值同调色板的 hex */
74
+ export const COMBO_STYLES = [
75
+ { color: '#000000', backgroundColor: '#fde9e9' },
76
+ { color: '#980000', backgroundColor: '#ffd4d4' },
77
+ { color: '#bf9000', backgroundColor: '#fff3d6' },
78
+ { color: '#38761d', backgroundColor: '#e8fad4' },
79
+ { color: '#4a86e8', backgroundColor: '#dae8fc' },
80
+ { color: '#9900ff', backgroundColor: '#e7e9eb' },
81
+ ];
82
+
83
+ /** 「最近使用的外观」保留条数 */
84
+ export const RECENT_STYLE_LIMIT = 14;