@a200888213/gbdocx 0.6.1 → 0.6.2

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 (74) hide show
  1. package/package.json +1 -1
  2. package/src/app/file-io.js +122 -122
  3. package/src/app/main.js +9 -9
  4. package/src/app/word/catalog.js +52 -52
  5. package/src/app/word/comments.js +112 -112
  6. package/src/app/word/doc.js +113 -113
  7. package/src/app/word/edit.js +72 -72
  8. package/src/app/word/hf.js +76 -76
  9. package/src/app/word/layout.js +155 -155
  10. package/src/app/word/notes.js +110 -110
  11. package/src/app/word/shared.js +22 -22
  12. package/src/app/word-sheets.js +101 -101
  13. package/src/kernel/docx/codec/blocks.js +123 -123
  14. package/src/kernel/docx/codec/carry.js +129 -129
  15. package/src/kernel/docx/codec/comments.js +25 -25
  16. package/src/kernel/docx/codec/docx.js +198 -198
  17. package/src/kernel/docx/codec/docxStyles.js +177 -177
  18. package/src/kernel/docx/codec/fonts.js +195 -195
  19. package/src/kernel/docx/codec/helpers.js +161 -161
  20. package/src/kernel/docx/codec/hfHtml.js +152 -152
  21. package/src/kernel/docx/codec/html.js +739 -739
  22. package/src/kernel/docx/codec/losses.js +420 -420
  23. package/src/kernel/docx/codec/markdown.js +170 -170
  24. package/src/kernel/docx/codec/parts.js +249 -249
  25. package/src/kernel/docx/codec/read.js +603 -603
  26. package/src/kernel/docx/codec/render.js +1156 -1156
  27. package/src/kernel/docx/codec/roundtrip.js +236 -236
  28. package/src/kernel/docx/codec/write.js +833 -833
  29. package/src/kernel/docx/comments.js +14 -14
  30. package/src/kernel/docx/pageGeometry.js +123 -123
  31. package/src/kernel/docx/pagination.js +481 -481
  32. package/src/kernel/docx/watermark.js +45 -45
  33. package/src/kernel/editor/constants.js +8 -8
  34. package/src/kernel/editor/engine/blocks.js +594 -594
  35. package/src/kernel/editor/engine/blocksEnter.js +109 -109
  36. package/src/kernel/editor/engine/blocksInsert.js +254 -254
  37. package/src/kernel/editor/engine/blocksStructure.js +226 -226
  38. package/src/kernel/editor/engine/commands.js +181 -181
  39. package/src/kernel/editor/engine/dom.js +646 -646
  40. package/src/kernel/editor/engine/history.js +149 -149
  41. package/src/kernel/editor/engine/inline.js +656 -656
  42. package/src/kernel/editor/engine/input.js +554 -554
  43. package/src/kernel/editor/engine/interaction.js +137 -137
  44. package/src/kernel/editor/engine/pointer.js +39 -39
  45. package/src/kernel/editor/engine/revision.js +138 -138
  46. package/src/kernel/editor/engine/schema.js +417 -417
  47. package/src/kernel/editor/engine/selection.js +119 -119
  48. package/src/kernel/editor/engine/state.js +118 -118
  49. package/src/kernel/editor/engine/tableClip.js +154 -154
  50. package/src/kernel/editor/engine/tableGrid.js +55 -55
  51. package/src/kernel/editor/engine/tableInteraction.js +388 -388
  52. package/src/kernel/editor/engine/tableMenu.js +250 -250
  53. package/src/kernel/editor/engine/tableOps.js +174 -174
  54. package/src/kernel/editor/engine/tables.js +732 -732
  55. package/src/kernel/editor/overlayGeometry.js +20 -20
  56. package/src/kernel/editor/utils.js +48 -48
  57. package/src/kernel/keyboard.js +114 -114
  58. package/src/kernel/textStyles.js +84 -84
  59. package/src/kernel/util/imageFile.js +91 -91
  60. package/src/kernel/util/shortcutKey.js +33 -33
  61. package/src/surface/editor-surface.js +600 -600
  62. package/src/ui/color-panel.js +69 -69
  63. package/src/ui/context-menu.js +133 -133
  64. package/src/ui/find-bar.js +151 -151
  65. package/src/ui/menubar.js +28 -28
  66. package/src/ui/panels.js +115 -115
  67. package/src/ui/prompt.js +89 -89
  68. package/src/ui/ribbon.js +485 -485
  69. package/src/ui/special-chars.js +39 -39
  70. package/src/ui/statusbar.js +81 -81
  71. package/src/ui/toolbar.js +32 -32
  72. package/styles/editor-content.css +440 -440
  73. package/styles/tokens.css +154 -154
  74. package/styles/word-panel.css +1 -1
package/src/ui/prompt.js CHANGED
@@ -1,89 +1,89 @@
1
- // [文件] gbdocx·PromptPopover —— 单字段气泡表单(链接地址 / 批注内容 / 脚注内容共用一套;触发点无稳定 DOM 时走 openAt 锚点)
2
- import { openPopup } from './popup.js';
3
-
4
- /** 单字段气泡:openAt(anchor, spec) 打开;关闭未提交回调 onClosed(false),提交返回 true 即关闭并不回调 */
5
- export class PromptPopover {
6
- constructor() {
7
- this.handle = null;
8
- this.onClosed = null;
9
- }
10
-
11
- /**
12
- * @param {HTMLElement|DOMRect|undefined} anchor 锚点(缺省回落屏上方居中)
13
- * @param {object} spec {title, placeholder, maxlength, required, submit(text)->bool}
14
- */
15
- openAt(anchor, spec = {}) {
16
- this.close();
17
- const box = document.createElement('div');
18
- box.className = 'gbd-prompt';
19
- box.innerHTML = `
20
- <div class="gbd-prompt__title"></div>
21
- <input class="gbd-prompt__input" type="text" />
22
- <div class="gbd-prompt__actions">
23
- <button type="button" class="gbd-btn" data-act="cancel">取消</button>
24
- <button type="button" class="gbd-btn gbd-btn--primary" data-act="ok">确定</button>
25
- </div>`;
26
- const titleEl = box.querySelector('.gbd-prompt__title');
27
- const input = box.querySelector('.gbd-prompt__input');
28
- titleEl.textContent = spec.title || '';
29
- if (spec.placeholder) input.placeholder = spec.placeholder;
30
- if (spec.maxlength) input.maxLength = spec.maxlength;
31
- input.value = spec.value || '';
32
-
33
- const closeAndReport = (submitted) => {
34
- notifyClosed(submitted);
35
- this.close();
36
- };
37
- // 每条气泡只上报一次关闭,但不清空宿主注册的 onClosed:
38
- // 该回调是实例级(WordApp 只在构造时赋值一次),旧实现关闭第一条气泡就把它置空,
39
- // 之后所有「取消批注/取消脚注」的未提交回滚都不会再执行
40
- let settled = false;
41
- const notifyClosed = (submitted) => {
42
- if (settled) return;
43
- settled = true;
44
- this.onClosed?.(submitted);
45
- };
46
- const submit = () => {
47
- const text = input.value;
48
- if (spec.required !== false && spec.required !== undefined && spec.required && !String(text).trim()) {
49
- input.focus();
50
- return;
51
- }
52
- if (spec.submit ? spec.submit(text) !== false : true) {
53
- notifyClosed(true);
54
- this.close();
55
- } else {
56
- input.focus();
57
- input.select();
58
- }
59
- };
60
- box.querySelector('[data-act="cancel"]').addEventListener('click', () => closeAndReport(false));
61
- box.querySelector('[data-act="ok"]').addEventListener('click', submit);
62
- input.addEventListener('keydown', (e) => {
63
- if (e.key === 'Enter') {
64
- e.preventDefault();
65
- submit();
66
- } else if (e.key === 'Escape') {
67
- e.preventDefault();
68
- closeAndReport(false);
69
- }
70
- });
71
-
72
- const rect = anchor instanceof Element ? anchor.getBoundingClientRect() : anchor;
73
- const fallback = rect || { left: window.innerWidth / 2 - 120, top: 120, right: window.innerWidth / 2 + 120, bottom: 120 };
74
- this.handle = openPopup({
75
- anchor: fallback,
76
- content: box,
77
- placement: 'bottom-start',
78
- className: 'gbd-popup--prompt',
79
- onClose: () => notifyClosed(false),
80
- });
81
- requestAnimationFrame(() => input.focus());
82
- }
83
-
84
- close() {
85
- const h = this.handle;
86
- this.handle = null;
87
- h?.close();
88
- }
89
- }
1
+ // [文件] gbdocx·PromptPopover —— 单字段气泡表单(链接地址 / 批注内容 / 脚注内容共用一套;触发点无稳定 DOM 时走 openAt 锚点)
2
+ import { openPopup } from './popup.js';
3
+
4
+ /** 单字段气泡:openAt(anchor, spec) 打开;关闭未提交回调 onClosed(false),提交返回 true 即关闭并不回调 */
5
+ export class PromptPopover {
6
+ constructor() {
7
+ this.handle = null;
8
+ this.onClosed = null;
9
+ }
10
+
11
+ /**
12
+ * @param {HTMLElement|DOMRect|undefined} anchor 锚点(缺省回落屏上方居中)
13
+ * @param {object} spec {title, placeholder, maxlength, required, submit(text)->bool}
14
+ */
15
+ openAt(anchor, spec = {}) {
16
+ this.close();
17
+ const box = document.createElement('div');
18
+ box.className = 'gbd-prompt';
19
+ box.innerHTML = `
20
+ <div class="gbd-prompt__title"></div>
21
+ <input class="gbd-prompt__input" type="text" />
22
+ <div class="gbd-prompt__actions">
23
+ <button type="button" class="gbd-btn" data-act="cancel">取消</button>
24
+ <button type="button" class="gbd-btn gbd-btn--primary" data-act="ok">确定</button>
25
+ </div>`;
26
+ const titleEl = box.querySelector('.gbd-prompt__title');
27
+ const input = box.querySelector('.gbd-prompt__input');
28
+ titleEl.textContent = spec.title || '';
29
+ if (spec.placeholder) input.placeholder = spec.placeholder;
30
+ if (spec.maxlength) input.maxLength = spec.maxlength;
31
+ input.value = spec.value || '';
32
+
33
+ const closeAndReport = (submitted) => {
34
+ notifyClosed(submitted);
35
+ this.close();
36
+ };
37
+ // 每条气泡只上报一次关闭,但不清空宿主注册的 onClosed:
38
+ // 该回调是实例级(WordApp 只在构造时赋值一次),旧实现关闭第一条气泡就把它置空,
39
+ // 之后所有「取消批注/取消脚注」的未提交回滚都不会再执行
40
+ let settled = false;
41
+ const notifyClosed = (submitted) => {
42
+ if (settled) return;
43
+ settled = true;
44
+ this.onClosed?.(submitted);
45
+ };
46
+ const submit = () => {
47
+ const text = input.value;
48
+ if (spec.required !== false && spec.required !== undefined && spec.required && !String(text).trim()) {
49
+ input.focus();
50
+ return;
51
+ }
52
+ if (spec.submit ? spec.submit(text) !== false : true) {
53
+ notifyClosed(true);
54
+ this.close();
55
+ } else {
56
+ input.focus();
57
+ input.select();
58
+ }
59
+ };
60
+ box.querySelector('[data-act="cancel"]').addEventListener('click', () => closeAndReport(false));
61
+ box.querySelector('[data-act="ok"]').addEventListener('click', submit);
62
+ input.addEventListener('keydown', (e) => {
63
+ if (e.key === 'Enter') {
64
+ e.preventDefault();
65
+ submit();
66
+ } else if (e.key === 'Escape') {
67
+ e.preventDefault();
68
+ closeAndReport(false);
69
+ }
70
+ });
71
+
72
+ const rect = anchor instanceof Element ? anchor.getBoundingClientRect() : anchor;
73
+ const fallback = rect || { left: window.innerWidth / 2 - 120, top: 120, right: window.innerWidth / 2 + 120, bottom: 120 };
74
+ this.handle = openPopup({
75
+ anchor: fallback,
76
+ content: box,
77
+ placement: 'bottom-start',
78
+ className: 'gbd-popup--prompt',
79
+ onClose: () => notifyClosed(false),
80
+ });
81
+ requestAnimationFrame(() => input.focus());
82
+ }
83
+
84
+ close() {
85
+ const h = this.handle;
86
+ this.handle = null;
87
+ h?.close();
88
+ }
89
+ }