@ecomcx/ecomweb-editor 1.19.0 → 1.20.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 +1 -1
- package/src/v2/blocks/media.tsx +3 -3
- package/src/v2/blocks/text.tsx +2 -1
- package/src/v2/blocks/theme.tsx +2 -2
- package/src/v2/editor.css +15 -1
- package/src/v2/labels.ts +8 -0
- package/src/v2/ui/attr-hints.ts +21 -1
- package/src/v2/ui/toolbar.tsx +10 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecomcx/ecomweb-editor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.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": {
|
package/src/v2/blocks/media.tsx
CHANGED
|
@@ -218,12 +218,12 @@ export function mediaBlocks(): BlockType[] {
|
|
|
218
218
|
return [
|
|
219
219
|
{
|
|
220
220
|
name: "image", title: "Ảnh", icon: ImageIcon, category: "media", keywords: "anh hinh image photo", kind: "atom", edit: ImageEdit,
|
|
221
|
-
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"] } },
|
|
221
|
+
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"] } },
|
|
222
222
|
supports: { style: true, anchor: true, className: true, blockStyle: true }, summary: (a) => a.alt || a.src,
|
|
223
223
|
},
|
|
224
224
|
{ 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" } }, supports: { style: true, anchor: true, className: true } },
|
|
225
|
-
{ 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" } }, supports: { style: true, anchor: true } },
|
|
226
|
-
{ 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" } }, supports: { style: true, anchor: true } },
|
|
225
|
+
{ 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 } },
|
|
226
|
+
{ 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 } },
|
|
227
227
|
{ 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 } },
|
|
228
228
|
{ name: "youtube", title: "YouTube", icon: Play, category: "embed", keywords: "video youtube", kind: "atom", edit: YoutubeEdit, attributes: { src: { type: "url" }, start: { type: "integer" } }, supports: { style: true, anchor: true } },
|
|
229
229
|
{ name: "embed", title: "Nhúng", icon: Globe, category: "embed", keywords: "nhung embed youtube vimeo tiktok facebook twitter x instagram spotify google map", kind: "atom", edit: EmbedEdit, attributes: { url: { type: "url" }, caption: { type: "string" } }, supports: { style: true, anchor: true }, summary: (a) => a.url },
|
package/src/v2/blocks/text.tsx
CHANGED
|
@@ -114,7 +114,7 @@ export function textBlocks(): BlockType[] {
|
|
|
114
114
|
},
|
|
115
115
|
{
|
|
116
116
|
name: "orderedList", title: "Danh sách số", icon: ListOrdered, category: "text", keywords: "danh sach so ordered number ol", kind: "container", edit: ListEdit,
|
|
117
|
-
attributes: { start: { type: "integer", default: 1, min: 1 } },
|
|
117
|
+
attributes: { start: { type: "integer", default: 1, min: 1 }, reversed: { type: "boolean", default: false } },
|
|
118
118
|
create: () => makeBlock("orderedList", {}, [makeBlock("listItem", {}, [makeBlock("paragraph")])]),
|
|
119
119
|
supports: { style: true, anchor: true, className: true }, transforms: textTransforms("orderedList"),
|
|
120
120
|
},
|
|
@@ -126,6 +126,7 @@ export function textBlocks(): BlockType[] {
|
|
|
126
126
|
{ name: "taskItem", title: "Việc", icon: ListChecks, kind: "container", edit: TaskItemEdit, hidden: true, attributes: { checked: { type: "boolean", default: false } } },
|
|
127
127
|
{
|
|
128
128
|
name: "blockquote", title: "Trích dẫn", icon: Quote, category: "text", keywords: "trich dan quote blockquote", kind: "container", edit: QuoteEdit,
|
|
129
|
+
attributes: { citation: { type: "string" } },
|
|
129
130
|
create: () => makeBlock("blockquote", {}, [makeBlock("paragraph")]),
|
|
130
131
|
supports: { style: true, anchor: true, className: true, blockStyle: true },
|
|
131
132
|
transforms: [{ to: "paragraph", convert: toTextBlocks("paragraph"), multiple: true }, { to: "pullquote", convert: (b) => [makeBlock("pullquote", {}, textsOf(b)[0] ?? [])] }],
|
package/src/v2/blocks/theme.tsx
CHANGED
|
@@ -270,7 +270,7 @@ export function themeBlocks(): BlockType[] {
|
|
|
270
270
|
{ name: "postContent", title: "Nội dung bài", icon: FileText, category: theme, keywords: "noi dung bai post content", kind: "atom", edit: PostContentEdit },
|
|
271
271
|
{ name: "postExcerpt", title: "Tóm tắt bài", icon: FileText, category: theme, keywords: "tom tat excerpt", kind: "atom", edit: PostExcerptEdit, attributes: { moreText: { type: "string" } }, supports: { style: true, className: true } },
|
|
272
272
|
{ name: "featuredImage", title: "Ảnh đại diện", icon: ImageIcon, category: theme, keywords: "anh dai dien featured image thumbnail", kind: "atom", edit: FeaturedImageEdit, attributes: { size: { type: "string", default: "large" }, link: { type: "boolean", default: false }, aspect: { type: "string", enum: ["auto", "16/9", "4/3", "1/1", "3/4"], default: "auto" } }, supports: { style: true, className: true } },
|
|
273
|
-
{ name: "postDate", title: "Ngày đăng", icon: CalendarDays, category: theme, keywords: "ngay dang date", kind: "atom", edit: PostDateEdit, attributes: { textAlign: TEXT_ALIGN }, supports: { style: true, className: true } },
|
|
273
|
+
{ name: "postDate", title: "Ngày đăng", icon: CalendarDays, category: theme, keywords: "ngay dang date", kind: "atom", edit: PostDateEdit, attributes: { textAlign: TEXT_ALIGN, displayType: { type: "string", enum: ["published", "modified"], default: "published" } }, supports: { style: true, className: true } },
|
|
274
274
|
{ name: "postAuthor", title: "Tác giả", icon: User, category: theme, keywords: "tac gia author", kind: "atom", edit: PostAuthorEdit, attributes: { avatar: { type: "boolean", default: false } }, supports: { style: true, className: true } },
|
|
275
275
|
{ name: "postTerms", title: "Chuyên mục / thẻ", icon: Tag, category: theme, keywords: "chuyen muc the category tag terms", kind: "atom", edit: PostTermsEdit, attributes: { taxonomy: { type: "string", default: "category" }, separator: { type: "string", default: ", " } }, supports: { style: true, className: true } },
|
|
276
276
|
{ name: "comments", title: "Bình luận", icon: MessageSquare, category: theme, keywords: "binh luan comments", kind: "atom", edit: CommentsEdit },
|
|
@@ -280,7 +280,7 @@ export function themeBlocks(): BlockType[] {
|
|
|
280
280
|
{ name: "postNavigation", title: "Bài trước / bài sau", icon: ArrowLeftRight, category: theme, keywords: "bai truoc bai sau dieu huong post navigation", kind: "atom", edit: PostNavigationEdit, attributes: { showTitle: { type: "boolean", default: true } }, supports: { style: true, className: true } },
|
|
281
281
|
{
|
|
282
282
|
name: "query", title: "Danh sách bài", icon: Rows3, category: theme, keywords: "danh sach bai query loop tin tuc", kind: "container", edit: QueryEdit,
|
|
283
|
-
attributes: { inherit: { type: "boolean", default: true }, postType: { type: "string", default: "post" }, perPage: { type: "integer", default: 10, min: 1, max: 100 }, category: { type: "string" }, tag: { type: "string" }, orderBy: { type: "string", enum: ["date", "title", "menu_order"], default: "date" }, order: { type: "string", enum: ["desc", "asc"], default: "desc" } },
|
|
283
|
+
attributes: { inherit: { type: "boolean", default: true }, postType: { type: "string", default: "post" }, perPage: { type: "integer", default: 10, min: 1, max: 100 }, category: { type: "string" }, tag: { type: "string" }, orderBy: { type: "string", enum: ["date", "title", "modified", "menu_order", "comment_count", "rand"], default: "date" }, order: { type: "string", enum: ["desc", "asc"], default: "desc" }, authorId: { type: "integer", min: 1 }, search: { type: "string" }, exclude: { type: "string" }, sticky: { type: "string", enum: ["any", "only", "exclude"], default: "any" }, orderByMeta: { type: "string" }, paginate: { type: "boolean", default: false } },
|
|
284
284
|
create: () => makeBlock("query", { inherit: true }, [makeBlock("postTemplate", { layout: "list" }, [makeBlock("postTitle", { level: 2, link: true }), makeBlock("postExcerpt")]), makeBlock("pagination")]),
|
|
285
285
|
supports: { style: true, className: true },
|
|
286
286
|
},
|
package/src/v2/editor.css
CHANGED
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
.ecx-save { min-width: 92px; margin-left: 6px; }
|
|
75
75
|
|
|
76
76
|
/* Thanh công cụ nổi của khối */
|
|
77
|
-
.ecx-toolbar { position: fixed; z-index: 30; display: flex; align-items: center; gap: 2px; height: 40px; padding: 3px; background: var(--ecx-ed-panel); border: 1px solid var(--ecx-ed-line);
|
|
77
|
+
.ecx-toolbar { max-width: calc(100vw - 8px); overflow-x: auto; scrollbar-width: none; position: fixed; z-index: 30; display: flex; align-items: center; gap: 2px; height: 40px; padding: 3px; background: var(--ecx-ed-panel); border: 1px solid var(--ecx-ed-line);
|
|
78
78
|
border-radius: 8px; box-shadow: var(--ecx-ed-shadow); color: var(--ecx-ed-fg); animation: ecx-pop .16s var(--ecx-ed-ease); }
|
|
79
79
|
.ecx-toolbar .ecx-tool-group { position: relative; gap: 1px; padding: 0 2px; }
|
|
80
80
|
.ecx-toolbar .ecx-tool-group + .ecx-tool-group::before { content: ""; position: absolute; left: -1px; top: 6px; bottom: 6px; width: 1px; background: var(--ecx-ed-line); }
|
|
@@ -308,3 +308,17 @@ body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select:
|
|
|
308
308
|
.ecx-block-preview { position: fixed; z-index: 70; width: 280px; padding: 14px 16px; border: 1px solid var(--ecx-ed-line); border-radius: 10px; background: var(--ecx-ed-panel); box-shadow: var(--ecx-ed-shadow); pointer-events: none; display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; }
|
|
309
309
|
.ecx-block-preview strong { font-weight: 600; }
|
|
310
310
|
.ecx-block-preview p { grid-column: 1 / -1; margin: 0; color: var(--ecx-ed-muted); font-size: 13px; line-height: 1.5; }
|
|
311
|
+
|
|
312
|
+
/* Màn hẹp / cảm ứng */
|
|
313
|
+
@media (max-width: 600px) {
|
|
314
|
+
.ecx-prefs { flex-direction: column; }
|
|
315
|
+
.ecx-prefs-tabs { width: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--ecx-ed-line); }
|
|
316
|
+
.ecx-prefs-tabs button { flex: none; gap: 6px; }
|
|
317
|
+
.ecx-prefs-body { padding: 8px 12px 16px; }
|
|
318
|
+
.ecx-block-visibility { grid-template-columns: minmax(0, 1fr); }
|
|
319
|
+
}
|
|
320
|
+
@media (pointer: coarse) {
|
|
321
|
+
.ecx-toolbar { height: 48px; }
|
|
322
|
+
.ecx-toolbar .ecx-tool { height: 40px; min-width: 38px; }
|
|
323
|
+
.ecx-movers .ecx-tool { height: 20px; min-width: 30px; }
|
|
324
|
+
}
|
package/src/v2/labels.ts
CHANGED
|
@@ -27,6 +27,10 @@ export const viV2 = {
|
|
|
27
27
|
italic: "Nghiêng",
|
|
28
28
|
underline: "Gạch chân",
|
|
29
29
|
strike: "Gạch ngang",
|
|
30
|
+
subscript: "Chữ nhỏ ở dưới",
|
|
31
|
+
superscript: "Chữ nhỏ ở trên",
|
|
32
|
+
highlight: "Làm nổi bật",
|
|
33
|
+
moreFormats: "Định dạng khác",
|
|
30
34
|
code: "Mã",
|
|
31
35
|
link: "Liên kết",
|
|
32
36
|
unlink: "Bỏ liên kết",
|
|
@@ -198,6 +202,10 @@ export const enV2: V2Labels = {
|
|
|
198
202
|
italic: "Italic",
|
|
199
203
|
underline: "Underline",
|
|
200
204
|
strike: "Strikethrough",
|
|
205
|
+
subscript: "Subscript",
|
|
206
|
+
superscript: "Superscript",
|
|
207
|
+
highlight: "Highlight",
|
|
208
|
+
moreFormats: "More formatting",
|
|
201
209
|
code: "Code",
|
|
202
210
|
link: "Link",
|
|
203
211
|
unlink: "Remove link",
|
package/src/v2/ui/attr-hints.ts
CHANGED
|
@@ -37,6 +37,15 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
|
|
|
37
37
|
"*.textAlign": { control: "segmented", options: [...ALIGN, ["justify", "Đều hai bên", "Justify"]] },
|
|
38
38
|
"*.mime": { control: "hidden" },
|
|
39
39
|
"video.name": { control: "hidden" },
|
|
40
|
+
"video.autoplay": { label: ["Tự phát (sẽ tắt tiếng)", "Autoplay (muted)"] },
|
|
41
|
+
"video.loop": { label: ["Lặp lại", "Loop"] },
|
|
42
|
+
"video.muted": { label: ["Tắt tiếng", "Muted"] },
|
|
43
|
+
"video.controls": { label: ["Hiện thanh điều khiển", "Show controls"] },
|
|
44
|
+
"video.playsInline": { label: ["Phát ngay trong trang (iPhone)", "Play inline (iPhone)"] },
|
|
45
|
+
"video.preload": { control: "select", label: ["Tải trước", "Preload"], options: [["none", "Không", "None"], ["metadata", "Thông tin video", "Metadata"], ["auto", "Cả video", "All"]] },
|
|
46
|
+
"audio.autoplay": { label: ["Tự phát", "Autoplay"] },
|
|
47
|
+
"audio.loop": { label: ["Lặp lại", "Loop"] },
|
|
48
|
+
"audio.preload": { control: "select", label: ["Tải trước", "Preload"], options: [["none", "Không", "None"], ["metadata", "Thông tin", "Metadata"], ["auto", "Cả tệp", "All"]] },
|
|
40
49
|
"file.size": { control: "hidden" },
|
|
41
50
|
"file.name": { label: ["Tên hiển thị", "Display name"] },
|
|
42
51
|
"file.src": { label: ["Tệp", "File"] },
|
|
@@ -82,7 +91,18 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
|
|
|
82
91
|
"query.category": { control: "choice", choice: { kind: "term", args: () => ({ taxonomy: "category" }) }, when: notInherit },
|
|
83
92
|
"query.tag": { control: "choice", choice: { kind: "term", args: () => ({ taxonomy: "post_tag" }) }, when: notInherit },
|
|
84
93
|
"query.perPage": { when: notInherit },
|
|
85
|
-
"query.orderBy": { control: "select", options: [["date", "Ngày đăng", "Date"], ["title", "Tiêu đề", "Title"], ["menu_order", "Thứ tự tự đặt", "Custom order"]], when: notInherit },
|
|
94
|
+
"query.orderBy": { control: "select", options: [["date", "Ngày đăng", "Date"], ["modified", "Ngày sửa", "Modified"], ["title", "Tiêu đề", "Title"], ["comment_count", "Số bình luận", "Comments"], ["menu_order", "Thứ tự tự đặt", "Custom order"], ["rand", "Ngẫu nhiên", "Random"]], when: notInherit },
|
|
95
|
+
"query.authorId": { label: ["Mã tác giả", "Author ID"], when: notInherit },
|
|
96
|
+
"query.search": { label: ["Từ khoá", "Search keyword"], when: notInherit },
|
|
97
|
+
"query.exclude": { label: ["Loại trừ bài (mã, cách nhau bằng dấu phẩy)", "Exclude posts (IDs, comma-separated)"], when: notInherit },
|
|
98
|
+
"query.sticky": { control: "select", options: [["any", "Tất cả", "All"], ["only", "Chỉ bài ghim", "Sticky only"], ["exclude", "Bỏ bài ghim", "Hide sticky"]], when: notInherit },
|
|
99
|
+
"image.href": { label: ["Liên kết khi bấm vào ảnh", "Link when clicked"] },
|
|
100
|
+
"image.linkTarget": { control: "segmented", label: ["Mở liên kết", "Open link"], options: [["_self", "Cùng tab", "Same tab"], ["_blank", "Tab mới", "New tab"]] },
|
|
101
|
+
"orderedList.reversed": { label: ["Đếm ngược", "Reversed"] },
|
|
102
|
+
"blockquote.citation": { label: ["Nguồn trích dẫn", "Citation"] },
|
|
103
|
+
"postDate.displayType": { control: "segmented", label: ["Hiện ngày", "Show date"], options: [["published", "Đăng", "Published"], ["modified", "Sửa lần cuối", "Last modified"]] },
|
|
104
|
+
"query.paginate": { label: ["Phân trang (?qpage=)", "Paginate (?qpage=)"], help: ["Bật khi khối nằm trong trang thường; trang lưu trữ dùng \"Kế thừa\"", "Use on regular pages; archives use \"Inherit\""], when: notInherit },
|
|
105
|
+
"query.orderByMeta": { label: ["Sắp xếp theo trường tuỳ biến", "Order by custom field"], help: ["Khoá phải khai báo filterable; thay cho \"Sắp xếp theo\"", "Key must be declared filterable; replaces \"Order by\""], when: notInherit },
|
|
86
106
|
"query.order": { control: "segmented", options: [["desc", "Mới → cũ / Z → A", "Descending"], ["asc", "Cũ → mới / A → Z", "Ascending"]], when: notInherit },
|
|
87
107
|
"query.inherit": { help: ["Trang danh mục / tìm kiếm / lưu trữ: hiện đúng bài của trang đó", "On archive / search pages, show that page's posts"] },
|
|
88
108
|
"postTemplate.layout": { control: "segmented", options: [["list", "Danh sách", "List"], ["grid", "Lưới", "Grid"]] },
|
package/src/v2/ui/toolbar.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlignCenter, AlignLeft, AlignRight, ArrowUpLeft, Bold, ChevronDown, ChevronUp, Code, Copy, CopyPlus, GripVertical, IndentDecrease, IndentIncrease, Italic, Link2, Link2Off, MoreVertical, PanelTop, Strikethrough, Trash2, Underline, Ungroup, Group as GroupIcon, Blocks, ArrowUpToLine, ArrowDownToLine, Shapes, Lock } from "lucide-react";
|
|
1
|
+
import { AlignCenter, AlignLeft, AlignRight, ArrowUpLeft, Bold, ChevronDown, ChevronUp, Code, Copy, CopyPlus, GripVertical, IndentDecrease, IndentIncrease, Italic, Link2, Link2Off, MoreVertical, PanelTop, Strikethrough, Trash2, Underline, Ungroup, Group as GroupIcon, Blocks, ArrowUpToLine, ArrowDownToLine, Shapes, Lock, Subscript, Superscript, Highlighter } from "lucide-react";
|
|
2
2
|
import { TextSelection } from "prosemirror-state";
|
|
3
3
|
import type { EditorView } from "prosemirror-view";
|
|
4
4
|
import { useEffect, useLayoutEffect, useRef, useState, type ComponentType, type ReactNode } from "react";
|
|
@@ -97,9 +97,10 @@ export function BlockToolbar({ placement = "floating" }: { placement?: "floating
|
|
|
97
97
|
});
|
|
98
98
|
const nodes = ids.map((id) => store.block(id)).filter(Boolean) as BNode[];
|
|
99
99
|
const fixed = placement === "fixed";
|
|
100
|
+
const coarse = typeof matchMedia === "function" && matchMedia("(pointer: coarse)").matches;
|
|
100
101
|
if (fixed !== fixedPref) return null;
|
|
101
102
|
if (fixed && !nodes.length) return <span className="ecx-toolbar-hint">{labels.toolbarHint}</span>;
|
|
102
|
-
if (!nodes.length || ui.drag || ui.inserter?.mode === "slash" || (ui.typing && !link && !fixed)) return null;
|
|
103
|
+
if (!nodes.length || ui.drag || ui.inserter?.mode === "slash" || (ui.typing && !link && !fixed && !coarse)) return null;
|
|
103
104
|
const loc = store.locate(nodes[0].id);
|
|
104
105
|
if (!loc || store.getState().docs[loc.docId].mode === "disabled") return null;
|
|
105
106
|
const frame = ui.canvasFrame?.getBoundingClientRect();
|
|
@@ -117,7 +118,7 @@ export function BlockToolbar({ placement = "floating" }: { placement?: "floating
|
|
|
117
118
|
const transforms = sameType ? (type?.transforms ?? []).filter((t) => nodes.length === 1 || t.multiple) : [];
|
|
118
119
|
const height = 44;
|
|
119
120
|
const top = fixed || !rect || !frame ? 0 : Math.round(Math.max(frame.top + 4, rect.top - height - 8));
|
|
120
|
-
const left = fixed || !rect || !frame ? 0 : Math.round(Math.max(frame.left + 4, Math.min(rect.left, frame.right - 420)));
|
|
121
|
+
const left = fixed || !rect || !frame ? 0 : Math.round(Math.max(frame.left + 4, Math.min(rect.left, frame.right - Math.min(420, window.innerWidth - 8))));
|
|
121
122
|
const editProps = { block: first, attrs: first.attrs, setAttrs: (a: Record<string, unknown>) => store.setAttrs(ids, a), blockProps: null as never, selected: true, editable: true, labels };
|
|
122
123
|
const Extra = sameType && nodes.length === 1 ? type?.toolbar : undefined;
|
|
123
124
|
const hasAlign = sameType && !!type?.attributes?.textAlign;
|
|
@@ -281,11 +282,15 @@ function MarkTools({ view, onLink }: { view: EditorView; onLink(): void }) {
|
|
|
281
282
|
view.dispatch(tr);
|
|
282
283
|
view.focus();
|
|
283
284
|
};
|
|
284
|
-
const
|
|
285
|
+
const main: Array<[string, typeof Bold, string, string]> = [["bold", Bold, labels.bold, `${mod}B`], ["italic", Italic, labels.italic, `${mod}I`], ["underline", Underline, labels.underline, `${mod}U`]];
|
|
286
|
+
const more: Array<[string, typeof Bold, string]> = [["strike", Strikethrough, labels.strike], ["code", Code, labels.code], ["subscript", Subscript, labels.subscript], ["superscript", Superscript, labels.superscript], ["highlight", Highlighter, labels.highlight]];
|
|
285
287
|
return (
|
|
286
288
|
<div className="ecx-tool-group">
|
|
287
|
-
{
|
|
289
|
+
{main.map(([name, I, l, k]) => <ToolButton key={name} label={`${l} (${k})`} active={isActive(name)} onClick={() => toggle(name)}><I className="ecx-icon" /></ToolButton>)}
|
|
288
290
|
<ToolButton label={`${labels.link} (${mod}K)`} active={isActive("link")} onClick={onLink}><Link2 className="ecx-icon" /></ToolButton>
|
|
291
|
+
<Dropdown label={labels.moreFormats} trigger={<ChevronDown className="ecx-icon ecx-icon-sm" />}>
|
|
292
|
+
{(close) => more.map(([name, I, l]) => <MenuItem key={name} icon={I} label={isActive(name) ? `✓ ${l}` : l} onClick={() => { close(); toggle(name); }} />)}
|
|
293
|
+
</Dropdown>
|
|
289
294
|
</div>
|
|
290
295
|
);
|
|
291
296
|
}
|