@enyxs/wikex-components 0.11.19 → 0.11.20
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/dist/index.d.mts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +153 -91
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +154 -92
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/README.md +0 -146
package/dist/index.d.mts
CHANGED
|
@@ -99,6 +99,7 @@ declare function patchCmsRichText(value: unknown, text: string, start: number, e
|
|
|
99
99
|
declare function renderCmsRichText(children: ReactNode, value: unknown, allowLinks?: boolean): ReactNode;
|
|
100
100
|
|
|
101
101
|
declare const CMS_TEXT_FONTS: {
|
|
102
|
+
readonly 'Inter, sans-serif': "Inter";
|
|
102
103
|
readonly 'Arial, sans-serif': "Arial";
|
|
103
104
|
readonly 'Georgia, serif': "Georgia";
|
|
104
105
|
readonly '"Times New Roman", serif': "Times New Roman";
|
|
@@ -110,6 +111,9 @@ type CmsTextLayout = {
|
|
|
110
111
|
height?: number;
|
|
111
112
|
fontFamily?: string;
|
|
112
113
|
fontSize?: number;
|
|
114
|
+
lineHeight?: number;
|
|
115
|
+
textAlign?: "left" | "center" | "right";
|
|
116
|
+
listType?: "ul" | "ol";
|
|
113
117
|
richText?: CmsRichText;
|
|
114
118
|
blockType?: "p" | "h1" | "h2" | "h3" | "ul" | "ol";
|
|
115
119
|
};
|
|
@@ -127,11 +131,14 @@ type CmsTextToolbarProps = {
|
|
|
127
131
|
inlineControls?: ReactNode;
|
|
128
132
|
structureControls?: ReactNode;
|
|
129
133
|
computedFontSize?: number;
|
|
130
|
-
|
|
134
|
+
computedLineHeight?: number;
|
|
135
|
+
computedFontFamily?: string;
|
|
136
|
+
computedTextAlign?: string;
|
|
137
|
+
onLayoutChange: (change: Pick<CmsTextLayout, "fontFamily" | "fontSize" | "lineHeight" | "textAlign">) => void;
|
|
131
138
|
onColorChange: (color: string) => void;
|
|
132
139
|
onReset: () => void;
|
|
133
140
|
};
|
|
134
|
-
declare function CmsTextToolbar({ layout, color, colorPicker, inlineControls, structureControls, computedFontSize, onLayoutChange, onColorChange, onReset }: CmsTextToolbarProps): react.JSX.Element;
|
|
141
|
+
declare function CmsTextToolbar({ layout, color, colorPicker, inlineControls, structureControls, computedFontSize, computedLineHeight, computedFontFamily, computedTextAlign, onLayoutChange, onColorChange, onReset }: CmsTextToolbarProps): react.JSX.Element;
|
|
135
142
|
|
|
136
143
|
declare const CMS_ELEMENTS_FIELD = "__cmsElements";
|
|
137
144
|
type CmsElementState = {
|
package/dist/index.d.ts
CHANGED
|
@@ -99,6 +99,7 @@ declare function patchCmsRichText(value: unknown, text: string, start: number, e
|
|
|
99
99
|
declare function renderCmsRichText(children: ReactNode, value: unknown, allowLinks?: boolean): ReactNode;
|
|
100
100
|
|
|
101
101
|
declare const CMS_TEXT_FONTS: {
|
|
102
|
+
readonly 'Inter, sans-serif': "Inter";
|
|
102
103
|
readonly 'Arial, sans-serif': "Arial";
|
|
103
104
|
readonly 'Georgia, serif': "Georgia";
|
|
104
105
|
readonly '"Times New Roman", serif': "Times New Roman";
|
|
@@ -110,6 +111,9 @@ type CmsTextLayout = {
|
|
|
110
111
|
height?: number;
|
|
111
112
|
fontFamily?: string;
|
|
112
113
|
fontSize?: number;
|
|
114
|
+
lineHeight?: number;
|
|
115
|
+
textAlign?: "left" | "center" | "right";
|
|
116
|
+
listType?: "ul" | "ol";
|
|
113
117
|
richText?: CmsRichText;
|
|
114
118
|
blockType?: "p" | "h1" | "h2" | "h3" | "ul" | "ol";
|
|
115
119
|
};
|
|
@@ -127,11 +131,14 @@ type CmsTextToolbarProps = {
|
|
|
127
131
|
inlineControls?: ReactNode;
|
|
128
132
|
structureControls?: ReactNode;
|
|
129
133
|
computedFontSize?: number;
|
|
130
|
-
|
|
134
|
+
computedLineHeight?: number;
|
|
135
|
+
computedFontFamily?: string;
|
|
136
|
+
computedTextAlign?: string;
|
|
137
|
+
onLayoutChange: (change: Pick<CmsTextLayout, "fontFamily" | "fontSize" | "lineHeight" | "textAlign">) => void;
|
|
131
138
|
onColorChange: (color: string) => void;
|
|
132
139
|
onReset: () => void;
|
|
133
140
|
};
|
|
134
|
-
declare function CmsTextToolbar({ layout, color, colorPicker, inlineControls, structureControls, computedFontSize, onLayoutChange, onColorChange, onReset }: CmsTextToolbarProps): react.JSX.Element;
|
|
141
|
+
declare function CmsTextToolbar({ layout, color, colorPicker, inlineControls, structureControls, computedFontSize, computedLineHeight, computedFontFamily, computedTextAlign, onLayoutChange, onColorChange, onReset }: CmsTextToolbarProps): react.JSX.Element;
|
|
135
142
|
|
|
136
143
|
declare const CMS_ELEMENTS_FIELD = "__cmsElements";
|
|
137
144
|
type CmsElementState = {
|
package/dist/index.js
CHANGED
|
@@ -274,8 +274,7 @@ function CmsAddedElements({ field }) {
|
|
|
274
274
|
value: context.content[item.field] ?? "",
|
|
275
275
|
component: "p",
|
|
276
276
|
sx: {
|
|
277
|
-
font: "inherit"
|
|
278
|
-
my: 1
|
|
277
|
+
font: "inherit"
|
|
279
278
|
},
|
|
280
279
|
editable: context.editable,
|
|
281
280
|
onChange: context.onChange
|
|
@@ -290,9 +289,9 @@ function CmsTextList({ field, type, children }) {
|
|
|
290
289
|
});
|
|
291
290
|
}
|
|
292
291
|
var NativeList = import_styled_components2.default.ul.withConfig({
|
|
293
|
-
componentId: "sc-
|
|
292
|
+
componentId: "sc-4154c689-0"
|
|
294
293
|
})([
|
|
295
|
-
|
|
294
|
+
`> li{display:list-item !important;padding-left:0 !important;}> li::before{content:none !important;}`
|
|
296
295
|
]);
|
|
297
296
|
function CmsTemplateList({ cmsAs, cmsId, children }) {
|
|
298
297
|
const context = (0, import_react.useContext)(ElementContext);
|
|
@@ -319,7 +318,8 @@ function CmsTemplateList({ cmsAs, cmsId, children }) {
|
|
|
319
318
|
const text = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditableText, {
|
|
320
319
|
component: "span",
|
|
321
320
|
sx: {
|
|
322
|
-
font: "inherit"
|
|
321
|
+
font: "inherit",
|
|
322
|
+
display: "block"
|
|
323
323
|
},
|
|
324
324
|
field: added.field,
|
|
325
325
|
value: context?.content[added.field] ?? "M\u1EE5c m\u1EDBi",
|
|
@@ -336,7 +336,8 @@ function CmsTemplateList({ cmsAs, cmsId, children }) {
|
|
|
336
336
|
if (!items.length) return null;
|
|
337
337
|
return /* @__PURE__ */ (0, import_react.createElement)(stored?.type || stored?.marker ? NativeList : cmsAs, {
|
|
338
338
|
...stored?.type || stored?.marker ? {
|
|
339
|
-
as:
|
|
339
|
+
as: cmsAs,
|
|
340
|
+
forwardedAs: stored?.type ?? (stored?.marker === "decimal" || stored?.marker === "lower-alpha" || stored?.marker === "lower-roman" ? "ol" : "ul"),
|
|
340
341
|
style: {
|
|
341
342
|
listStyleType: stored?.marker ?? (stored?.type === "ol" ? "decimal" : "disc")
|
|
342
343
|
}
|
|
@@ -469,6 +470,7 @@ function renderCmsRichText(children, value4, allowLinks = true) {
|
|
|
469
470
|
|
|
470
471
|
// src/shared/text-layout.ts
|
|
471
472
|
var CMS_TEXT_FONTS = {
|
|
473
|
+
"Inter, sans-serif": "Inter",
|
|
472
474
|
"Arial, sans-serif": "Arial",
|
|
473
475
|
"Georgia, serif": "Georgia",
|
|
474
476
|
'"Times New Roman", serif': "Times New Roman",
|
|
@@ -487,6 +489,9 @@ function parseCmsTextLayout(value4) {
|
|
|
487
489
|
if (typeof parsed.fontFamily === "string" && Object.prototype.hasOwnProperty.call(CMS_TEXT_FONTS, parsed.fontFamily)) layout.fontFamily = parsed.fontFamily;
|
|
488
490
|
if (typeof parsed.fontSize === "number" && Number.isFinite(parsed.fontSize) && parsed.fontSize >= 8 && parsed.fontSize <= 300) layout.fontSize = parsed.fontSize;
|
|
489
491
|
if (["p", "h1", "h2", "h3", "ul", "ol"].includes(parsed.blockType)) layout.blockType = parsed.blockType;
|
|
492
|
+
if (typeof parsed.lineHeight === "number" && Number.isFinite(parsed.lineHeight) && parsed.lineHeight >= 0.5 && parsed.lineHeight <= 5) layout.lineHeight = parsed.lineHeight;
|
|
493
|
+
if (["left", "center", "right"].includes(parsed.textAlign)) layout.textAlign = parsed.textAlign;
|
|
494
|
+
if (["ul", "ol"].includes(parsed.listType)) layout.listType = parsed.listType;
|
|
490
495
|
const richText = parseCmsRichText(parsed.richText);
|
|
491
496
|
if (richText) layout.richText = richText;
|
|
492
497
|
return layout;
|
|
@@ -495,11 +500,13 @@ function parseCmsTextLayout(value4) {
|
|
|
495
500
|
}
|
|
496
501
|
}
|
|
497
502
|
function cmsTextLayoutStyle(value4, templateBlock = false) {
|
|
498
|
-
const { width, height, fontFamily, fontSize, blockType } = parseCmsTextLayout(value4);
|
|
503
|
+
const { width, height, fontFamily, fontSize, blockType, lineHeight, textAlign } = parseCmsTextLayout(value4);
|
|
499
504
|
return {
|
|
500
|
-
...blockType && !templateBlock ? { fontSize: blockType === "h1" ? "2rem" : blockType === "h2" ? "1.5rem" : blockType === "h3" ? "1.25rem" : "1rem", fontWeight: blockType.startsWith("h") ? 700 : 400, lineHeight: 1.5 } : {},
|
|
505
|
+
...blockType && blockType !== "ul" && blockType !== "ol" && !templateBlock ? { fontSize: blockType === "h1" ? "2rem" : blockType === "h2" ? "1.5rem" : blockType === "h3" ? "1.25rem" : "1rem", fontWeight: blockType.startsWith("h") ? 700 : 400, lineHeight: 1.5 } : {},
|
|
501
506
|
...fontFamily ? { fontFamily } : {},
|
|
502
|
-
...fontSize ? { fontSize: `${fontSize}px
|
|
507
|
+
...fontSize ? { fontSize: `${fontSize}px` } : {},
|
|
508
|
+
...lineHeight ? { lineHeight } : {},
|
|
509
|
+
...textAlign ? { textAlign, justifyContent: textAlign === "center" ? "center" : textAlign === "right" ? "flex-end" : "flex-start" } : {},
|
|
503
510
|
whiteSpace: "pre-wrap",
|
|
504
511
|
overflowWrap: "anywhere",
|
|
505
512
|
...width !== void 0 || height !== void 0 ? {
|
|
@@ -513,8 +520,8 @@ function cmsTextLayoutStyle(value4, templateBlock = false) {
|
|
|
513
520
|
function applyCmsTextLayout(element, value4) {
|
|
514
521
|
const styles = cmsTextLayoutStyle(value4);
|
|
515
522
|
const view = element.ownerDocument.defaultView;
|
|
516
|
-
if ((styles.width || styles.minHeight) && view?.getComputedStyle(element).display === "inline") {
|
|
517
|
-
styles.display = "inline-block";
|
|
523
|
+
if ((styles.textAlign || styles.width || styles.minHeight) && view?.getComputedStyle(element).display === "inline") {
|
|
524
|
+
styles.display = styles.textAlign ? "block" : "inline-block";
|
|
518
525
|
}
|
|
519
526
|
const previous = Object.keys(styles).map((key) => {
|
|
520
527
|
const property = key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
@@ -589,10 +596,12 @@ function EditableText({
|
|
|
589
596
|
}) {
|
|
590
597
|
const colorContext = (0, import_react4.useContext)(getTextColorContext());
|
|
591
598
|
const hidden = useCmsElementHidden(field);
|
|
592
|
-
const
|
|
599
|
+
const metadata = parseCmsTextLayout(colorContext?.content[`${field}TextLayout`]);
|
|
600
|
+
const legacyList = metadata.blockType === "ul" || metadata.blockType === "ol" ? metadata.blockType : void 0;
|
|
601
|
+
const listType = metadata.listType ?? legacyList;
|
|
602
|
+
const block = legacyList ? void 0 : metadata.blockType;
|
|
593
603
|
const templateBlock = useCmsTextBlock(block);
|
|
594
604
|
if (hidden) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CmsAddedElements, { field });
|
|
595
|
-
const isList = block === "ul" || block === "ol";
|
|
596
605
|
const colorValue = colorContext?.content[`${field}Color`];
|
|
597
606
|
const color = validTextColor(colorValue) ? colorValue : void 0;
|
|
598
607
|
const selected = editable && colorContext?.selectedTextField === field;
|
|
@@ -601,7 +610,7 @@ function EditableText({
|
|
|
601
610
|
"data-cms-text-field": field,
|
|
602
611
|
"data-cms-text-rendered": "true",
|
|
603
612
|
contentEditable: editable ? "plaintext-only" : false,
|
|
604
|
-
style: cmsTextLayoutStyle(colorContext?.content[`${field}TextLayout`], Boolean(templateBlock)),
|
|
613
|
+
style: { ...cmsTextLayoutStyle(colorContext?.content[`${field}TextLayout`], Boolean(templateBlock)), ...metadata.textAlign && !templateBlock ? { display: "block" } : {} },
|
|
605
614
|
suppressContentEditableWarning: true,
|
|
606
615
|
onBlur: (event) => onChange?.(field, readCmsEditableText(event.currentTarget)),
|
|
607
616
|
onClick: (event) => {
|
|
@@ -624,15 +633,16 @@ function EditableText({
|
|
|
624
633
|
"&:focus": { boxShadow: "0 0 0 2px #00A76F" }
|
|
625
634
|
}
|
|
626
635
|
},
|
|
636
|
+
...listType ? [{ font: "inherit", display: "block" }] : [],
|
|
627
637
|
...!templateBlock ? Array.isArray(sx) ? sx : sx ? [sx] : [] : [],
|
|
628
638
|
...color ? [{ color }] : [],
|
|
629
639
|
...selected ? [{ outline: "2px solid #00A76F", outlineOffset: 2 }] : []
|
|
630
640
|
],
|
|
631
641
|
children: renderCmsRichText(value4, parseCmsTextLayout(colorContext?.content[`${field}TextLayout`]).richText, component !== "a" && component !== "button")
|
|
632
642
|
};
|
|
633
|
-
const rendered = templateBlock ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_Box.default, { component: templateBlock, ...textProps }, String(value4 ?? "")) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_Typography.default, { component:
|
|
643
|
+
const rendered = templateBlock ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_Box.default, { component: templateBlock, ...textProps }, String(value4 ?? "")) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_Typography.default, { component: block ?? (listType ? "span" : component) ?? "div", variant, ...textProps }, String(value4 ?? ""));
|
|
634
644
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
635
|
-
|
|
645
|
+
listType ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CmsTextList, { field, type: listType, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { children: rendered }) }) : rendered,
|
|
636
646
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CmsAddedElements, { field })
|
|
637
647
|
] });
|
|
638
648
|
}
|
|
@@ -3595,16 +3605,20 @@ function ExactText({ cmsAs, children, style, cmsDefaultRichText, cmsField, ...pr
|
|
|
3595
3605
|
const entry = explicitField ? { field: explicitField, layout: content?.[`${explicitField}TextLayout`], color: typeof content?.[`${explicitField}Color`] === "string" ? String(content[`${explicitField}Color`]) : void 0 } : entries.get(normalize(plainText(children)));
|
|
3596
3606
|
if (explicitField && content?.[explicitField] !== void 0) children = String(content[explicitField]);
|
|
3597
3607
|
const hidden = useCmsElementHidden(entry?.field);
|
|
3598
|
-
const
|
|
3608
|
+
const metadata = parseCmsTextLayout(entry?.layout);
|
|
3609
|
+
const legacyList = metadata.blockType === "ul" || metadata.blockType === "ol" ? metadata.blockType : void 0;
|
|
3610
|
+
const listType = metadata.listType ?? legacyList;
|
|
3611
|
+
const block = legacyList ? void 0 : metadata.blockType;
|
|
3612
|
+
const listItem = cmsAs === "li" && Boolean(block);
|
|
3599
3613
|
const templateBlock = useCmsTextBlock(block);
|
|
3600
3614
|
if (hidden) return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CmsAddedElements, { field: entry?.field });
|
|
3601
|
-
const
|
|
3602
|
-
const host = block ? isList ? "li" : block : cmsAs;
|
|
3615
|
+
const host = block ?? (listType ? "span" : cmsAs);
|
|
3603
3616
|
const layout = entry ? cmsTextLayoutStyle(entry.layout, Boolean(templateBlock)) : void 0;
|
|
3604
3617
|
const sized = layout?.width || layout?.minHeight;
|
|
3605
3618
|
const rendered = (0, import_react9.createElement)(templateBlock ?? (typeof cmsAs === "string" ? host : cmsAs), {
|
|
3606
3619
|
...block && !templateBlock && typeof cmsAs !== "string" ? { as: host } : {},
|
|
3607
3620
|
...props,
|
|
3621
|
+
...listItem ? { "data-cms-list-item": void 0 } : {},
|
|
3608
3622
|
// Replace the edited host when plain text changes; browser-created text nodes
|
|
3609
3623
|
// must not be reconciled against the previous annotation tree.
|
|
3610
3624
|
key: plainText(children),
|
|
@@ -3613,11 +3627,11 @@ function ExactText({ cmsAs, children, style, cmsDefaultRichText, cmsField, ...pr
|
|
|
3613
3627
|
"data-cms-text-rendered": "true",
|
|
3614
3628
|
"data-cms-text-default-rich": cmsDefaultRichText ? JSON.stringify(cmsDefaultRichText) : void 0,
|
|
3615
3629
|
"data-cms-text-sized": sized ? "true" : void 0,
|
|
3616
|
-
style: { ...style, ...layout, ...entry.color ? { color: entry.color } : {} }
|
|
3630
|
+
style: { ...style, ...layout, ...metadata.textAlign && host === "span" ? { display: "block" } : {}, ...entry.color ? { color: entry.color } : {} }
|
|
3617
3631
|
} : { style }
|
|
3618
3632
|
}, entry ? renderCmsRichText(children, parseCmsTextLayout(entry.layout).richText ?? cmsDefaultRichText, cmsAs !== "a" && cmsAs !== "button" && !props.href) : children);
|
|
3619
3633
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
3620
|
-
|
|
3634
|
+
listType && entry ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CmsTextList, { field: entry.field, type: listType, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: rendered }) }) : listItem ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { "data-cms-list-item": props["data-cms-list-item"], children: rendered }) : rendered,
|
|
3621
3635
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CmsAddedElements, { field: entry?.field })
|
|
3622
3636
|
] });
|
|
3623
3637
|
}
|
|
@@ -16579,10 +16593,28 @@ var wikexCommodityRoutes = wikexCommodityPageTemplates.map(({ route, slug, key }
|
|
|
16579
16593
|
var import_react36 = require("react");
|
|
16580
16594
|
var import_material = require("@mui/material");
|
|
16581
16595
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
16582
|
-
function CmsTextToolbar({ layout, color, colorPicker, inlineControls, structureControls, computedFontSize, onLayoutChange, onColorChange, onReset }) {
|
|
16596
|
+
function CmsTextToolbar({ layout, color, colorPicker, inlineControls, structureControls, computedFontSize, computedLineHeight, computedFontFamily, computedTextAlign, onLayoutChange, onColorChange, onReset }) {
|
|
16583
16597
|
const toolbarRef = (0, import_react36.useRef)(null);
|
|
16584
16598
|
const [hex, setHex] = (0, import_react36.useState)(color);
|
|
16585
16599
|
const displayedSize = String(computedFontSize ?? layout.fontSize ?? 16);
|
|
16600
|
+
const displayedLineHeight = String(layout.lineHeight ?? computedLineHeight ?? 1.5);
|
|
16601
|
+
const dirtyLineHeight = (0, import_react36.useRef)(false);
|
|
16602
|
+
const [lineHeight, setLineHeight] = (0, import_react36.useState)(displayedLineHeight);
|
|
16603
|
+
(0, import_react36.useEffect)(() => {
|
|
16604
|
+
dirtyLineHeight.current = false;
|
|
16605
|
+
setLineHeight(displayedLineHeight);
|
|
16606
|
+
}, [displayedLineHeight]);
|
|
16607
|
+
const commitLineHeight = () => {
|
|
16608
|
+
if (!dirtyLineHeight.current) return;
|
|
16609
|
+
dirtyLineHeight.current = false;
|
|
16610
|
+
if (!lineHeight.trim()) {
|
|
16611
|
+
onLayoutChange({ lineHeight: void 0 });
|
|
16612
|
+
return;
|
|
16613
|
+
}
|
|
16614
|
+
const value4 = Number(lineHeight);
|
|
16615
|
+
if (Number.isFinite(value4) && value4 >= 0.5 && value4 <= 5) onLayoutChange({ lineHeight: value4 });
|
|
16616
|
+
else setLineHeight(displayedLineHeight);
|
|
16617
|
+
};
|
|
16586
16618
|
const dirtySize = (0, import_react36.useRef)(false);
|
|
16587
16619
|
const [size, setSize] = (0, import_react36.useState)(displayedSize);
|
|
16588
16620
|
(0, import_react36.useEffect)(() => setHex(color), [color]);
|
|
@@ -16605,6 +16637,13 @@ function CmsTextToolbar({ layout, color, colorPicker, inlineControls, structureC
|
|
|
16605
16637
|
if (Number.isFinite(value4) && value4 >= 8 && value4 <= 300) onLayoutChange({ fontSize: value4 });
|
|
16606
16638
|
else setSize(displayedSize);
|
|
16607
16639
|
};
|
|
16640
|
+
const fontName = (computedFontFamily ?? layout.fontFamily ?? "Arial").split(",")[0].trim().replace(/^["']|["']$/g, "");
|
|
16641
|
+
const matchedFont = Object.entries(CMS_TEXT_FONTS).find(([family]) => family.split(",")[0].replace(/^["']|["']$/g, "").toLowerCase() === fontName.toLowerCase());
|
|
16642
|
+
const fontLabel = matchedFont?.[1] ?? fontName;
|
|
16643
|
+
const selectedFont = layout.fontFamily ?? matchedFont?.[0] ?? "";
|
|
16644
|
+
const tooltipProps = { slotProps: { popper: { sx: { zIndex: 1800 } } } };
|
|
16645
|
+
const inputSx = { width: 52, flexShrink: 0, "& .MuiInputBase-root": { height: 32 }, "& input": { py: 0.5, px: 0.75, fontSize: 12 } };
|
|
16646
|
+
const groupSx = { display: "flex", alignItems: "center", gap: 0.5 };
|
|
16608
16647
|
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
16609
16648
|
import_material.Box,
|
|
16610
16649
|
{
|
|
@@ -16612,80 +16651,103 @@ function CmsTextToolbar({ layout, color, colorPicker, inlineControls, structureC
|
|
|
16612
16651
|
role: "toolbar",
|
|
16613
16652
|
"aria-label": "\u0110\u1ECBnh d\u1EA1ng ch\u1EEF",
|
|
16614
16653
|
"data-cms-text-toolbar": true,
|
|
16615
|
-
sx: { display: "flex",
|
|
16654
|
+
sx: { display: "flex", flexDirection: "column", gap: 0.5, p: 0.75, border: "1px solid", borderColor: "divider", borderRadius: 1, bgcolor: "background.paper", boxShadow: 8, color: "text.primary", maxWidth: "100%" },
|
|
16616
16655
|
children: [
|
|
16617
|
-
|
|
16618
|
-
|
|
16619
|
-
|
|
16620
|
-
|
|
16621
|
-
|
|
16622
|
-
|
|
16623
|
-
|
|
16624
|
-
|
|
16625
|
-
|
|
16626
|
-
|
|
16627
|
-
|
|
16628
|
-
|
|
16629
|
-
|
|
16630
|
-
|
|
16631
|
-
|
|
16632
|
-
|
|
16633
|
-
|
|
16634
|
-
|
|
16635
|
-
|
|
16636
|
-
|
|
16637
|
-
|
|
16638
|
-
|
|
16639
|
-
|
|
16640
|
-
|
|
16641
|
-
|
|
16642
|
-
|
|
16643
|
-
|
|
16644
|
-
|
|
16645
|
-
|
|
16646
|
-
|
|
16647
|
-
|
|
16648
|
-
|
|
16649
|
-
|
|
16650
|
-
|
|
16656
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_material.Box, { sx: { ...groupSx, flexWrap: "wrap", pb: 0.5, borderBottom: "1px solid", borderColor: "divider" }, children: [
|
|
16657
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
16658
|
+
import_material.Select,
|
|
16659
|
+
{
|
|
16660
|
+
size: "small",
|
|
16661
|
+
displayEmpty: true,
|
|
16662
|
+
value: selectedFont,
|
|
16663
|
+
inputProps: { "aria-label": "Font ch\u1EEF" },
|
|
16664
|
+
renderValue: (value4) => value4 ? CMS_TEXT_FONTS[value4] : fontLabel,
|
|
16665
|
+
MenuProps: { disableScrollLock: true, container: () => toolbarRef.current?.ownerDocument.body ?? null, sx: { zIndex: 1600 }, slotProps: { paper: { sx: { maxHeight: 320 } } } },
|
|
16666
|
+
sx: { width: 128, height: 30, fontSize: 12, "& .MuiSelect-select": { py: 0.5, pl: 1, pr: "24px !important" }, "& .MuiSelect-icon": { right: 3 } },
|
|
16667
|
+
onChange: (event) => onLayoutChange({ fontFamily: event.target.value || void 0 }),
|
|
16668
|
+
children: [
|
|
16669
|
+
!selectedFont && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.MenuItem, { value: "", sx: { fontSize: 12 }, children: fontLabel }),
|
|
16670
|
+
Object.entries(CMS_TEXT_FONTS).map(([value4, label]) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.MenuItem, { value: value4, sx: { fontFamily: value4, fontSize: 13 }, children: label }, value4))
|
|
16671
|
+
]
|
|
16672
|
+
}
|
|
16673
|
+
),
|
|
16674
|
+
structureControls
|
|
16675
|
+
] }),
|
|
16676
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_material.Box, { sx: { ...groupSx, flexWrap: "wrap" }, children: [
|
|
16677
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.Tooltip, { title: "C\u1EE1 ch\u1EEF (px)", ...tooltipProps, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
16678
|
+
import_material.TextField,
|
|
16679
|
+
{
|
|
16680
|
+
size: "small",
|
|
16681
|
+
type: "number",
|
|
16682
|
+
value: size,
|
|
16683
|
+
slotProps: { htmlInput: { "aria-label": "C\u1EE1 ch\u1EEF (px)", min: 8, max: 300, step: 1 } },
|
|
16684
|
+
sx: inputSx,
|
|
16685
|
+
onChange: (event) => {
|
|
16686
|
+
dirtySize.current = true;
|
|
16687
|
+
setSize(event.target.value);
|
|
16688
|
+
},
|
|
16689
|
+
onBlur: commitSize,
|
|
16690
|
+
onKeyDown: (event) => {
|
|
16691
|
+
if (event.key === "Enter") {
|
|
16692
|
+
event.preventDefault();
|
|
16693
|
+
commitSize();
|
|
16694
|
+
}
|
|
16651
16695
|
}
|
|
16652
16696
|
}
|
|
16653
|
-
}
|
|
16654
|
-
|
|
16655
|
-
|
|
16656
|
-
|
|
16657
|
-
|
|
16658
|
-
|
|
16659
|
-
|
|
16660
|
-
|
|
16661
|
-
|
|
16662
|
-
|
|
16663
|
-
|
|
16664
|
-
|
|
16665
|
-
|
|
16666
|
-
|
|
16667
|
-
|
|
16668
|
-
|
|
16669
|
-
|
|
16670
|
-
|
|
16697
|
+
) }),
|
|
16698
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.Tooltip, { title: "Chi\u1EC1u cao d\xF2ng (l\u1EA7n c\u1EE1 ch\u1EEF)", ...tooltipProps, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
16699
|
+
import_material.TextField,
|
|
16700
|
+
{
|
|
16701
|
+
size: "small",
|
|
16702
|
+
type: "number",
|
|
16703
|
+
value: lineHeight,
|
|
16704
|
+
slotProps: { input: { startAdornment: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.InputAdornment, { position: "start", sx: { mr: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.SvgIcon, { sx: { fontSize: 17 }, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("path", { d: "M3 4 0 7h2v10H0l3 3 3-3H4V7h2L3 4zm5 2h16v2H8zm0 5h16v2H8zm0 5h16v2H8z" }) }) }) }, htmlInput: { "aria-label": "Chi\u1EC1u cao d\xF2ng", min: 0.5, max: 5, step: 0.1 } },
|
|
16705
|
+
sx: { ...inputSx, width: 78, "& .MuiInputBase-root": { height: 32, pl: 0.75 } },
|
|
16706
|
+
onChange: (event) => {
|
|
16707
|
+
dirtyLineHeight.current = true;
|
|
16708
|
+
setLineHeight(event.target.value);
|
|
16709
|
+
},
|
|
16710
|
+
onBlur: commitLineHeight,
|
|
16711
|
+
onKeyDown: (event) => {
|
|
16712
|
+
if (event.key === "Enter") {
|
|
16713
|
+
event.preventDefault();
|
|
16714
|
+
commitLineHeight();
|
|
16715
|
+
}
|
|
16671
16716
|
}
|
|
16672
16717
|
}
|
|
16673
|
-
}
|
|
16674
|
-
|
|
16675
|
-
|
|
16676
|
-
|
|
16677
|
-
|
|
16678
|
-
|
|
16679
|
-
|
|
16680
|
-
|
|
16681
|
-
|
|
16682
|
-
|
|
16683
|
-
|
|
16684
|
-
|
|
16685
|
-
|
|
16686
|
-
|
|
16687
|
-
|
|
16688
|
-
|
|
16718
|
+
) }),
|
|
16719
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.Box, { sx: groupSx, children: inlineControls }),
|
|
16720
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.Box, { sx: { ...groupSx, borderLeft: "1px solid", borderColor: "divider", pl: 1, ml: 0.5 }, children: [["left", "C\u0103n tr\xE1i"], ["center", "C\u0103n gi\u1EEFa"], ["right", "C\u0103n ph\u1EA3i"]].map(([align, label]) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.Tooltip, { title: label, ...tooltipProps, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
16721
|
+
import_material.ToggleButton,
|
|
16722
|
+
{
|
|
16723
|
+
value: align,
|
|
16724
|
+
selected: (layout.textAlign ?? computedTextAlign ?? "left") === align,
|
|
16725
|
+
"aria-label": label,
|
|
16726
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
16727
|
+
onClick: () => onLayoutChange({ textAlign: align }),
|
|
16728
|
+
sx: { width: 30, height: 30, p: 0.5, border: 0 },
|
|
16729
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.SvgIcon, { sx: { fontSize: 19 }, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("path", { d: align === "left" ? "M3 4h18v2H3zm0 5h12v2H3zm0 5h18v2H3zm0 5h12v2H3z" : align === "right" ? "M3 4h18v2H3zm6 5h12v2H9zm-6 5h18v2H3zm6 5h12v2H9z" : "M3 4h18v2H3zm3 5h12v2H6zm-3 5h18v2H3zm3 5h12v2H6z" }) })
|
|
16730
|
+
}
|
|
16731
|
+
) }, align)) }),
|
|
16732
|
+
colorPicker || /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
16733
|
+
import_material.TextField,
|
|
16734
|
+
{
|
|
16735
|
+
size: "small",
|
|
16736
|
+
value: hex,
|
|
16737
|
+
slotProps: { htmlInput: { "aria-label": "M\xE3 m\xE0u ch\u1EEF", maxLength: 7, spellCheck: false } },
|
|
16738
|
+
sx: { ...inputSx, width: 76 },
|
|
16739
|
+
onChange: (event) => setHex(event.target.value),
|
|
16740
|
+
onBlur: commitColor,
|
|
16741
|
+
onKeyDown: (event) => {
|
|
16742
|
+
if (event.key === "Enter") {
|
|
16743
|
+
event.preventDefault();
|
|
16744
|
+
commitColor();
|
|
16745
|
+
}
|
|
16746
|
+
}
|
|
16747
|
+
}
|
|
16748
|
+
),
|
|
16749
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.Tooltip, { title: "\u0110\u1EB7t l\u1EA1i \u0111\u1ECBnh d\u1EA1ng ch\u1EEF", ...tooltipProps, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.IconButton, { size: "small", "aria-label": "\u0110\u1EB7t l\u1EA1i \u0111\u1ECBnh d\u1EA1ng ch\u1EEF", onClick: onReset, sx: { width: 30, height: 30, ml: "auto" }, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.SvgIcon, { sx: { fontSize: 19 }, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("path", { d: "m18 4 3 3-9 9-3-3 9-9zM8 14l3 3-3 3H4l-3-3 4-4 3 1zm4 6h10v2H10z" }) }) }) })
|
|
16750
|
+
] })
|
|
16689
16751
|
]
|
|
16690
16752
|
}
|
|
16691
16753
|
);
|