@ecomcx/ecomweb-editor 1.25.2 → 1.26.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.
- package/package.json +3 -3
- package/src/locales/en/attrs.ts +1 -0
- package/src/locales/en/block-titles.ts +15 -3
- package/src/locales/en/blocks.ts +5 -0
- package/src/locales/en/controls.ts +4 -0
- package/src/locales/en/v2.ts +24 -0
- package/src/locales/vi/attrs.ts +1 -0
- package/src/locales/vi/block-titles.ts +12 -0
- package/src/locales/vi/blocks.ts +5 -0
- package/src/locales/vi/controls.ts +4 -0
- package/src/locales/vi/v2.ts +24 -0
- package/src/shared/color-swatch.tsx +4 -2
- package/src/v2/blocks/compat.tsx +3 -1
- package/src/v2/blocks/layout.tsx +6 -4
- package/src/v2/blocks/media-actions.tsx +2 -1
- package/src/v2/blocks/media.tsx +34 -1
- package/src/v2/blocks/theme.tsx +44 -4
- package/src/v2/canvas/block-list.tsx +7 -1
- package/src/v2/canvas/canvas-css.ts +33 -8
- package/src/v2/canvas/canvas.tsx +49 -4
- package/src/v2/canvas/dnd.ts +20 -0
- package/src/v2/canvas/table-select.ts +74 -0
- package/src/v2/core/host.ts +6 -1
- package/src/v2/core/media.ts +11 -0
- package/src/v2/core/tables.ts +69 -0
- package/src/v2/editor.css +14 -0
- package/src/v2/editor.tsx +1 -1
- package/src/v2/prefs.ts +10 -2
- package/src/v2/text/rich-text.tsx +2 -1
- package/src/v2/ui/ai.tsx +72 -0
- package/src/v2/ui/attr-form.tsx +7 -3
- package/src/v2/ui/color-field.tsx +7 -2
- package/src/v2/ui/inserter.tsx +36 -7
- package/src/v2/ui/list-view.tsx +7 -3
- package/src/v2/ui/options.tsx +1 -1
- package/src/v2/ui/style-tab.tsx +15 -5
- package/src/v2/ui/toolbar.tsx +51 -8
- package/src/v2/ui/unit-controls.tsx +5 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecomcx/ecomweb-editor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"description": "Trình soạn nội dung dạng khối của CMS — dùng độc lập trong mọi dự án React (1.x: TipTap; ./v2: cây khối, khung soạn iframe, sửa header/footer tại chỗ).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"*.css"
|
|
30
30
|
],
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@ecomcx/ecomweb-content": "^1.
|
|
32
|
+
"@ecomcx/ecomweb-content": "^1.20.0",
|
|
33
33
|
"react": ">=18",
|
|
34
34
|
"react-dom": ">=18"
|
|
35
35
|
},
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"prosemirror-view": "1.42.7"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@ecomcx/ecomweb-content": "^1.
|
|
48
|
+
"@ecomcx/ecomweb-content": "^1.20.0",
|
|
49
49
|
"@playwright/test": "1.53.0",
|
|
50
50
|
"@types/react": "19.2.2",
|
|
51
51
|
"@types/react-dom": "19.2.2",
|
package/src/locales/en/attrs.ts
CHANGED
|
@@ -32,10 +32,22 @@ export const blockTitles = {
|
|
|
32
32
|
postAuthor: "Author",
|
|
33
33
|
postTerms: "Terms",
|
|
34
34
|
comments: "Comments",
|
|
35
|
-
queryTitle: "
|
|
36
|
-
termDescription: "
|
|
35
|
+
queryTitle: "Archive title",
|
|
36
|
+
termDescription: "Term description",
|
|
37
37
|
breadcrumbs: "Breadcrumb",
|
|
38
|
-
|
|
38
|
+
countdown: "Countdown",
|
|
39
|
+
rating: "Star rating",
|
|
40
|
+
readMore: "Read more",
|
|
41
|
+
commentsCount: "Comment count",
|
|
42
|
+
avatar: "Author avatar",
|
|
43
|
+
queryTotal: "Total posts",
|
|
44
|
+
termList: "Category / tag list",
|
|
45
|
+
loginout: "Log in / Log out",
|
|
46
|
+
footnotes: "Footnotes",
|
|
47
|
+
pageBreak: "Page break",
|
|
48
|
+
pageList: "Page list",
|
|
49
|
+
archives: "Monthly archives",
|
|
50
|
+
postNavigation: "Previous / next post",
|
|
39
51
|
query: "Query loop",
|
|
40
52
|
postTemplate: "Post template",
|
|
41
53
|
pagination: "Pagination",
|
package/src/locales/en/blocks.ts
CHANGED
|
@@ -18,9 +18,14 @@ export const blocks = {
|
|
|
18
18
|
down: "Down",
|
|
19
19
|
removeLink: "Remove link",
|
|
20
20
|
addLink: "Add link",
|
|
21
|
+
galleryImages: "Gallery images",
|
|
22
|
+
imageAltN: "Image {n} description",
|
|
23
|
+
removeImage: "Remove image",
|
|
24
|
+
addImages: "Add images",
|
|
21
25
|
contents: "Contents",
|
|
22
26
|
menu: "Menu",
|
|
23
27
|
noMenuIsAssigned: "No menu is assigned to this location — assign one in Appearance › Menus, or pick another location.",
|
|
28
|
+
searchLabel: "Search", searchPlaceholder: "Search the site…", searchButton: "Search",
|
|
24
29
|
categoryName: "Category name",
|
|
25
30
|
category: "Category: ",
|
|
26
31
|
theDescriptionOfThe: "The description of the category / tag being viewed.",
|
package/src/locales/en/v2.ts
CHANGED
|
@@ -42,6 +42,25 @@ export const v2 = {
|
|
|
42
42
|
alignLeft: "Align left",
|
|
43
43
|
alignCenter: "Align center",
|
|
44
44
|
alignRight: "Align right",
|
|
45
|
+
width: "Width",
|
|
46
|
+
ai: "AI",
|
|
47
|
+
aiRewrite: "Rewrite to read better",
|
|
48
|
+
aiShorten: "Shorten",
|
|
49
|
+
aiExpand: "Make longer",
|
|
50
|
+
aiFix: "Fix spelling & grammar",
|
|
51
|
+
aiSummarize: "Summarize",
|
|
52
|
+
aiTranslateEn: "Translate to English",
|
|
53
|
+
aiTranslateVi: "Translate to Vietnamese",
|
|
54
|
+
aiCustom: "Other request…",
|
|
55
|
+
aiCustomPrompt: "What should the AI do with this text?",
|
|
56
|
+
aiWorking: "AI is writing…",
|
|
57
|
+
aiNote: "Check before using — AI can be wrong. You can still undo after replacing (⌘Z).",
|
|
58
|
+
aiReplace: "Replace",
|
|
59
|
+
aiInsertBelow: "Insert below",
|
|
60
|
+
aiRetry: "Try again",
|
|
61
|
+
widthDefault: "Text column",
|
|
62
|
+
widthWide: "Wide",
|
|
63
|
+
widthFull: "Full width",
|
|
45
64
|
devices: "Device",
|
|
46
65
|
deviceDesktop: "Desktop",
|
|
47
66
|
deviceTablet: "Tablet",
|
|
@@ -119,6 +138,8 @@ export const v2 = {
|
|
|
119
138
|
deleteRow: "Delete row",
|
|
120
139
|
deleteColumn: "Delete column",
|
|
121
140
|
mergeRight: "Merge with cell on the right",
|
|
141
|
+
mergeCells: "Merge selected cells",
|
|
142
|
+
clearCells: "Clear cell contents",
|
|
122
143
|
mergeDown: "Merge with cell below",
|
|
123
144
|
splitCell: "Split cell",
|
|
124
145
|
toolbarHint: "Select a block to show its tools here",
|
|
@@ -172,6 +193,8 @@ export const v2 = {
|
|
|
172
193
|
createPattern: "Create pattern",
|
|
173
194
|
lock: "Lock…",
|
|
174
195
|
locked: "Locked",
|
|
196
|
+
collapse: "Collapse",
|
|
197
|
+
expand: "Expand",
|
|
175
198
|
lockTitle: "Lock block",
|
|
176
199
|
lockMove: "Disable movement",
|
|
177
200
|
lockRemove: "Prevent removal",
|
|
@@ -182,4 +205,5 @@ export const v2 = {
|
|
|
182
205
|
choiceSelect: "— Select —",
|
|
183
206
|
choiceMissing: "(missing)",
|
|
184
207
|
openInNewTab: "Open in new tab",
|
|
208
|
+
countdownNoTarget: "No end time yet — set “Target” in the sidebar (until then the website does not show this block)",
|
|
185
209
|
};
|
package/src/locales/vi/attrs.ts
CHANGED
|
@@ -35,6 +35,18 @@ export const blockTitles = {
|
|
|
35
35
|
queryTitle: "Tiêu đề trang lưu trữ",
|
|
36
36
|
termDescription: "Mô tả chuyên mục",
|
|
37
37
|
breadcrumbs: "Breadcrumb",
|
|
38
|
+
countdown: "Đếm ngược",
|
|
39
|
+
rating: "Đánh giá sao",
|
|
40
|
+
readMore: "Đọc tiếp",
|
|
41
|
+
commentsCount: "Số bình luận",
|
|
42
|
+
avatar: "Ảnh đại diện tác giả",
|
|
43
|
+
queryTotal: "Tổng số bài",
|
|
44
|
+
termList: "Danh sách chuyên mục / thẻ",
|
|
45
|
+
loginout: "Đăng nhập / Đăng xuất",
|
|
46
|
+
footnotes: "Chú thích cuối bài",
|
|
47
|
+
pageBreak: "Ngắt trang",
|
|
48
|
+
pageList: "Danh sách trang",
|
|
49
|
+
archives: "Lưu trữ theo tháng",
|
|
38
50
|
postNavigation: "Bài trước / bài sau",
|
|
39
51
|
query: "Danh sách bài",
|
|
40
52
|
postTemplate: "Khuôn mỗi bài",
|
package/src/locales/vi/blocks.ts
CHANGED
|
@@ -18,9 +18,14 @@ export const blocks = {
|
|
|
18
18
|
down: "Xuống",
|
|
19
19
|
removeLink: "Xoá liên kết",
|
|
20
20
|
addLink: "Thêm liên kết",
|
|
21
|
+
galleryImages: "Ảnh trong gallery",
|
|
22
|
+
imageAltN: "Mô tả ảnh {n}",
|
|
23
|
+
removeImage: "Xoá ảnh",
|
|
24
|
+
addImages: "Thêm ảnh",
|
|
21
25
|
contents: "Mục lục",
|
|
22
26
|
menu: "Menu",
|
|
23
27
|
noMenuIsAssigned: "Chưa có menu nào gán cho vị trí này — gán ở Giao diện › Menu, hoặc chọn vị trí khác trong bảng cài đặt.",
|
|
28
|
+
searchLabel: "Tìm kiếm", searchPlaceholder: "Tìm trên website…", searchButton: "Tìm",
|
|
24
29
|
categoryName: "Tên chuyên mục",
|
|
25
30
|
category: "Chuyên mục: ",
|
|
26
31
|
theDescriptionOfThe: "Mô tả của chuyên mục / thẻ đang xem.",
|
package/src/locales/vi/v2.ts
CHANGED
|
@@ -42,6 +42,25 @@ export const v2 = {
|
|
|
42
42
|
alignLeft: "Căn trái",
|
|
43
43
|
alignCenter: "Căn giữa",
|
|
44
44
|
alignRight: "Căn phải",
|
|
45
|
+
width: "Độ rộng",
|
|
46
|
+
ai: "AI",
|
|
47
|
+
aiRewrite: "Viết lại cho hay hơn",
|
|
48
|
+
aiShorten: "Rút gọn",
|
|
49
|
+
aiExpand: "Viết dài hơn",
|
|
50
|
+
aiFix: "Sửa chính tả, ngữ pháp",
|
|
51
|
+
aiSummarize: "Tóm tắt",
|
|
52
|
+
aiTranslateEn: "Dịch sang tiếng Anh",
|
|
53
|
+
aiTranslateVi: "Dịch sang tiếng Việt",
|
|
54
|
+
aiCustom: "Yêu cầu khác…",
|
|
55
|
+
aiCustomPrompt: "Bạn muốn AI làm gì với đoạn này?",
|
|
56
|
+
aiWorking: "AI đang viết…",
|
|
57
|
+
aiNote: "Kiểm tra lại trước khi dùng — AI có thể sai. Thay thế xong vẫn hoàn tác được (⌘Z).",
|
|
58
|
+
aiReplace: "Thay thế",
|
|
59
|
+
aiInsertBelow: "Chèn bên dưới",
|
|
60
|
+
aiRetry: "Thử lại",
|
|
61
|
+
widthDefault: "Theo cột chữ",
|
|
62
|
+
widthWide: "Rộng",
|
|
63
|
+
widthFull: "Toàn trang",
|
|
45
64
|
devices: "Thiết bị",
|
|
46
65
|
deviceDesktop: "Máy tính",
|
|
47
66
|
deviceTablet: "Máy tính bảng",
|
|
@@ -119,6 +138,8 @@ export const v2 = {
|
|
|
119
138
|
deleteRow: "Xoá hàng",
|
|
120
139
|
deleteColumn: "Xoá cột",
|
|
121
140
|
mergeRight: "Gộp với ô bên phải",
|
|
141
|
+
mergeCells: "Gộp các ô đã chọn",
|
|
142
|
+
clearCells: "Xoá nội dung ô",
|
|
122
143
|
mergeDown: "Gộp với ô bên dưới",
|
|
123
144
|
splitCell: "Tách ô",
|
|
124
145
|
toolbarHint: "Chọn một khối để hiện công cụ của khối ở đây",
|
|
@@ -172,6 +193,8 @@ export const v2 = {
|
|
|
172
193
|
createPattern: "Tạo mẫu",
|
|
173
194
|
lock: "Khoá…",
|
|
174
195
|
locked: "Đang khoá",
|
|
196
|
+
collapse: "Thu gọn",
|
|
197
|
+
expand: "Mở rộng",
|
|
175
198
|
lockTitle: "Khoá khối",
|
|
176
199
|
lockMove: "Không cho di chuyển",
|
|
177
200
|
lockRemove: "Không cho xoá",
|
|
@@ -182,4 +205,5 @@ export const v2 = {
|
|
|
182
205
|
choiceSelect: "— Chọn —",
|
|
183
206
|
choiceMissing: "(không còn)",
|
|
184
207
|
openInNewTab: "Mở trong tab mới",
|
|
208
|
+
countdownNoTarget: "Chưa chọn thời điểm kết thúc — đặt ở ô “Thời điểm” bên phải (khi chưa đặt, website không hiện khối này)",
|
|
185
209
|
};
|
|
@@ -9,9 +9,11 @@ const EMPTY: CSSProperties = { background: "linear-gradient(to top right, transp
|
|
|
9
9
|
*/
|
|
10
10
|
export function ColorSwatchInput({ value, onChange, label, className, size = 26 }: { value?: string; onChange(hex: string): void; label: string; className?: string; size?: number }) {
|
|
11
11
|
const hex = value && /^#[0-9a-f]{6}$/i.test(value) ? value : undefined;
|
|
12
|
+
// rgb()/hsl()/tên màu hợp lệ cũng hiện đúng màu (bảng chọn của trình duyệt vẫn chỉ nhận #rrggbb nên ô input giữ `hex`)
|
|
13
|
+
const shown = hex ?? (value && typeof CSS !== "undefined" && CSS.supports?.("color", value) ? value : undefined);
|
|
12
14
|
return (
|
|
13
|
-
<label className={className} title={
|
|
14
|
-
style={{ position: "relative", display: "inline-block", width: size, height: size, flex: "none", borderRadius: 6, border: "1px solid rgb(0 0 0 / .18)", cursor: "pointer", overflow: "hidden", ...(
|
|
15
|
+
<label className={className} title={shown ?? label} data-empty={shown ? undefined : ""}
|
|
16
|
+
style={{ position: "relative", display: "inline-block", width: size, height: size, flex: "none", borderRadius: 6, border: "1px solid rgb(0 0 0 / .18)", cursor: "pointer", overflow: "hidden", ...(shown ? { background: shown } : EMPTY) }}>
|
|
15
17
|
<input type="color" aria-label={label} value={hex ?? "#ffffff"} onChange={(e) => onChange(e.target.value)}
|
|
16
18
|
style={{ position: "absolute", inset: 0, width: "100%", height: "100%", opacity: 0, cursor: "pointer", border: 0, padding: 0 }} />
|
|
17
19
|
</label>
|
package/src/v2/blocks/compat.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { blockDefaults } from "@ecomcx/ecomweb-content";
|
|
1
2
|
import { Blocks } from "lucide-react";
|
|
2
3
|
import type { ComponentType } from "react";
|
|
3
4
|
import { blockOptions, onBlockDefinitionsChange, registeredBlocks, type BlockEditProps as V1EditProps } from "../../shared/block-defs";
|
|
@@ -40,7 +41,8 @@ export function syncPluginBlocks(registry: BlockTypeRegistry): () => void {
|
|
|
40
41
|
// Không có xem trước riêng và không chứa khối con → website vẽ bằng renderer của theme/plugin (viết khối một lần)
|
|
41
42
|
serverRender: !o.edit && def.content !== "blocks",
|
|
42
43
|
create: (attrs) => {
|
|
43
|
-
|
|
44
|
+
// blockDefaults kèm "_v" = phiên bản khối: thiếu nó website coi dữ liệu mới là bản 1 rồi chạy migrate lên dữ liệu đã ở bản mới
|
|
45
|
+
const defaults = blockDefaults(def);
|
|
44
46
|
const content = def.content === "blocks" ? (o.initialContent?.() ?? [{ type: "paragraph" }]).map((n) => fromRich(n as never)) : undefined;
|
|
45
47
|
return makeBlock(def.name, { ...defaults, ...attrs }, content);
|
|
46
48
|
},
|
package/src/v2/blocks/layout.tsx
CHANGED
|
@@ -160,9 +160,11 @@ function ShortcodeEdit({ block, blockProps }: BlockEditProps) {
|
|
|
160
160
|
return <div {...(merge(blockProps, "ecx-shortcode", { fontFamily: "monospace", opacity: 0.8 }) as object)}>[{String(block.attrs.name || "shortcode")}]</div>;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
function CountdownEdit({ block, blockProps }: BlockEditProps) {
|
|
163
|
+
function CountdownEdit({ block, blockProps, labels }: BlockEditProps) {
|
|
164
164
|
const a = block.attrs;
|
|
165
|
-
|
|
165
|
+
// Thiếu / sai thời điểm: website không vẽ khối → trong trình soạn nói rõ, không để khối "mất tích" im lặng
|
|
166
|
+
if (!Number.isFinite(Date.parse(String(a.target ?? "")))) return <div {...(merge(blockProps, "ecx-countdown ecx-placeholder-block", {}) as object)}>{a.label ? <strong>{String(a.label)}</strong> : null}<span>{labels.countdownNoTarget}</span></div>;
|
|
167
|
+
return <div {...(merge(blockProps, "ecx-countdown", { textAlign: "center" }) as object)}>{a.label ? <p style={{ margin: 0 }}>{String(a.label)}</p> : null}<strong>{String(a.target)}</strong></div>;
|
|
166
168
|
}
|
|
167
169
|
|
|
168
170
|
function RatingEdit({ block, blockProps }: BlockEditProps) {
|
|
@@ -250,7 +252,7 @@ export function layoutBlocks(): BlockType[] {
|
|
|
250
252
|
return [
|
|
251
253
|
{
|
|
252
254
|
name: "group", title: "Nhóm", icon: Square, category: "design", keywords: "nhom group khung section container", kind: "container", edit: GroupEdit,
|
|
253
|
-
attributes: { background: { type: "string", control: "color" }, textColor: { type: "string", control: "color" }, padding: { type: "string", enum: ["none", "small", "medium", "large"], default: "medium" } },
|
|
255
|
+
attributes: { background: { type: "string", control: "color" }, textColor: { type: "string", control: "color" }, padding: { type: "string", enum: ["none", "small", "medium", "large"], default: "medium" }, constrained: { type: "boolean", default: false } },
|
|
254
256
|
create: (attrs) => makeBlock("group", attrs ?? {}, [makeBlock("paragraph")]),
|
|
255
257
|
toolbar: GroupLayoutTools,
|
|
256
258
|
variations: [
|
|
@@ -334,7 +336,7 @@ export function layoutBlocks(): BlockType[] {
|
|
|
334
336
|
},
|
|
335
337
|
{
|
|
336
338
|
name: "cover", title: "Ảnh bìa", icon: ImageIcon, category: "media", keywords: "anh bia cover banner hero", kind: "container", edit: CoverEdit,
|
|
337
|
-
attributes: { src: { type: "url", control: "media" }, alt: { type: "string" }, overlay: { type: "string", control: "color" }, opacity: { type: "integer", default: 50, min: 0, max: 100 }, minHeight: { type: "string", default: "400px" }, contentAlign: { type: "string", enum: ["top", "center", "bottom"], default: "center" }, fixed: { type: "boolean", default: false } },
|
|
339
|
+
attributes: { src: { type: "url", control: "media" }, alt: { type: "string" }, overlay: { type: "string", control: "color" }, opacity: { type: "integer", default: 50, min: 0, max: 100 }, minHeight: { type: "string", default: "400px" }, contentAlign: { type: "string", enum: ["top", "center", "bottom"], default: "center" }, fixed: { type: "boolean", default: false }, constrained: { type: "boolean", default: false } },
|
|
338
340
|
create: () => makeBlock("cover", { opacity: 50, minHeight: "400px" }, [makeBlock("heading", { level: 2, textAlign: "center" })]),
|
|
339
341
|
supports: { style: true, anchor: true, className: true },
|
|
340
342
|
},
|
|
@@ -3,6 +3,7 @@ import { Link2, Upload } from "lucide-react";
|
|
|
3
3
|
import { useRef, useState, type DragEvent, type ReactNode } from "react";
|
|
4
4
|
import type { MediaItem, MediaKind } from "../../shared/types";
|
|
5
5
|
import { useEditor } from "../context";
|
|
6
|
+
import { mediaSrcsets } from "../core/media";
|
|
6
7
|
|
|
7
8
|
const cx = (...c: unknown[]) => c.filter((x): x is string => typeof x === "string" && x !== "").join(" ");
|
|
8
9
|
const ACCEPT: Record<MediaKind, string> = { image: "image/*", gallery: "image/*", video: "video/*", audio: "audio/*", file: "" };
|
|
@@ -11,7 +12,7 @@ const ACCEPT: Record<MediaKind, string> = { image: "image/*", gallery: "image/*"
|
|
|
11
12
|
export function mediaAttrs(kind: MediaKind, items: MediaItem[]): Record<string, unknown> {
|
|
12
13
|
if (kind === "gallery") return { images: items.map((m) => ({ src: m.url, alt: m.alt, width: m.width ?? undefined, height: m.height ?? undefined, id: m.id })) };
|
|
13
14
|
const m = items[0];
|
|
14
|
-
return { src: m.url, alt: kind === "image" ? m.alt || undefined : undefined, name: kind !== "image" ? m.fileName : undefined, mime: m.mimeType, mediaId: m.id, width: kind === "image" ? m.width ?? undefined : undefined, height: kind === "image" ? m.height ?? undefined : undefined };
|
|
15
|
+
return { src: m.url, alt: kind === "image" ? m.alt || undefined : undefined, name: kind !== "image" ? m.fileName : undefined, mime: m.mimeType, mediaId: m.id, ...(kind === "image" ? mediaSrcsets(m) : {}), width: kind === "image" ? m.width ?? undefined : undefined, height: kind === "image" ? m.height ?? undefined : undefined };
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
/**
|
package/src/v2/blocks/media.tsx
CHANGED
|
@@ -196,6 +196,39 @@ function SocialInspector({ attrs, setAttrs, labels }: BlockEditProps) {
|
|
|
196
196
|
);
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
/** Danh sách ảnh của gallery trong bảng cài đặt: thêm (nhiều ảnh), mô tả (alt) từng ảnh, đổi thứ tự, xoá. */
|
|
200
|
+
function GalleryInspector({ attrs, setAttrs }: BlockEditProps) {
|
|
201
|
+
const t = useMsgs("blocks");
|
|
202
|
+
const { host } = useEditor();
|
|
203
|
+
type Img = { src: string; alt?: string; width?: number; height?: number; id?: number | string };
|
|
204
|
+
const images = (Array.isArray(attrs.images) ? attrs.images : []) as Img[];
|
|
205
|
+
const save = (next: Img[]) => setAttrs({ images: next });
|
|
206
|
+
const patch = (i: number, p: Partial<Img>) => save(images.map((im, k) => (k === i ? { ...im, ...p } : im)));
|
|
207
|
+
const move = (i: number, d: -1 | 1) => { const n = [...images]; [n[i], n[i + d]] = [n[i + d], n[i]]; save(n); };
|
|
208
|
+
const add = async () => {
|
|
209
|
+
if (!host.media) return;
|
|
210
|
+
const items = await host.media.pick({ kind: "image", multiple: true });
|
|
211
|
+
if (items.length) save([...images, ...((mediaAttrs("gallery", items).images ?? []) as Img[])]);
|
|
212
|
+
};
|
|
213
|
+
return (
|
|
214
|
+
<div className="ecx-gallery-editor" role="group" aria-label={t.galleryImages}>
|
|
215
|
+
<span className="ecx-field-label">{t.galleryImages}</span>
|
|
216
|
+
{images.map((im, i) => (
|
|
217
|
+
<div key={`${i}-${im.src}`} className="ecx-social-row" data-gallery-row={i}>
|
|
218
|
+
<img src={isSafeUrl(im.src) ? im.src : ""} alt="" width={36} height={36} style={{ objectFit: "cover", borderRadius: 4, flex: "none" }} />
|
|
219
|
+
<input className="ecx-input" type="text" aria-label={format(t.imageAltN, { n: i + 1 })} placeholder={t.imageAltN.replace("{n}", String(i + 1))} value={im.alt ?? ""} onChange={(e) => patch(i, { alt: e.target.value })} />
|
|
220
|
+
<span className="ecx-social-row-tools">
|
|
221
|
+
<button type="button" className="ecx-tool" aria-label={t.up} disabled={i === 0} onClick={() => move(i, -1)}><ArrowUp className="ecx-icon ecx-icon-sm" /></button>
|
|
222
|
+
<button type="button" className="ecx-tool" aria-label={t.down} disabled={i === images.length - 1} onClick={() => move(i, 1)}><ArrowDown className="ecx-icon ecx-icon-sm" /></button>
|
|
223
|
+
<button type="button" className="ecx-tool" aria-label={t.removeImage} onClick={() => save(images.filter((_, k) => k !== i))}><X className="ecx-icon ecx-icon-sm" /></button>
|
|
224
|
+
</span>
|
|
225
|
+
</div>
|
|
226
|
+
))}
|
|
227
|
+
{host.media && <button type="button" className="ecx-btn" onClick={add}><Plus className="ecx-icon ecx-icon-sm" /> {t.addImages}</button>}
|
|
228
|
+
</div>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
199
232
|
function TocEdit({ block, blockProps, labels }: BlockEditProps) {
|
|
200
233
|
const t = useMsgs("blocks");
|
|
201
234
|
return (
|
|
@@ -227,7 +260,7 @@ export function mediaBlocks(): BlockType[] {
|
|
|
227
260
|
attributes: { ...media, alt: { type: "string", control: "textarea" }, title: { type: "string" }, width: { type: "number" }, height: { type: "number" }, size: { type: "string", default: "large" }, align: { type: "string", enum: ["left", "right", "center", "wide", "full"] }, href: { type: "url" }, linkTarget: { type: "string", enum: ["_self", "_blank"] }, lightbox: { type: "boolean", default: false } },
|
|
228
261
|
supports: { style: true, anchor: true, className: true, blockStyle: true }, summary: (a) => a.alt || a.src,
|
|
229
262
|
},
|
|
230
|
-
{ name: "gallery", title: "Gallery", icon: Images, category: "media", keywords: "gallery bo suu tap nhieu anh album", kind: "atom", edit: GalleryEdit, attributes: { images: { type: "json", default: [] }, columns: { type: "integer", default: 3, min: 1, max: 6 }, caption: { type: "string" }, linkTo: { type: "string", enum: ["none", "media"], default: "media" }, imageCrop: { type: "boolean", default: true }, lightbox: { type: "boolean", default: false } }, supports: { style: true, anchor: true, className: true } },
|
|
263
|
+
{ name: "gallery", title: "Gallery", icon: Images, category: "media", keywords: "gallery bo suu tap nhieu anh album", kind: "atom", edit: GalleryEdit, inspector: GalleryInspector, attributes: { images: { type: "json", default: [] }, columns: { type: "integer", default: 3, min: 1, max: 6 }, caption: { type: "string" }, linkTo: { type: "string", enum: ["none", "media"], default: "media" }, imageCrop: { type: "boolean", default: true }, lightbox: { type: "boolean", default: false } }, supports: { style: true, anchor: true, className: true } },
|
|
231
264
|
{ name: "video", title: "Video", icon: Video, category: "media", keywords: "video mp4 phim", kind: "atom", edit: VideoEdit, attributes: { ...media, name: { type: "string" }, mime: { type: "string" }, poster: { type: "url", control: "media" }, autoplay: { type: "boolean", default: false }, loop: { type: "boolean", default: false }, muted: { type: "boolean", default: false }, controls: { type: "boolean", default: true }, playsInline: { type: "boolean", default: true }, preload: { type: "string", enum: ["none", "metadata", "auto"], default: "metadata" } }, supports: { style: true, anchor: true } },
|
|
232
265
|
{ name: "audio", title: "Âm thanh", icon: Music, category: "media", keywords: "am thanh audio nhac mp3 podcast", kind: "atom", edit: AudioEdit, attributes: { ...media, name: { type: "string" }, mime: { type: "string" }, autoplay: { type: "boolean", default: false }, loop: { type: "boolean", default: false }, preload: { type: "string", enum: ["none", "metadata", "auto"], default: "metadata" } }, supports: { style: true, anchor: true } },
|
|
233
266
|
{ name: "file", title: "Tệp", icon: FileIcon, category: "media", keywords: "tep file pdf tai xuong download tai lieu", kind: "atom", edit: FileEdit, attributes: { ...media, name: { type: "string" }, mime: { type: "string" }, size: { type: "number" }, embed: { type: "boolean", default: true }, download: { type: "boolean" } }, supports: { style: true, anchor: true } },
|
package/src/v2/blocks/theme.tsx
CHANGED
|
@@ -66,10 +66,20 @@ function NavigationEdit({ block, blockProps, selected }: BlockEditProps) {
|
|
|
66
66
|
</div>
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
|
+
/** Giống hệt website (SearchFormClient trong theme-sdk): cùng class `search-form` / `search-button-*`, nhãn, vị trí nút — để CSS của theme và các thuộc tính "Hiện nhãn", "Vị trí nút" thấy ngay trong khung soạn. */
|
|
69
70
|
function SearchEdit({ block, blockProps }: BlockEditProps) {
|
|
71
|
+
const t = useMsgs("blocks");
|
|
72
|
+
const pos = String(block.attrs.buttonPosition ?? "right");
|
|
73
|
+
const button = <button type="button" tabIndex={-1}>{String(block.attrs.buttonText || t.searchButton)}</button>;
|
|
70
74
|
return (
|
|
71
75
|
<div {...merge(blockProps, "ecx-search")}>
|
|
72
|
-
<form onSubmit={(e) => e.preventDefault()}
|
|
76
|
+
<form role="search" onSubmit={(e) => e.preventDefault()} style={pos === "below" ? { display: "flex", flexDirection: "column", gap: 8 } : undefined}
|
|
77
|
+
className={`search-form${pos !== "right" ? ` search-button-${pos}` : ""}`}>
|
|
78
|
+
{block.attrs.showLabel === true && <label className="search-label">{t.searchLabel}</label>}
|
|
79
|
+
{pos === "left" && button}
|
|
80
|
+
<input type="search" placeholder={String(block.attrs.placeholder || t.searchPlaceholder)} aria-label={t.searchLabel} readOnly tabIndex={-1} />
|
|
81
|
+
{pos !== "left" && button}
|
|
82
|
+
</form>
|
|
73
83
|
</div>
|
|
74
84
|
);
|
|
75
85
|
}
|
|
@@ -157,9 +167,35 @@ function PageListEdit({ blockProps }: BlockEditProps) {
|
|
|
157
167
|
function ArchivesEdit({ block, blockProps }: BlockEditProps) {
|
|
158
168
|
return <ul {...merge(blockProps, "ecx-archives")}>{["11/2026", "10/2026"].map((m, i) => <li key={m}>{m}{block.attrs.showCount === false ? "" : ` (${4 - i})`}</li>)}</ul>;
|
|
159
169
|
}
|
|
160
|
-
|
|
170
|
+
/** Cùng markup / class với khu bình luận của website (theme-sdk Comments) → CSS của theme tô canvas như website: 1 bình luận mẫu + form. */
|
|
171
|
+
function CommentsEdit({ block, blockProps }: BlockEditProps) {
|
|
161
172
|
const d = useDynamic();
|
|
162
|
-
|
|
173
|
+
const size = Math.min(128, Math.max(16, Number(block.attrs.avatarSize) || 40));
|
|
174
|
+
const field = { readOnly: true, tabIndex: -1 } as const;
|
|
175
|
+
return (
|
|
176
|
+
<section {...merge(blockProps, "comments-area")}>
|
|
177
|
+
<h2 className="comments-title">{String(block.attrs.title || "Bình luận")} ({d.post?.comments ?? 0})</h2>
|
|
178
|
+
<ol className="comment-list">
|
|
179
|
+
<li className="comment">
|
|
180
|
+
<article>
|
|
181
|
+
<header className="comment-meta">
|
|
182
|
+
<span className="comment-avatar avatar" style={{ display: "inline-block", width: size, height: size, borderRadius: "50%", background: "rgba(127,127,127,.3)", verticalAlign: "middle" }} />
|
|
183
|
+
<b className="comment-author">Người đọc</b>
|
|
184
|
+
{block.attrs.showDate === false ? null : <>{" · "}<time>01/11/2026</time></>}
|
|
185
|
+
</header>
|
|
186
|
+
<div className="comment-content"><p>Bình luận mẫu — website hiện bình luận thật của bài.</p></div>
|
|
187
|
+
</article>
|
|
188
|
+
</li>
|
|
189
|
+
</ol>
|
|
190
|
+
<form className="comment-form" onSubmit={(e) => e.preventDefault()}>
|
|
191
|
+
<h3>Để lại bình luận</h3>
|
|
192
|
+
<p><label>Bình luận *<textarea rows={5} {...field} /></label></p>
|
|
193
|
+
<p className="comment-form-row"><label>Tên *<input {...field} /></label><label>Email *<input type="email" {...field} /></label></p>
|
|
194
|
+
<p><label>Website<input type="url" {...field} /></label></p>
|
|
195
|
+
<p><button type="button" tabIndex={-1}>Gửi bình luận</button></p>
|
|
196
|
+
</form>
|
|
197
|
+
</section>
|
|
198
|
+
);
|
|
163
199
|
}
|
|
164
200
|
/** Tiêu đề trang lưu trữ / tìm kiếm (H1 của trang chuyên mục, thẻ, tác giả…). */
|
|
165
201
|
function QueryTitleEdit({ block, blockProps, labels }: BlockEditProps) {
|
|
@@ -178,7 +214,11 @@ function BreadcrumbsEdit({ block, blockProps, labels }: BlockEditProps) {
|
|
|
178
214
|
const d = useDynamic();
|
|
179
215
|
const t = useMsgs("blocks");
|
|
180
216
|
const sep = String(block.attrs.separator ?? "›");
|
|
181
|
-
|
|
217
|
+
// Như website: giữa = chuyên mục đầu tiên của bài (trang không có thì bỏ), cuối = tiêu đề bài / trang lưu trữ. Chưa có mẫu → chữ giữ chỗ.
|
|
218
|
+
// Host cũ chưa gửi `category` → term đầu tiên (thường là chuyên mục)
|
|
219
|
+
const middle = d.post ? ("category" in d.post ? d.post.category : d.post.terms?.[0]) : d.archive ? undefined : t.category2;
|
|
220
|
+
const current = d.post?.title || d.archive?.title || t.currentPage;
|
|
221
|
+
const items = [...(block.attrs.showHome !== false ? [t.home] : []), ...(middle ? [middle] : []), ...(block.attrs.showCurrent !== false ? [current] : [])];
|
|
182
222
|
return (
|
|
183
223
|
<nav {...(merge(blockProps, "ecx-breadcrumbs") as object)}>
|
|
184
224
|
<ol>{items.map((t, i) => <li key={i}>{i > 0 && <span className="ecx-breadcrumbs-sep" aria-hidden="true">{sep}</span>}{i < items.length - 1 ? <a>{t}</a> : <span>{t}</span>}</li>)}</ol>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeStyle, styleClass } from "@ecomcx/ecomweb-content";
|
|
1
|
+
import { normalizeStyle, styleClass, widthClass } from "@ecomcx/ecomweb-content";
|
|
2
2
|
import { Component, memo, useCallback, useContext, useEffect, useMemo, useRef, type ErrorInfo, type MouseEvent, type ReactElement, type ReactNode } from "react";
|
|
3
3
|
import { DocScopeProvider, LoopPostContext, useDocScope, useEditor, useEditorState } from "../context";
|
|
4
4
|
import { ServerBlock } from "./server-block";
|
|
@@ -42,6 +42,11 @@ export function useBlockProps(block: BNode, state: { selected: boolean; editing:
|
|
|
42
42
|
const rich = target.closest<HTMLElement>("[data-ecx-rich]");
|
|
43
43
|
if (rich && rich.isContentEditable && !e.shiftKey) return; // bấm vào chữ: ProseMirror đặt con trỏ, focus báo đang gõ
|
|
44
44
|
if (target.closest("input, textarea, select, button, [contenteditable=true]") && !e.shiftKey) return;
|
|
45
|
+
// Bấm vào phần đệm của ô bảng: con trỏ vào chữ trong ô (như bấm vào ô của Word / WordPress), không chọn cả ô
|
|
46
|
+
if ((block.type === "tableCell" || block.type === "tableHeader") && !e.shiftKey && !e.metaKey && !e.ctrlKey) {
|
|
47
|
+
const text = block.content?.find((b) => b.inline);
|
|
48
|
+
if (text) { e.preventDefault(); store.focusText(text.id, -1); return; }
|
|
49
|
+
}
|
|
45
50
|
e.preventDefault();
|
|
46
51
|
// Chọn khối: rời ô gõ, đưa focus về khung soạn (phím Delete, ⌘C… thuộc về vùng chọn khối)
|
|
47
52
|
const active = own.ownerDocument.activeElement as HTMLElement | null;
|
|
@@ -67,6 +72,7 @@ export function useBlockProps(block: BNode, state: { selected: boolean; editing:
|
|
|
67
72
|
state.editing && "is-editing",
|
|
68
73
|
state.mode === "disabled" && "is-locked",
|
|
69
74
|
style && styleClass(style),
|
|
75
|
+
widthClass(block.type, a),
|
|
70
76
|
typeof a.blockStyle === "string" && `ecx-is-${a.blockStyle}`,
|
|
71
77
|
typeof a.className === "string" && a.className,
|
|
72
78
|
),
|
|
@@ -14,20 +14,41 @@ body.ecx-canvas-body { padding: 0; }
|
|
|
14
14
|
.ecx-edit-link:hover { background: var(--ecx-ui, #1a597b); color: #fff; }
|
|
15
15
|
/* HTML do website vẽ (khối theme/plugin): các lớp hiệu ứng "ẩn tới khi JS chạy" thường gặp luôn ở trạng thái cuối. Theme nên đặt trạng thái ẩn dưới html.ecx-js (chỉ có khi JS chạy) để khỏi phụ thuộc đoán tên lớp. */
|
|
16
16
|
.ecx-server-html [class*="stagger"], .ecx-server-html [class*="reveal"], .ecx-server-html [class*="animate"], .ecx-server-html [class*="fade-"], .ecx-server-html [class*="aos"], .ecx-server-html [data-aos] { opacity: 1 !important; visibility: visible !important; transform: none !important; animation: none !important; transition: none !important; }
|
|
17
|
-
.ecx-canvas-root { min-height: 100vh; padding:
|
|
18
|
-
|
|
19
|
-
.ecx-canvas-root >
|
|
20
|
-
|
|
21
|
-
.ecx-canvas-root.
|
|
17
|
+
.ecx-canvas-root { min-height: 100vh; padding: 52px clamp(1rem, 4vw, 3rem) 40vh; box-sizing: border-box; outline: none; }
|
|
18
|
+
/* --ecx-canvas-col: bề rộng cột của khung soạn; KHÔNG đổi --ecx-content-width (nhóm "giữ chữ theo cột" của nội dung dùng biến đó) */
|
|
19
|
+
.ecx-canvas-root > * { max-width: var(--ecx-canvas-col, var(--ecx-content-width, 760px)); margin-left: auto; margin-right: auto; }
|
|
20
|
+
/* Mặc định của trình soạn: độ ưu tiên chỉ bằng "1 class" (:where) — đứng sau dòng trên nên thắng nó, nhưng CSS theme nạp sau (vd .ecx-template > * { max-width: 960px }) thắng lại, như trên website */
|
|
21
|
+
:where(.ecx-canvas-root) > :is(.ecx-nested, .ecx-cover, [data-type="columns"], .ecx-align-wide) { max-width: var(--ecx-wide-width, 1200px); }
|
|
22
|
+
.ecx-canvas-root.ecx-canvas-root > .ecx-align-full { max-width: none; }
|
|
23
|
+
/* Header/footer trong template: mặc định rộng hết (cùng mức ưu tiên — theme giới hạn bề rộng phần con của template thì canvas theo) */
|
|
24
|
+
:where(.ecx-canvas-root) > .ecx-template-part { max-width: none; }
|
|
25
|
+
/* Template rộng (full-width / canvas có sẵn): như website — chữ vẫn ở cột chữ, khối Rộng / Toàn trang mới tràn ra */
|
|
26
|
+
.ecx-canvas-root.is-wide { --ecx-canvas-col: var(--ecx-content-width, 760px); }
|
|
22
27
|
/* Template (theme dựng bằng khối): website không giới hạn bề rộng khối con và không có lề soạn — canvas làm y hệt, theme tự quyết bằng CSS của nó
|
|
23
28
|
(chỉ đổi giá trị mặc định của biến, nên CSS theme vẫn thắng nếu có đặt max-width cho .ecx-template > *). */
|
|
24
|
-
.ecx-canvas-root.ecx-template, .ecx-canvas-root.entry-content { --ecx-
|
|
29
|
+
.ecx-canvas-root.ecx-template, .ecx-canvas-root.entry-content { --ecx-canvas-col: none; padding-left: 0; padding-right: 0; }
|
|
30
|
+
/* padding-top 52px (canvas mặc định + template) = chỗ cho thanh công cụ nổi (44px + 8) trên khối đầu: thiếu chỗ thì thanh đè lên chữ, bấm vào khối trúng nút của thanh.
|
|
31
|
+
Bài (.entry-content): ô tiêu đề nằm trên khối đầu nên đã đủ chỗ — giữ 0 như website (thêm khoảng làm khung bao của trang bài lệch so với lúc mở) */
|
|
32
|
+
.ecx-canvas-root.entry-content { padding-top: 0; }
|
|
33
|
+
/* Vùng bài của template full-width / canvas có sẵn (.ecx-layout-constrained): cột chữ + lề hai bên như website */
|
|
34
|
+
.ecx-canvas-root.ecx-canvas-root.ecx-layout-constrained { --ecx-canvas-col: var(--ecx-content-width, 760px); padding-left: var(--ecx-gutter, 1.25rem); padding-right: var(--ecx-gutter, 1.25rem); }
|
|
35
|
+
.ecx-canvas-root.ecx-layout-constrained > :is(.ecx-nested, .ecx-cover, [data-type="columns"]):not(.ecx-align-wide, .ecx-align-full) { max-width: var(--ecx-canvas-col); }
|
|
36
|
+
:where(.ecx-canvas-root.ecx-template, .ecx-canvas-root.entry-content) > :is(.ecx-nested, .ecx-cover, [data-type="columns"]) { max-width: none; }
|
|
37
|
+
/* Khối "Rộng" / "Toàn trang" (align wide/full): bề rộng và lề âm do style.css của @ecomcx/ecomweb-content (như website), canvas chỉ bỏ giới hạn */
|
|
38
|
+
:where(.ecx-canvas-root.ecx-template, .ecx-canvas-root.entry-content) > :is(.ecx-align-wide, .ecx-align-full) { max-width: none; }
|
|
39
|
+
/* Lề tự căn giữa của khung soạn (.ecx-canvas-root > * margin auto) không được đè lề âm của khối rộng / toàn trang */
|
|
40
|
+
.ecx-canvas-root > :is(.ecx-align-wide, .ecx-align-full) { margin-left: calc((100% - var(--_w, 100%)) / 2); margin-right: calc((100% - var(--_w, 100%)) / 2); }
|
|
25
41
|
/* Soạn bài / trang trong khung của website (class entry-content do PostContent đặt): bề rộng cột do theme quyết định, không phải 760px của trình soạn */
|
|
26
42
|
|
|
27
43
|
.ecx-block { position: relative; scroll-margin: 80px; }
|
|
28
44
|
.ecx-block:focus { outline: none; }
|
|
29
45
|
.ecx-block:not([data-ecx-rich]):hover:not(:has(.ecx-block:hover)) { outline: 1px solid color-mix(in srgb, var(--ecx-ui) 40%, transparent); outline-offset: 3px; }
|
|
30
46
|
.ecx-block.is-selected { outline: 2px solid var(--ecx-ui) !important; outline-offset: 3px; }
|
|
47
|
+
/* Ô bảng đang chọn (một hoặc cả vùng): tô màu như bôi đen, không viền (viền ô chồng lên viền bảng) */
|
|
48
|
+
.ecx-block.is-selected:is([data-type="tableCell"], [data-type="tableHeader"]) { outline: none !important; box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--ecx-ui) 16%, transparent); }
|
|
49
|
+
.ecx-block.is-selected:is([data-type="tableCell"], [data-type="tableHeader"], [data-type="tableRow"])::after { display: none; }
|
|
50
|
+
/* Đang kéo bôi vùng ô: tắt bôi chữ của trình duyệt (chỉ tô ô) */
|
|
51
|
+
.ecx-cell-selecting, .ecx-cell-selecting * { user-select: none !important; -webkit-user-select: none !important; caret-color: transparent; }
|
|
31
52
|
/* Nhãn loại khối (chỉ khi chọn, khối cấp thường; khối lồng đã có .ecx-nested-label). Không đổi bố cục: absolute, không nhận chuột */
|
|
32
53
|
.ecx-block.is-selected:not(.ecx-nested):not(.ecx-column)[data-type]::after { content: attr(data-ecx-title); position: absolute; left: -2px; top: -3px; transform: translateY(-100%); padding: 1px 8px; border-radius: 4px 4px 0 0; background: var(--ecx-ui); color: #fff; font: 600 11px/1.7 var(--ecx-ui-font); letter-spacing: 0; text-transform: none; white-space: nowrap; pointer-events: none; z-index: 5; }
|
|
33
54
|
.ecx-block.is-selected[data-ecx-title=""]::after { content: none; }
|
|
@@ -39,7 +60,9 @@ pre [data-ecx-rich], pre[data-ecx-rich] { white-space: pre-wrap; }
|
|
|
39
60
|
[data-ecx-rich][data-empty]:not([data-placeholder-always]):not(:focus)::before { content: none; }
|
|
40
61
|
[data-ecx-rich][data-empty] { position: relative; }
|
|
41
62
|
/* min(100%, …) = 0 trong khung co theo nội dung (nút) → dùng độ dài chữ gợi ý, chặn tràn bằng max-width */
|
|
42
|
-
|
|
63
|
+
/* Chỉ ô chữ dạng span (nút, nhãn…): đoạn văn trống KHÔNG đặt max-width — luật này ưu tiên cao hơn cột chữ của khung soạn,
|
|
64
|
+
đoạn trống sẽ rộng hết khung và lệch khỏi cột (gõ chữ vào mới nhảy về) */
|
|
65
|
+
span[data-ecx-rich][data-empty][data-placeholder] { min-width: calc(var(--ecx-ph, 0) * .6em); max-width: 100%; }
|
|
43
66
|
span[data-ecx-rich][data-empty][data-placeholder] { display: inline-block; vertical-align: top; }
|
|
44
67
|
[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 */
|
|
45
68
|
[data-ecx-rich][data-empty][data-placeholder]::before { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
|
|
@@ -50,7 +73,7 @@ span[data-ecx-rich][data-empty][data-placeholder] { display: inline-block; verti
|
|
|
50
73
|
.ecx-block.is-locked { pointer-events: none; }
|
|
51
74
|
.ecx-block.is-locked .ecx-nested:not(.is-locked), .ecx-block.is-locked [data-ecx-editable-doc] { pointer-events: auto; }
|
|
52
75
|
|
|
53
|
-
.ecx-default-appender { cursor: text; color: #5d6a75; margin: 0; padding: .25em 0; }
|
|
76
|
+
.ecx-default-appender { cursor: text; color: #5d6a75; margin-top: 0; margin-bottom: 0; padding: .25em 0; } /* lề trái/phải auto như khối khác (thẳng cột chữ) */
|
|
54
77
|
.ecx-default-appender:focus { outline: none; }
|
|
55
78
|
.ecx-appender { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; margin: 0; border: 1px dashed color-mix(in srgb, currentColor 30%, transparent); border-radius: 4px; background: transparent; color: inherit; font: 600 20px/1 var(--ecx-ui-font); cursor: pointer; opacity: .6; }
|
|
56
79
|
.ecx-appender:hover { opacity: 1; border-color: var(--ecx-ui); color: var(--ecx-ui); }
|
|
@@ -100,6 +123,8 @@ body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select:
|
|
|
100
123
|
.ecx-doc-title { margin-top: 0; }
|
|
101
124
|
.ecx-doc-title-input { display: block; width: 100%; margin: 0; padding: 0; border: 0; outline: none; resize: none; overflow: hidden; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; line-height: inherit; text-align: inherit; }
|
|
102
125
|
.ecx-doc-title-input::placeholder { color: inherit; opacity: .35; }
|
|
126
|
+
/* 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 */
|
|
127
|
+
.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; }
|
|
103
128
|
.ecx-col-handles { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
|
|
104
129
|
.ecx-col-handle { position: absolute; width: 12px; margin-left: -6px; cursor: col-resize; pointer-events: auto; touch-action: none; }
|
|
105
130
|
.ecx-col-handle::after { content: ""; position: absolute; left: 5px; top: 0; bottom: 0; width: 2px; background: var(--ecx-ui); opacity: .35; border-radius: 1px; }
|