@a200888213/gbdocx 0.6.0 → 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 (76) 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/view.js +3 -0
  13. package/src/app/word-app.js +1 -0
  14. package/src/app/word-sheets.js +101 -101
  15. package/src/kernel/docx/codec/blocks.js +123 -123
  16. package/src/kernel/docx/codec/carry.js +129 -129
  17. package/src/kernel/docx/codec/comments.js +25 -25
  18. package/src/kernel/docx/codec/docx.js +198 -198
  19. package/src/kernel/docx/codec/docxStyles.js +177 -177
  20. package/src/kernel/docx/codec/fonts.js +195 -195
  21. package/src/kernel/docx/codec/helpers.js +161 -161
  22. package/src/kernel/docx/codec/hfHtml.js +152 -152
  23. package/src/kernel/docx/codec/html.js +739 -739
  24. package/src/kernel/docx/codec/losses.js +420 -420
  25. package/src/kernel/docx/codec/markdown.js +170 -170
  26. package/src/kernel/docx/codec/parts.js +249 -249
  27. package/src/kernel/docx/codec/read.js +603 -603
  28. package/src/kernel/docx/codec/render.js +1156 -1156
  29. package/src/kernel/docx/codec/roundtrip.js +236 -236
  30. package/src/kernel/docx/codec/write.js +833 -833
  31. package/src/kernel/docx/comments.js +14 -14
  32. package/src/kernel/docx/pageGeometry.js +123 -123
  33. package/src/kernel/docx/pagination.js +481 -481
  34. package/src/kernel/docx/watermark.js +45 -45
  35. package/src/kernel/editor/constants.js +8 -8
  36. package/src/kernel/editor/engine/blocks.js +594 -594
  37. package/src/kernel/editor/engine/blocksEnter.js +109 -109
  38. package/src/kernel/editor/engine/blocksInsert.js +254 -254
  39. package/src/kernel/editor/engine/blocksStructure.js +226 -226
  40. package/src/kernel/editor/engine/commands.js +181 -181
  41. package/src/kernel/editor/engine/dom.js +646 -646
  42. package/src/kernel/editor/engine/history.js +149 -149
  43. package/src/kernel/editor/engine/inline.js +656 -656
  44. package/src/kernel/editor/engine/input.js +554 -554
  45. package/src/kernel/editor/engine/interaction.js +137 -137
  46. package/src/kernel/editor/engine/pointer.js +39 -39
  47. package/src/kernel/editor/engine/revision.js +138 -138
  48. package/src/kernel/editor/engine/schema.js +417 -417
  49. package/src/kernel/editor/engine/selection.js +119 -119
  50. package/src/kernel/editor/engine/state.js +118 -118
  51. package/src/kernel/editor/engine/tableClip.js +154 -154
  52. package/src/kernel/editor/engine/tableGrid.js +55 -55
  53. package/src/kernel/editor/engine/tableInteraction.js +388 -388
  54. package/src/kernel/editor/engine/tableMenu.js +250 -250
  55. package/src/kernel/editor/engine/tableOps.js +174 -174
  56. package/src/kernel/editor/engine/tables.js +732 -732
  57. package/src/kernel/editor/overlayGeometry.js +20 -20
  58. package/src/kernel/editor/utils.js +48 -48
  59. package/src/kernel/keyboard.js +114 -114
  60. package/src/kernel/textStyles.js +84 -84
  61. package/src/kernel/util/imageFile.js +91 -91
  62. package/src/kernel/util/shortcutKey.js +33 -33
  63. package/src/surface/editor-surface.js +600 -600
  64. package/src/ui/color-panel.js +69 -69
  65. package/src/ui/context-menu.js +133 -133
  66. package/src/ui/find-bar.js +151 -151
  67. package/src/ui/menubar.js +28 -28
  68. package/src/ui/panels.js +115 -115
  69. package/src/ui/prompt.js +89 -89
  70. package/src/ui/ribbon.js +485 -485
  71. package/src/ui/special-chars.js +39 -39
  72. package/src/ui/statusbar.js +81 -81
  73. package/src/ui/toolbar.js +32 -32
  74. package/styles/editor-content.css +440 -440
  75. package/styles/tokens.css +154 -154
  76. package/styles/word-panel.css +1 -1
@@ -1,109 +1,109 @@
1
- // [文件] web·editor-kernel·blocks·回车与退格 —— 硬换行/代码块换行/向后合块/退格计划
2
- import { blockLength, blockOf, charOffset, firstTextBlockIn, isBlockEmpty, isCell, isTextBlock, moveChildren, rangeOf, setCaret } from './dom.js';
3
- import { liftOneOutOf, listItemOf, noteContainerOf, pruneEmpty, quoteOf, releaseListItem } from './blocks.js';
4
- import { liftListItem, settleBlock } from './blocksStructure.js';
5
-
6
- /** 换行(Shift+Enter 与单元格内回车) */
7
- export function insertHardBreak(range) {
8
- const br = document.createElement('br');
9
- range.insertNode(br);
10
- const anchor = document.createTextNode('');
11
- br.after(anchor);
12
- const sel = window.getSelection();
13
- const next = document.createRange();
14
- next.setStart(anchor, 0);
15
- next.collapse(true);
16
- sel.removeAllRanges();
17
- sel.addRange(next);
18
- return true;
19
- }
20
-
21
- /** 代码块内回车 = 真的换行 */
22
- export function insertNewlineInCode(code, range) {
23
- const node = range.startContainer;
24
- if (node.nodeType !== Node.TEXT_NODE) {
25
- code.appendChild(document.createTextNode('\n'));
26
- const sel = window.getSelection();
27
- const next = document.createRange();
28
- next.setStart(code.lastChild, 1);
29
- next.collapse(true);
30
- sel.removeAllRanges();
31
- sel.addRange(next);
32
- return true;
33
- }
34
- const after = node.splitText(range.startOffset);
35
- node.appendData('\n');
36
- const sel = window.getSelection();
37
- const next = document.createRange();
38
- next.setStart(after, 0);
39
- next.collapse(true);
40
- sel.removeAllRanges();
41
- sel.addRange(next);
42
- return true;
43
- }
44
-
45
- /**
46
- * 段首退格:把本块并回上一块,或删掉这一行空段
47
- * [坑] 表格单元格的 prev 就是同一行的左邻格,跨格合并会撕坏网格 → 直接交给原生行为;
48
- * 列表项与引用各有自己的分支(在上面提前返回),代码块内没有同级文本块,都不会走到这里
49
- */
50
- function mergeBackward(block, root) {
51
- if (isCell(block)) return null;
52
- const prev = block.previousElementSibling;
53
- if (!prev) return null;
54
- if (isTextBlock(prev, root)) {
55
- const at = blockLength(prev);
56
- const carry = !isBlockEmpty(block);
57
- return () => {
58
- if (carry) {
59
- // 前块只剩占位 br:先清空,否则并进来的正文前多出一个空行
60
- if (isBlockEmpty(prev)) prev.replaceChildren();
61
- moveChildren(block, prev);
62
- }
63
- block.remove();
64
- settleBlock(prev);
65
- setCaret(prev, at);
66
- };
67
- }
68
- // 上一块是结构块(分割线 / 图片 / 列表 / 表格 / 代码块):只有本块是空行才删,且必须先找到落脚点
69
- if (!isBlockEmpty(block)) return null;
70
- const landing = firstTextBlockIn(prev, root) || firstTextBlockIn(block.nextElementSibling, root);
71
- if (!landing) return null;
72
- return () => {
73
- block.remove();
74
- setCaret(landing, 0);
75
- };
76
- }
77
-
78
- /**
79
- * 光标在块首退格的动作计划(纯判据不改 DOM;返回 null 表示交给浏览器合并块)
80
- * [设计] 判据与执行分离:输入层要先知道「本键是否被内核接管」才能决定 preventDefault。
81
- */
82
- export function backspacePlan(root) {
83
- const range = rangeOf(root);
84
- if (!range || !range.collapsed) return null;
85
- const block = blockOf(range.startContainer, root);
86
- if (!block) return null;
87
- if (charOffset(block, range.startContainer, range.startOffset) !== 0) return null;
88
-
89
- const li = listItemOf(block, root);
90
- if (li) {
91
- // 行首退格把列表项提成段落:若该列表原是高亮块/超级块内唯一内容,提完要顺带收掉空容器(否则空容器残留)
92
- const nc = noteContainerOf(block, root);
93
- if (isBlockEmpty(block)) {
94
- return () => {
95
- const released = releaseListItem(li);
96
- if (nc) pruneEmpty(nc);
97
- setCaret(released, 0);
98
- };
99
- }
100
- if (li.parentElement?.parentElement?.tagName === 'LI') return () => { liftListItem(li); setCaret(block, 0); };
101
- return null;
102
- }
103
- const quote = quoteOf(block, root);
104
- if (quote) return () => { liftOneOutOf(quote, block); pruneEmpty(quote); setCaret(block, 0); };
105
- // 高亮块/超级块行首退格:把本块提出容器(列归到其超级块),空容器/空列由 pruneEmpty 收尾
106
- const nc = noteContainerOf(block, root);
107
- if (nc) return () => { liftOneOutOf(nc, block); pruneEmpty(nc); setCaret(block, 0); };
108
- return mergeBackward(block, root);
109
- }
1
+ // [文件] web·editor-kernel·blocks·回车与退格 —— 硬换行/代码块换行/向后合块/退格计划
2
+ import { blockLength, blockOf, charOffset, firstTextBlockIn, isBlockEmpty, isCell, isTextBlock, moveChildren, rangeOf, setCaret } from './dom.js';
3
+ import { liftOneOutOf, listItemOf, noteContainerOf, pruneEmpty, quoteOf, releaseListItem } from './blocks.js';
4
+ import { liftListItem, settleBlock } from './blocksStructure.js';
5
+
6
+ /** 换行(Shift+Enter 与单元格内回车) */
7
+ export function insertHardBreak(range) {
8
+ const br = document.createElement('br');
9
+ range.insertNode(br);
10
+ const anchor = document.createTextNode('');
11
+ br.after(anchor);
12
+ const sel = window.getSelection();
13
+ const next = document.createRange();
14
+ next.setStart(anchor, 0);
15
+ next.collapse(true);
16
+ sel.removeAllRanges();
17
+ sel.addRange(next);
18
+ return true;
19
+ }
20
+
21
+ /** 代码块内回车 = 真的换行 */
22
+ export function insertNewlineInCode(code, range) {
23
+ const node = range.startContainer;
24
+ if (node.nodeType !== Node.TEXT_NODE) {
25
+ code.appendChild(document.createTextNode('\n'));
26
+ const sel = window.getSelection();
27
+ const next = document.createRange();
28
+ next.setStart(code.lastChild, 1);
29
+ next.collapse(true);
30
+ sel.removeAllRanges();
31
+ sel.addRange(next);
32
+ return true;
33
+ }
34
+ const after = node.splitText(range.startOffset);
35
+ node.appendData('\n');
36
+ const sel = window.getSelection();
37
+ const next = document.createRange();
38
+ next.setStart(after, 0);
39
+ next.collapse(true);
40
+ sel.removeAllRanges();
41
+ sel.addRange(next);
42
+ return true;
43
+ }
44
+
45
+ /**
46
+ * 段首退格:把本块并回上一块,或删掉这一行空段
47
+ * [坑] 表格单元格的 prev 就是同一行的左邻格,跨格合并会撕坏网格 → 直接交给原生行为;
48
+ * 列表项与引用各有自己的分支(在上面提前返回),代码块内没有同级文本块,都不会走到这里
49
+ */
50
+ function mergeBackward(block, root) {
51
+ if (isCell(block)) return null;
52
+ const prev = block.previousElementSibling;
53
+ if (!prev) return null;
54
+ if (isTextBlock(prev, root)) {
55
+ const at = blockLength(prev);
56
+ const carry = !isBlockEmpty(block);
57
+ return () => {
58
+ if (carry) {
59
+ // 前块只剩占位 br:先清空,否则并进来的正文前多出一个空行
60
+ if (isBlockEmpty(prev)) prev.replaceChildren();
61
+ moveChildren(block, prev);
62
+ }
63
+ block.remove();
64
+ settleBlock(prev);
65
+ setCaret(prev, at);
66
+ };
67
+ }
68
+ // 上一块是结构块(分割线 / 图片 / 列表 / 表格 / 代码块):只有本块是空行才删,且必须先找到落脚点
69
+ if (!isBlockEmpty(block)) return null;
70
+ const landing = firstTextBlockIn(prev, root) || firstTextBlockIn(block.nextElementSibling, root);
71
+ if (!landing) return null;
72
+ return () => {
73
+ block.remove();
74
+ setCaret(landing, 0);
75
+ };
76
+ }
77
+
78
+ /**
79
+ * 光标在块首退格的动作计划(纯判据不改 DOM;返回 null 表示交给浏览器合并块)
80
+ * [设计] 判据与执行分离:输入层要先知道「本键是否被内核接管」才能决定 preventDefault。
81
+ */
82
+ export function backspacePlan(root) {
83
+ const range = rangeOf(root);
84
+ if (!range || !range.collapsed) return null;
85
+ const block = blockOf(range.startContainer, root);
86
+ if (!block) return null;
87
+ if (charOffset(block, range.startContainer, range.startOffset) !== 0) return null;
88
+
89
+ const li = listItemOf(block, root);
90
+ if (li) {
91
+ // 行首退格把列表项提成段落:若该列表原是高亮块/超级块内唯一内容,提完要顺带收掉空容器(否则空容器残留)
92
+ const nc = noteContainerOf(block, root);
93
+ if (isBlockEmpty(block)) {
94
+ return () => {
95
+ const released = releaseListItem(li);
96
+ if (nc) pruneEmpty(nc);
97
+ setCaret(released, 0);
98
+ };
99
+ }
100
+ if (li.parentElement?.parentElement?.tagName === 'LI') return () => { liftListItem(li); setCaret(block, 0); };
101
+ return null;
102
+ }
103
+ const quote = quoteOf(block, root);
104
+ if (quote) return () => { liftOneOutOf(quote, block); pruneEmpty(quote); setCaret(block, 0); };
105
+ // 高亮块/超级块行首退格:把本块提出容器(列归到其超级块),空容器/空列由 pruneEmpty 收尾
106
+ const nc = noteContainerOf(block, root);
107
+ if (nc) return () => { liftOneOutOf(nc, block); pruneEmpty(nc); setCaret(block, 0); };
108
+ return mergeBackward(block, root);
109
+ }