@ecomcx/ecomweb-editor 1.31.0 → 1.32.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 (88) hide show
  1. package/package.json +3 -3
  2. package/src/locales/en/attrs.ts +10 -0
  3. package/src/locales/en/background.ts +17 -0
  4. package/src/locales/en/block-desc.ts +1 -0
  5. package/src/locales/en/block-style.ts +7 -4
  6. package/src/locales/en/block-titles.ts +1 -0
  7. package/src/locales/en/blocks.ts +10 -2
  8. package/src/locales/en/columns.ts +12 -0
  9. package/src/locales/en/controls.ts +21 -0
  10. package/src/locales/en/hints.ts +215 -1
  11. package/src/locales/en/index.ts +5 -2
  12. package/src/locales/en/layout.ts +32 -0
  13. package/src/locales/en/legacy.ts +1 -1
  14. package/src/locales/en/library.ts +38 -0
  15. package/src/locales/en/parts.ts +12 -0
  16. package/src/locales/en/placeholders.ts +9 -1
  17. package/src/locales/en/presets.ts +6 -0
  18. package/src/locales/en/v2.ts +21 -0
  19. package/src/locales/vi/attrs.ts +10 -0
  20. package/src/locales/vi/background.ts +17 -0
  21. package/src/locales/vi/block-desc.ts +1 -0
  22. package/src/locales/vi/block-style.ts +7 -4
  23. package/src/locales/vi/block-titles.ts +1 -0
  24. package/src/locales/vi/blocks.ts +10 -2
  25. package/src/locales/vi/columns.ts +12 -0
  26. package/src/locales/vi/controls.ts +21 -0
  27. package/src/locales/vi/hints.ts +216 -2
  28. package/src/locales/vi/index.ts +5 -2
  29. package/src/locales/vi/layout.ts +32 -0
  30. package/src/locales/vi/legacy.ts +1 -1
  31. package/src/locales/vi/library.ts +38 -0
  32. package/src/locales/vi/parts.ts +12 -0
  33. package/src/locales/vi/placeholders.ts +9 -1
  34. package/src/locales/vi/presets.ts +6 -0
  35. package/src/locales/vi/v2.ts +21 -0
  36. package/src/shared/panel-store.ts +3 -3
  37. package/src/shared/patterns.ts +3 -52
  38. package/src/shared/style-panel.tsx +2 -2
  39. package/src/shared/types.ts +2 -0
  40. package/src/v2/blocks/columns-inspector.tsx +210 -0
  41. package/src/v2/blocks/form.tsx +4 -4
  42. package/src/v2/blocks/index.ts +10 -4
  43. package/src/v2/blocks/inline-style.ts +1 -1
  44. package/src/v2/blocks/layout.tsx +173 -42
  45. package/src/v2/blocks/media.tsx +22 -13
  46. package/src/v2/blocks/resize.tsx +172 -4
  47. package/src/v2/blocks/text.tsx +14 -7
  48. package/src/v2/blocks/theme.tsx +10 -5
  49. package/src/v2/blocks/tools.tsx +50 -5
  50. package/src/v2/blocks/widgets.tsx +44 -16
  51. package/src/v2/canvas/block-list.tsx +17 -2
  52. package/src/v2/canvas/canvas-css.ts +54 -4
  53. package/src/v2/canvas/canvas.tsx +20 -3
  54. package/src/v2/canvas/dnd.ts +34 -3
  55. package/src/v2/canvas/move-animation.ts +94 -0
  56. package/src/v2/canvas/spacing-viz.ts +51 -0
  57. package/src/v2/core/block-presets.ts +68 -0
  58. package/src/v2/core/host.ts +5 -0
  59. package/src/v2/core/structure.ts +2 -1
  60. package/src/v2/editor.css +238 -9
  61. package/src/v2/editor.tsx +8 -2
  62. package/src/v2/ui/attr-form.tsx +40 -11
  63. package/src/v2/ui/attr-hints.ts +104 -6
  64. package/src/v2/ui/background-panel.tsx +65 -21
  65. package/src/v2/ui/block-icons.tsx +152 -0
  66. package/src/v2/ui/block-menu.ts +22 -0
  67. package/src/v2/ui/block-style-panel.tsx +14 -3
  68. package/src/v2/ui/color-field.tsx +74 -9
  69. package/src/v2/ui/divider-panel.tsx +58 -0
  70. package/src/v2/ui/group-width.tsx +38 -0
  71. package/src/v2/ui/icon-picker.tsx +51 -0
  72. package/src/v2/ui/inserter.tsx +51 -7
  73. package/src/v2/ui/inspector.tsx +48 -16
  74. package/src/v2/ui/layout-panel.tsx +5 -47
  75. package/src/v2/ui/list-view.tsx +81 -7
  76. package/src/v2/ui/motion-panel.tsx +2 -1
  77. package/src/v2/ui/parts-panel.tsx +164 -0
  78. package/src/v2/ui/pattern-library.tsx +228 -0
  79. package/src/v2/ui/preset-bar.tsx +83 -0
  80. package/src/v2/ui/style-controls.tsx +65 -15
  81. package/src/v2/ui/style-supports.ts +1 -1
  82. package/src/v2/ui/style-tab.tsx +127 -41
  83. package/src/v2/ui/toolbar.tsx +52 -13
  84. package/src/v2/ui/unit-controls.tsx +88 -39
  85. package/src/locales/en/patterns.ts +0 -50
  86. package/src/locales/vi/patterns.ts +0 -50
  87. package/src/shared/patterns-kit.ts +0 -7
  88. package/src/shared/patterns-library.ts +0 -172
@@ -3,7 +3,7 @@
3
3
  * Nạp TRƯỚC CSS của website nên không đè kiểu dáng nội dung; dùng outline (theme hầu như không dùng) để không đổi bố cục.
4
4
  */
5
5
  export const CANVAS_CSS = String.raw`
6
- :root { --ecx-ui-font: "Be Vietnam Pro", ui-sans-serif, system-ui, sans-serif; --ecx-ui: #1a597b; --ecx-ui-nested: #7c3aed; --ecx-ui-soft: color-mix(in srgb, var(--ecx-ui) 8%, transparent); color-scheme: light; }
6
+ :root { --ecx-ui-font: "Be Vietnam Pro", ui-sans-serif, system-ui, sans-serif; --ecx-ui: #1a597b; --ecx-ui-nested: #f26251; --ecx-ui-soft: color-mix(in srgb, var(--ecx-ui) 8%, transparent); color-scheme: light; }
7
7
  html, body { margin: 0; min-height: 100%; }
8
8
  body.ecx-canvas-body { padding: 0; }
9
9
  /* Nền trắng chỉ là mặc định (độ ưu tiên 0): theme nền tối / có màu nền riêng trên body thì canvas phải theo theme */
@@ -64,9 +64,10 @@ span[data-ecx-rich][data-empty][data-placeholder] { min-width: calc(var(--ecx-ph
64
64
  span[data-ecx-rich][data-empty][data-placeholder] { display: inline-block; vertical-align: top; }
65
65
  [data-ecx-rich][data-empty][data-placeholder] { min-width: 0; } /* ô lưới/flex trống không bị chữ gợi ý (nowrap) đẩy rộng hơn khung */
66
66
  [data-ecx-rich][data-empty][data-placeholder][contenteditable="true"] { opacity: 1 !important; } /* phần tử vốn mờ (chức danh, chú thích): gợi ý không mờ chồng mờ */
67
- .ecx-button [data-ecx-rich][data-empty][data-placeholder]::before { opacity: 1; font-style: italic; } /* chữ trên nền màu nút: mờ đi là không đủ tương phản */
67
+ .ecx-button [data-ecx-rich][data-empty][data-placeholder]::before { opacity: .8; font-style: normal; left: 0; right: 0; text-align: center; } /* chữ gợi ý trên nền màu nút: sáng vừa đủ tương phản, không nghiêng */
68
+ .ecx-button span[data-ecx-rich][data-empty][data-placeholder] { min-width: calc(var(--ecx-ph, 0) * .75em); } /* chữ đậm của nút rộng hơn chữ thường: chừa chỗ để gợi ý không bị cắt */
68
69
  [data-ecx-rich][data-empty][data-placeholder] { flex: 1 1 8em; } /* trong hàng ngang (flex): ô trống không co về 0px (gợi ý là ::before absolute) */
69
- [data-ecx-rich][data-empty][data-placeholder]::before { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
70
+ [data-ecx-rich][data-empty][data-placeholder]::before { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; left: 0; right: 0; } /* bám hai mép của ô (căn giữa / cỡ chữ lớn: không tràn ra ngoài khối) */
70
71
  .ProseMirror-hideselection *::selection { background: transparent; }
71
72
  .ProseMirror-selectednode { outline: 2px solid var(--ecx-ui); }
72
73
  .ecx-inline-atom { padding: 0 .25em; border-radius: 4px; background: var(--ecx-ui-soft); font-size: .85em; }
@@ -117,6 +118,14 @@ span[data-ecx-rich][data-empty][data-placeholder] { display: inline-block; verti
117
118
  .ecx-drop-indicator { position: absolute; z-index: 50; background: var(--ecx-ui); border-radius: 2px; pointer-events: none; }
118
119
  body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none !important; }
119
120
  .ecx-block.is-dragging-source { opacity: .35; }
121
+ /* Tô vùng đệm (trong) / lề (ngoài) khi rê ô Đệm / Lề ở bảng bên phải */
122
+ .ecx-spacing-viz { position: fixed; z-index: 60; pointer-events: none; display: grid; place-items: center; overflow: hidden; background: rgb(74 163 120 / .22); box-shadow: inset 0 0 0 1px rgb(46 125 90 / .45); }
123
+ .ecx-spacing-viz.is-margin { background: rgb(232 137 12 / .18); box-shadow: inset 0 0 0 1px rgb(184 104 0 / .45); }
124
+ .ecx-spacing-viz span { padding: 1px 6px; border-radius: 4px; background: rgb(255 255 255 / .9); color: #1f6b47; font: 600 11px/1.4 system-ui, sans-serif; white-space: nowrap; }
125
+ .ecx-spacing-viz.is-margin span { color: #8a4b00; }
126
+ /* Khối chứa sắp nhận khối thả: nền + viền nhẹ, trễ 100ms để lướt chuột qua không nháy */
127
+ .ecx-block.is-drop-parent { outline: 1px dashed color-mix(in srgb, var(--ecx-ui) 55%, transparent); outline-offset: 2px; box-shadow: inset 0 0 0 100vmax color-mix(in srgb, var(--ecx-ui) 6%, transparent); transition: outline-color .1s linear .1s, box-shadow .1s linear .1s; }
128
+ @media (prefers-reduced-motion: reduce) { .ecx-block.is-drop-parent { transition: none; } }
120
129
 
121
130
  /* Làm nổi khối đang sửa: các khối cấp cao nhất khác mờ đi */
122
131
  .is-spotlight > .ecx-block:not(.is-selected):not(.is-editing):not(:has(.is-selected, .is-editing)) { opacity: .3; transition: opacity .2s ease; }
@@ -127,7 +136,37 @@ body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select:
127
136
  /* Theme thường tạo kiểu mọi ô nhập (textarea { border; padding } textarea:focus { outline }) — ô tiêu đề không được mang khung ô nhập */
128
137
  .ecx-doc-title .ecx-doc-title-input, .ecx-doc-title .ecx-doc-title-input:focus { border: 0; border-radius: 0; outline: none; box-shadow: none; padding: 0; background: transparent; min-height: 0; }
129
138
  .ecx-col-handles { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
139
+ /* Dải kéo đệm trên / dưới của khối bố cục đang chọn */
140
+ .ecx-block.is-selected:has(> .ecx-pad-handles) { position: relative; }
141
+ /* Khối bố cục đang chọn: chỗ trống nắm được để kéo đổi chỗ; khối con / chữ giữ con trỏ thường */
142
+ .ecx-block[data-ecx-grab] { cursor: grab; }
143
+ .ecx-block[data-ecx-grab] .ecx-block, .ecx-block[data-ecx-grab] [data-ecx-rich] { cursor: auto; }
144
+ .ecx-pad-handles { position: absolute; inset: 0; max-width: none; margin: 0; pointer-events: none; z-index: 7; }
145
+ .ecx-block.is-selected:has(> .ecx-cw-handles) { position: relative; }
146
+ .ecx-cw-handles { position: absolute; inset: 0; max-width: none; margin: 0; pointer-events: none; z-index: 8; }
147
+ .ecx-cw-handle { position: absolute; top: 50%; width: 10px; height: 44px; margin: -22px 0 0 4px; border-radius: 6px; background: var(--ecx-ui); box-shadow: 0 0 0 2px #fff; cursor: ew-resize; pointer-events: auto; opacity: .55; touch-action: none; }
148
+ .ecx-cw-handle.is-left { margin-left: -14px; }
149
+ .ecx-cw-handle:hover, .ecx-cw-handle.is-dragging { opacity: 1; }
150
+ .ecx-cw-tip { position: absolute; top: -28px; left: 50%; transform: translateX(-50%); padding: 2px 8px; border-radius: 4px; background: var(--ecx-ui); color: #fff; font: 600 12px/1.4 system-ui, sans-serif; white-space: nowrap; pointer-events: none; }
151
+ .ecx-pad-handle { position: absolute; left: 0; width: min(40%, 320px); height: 12px; cursor: ns-resize; pointer-events: auto; touch-action: none; }
152
+ /* vắt qua mép: khối không đệm thì tay nắm chỉ lấn 6px, không che chữ của khối con */
153
+ .ecx-pad-handle.is-top { top: -6px; }
154
+ .ecx-pad-handle.is-bottom { bottom: -6px; }
155
+ .ecx-pad-handle::after { content: ""; position: absolute; left: 16px; width: 36px; height: 4px; border-radius: 3px; background: var(--ecx-ui); opacity: 0; transition: opacity .1s linear; }
156
+ .ecx-pad-handle.is-top::after { top: 4px; }
157
+ .ecx-pad-handle.is-bottom::after { bottom: 4px; }
158
+ .ecx-pad-handle:hover::after, .ecx-pad-handle.is-dragging::after { opacity: 1; }
159
+ /* Vùng kéo đệm / lề của khối bố cục đang chọn: rộng hết khối, cao bằng giá trị thật — kéo ở đâu trong vùng cũng được */
160
+ .ecx-pad-zone { position: absolute; left: 0; right: 0; cursor: ns-resize; pointer-events: auto; touch-action: none; }
161
+ /* vạch kéo ở 1/4 bề rộng: giữa mép dưới là nút "+ Thêm section" */
162
+ .ecx-pad-zone::after { content: ""; position: absolute; left: 25%; width: 36px; height: 4px; margin-left: -18px; border-radius: 3px; background: var(--ecx-ui); opacity: 0; transition: opacity .1s linear; }
163
+ .ecx-pad-zone.is-top::after { top: calc(50% - 2px); }
164
+ .ecx-pad-zone.is-bottom::after { bottom: calc(50% - 2px); }
165
+ .ecx-pad-zone:hover::after, .ecx-pad-zone.is-dragging::after { opacity: 1; }
130
166
  .ecx-col-handle { position: absolute; width: 12px; margin-left: -6px; cursor: col-resize; pointer-events: auto; touch-action: none; }
167
+ .ecx-col-handle.is-dragging::before, .ecx-col-handle.is-dragging::after { position: absolute; top: 8px; padding: 1px 6px; border-radius: 4px; background: var(--ecx-ui); color: #fff; font: 600 11px/1.5 system-ui, sans-serif; white-space: nowrap; pointer-events: none; }
168
+ .ecx-col-handle.is-dragging::before { content: attr(data-left); right: 14px; }
169
+ .ecx-col-handle.is-dragging::after { content: attr(data-right); left: 14px; width: auto; bottom: auto; opacity: 1; } /* ghi đè vạch 2px của ::after thường: nhãn % bên phải không bị cắt */
131
170
  .ecx-col-handle::after { content: ""; position: absolute; left: 5px; top: 0; bottom: 0; width: 2px; background: var(--ecx-ui); opacity: .35; border-radius: 1px; }
132
171
  .ecx-col-handle:hover::after { opacity: 1; }
133
172
  .ecx-image-handle { position: absolute; z-index: 6; width: 14px; height: 14px; border: 2px solid #fff; border-radius: 50%; background: var(--ecx-ui); cursor: nwse-resize; touch-action: none; box-shadow: 0 0 0 1px var(--ecx-ui); }
@@ -170,7 +209,7 @@ img[data-ecx-bound] { outline: 2px solid color-mix(in srgb, var(--ecx-ui) 45%, t
170
209
  .ecx-canvas-root .ecx-table table { width: 100%; border-collapse: collapse; }
171
210
  .ecx-canvas-root .ecx-table :is(td, th) { min-width: 3em; height: 2.5em; outline: 1px dashed color-mix(in srgb, currentColor 22%, transparent); outline-offset: -1px; }
172
211
  /* Tabs: thanh tiêu đề luôn thấy và bấm được (thẻ đang ẩn: display none inline) */
173
- .ecx-canvas-root .ecx-tabs-list { display: flex; flex-wrap: wrap; min-height: 2.5em; }
212
+ .ecx-canvas-root .ecx-tabs-list { min-height: 2.5em; }
174
213
  .ecx-canvas-root .ecx-tab-button { cursor: pointer; }
175
214
  .ecx-canvas-root .ecx-tab-button [data-ecx-rich] { display: inline-block; min-width: 3em; }
176
215
  .ecx-btn-ghost { background: none; border-color: transparent; }
@@ -217,6 +256,14 @@ img[data-ecx-bound] { outline: 2px solid color-mix(in srgb, var(--ecx-ui) 45%, t
217
256
  .ecx-ph-choice:hover, .ecx-ph-choice:focus-visible { border-color: var(--ecx-ui); color: var(--ecx-ui); }
218
257
  .ecx-ph-choice .ecx-icon { width: 24px; height: 24px; }
219
258
  .ecx-ph-choose { align-items: center; text-align: center; }
259
+ /* Lưới chọn bố cục cột khi vừa chèn Bộ cột: mỗi ô vẽ tỉ lệ các cột */
260
+ .ecx-col-layouts { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; width: 100%; max-width: 640px; }
261
+ .ecx-col-layout { display: flex; gap: 3px; height: 44px; padding: 6px; border: 1px solid #c9d0d7; border-radius: 6px; background: #fff; cursor: pointer; }
262
+ .ecx-col-layout span { flex-basis: 0; border-radius: 2px; background: #c3ccd5; }
263
+ .ecx-col-layout:hover, .ecx-col-layout:focus-visible { border-color: var(--ecx-ui); outline: none; }
264
+ .ecx-col-layout:hover span, .ecx-col-layout:focus-visible span { background: var(--ecx-ui); }
265
+ .ecx-ph-skip { border: 0; background: none; padding: 2px 4px; color: #4a5a68; font: 13px var(--ecx-ui-font); text-decoration: underline; cursor: pointer; }
266
+ .ecx-ph-skip:hover { color: var(--ecx-ui); }
220
267
  /* Ô gõ của plugin / icon list: kế thừa phông + cỡ chữ của chỗ đặt ô */
221
268
  .ecx-ph-text { box-sizing: border-box; width: 100%; min-width: 4em; margin: 0; padding: 0 0 1px; border: 0; border-bottom: 1px dashed color-mix(in srgb, currentColor 35%, transparent); border-radius: 0; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; line-height: inherit; resize: vertical; outline: none; field-sizing: content; }
222
269
  .ecx-ph-text::placeholder { color: inherit; opacity: .85; }
@@ -234,6 +281,9 @@ img[data-ecx-bound] { outline: 2px solid color-mix(in srgb, var(--ecx-ui) 45%, t
234
281
  .ecx-ph-list-add .ecx-add-item { margin-top: 2px; }
235
282
  .ecx-gallery-add { grid-column: auto; min-height: 0; aspect-ratio: 1; }
236
283
  .ecx-gallery-add .ecx-placeholder-hint { display: none; }
284
+ /* Ảnh giữ tỉ lệ (không cắt / masonry): ô "+" không còn là ô vuông khổng lồ, ảnh không bị kéo giãn theo hàng */
285
+ .ecx-gallery.is-natural { align-items: start; }
286
+ .ecx-gallery.is-natural .ecx-gallery-add { aspect-ratio: auto; min-height: 7rem; }
237
287
  /* Mã nguồn: chọn ngôn ngữ trên khối; danh sách số: số bắt đầu */
238
288
  .ecx-ph-corner { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin: 0 0 6px; font: 12px var(--ecx-ui-font); white-space: normal; }
239
289
  .ecx-ph-corner > label, .ecx-ph-corner > span { background: #fff; color: #33414d; border-radius: 4px; padding: 1px 6px; }
@@ -13,6 +13,7 @@ import { wrapperNodes } from "./wrapper-props";
13
13
  import { makeBlock, type BNode } from "../core/model";
14
14
  import { flatten, topLevelOrdered } from "../core/ops";
15
15
  import { useTableRangeSelect } from "./table-select";
16
+ import { useMoveAnimation } from "./move-animation";
16
17
  import { clearCells, deleteRow, selectedCellRect, tableContext } from "../core/tables";
17
18
  import { insertSibling, now, richViews } from "../text/rich-text";
18
19
 
@@ -114,6 +115,7 @@ function CanvasRoot({ doc, contentClassName, before, after }: { doc: Document; c
114
115
  useCanvasStyles(doc);
115
116
  useCanvasKeys(doc);
116
117
  useCanvasEvents(doc);
118
+ useMoveAnimation(doc);
117
119
  useTableRangeSelect(doc);
118
120
  const hasRange = useRangeHighlight(doc);
119
121
  return (
@@ -246,6 +248,13 @@ function useCanvasEvents(doc: Document) {
246
248
  win.addEventListener("resize", bump);
247
249
  const ro = new ResizeObserver(bump);
248
250
  ro.observe(doc.body);
251
+ // Chọn cả khối (nút "Chọn khối cha", Cây khối, Esc…) trong khi tiêu điểm bàn phím còn ở ô gõ chữ bên trong:
252
+ // đưa tiêu điểm ra khung soạn, để ⌘⇧D / Delete / ⌘C tác động lên khối đang chọn chứ không lên đoạn văn bên trong.
253
+ const unsub = store.subscribe(() => {
254
+ if (!store.getState().selection.ids.length) return;
255
+ const ae = doc.activeElement as HTMLElement | null;
256
+ if (ae?.isContentEditable) doc.querySelector<HTMLElement>(".ecx-canvas-root")?.focus({ preventScroll: true });
257
+ });
249
258
  // Chuột phải / Shift+F10 / phím Menu trên khối → menu của khối (BlockContextMenu); Shift + chuột phải giữ menu của trình duyệt (chính tả, dán…)
250
259
  const menu = (e: MouseEvent) => {
251
260
  const el = (e.target as Element | null)?.closest?.<HTMLElement>("[data-ecx-block]");
@@ -263,7 +272,7 @@ function useCanvasEvents(doc: Document) {
263
272
  };
264
273
  doc.addEventListener("contextmenu", menu);
265
274
  return () => {
266
- win.removeEventListener("scroll", bump); win.removeEventListener("resize", bump); ro.disconnect(); cancelAnimationFrame(raf);
275
+ win.removeEventListener("scroll", bump); win.removeEventListener("resize", bump); ro.disconnect(); cancelAnimationFrame(raf); unsub();
267
276
  doc.removeEventListener("mousemove", moved); document.removeEventListener("mousemove", moved);
268
277
  doc.removeEventListener("contextmenu", menu);
269
278
  };
@@ -285,8 +294,8 @@ function useCanvasKeys(doc: Document) {
285
294
  const outer = fromTree(e);
286
295
  const mod = e.metaKey || e.ctrlKey;
287
296
  const k = e.key.toLowerCase();
288
- // Vừa bấm nút trên thanh đầu (Lưu, Hoàn tác…): focus ở trang ngoài (nút Lưu tắt sau khi lưu → focus về body) — ⌘Z/⌘Y vẫn là của trình soạn
289
- const fromTopbar = mod && (k === "z" || k === "y") && e.target instanceof Element && e.target.ownerDocument !== doc && !typing(e.target) && (!!e.target.closest(".ecx-topbar") || e.target === e.target.ownerDocument.body);
297
+ // Vừa bấm nút ở trang ngoài (thanh đầu, ô khối của thư viện, nút bảng phải…): focus ở trang ngoài (nút Lưu tắt sau khi lưu → focus về body) — ⌘Z/⌘Y vẫn là của trình soạn
298
+ const fromTopbar = mod && (k === "z" || k === "y") && e.target instanceof Element && e.target.ownerDocument !== doc && !typing(e.target) && !e.target.closest("[role=dialog], [role=menu], [aria-modal=true]");
290
299
  if (e.target instanceof Element && e.target.ownerDocument !== doc && !outer && !fromTopbar) return; // phím của trang ngoài ngoài Cây khối: không phải của khung soạn
291
300
  if (mod && k === "z") { e.preventDefault(); if (e.shiftKey) store.redo(); else store.undo(); return; }
292
301
  if (mod && k === "y") { e.preventDefault(); store.redo(); return; }
@@ -316,6 +325,12 @@ function useCanvasKeys(doc: Document) {
316
325
  }
317
326
  if (e.key === "Backspace" && !store.getState().selection.ids.length) { e.preventDefault(); return; }
318
327
  const ids = store.getState().selection.ids;
328
+ // Alt+Shift+↑ / ↓: đưa khối đang chọn lên / xuống một bước (giống nút Lên / Xuống của thanh công cụ)
329
+ if (e.altKey && e.shiftKey && !mod && ids.length && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
330
+ e.preventDefault();
331
+ store.moveBy(ids, e.key === "ArrowUp" ? -1 : 1);
332
+ return;
333
+ }
319
334
  if (mod && k === "a") {
320
335
  e.preventDefault();
321
336
  store.select(store.getState().docs[store.activeDocId].blocks.map((b) => b.id), { editing: null });
@@ -378,6 +393,8 @@ function useCanvasKeys(doc: Document) {
378
393
  }
379
394
  if (mod && e.shiftKey && k === "d") { e.preventDefault(); store.duplicate(ids); return; }
380
395
  if (e.altKey && e.shiftKey && k === "z") { e.preventDefault(); store.remove(ids); return; }
396
+ // ⇧⌥⌘T / ⇧⌥⌘Y: chuyển khối lên / xuống (trượt về chỗ mới — move-animation)
397
+ if (mod && e.altKey && e.shiftKey && (e.code === "KeyT" || e.code === "KeyY")) { e.preventDefault(); store.moveBy(ids, e.code === "KeyT" ? -1 : 1); return; }
381
398
  if (mod && e.altKey && k === "t") { e.preventDefault(); insertSibling(store, ids[0], 0); return; }
382
399
  if (mod && e.altKey && k === "y") { e.preventDefault(); insertSibling(store, ids[ids.length - 1], 1); return; }
383
400
  };
@@ -3,6 +3,7 @@ import type { EditorContextValue, DropTarget } from "../context";
3
3
  import type { InsertOption } from "../ui/inserter";
4
4
  import type { BNode } from "../core/model";
5
5
  import { canContain } from "../core/structure";
6
+ import { freshWithDefaults } from "../core/block-presets";
6
7
  import { sectionOf } from "./block-list";
7
8
 
8
9
  /**
@@ -35,7 +36,8 @@ export function startDragBlocks(ctx: EditorContextValue, e: ReactPointerEvent, c
35
36
 
36
37
  function begin(ctx: EditorContextValue, e: ReactPointerEvent, src: Source) {
37
38
  const { ui, store } = ctx;
38
- const sx = e.clientX, sy = e.clientY;
39
+ // Nắm từ trong khung soạn (iframe) → đổi toạ độ về trang ngoài như lúc kéo
40
+ const { x: sx, y: sy } = toParent(ctx, e.nativeEvent);
39
41
  const handle = e.currentTarget as HTMLElement;
40
42
  let started = false;
41
43
  let scrollTimer = 0;
@@ -53,8 +55,18 @@ function begin(ctx: EditorContextValue, e: ReactPointerEvent, src: Source) {
53
55
  }
54
56
  const target = unlocked(store, findTarget(ctx, x, y, src));
55
57
  ui.setDrag({ ids: src.ids, newType: src.newType, x, y, target });
58
+ markParent(target?.parentId ?? null);
56
59
  autoScroll(ctx, y);
57
60
  };
61
+ // Khối chứa sắp nhận khối thả (cột, nhóm…) báo nền nhẹ (CSS trễ 100ms: lướt qua không nháy)
62
+ let parentEl: HTMLElement | null = null;
63
+ const markParent = (id: string | null) => {
64
+ const el = id ? ui.blockEl(id) : null;
65
+ if (el === parentEl) return;
66
+ parentEl?.classList.remove("is-drop-parent");
67
+ el?.classList.add("is-drop-parent");
68
+ parentEl = el;
69
+ };
58
70
  const cleanup = () => {
59
71
  document.removeEventListener("pointermove", move);
60
72
  document.removeEventListener("pointerup", up);
@@ -67,6 +79,7 @@ function begin(ctx: EditorContextValue, e: ReactPointerEvent, src: Source) {
67
79
  document.body.classList.remove("is-dragging");
68
80
  ui.canvasDoc?.body.classList.remove("is-dragging");
69
81
  for (const id of src.ids) ui.blockEl(id)?.classList.remove("is-dragging-source");
82
+ markParent(null);
70
83
  clearInterval(scrollTimer);
71
84
  try { handle.releasePointerCapture(pointerId); } catch { /* không giữ */ }
72
85
  };
@@ -77,7 +90,7 @@ function begin(ctx: EditorContextValue, e: ReactPointerEvent, src: Source) {
77
90
  ui.setDrag(null);
78
91
  if (!wasStarted || !target) return;
79
92
  if (src.create) {
80
- const made = src.create();
93
+ const made = freshWithDefaults(src.create());
81
94
  const nodes = Array.isArray(made) ? made : [made];
82
95
  store.insert(target.docId, target.parentId, target.index, nodes);
83
96
  if (nodes.length > 1) store.select([nodes[0].id]);
@@ -93,7 +106,8 @@ function begin(ctx: EditorContextValue, e: ReactPointerEvent, src: Source) {
93
106
  ui.setDrag(null);
94
107
  };
95
108
  // Kéo bị huỷ (mất con trỏ, đổi cửa sổ) → bỏ kéo, không để nhãn kéo kẹt trên màn hình
96
- const cancel = () => { cleanup(); ui.setDrag(null); };
109
+ // (focus chuyển vào khung soạn — nắm khối ngay trong iframe — cũng làm trang ngoài "blur": không phải huỷ)
110
+ const cancel = (ev?: Event) => { if (ev?.type === "blur" && document.activeElement === ui.canvasFrame) return; cleanup(); ui.setDrag(null); };
97
111
  document.addEventListener("pointercancel", cancel);
98
112
  window.addEventListener("blur", cancel);
99
113
  document.addEventListener("pointermove", move);
@@ -194,6 +208,23 @@ function findTarget(ctx: EditorContextValue, x: number, y: number, src: Source):
194
208
  if (node.content && !node.content.length && canContainAll(node.type, src.types)) {
195
209
  return { docId: loc.docId, parentId: node.id, index: 0, rect: toParentRect(r), horizontal: false };
196
210
  }
211
+ // Con trỏ nằm trong khoảng trống bên trong khối chứa (đệm, khe giữa các khối con): thả vào GIỮA các khối con gần nhất,
212
+ // không nhảy ra trước / sau cả khối. Sát mép khối (≤ 16px) vẫn là trước / sau khối đó, để đưa khối ra ngoài nhóm.
213
+ if (id === blockEl.dataset.ecxBlock && node.content?.length && canContainAll(node.type, src.types)) {
214
+ const el = ui.blockEl(id)!, row0 = isRow(el);
215
+ const edge = Math.min(16, (row0 ? r.width : r.height) / 4);
216
+ const inner = row0 ? ix > r.left + edge && ix < r.right - edge : iy > r.top + edge && iy < r.bottom - edge;
217
+ const kids = node.content.map((k) => ui.blockEl(k.id)?.getBoundingClientRect()).filter((x): x is DOMRect => !!x);
218
+ if (inner && kids.length === node.content.length) {
219
+ let idx = kids.length;
220
+ for (let i = 0; i < kids.length; i++) if (row0 ? ix < kids[i].left + kids[i].width / 2 : iy < kids[i].top + kids[i].height / 2) { idx = i; break; }
221
+ const ref = kids[Math.min(idx, kids.length - 1)];
222
+ const line = row0
223
+ ? new DOMRect((idx < kids.length ? ref.left : ref.right) - 2, ref.top, 4, ref.height)
224
+ : new DOMRect(ref.left, (idx < kids.length ? ref.top : ref.bottom) - 2, ref.width, 4);
225
+ return { docId: loc.docId, parentId: node.id, index: idx, rect: toParentRect(line), horizontal: row0 };
226
+ }
227
+ }
197
228
  const parentEl = ui.blockEl(id)!.parentElement;
198
229
  const horizontal = !!parentEl && isRow(parentEl);
199
230
  const after = horizontal ? ix > r.left + r.width / 2 : iy > r.top + r.height / 2;
@@ -0,0 +1,94 @@
1
+ import { useEffect } from "react";
2
+ import { useEditor } from "../context";
3
+ import type { BNode } from "../core/model";
4
+ import type { EditorState } from "../core/store";
5
+
6
+ /**
7
+ * Khối trượt về chỗ mới khi thứ tự đổi (lên / xuống, kéo thả, chèn, xoá, hoàn tác) thay vì nhảy (kiểu FLIP):
8
+ * thứ tự trong cây đổi → đo vị trí cũ ngay lúc store báo (DOM chưa vẽ lại) → khung hình kế tiếp đo vị trí mới →
9
+ * đặt khối về chỗ cũ rồi thả về 0. Gõ chữ không đổi thứ tự → không đo, không chạy.
10
+ */
11
+ export const MOVE_MS = 340;
12
+ // Dừng êm, không nảy (như lò xo tắt dần): quãng đường còn lại giảm theo hàm mũ, hằng số thời gian 75ms → ~35% sau 40ms, ~70% sau 100ms
13
+ const TAU = 75;
14
+ export const MOVE_EASE = `linear(${Array.from({ length: 21 }, (_, i) => { const t = (i / 20) * MOVE_MS; return ((1 - Math.exp(-t / TAU)) / (1 - Math.exp(-MOVE_MS / TAU))).toFixed(3) + ` ${i * 5}%`; }).join(", ")})`;
15
+ // Trình duyệt chưa hiểu linear(): đường cong gần giống
16
+ const FALLBACK_EASE = "cubic-bezier(.25, .7, .3, 1)";
17
+
18
+ /** Vị trí của mọi khối trong cây: id → "cha:thứ tự". */
19
+ export function orderMap(docs: EditorState["docs"]): Map<string, string> {
20
+ const out = new Map<string, string>();
21
+ const walk = (list: readonly BNode[], parent: string) => list.forEach((b, i) => { out.set(b.id, `${parent}:${i}`); if (b.content) walk(b.content, b.id); });
22
+ for (const d of Object.values(docs)) walk(d.blocks, d.id);
23
+ return out;
24
+ }
25
+
26
+ /** Khối cần trượt: đã có trước, đổi chỗ trong cây, và vị trí trên màn hình đổi; bỏ khối con khi khối cha cùng trượt một quãng. */
27
+ export function movesToAnimate(before: Map<string, string>, after: Map<string, string>, oldRects: Map<string, DOMRect>, newRect: (id: string) => DOMRect | null, parentOf: (id: string) => string | null) {
28
+ const moves = new Map<string, { dx: number; dy: number }>();
29
+ for (const id of after.keys()) {
30
+ const o = oldRects.get(id);
31
+ if (!before.has(id) || !o) continue; // khối mới chèn: hiện ngay
32
+ const n = newRect(id);
33
+ if (!n) continue;
34
+ const dx = o.left - n.left, dy = o.top - n.top;
35
+ if (Math.abs(dx) < 1 && Math.abs(dy) < 1) continue;
36
+ moves.set(id, { dx, dy });
37
+ }
38
+ // Khối cha đã trượt → khối con đi theo; chỉ trượt riêng phần chênh lệch
39
+ const abs = new Map(moves);
40
+ for (const [id, m] of abs) {
41
+ for (let p = parentOf(id); p; p = parentOf(p)) {
42
+ const pm = abs.get(p);
43
+ if (!pm) continue;
44
+ const rx = m.dx - pm.dx, ry = m.dy - pm.dy;
45
+ if (Math.abs(rx) < 1 && Math.abs(ry) < 1) moves.delete(id); else moves.set(id, { dx: rx, dy: ry });
46
+ break;
47
+ }
48
+ }
49
+ return moves;
50
+ }
51
+
52
+ export function useMoveAnimation(doc: Document) {
53
+ const { store } = useEditor();
54
+ useEffect(() => {
55
+ const win = doc.defaultView;
56
+ if (!win) return;
57
+ let docs = store.getState().docs;
58
+ let order = orderMap(docs);
59
+ let raf = 0;
60
+ const els = () => doc.querySelectorAll<HTMLElement>("[data-ecx-block]");
61
+ const off = store.subscribe(() => {
62
+ const next = store.getState().docs;
63
+ if (next === docs) return;
64
+ const nextOrder = orderMap(next);
65
+ docs = next;
66
+ let changed = nextOrder.size !== order.size;
67
+ if (!changed) for (const [id, p] of nextOrder) if (order.get(id) !== p) { changed = true; break; }
68
+ const before = order;
69
+ order = nextOrder;
70
+ if (!changed || win.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
71
+ // DOM vẫn là bản cũ: đo vị trí cũ (bỏ phần đang trượt dở)
72
+ const old = new Map<string, DOMRect>();
73
+ for (const el of els()) {
74
+ for (const a of el.getAnimations?.() ?? []) if (a.id === "ecx-move") a.finish();
75
+ old.set(el.dataset.ecxBlock!, el.getBoundingClientRect());
76
+ }
77
+ win.cancelAnimationFrame(raf);
78
+ raf = win.requestAnimationFrame(() => {
79
+ const byId = new Map<string, HTMLElement>();
80
+ for (const el of els()) byId.set(el.dataset.ecxBlock!, el);
81
+ const parentOf = (id: string) => byId.get(id)?.parentElement?.closest<HTMLElement>("[data-ecx-block]")?.dataset.ecxBlock ?? null;
82
+ const moves = movesToAnimate(before, nextOrder, old, (id) => byId.get(id)?.getBoundingClientRect() ?? null, parentOf);
83
+ for (const [id, { dx, dy }] of moves) {
84
+ const el = byId.get(id);
85
+ if (!el?.animate) continue;
86
+ const frames = [{ transform: `translate(${dx}px, ${dy}px)` }, { transform: "translate(0, 0)" }];
87
+ try { el.animate(frames, { duration: MOVE_MS, easing: MOVE_EASE, id: "ecx-move" }); }
88
+ catch { el.animate(frames, { duration: MOVE_MS, easing: FALLBACK_EASE, id: "ecx-move" }); }
89
+ }
90
+ });
91
+ });
92
+ return () => { off(); win.cancelAnimationFrame(raf); };
93
+ }, [doc, store]);
94
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Tô vùng đệm (padding — bên trong khối) hoặc lề (margin — bên ngoài khối) của một khối trên khung soạn, kèm giá trị:
3
+ * rê chuột lên ô cạnh ở bảng bên phải → thấy ngay vùng đó trên khối. Lớp phủ riêng (position: fixed trong iframe), không đổi HTML của khối.
4
+ */
5
+ export type SpacingKind = "padding" | "margin";
6
+ export type Side = "top" | "right" | "bottom" | "left";
7
+ const SIDES: Side[] = ["top", "right", "bottom", "left"];
8
+ const CLS = "ecx-spacing-viz";
9
+
10
+ export function hideSpacingViz(doc: Document | null | undefined) {
11
+ doc?.querySelectorAll(`.${CLS}`).forEach((n) => n.remove());
12
+ }
13
+
14
+ /** Hình chữ nhật của từng cạnh (toạ độ khung nhìn của iframe). */
15
+ export function spacingRects(r: { left: number; top: number; right: number; bottom: number; width: number; height: number }, px: Record<Side, number>, kind: SpacingKind) {
16
+ const out: Record<Side, { left: number; top: number; width: number; height: number }> = {} as never;
17
+ if (kind === "padding") {
18
+ out.top = { left: r.left, top: r.top, width: r.width, height: px.top };
19
+ out.bottom = { left: r.left, top: r.bottom - px.bottom, width: r.width, height: px.bottom };
20
+ out.left = { left: r.left, top: r.top + px.top, width: px.left, height: Math.max(0, r.height - px.top - px.bottom) };
21
+ out.right = { left: r.right - px.right, top: r.top + px.top, width: px.right, height: Math.max(0, r.height - px.top - px.bottom) };
22
+ } else {
23
+ out.top = { left: r.left - px.left, top: r.top - px.top, width: r.width + px.left + px.right, height: px.top };
24
+ out.bottom = { left: r.left - px.left, top: r.bottom, width: r.width + px.left + px.right, height: px.bottom };
25
+ out.left = { left: r.left - px.left, top: r.top, width: px.left, height: r.height };
26
+ out.right = { left: r.right, top: r.top, width: px.right, height: r.height };
27
+ }
28
+ return out;
29
+ }
30
+
31
+ /** Vẽ lớp tô cho các cạnh `sides` (rỗng = cả 4). `names`: tên bậc hiện cạnh giá trị px (vd "MD · 20px"). */
32
+ export function showSpacingViz(el: HTMLElement | null, kind: SpacingKind, sides: Side[] = SIDES, names: Partial<Record<Side, string>> = {}) {
33
+ if (!el) return;
34
+ const doc = el.ownerDocument;
35
+ hideSpacingViz(doc);
36
+ const cs = doc.defaultView!.getComputedStyle(el);
37
+ const px = Object.fromEntries(SIDES.map((s) => [s, parseFloat(cs.getPropertyValue(`${kind}-${s}`)) || 0])) as Record<Side, number>;
38
+ const rects = spacingRects(el.getBoundingClientRect(), px, kind);
39
+ for (const s of sides.length ? sides : SIDES) {
40
+ const r = rects[s];
41
+ const box = doc.createElement("div");
42
+ box.className = `${CLS} is-${kind}`;
43
+ Object.assign(box.style, { left: `${r.left}px`, top: `${r.top}px`, width: `${Math.max(0, r.width)}px`, height: `${Math.max(0, r.height)}px` });
44
+ if (px[s] >= 1) {
45
+ const tag = doc.createElement("span");
46
+ tag.textContent = names[s] ? `${names[s]} · ${Math.round(px[s])}px` : `${Math.round(px[s])}px`;
47
+ box.appendChild(tag);
48
+ }
49
+ doc.body.appendChild(box);
50
+ }
51
+ }
@@ -0,0 +1,68 @@
1
+ import type { BlockControls } from "@ecomcx/ecomweb-content";
2
+ import type { BNode } from "./model";
3
+
4
+ /**
5
+ * Kiểu đặt sẵn + mặc định khi chèn của từng loại khối (toàn website, host.blockPresets):
6
+ * { "<loại>": { default?: attrs, presets?: [{ name, attrs }] } }. Chỉ chứa thuộc tính KIỂU (style, parts, biến thể, ô kiểu dáng của khối),
7
+ * không chứa nội dung (chữ, ảnh, liên kết) — "Mặc định của khối" không đổi khối đã có, không lưu nội dung.
8
+ */
9
+ export interface BlockPreset { name: string; attrs: Record<string, unknown> }
10
+ export interface BlockPresetEntry { default?: Record<string, unknown>; presets?: BlockPreset[] }
11
+ export type BlockPresetMap = Record<string, BlockPresetEntry>;
12
+
13
+ /** Thuộc tính kiểu chung của mọi khối. */
14
+ const COMMON = ["style", "parts", "blockStyle"];
15
+
16
+ /** Tên thuộc tính kiểu của một loại khối: chung + ô điều khiển khai CSS (lõi + plugin). */
17
+ export function styleKeys(type: string, controls: readonly BlockControls[]): string[] {
18
+ const own = controls.filter((c) => c.blocks === "*" || c.blocks.includes(type)).flatMap((c) => Object.keys(c.attributes));
19
+ return [...new Set([...COMMON, ...own])];
20
+ }
21
+
22
+ /** Lấy phần kiểu của attrs (bỏ ô trống). */
23
+ export function pickStyle(attrs: Record<string, unknown>, keys: string[]): Record<string, unknown> {
24
+ const out: Record<string, unknown> = {};
25
+ for (const k of keys) if (attrs[k] !== undefined && attrs[k] !== null && attrs[k] !== "") out[k] = attrs[k];
26
+ return out;
27
+ }
28
+
29
+ /** Áp một bộ kiểu: xoá mọi thuộc tính kiểu đang có rồi đặt theo bộ kiểu (nội dung giữ nguyên). */
30
+ export function applyStyle(keys: string[], style: Record<string, unknown>): Record<string, unknown> {
31
+ const patch: Record<string, unknown> = {};
32
+ for (const k of keys) patch[k] = style[k];
33
+ return patch;
34
+ }
35
+
36
+ /** So sánh hai bộ kiểu (thứ tự khoá không quan trọng). */
37
+ export const sameStyle = (a: Record<string, unknown>, b: Record<string, unknown>) => stable(a) === stable(b);
38
+ function stable(v: unknown): string {
39
+ if (v && typeof v === "object" && !Array.isArray(v)) return `{${Object.keys(v).sort().map((k) => `${JSON.stringify(k)}:${stable((v as Record<string, unknown>)[k])}`).join(",")}}`;
40
+ if (Array.isArray(v)) return `[${v.map(stable).join(",")}]`;
41
+ return JSON.stringify(v);
42
+ }
43
+
44
+ /** Khối mới chèn: thêm kiểu mặc định của loại khối (chỉ thuộc tính chưa có — mẫu / biến thể đã đặt thì giữ). */
45
+ export function withDefaults(node: BNode, map: BlockPresetMap | null): BNode {
46
+ const def = map?.[node.type]?.default;
47
+ if (!def) return node;
48
+ const attrs = { ...node.attrs };
49
+ for (const [k, v] of Object.entries(def)) if (attrs[k] === undefined) attrs[k] = v;
50
+ return { ...node, attrs };
51
+ }
52
+
53
+ // Kho trong bộ nhớ (một lần nạp mỗi phiên soạn); UI đăng ký nghe thay đổi
54
+ let current: BlockPresetMap | null = null;
55
+ let loading: Promise<void> | null = null;
56
+ const listeners = new Set<() => void>();
57
+ export const presetsSnapshot = () => current;
58
+ export const onPresetsChange = (l: () => void) => { listeners.add(l); return () => { listeners.delete(l); }; };
59
+ export function setPresets(m: BlockPresetMap | null) { current = m; listeners.forEach((l) => l()); }
60
+ export function ensurePresets(load?: () => Promise<Record<string, unknown>>) {
61
+ if (current || loading || !load) return;
62
+ loading = load().then((m) => setPresets((m ?? {}) as BlockPresetMap), () => setPresets({})).finally(() => { loading = null; });
63
+ }
64
+
65
+ /** Như withDefaults cho kết quả tạo khối (một khối hoặc mẫu nhiều khối). */
66
+ export function freshWithDefaults<T extends BNode | BNode[]>(made: T): T {
67
+ return (Array.isArray(made) ? made.map((n) => withDefaults(n, current)) : withDefaults(made, current)) as T;
68
+ }
@@ -45,6 +45,11 @@ export interface EditorHost {
45
45
  scope?: "template" | "content";
46
46
  /** Preset của theme (biến --ecx-*). */
47
47
  presets?: StylePresets;
48
+ /**
49
+ * v3: kiểu đặt sẵn + mặc định khi chèn của từng loại khối (toàn website). `save` không có = người dùng không có quyền lưu (chỉ chọn kiểu).
50
+ * Dạng dữ liệu: core/block-presets BlockPresetMap.
51
+ */
52
+ blockPresets?: { load(): Promise<Record<string, unknown>>; save?(map: Record<string, unknown>): Promise<Record<string, unknown>> };
48
53
  /** Chữ "%khoá%" của plugin → chữ theo ngôn ngữ. */
49
54
  translate?(text: string): string;
50
55
  /**
@@ -28,7 +28,8 @@ const RULES: Record<string, StructureRule> = {
28
28
  listItem: { parents: ["bulletList", "orderedList"], wrapSelfWith: "bulletList", required: p, firstChild: "paragraph" },
29
29
  taskList: { allowedChildren: ["taskItem"], wrapChildrenWith: "taskItem", removeWhenEmpty: true },
30
30
  taskItem: { parents: ["taskList"], wrapSelfWith: "taskList", required: p, firstChild: "paragraph" },
31
- columns: { allowedChildren: ["column"], wrapChildrenWith: "column", removeWhenEmpty: true },
31
+ // Bộ cột rỗng (vừa chèn, chưa chọn bố cục) giữ lại như bảng rỗng: trình soạn hiện lưới chọn bố cục cột
32
+ columns: { allowedChildren: ["column"], wrapChildrenWith: "column" },
32
33
  column: { parents: ["columns"], wrapSelfWith: "columns" },
33
34
  buttons: { allowedChildren: ["button"], removeWhenEmpty: true },
34
35
  button: { parents: ["buttons"], wrapSelfWith: "buttons" },