@enyxs/wikex-components 0.11.20 → 0.11.21
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -84,6 +84,7 @@ type CmsTextMark = {
|
|
|
84
84
|
start: number;
|
|
85
85
|
end: number;
|
|
86
86
|
bold?: boolean;
|
|
87
|
+
italic?: boolean;
|
|
87
88
|
underline?: boolean;
|
|
88
89
|
href?: string;
|
|
89
90
|
newTab?: boolean;
|
|
@@ -95,7 +96,7 @@ type CmsRichText = {
|
|
|
95
96
|
declare function safeCmsTextHref(value: string): string | undefined;
|
|
96
97
|
declare function parseCmsRichText(value: unknown): CmsRichText | undefined;
|
|
97
98
|
declare function rebaseCmsRichText(value: unknown, text: string): CmsRichText;
|
|
98
|
-
declare function patchCmsRichText(value: unknown, text: string, start: number, end: number, patch: Partial<Pick<CmsTextMark, 'bold' | 'underline' | 'href'>>): CmsRichText;
|
|
99
|
+
declare function patchCmsRichText(value: unknown, text: string, start: number, end: number, patch: Partial<Pick<CmsTextMark, 'bold' | 'italic' | 'underline' | 'href'>>): CmsRichText;
|
|
99
100
|
declare function renderCmsRichText(children: ReactNode, value: unknown, allowLinks?: boolean): ReactNode;
|
|
100
101
|
|
|
101
102
|
declare const CMS_TEXT_FONTS: {
|
package/dist/index.d.ts
CHANGED
|
@@ -84,6 +84,7 @@ type CmsTextMark = {
|
|
|
84
84
|
start: number;
|
|
85
85
|
end: number;
|
|
86
86
|
bold?: boolean;
|
|
87
|
+
italic?: boolean;
|
|
87
88
|
underline?: boolean;
|
|
88
89
|
href?: string;
|
|
89
90
|
newTab?: boolean;
|
|
@@ -95,7 +96,7 @@ type CmsRichText = {
|
|
|
95
96
|
declare function safeCmsTextHref(value: string): string | undefined;
|
|
96
97
|
declare function parseCmsRichText(value: unknown): CmsRichText | undefined;
|
|
97
98
|
declare function rebaseCmsRichText(value: unknown, text: string): CmsRichText;
|
|
98
|
-
declare function patchCmsRichText(value: unknown, text: string, start: number, end: number, patch: Partial<Pick<CmsTextMark, 'bold' | 'underline' | 'href'>>): CmsRichText;
|
|
99
|
+
declare function patchCmsRichText(value: unknown, text: string, start: number, end: number, patch: Partial<Pick<CmsTextMark, 'bold' | 'italic' | 'underline' | 'href'>>): CmsRichText;
|
|
99
100
|
declare function renderCmsRichText(children: ReactNode, value: unknown, allowLinks?: boolean): ReactNode;
|
|
100
101
|
|
|
101
102
|
declare const CMS_TEXT_FONTS: {
|
package/dist/index.js
CHANGED
|
@@ -383,9 +383,10 @@ function parseCmsRichText(value4) {
|
|
|
383
383
|
if (!mark || !Number.isInteger(mark.start) || !Number.isInteger(mark.end) || mark.start < 0 || mark.end <= mark.start || mark.end > raw.text.length) continue;
|
|
384
384
|
const next = { start: mark.start, end: mark.end };
|
|
385
385
|
if (typeof mark.bold === "boolean") next.bold = mark.bold;
|
|
386
|
+
if (typeof mark.italic === "boolean") next.italic = mark.italic;
|
|
386
387
|
if (typeof mark.underline === "boolean") next.underline = mark.underline;
|
|
387
388
|
if (typeof mark.href === "string") next.href = safeCmsTextHref(mark.href);
|
|
388
|
-
if (next.bold !== void 0 || next.underline !== void 0 || next.href) marks.push(next);
|
|
389
|
+
if (next.bold !== void 0 || next.italic !== void 0 || next.underline !== void 0 || next.href) marks.push(next);
|
|
389
390
|
}
|
|
390
391
|
return { text: raw.text, marks };
|
|
391
392
|
}
|
|
@@ -421,10 +422,10 @@ function patchCmsRichText(value4, text, start, end, patch) {
|
|
|
421
422
|
const style = {};
|
|
422
423
|
rich.marks.filter((m) => m.start <= a && m.end >= b).forEach((m) => Object.assign(style, m));
|
|
423
424
|
if (a >= start && b <= end) Object.assign(style, patch);
|
|
424
|
-
const next = { start: a, end: b, bold: style.bold, underline: style.underline, newTab: style.newTab, href: style.href ? safeCmsTextHref(style.href) : void 0 };
|
|
425
|
-
if (next.bold === void 0 && next.underline === void 0 && !next.href) continue;
|
|
425
|
+
const next = { start: a, end: b, bold: style.bold, italic: style.italic, underline: style.underline, newTab: style.newTab, href: style.href ? safeCmsTextHref(style.href) : void 0 };
|
|
426
|
+
if (next.bold === void 0 && next.italic === void 0 && next.underline === void 0 && !next.href) continue;
|
|
426
427
|
const previous = marks[marks.length - 1];
|
|
427
|
-
if (previous && previous.end === a && previous.bold === next.bold && previous.underline === next.underline && previous.href === next.href && previous.newTab === next.newTab) previous.end = b;
|
|
428
|
+
if (previous && previous.end === a && previous.bold === next.bold && previous.italic === next.italic && previous.underline === next.underline && previous.href === next.href && previous.newTab === next.newTab) previous.end = b;
|
|
428
429
|
else marks.push(next);
|
|
429
430
|
}
|
|
430
431
|
return { text, marks };
|
|
@@ -448,9 +449,10 @@ function renderCmsRichText(children, value4, allowLinks = true) {
|
|
|
448
449
|
const end = points[index + 1];
|
|
449
450
|
const mark = Object.assign({}, ...rich.marks.filter((m) => m.start <= start && m.end >= end));
|
|
450
451
|
const part = text.slice(start - base, end - base);
|
|
451
|
-
if (mark.bold === void 0 && mark.underline === void 0 && !mark.href) return part;
|
|
452
|
+
if (mark.bold === void 0 && mark.italic === void 0 && mark.underline === void 0 && !mark.href) return part;
|
|
452
453
|
const style = {
|
|
453
454
|
...mark.bold !== void 0 ? { fontWeight: mark.bold ? 700 : 400 } : {},
|
|
455
|
+
...mark.italic !== void 0 ? { fontStyle: mark.italic ? "italic" : "normal" } : {},
|
|
454
456
|
...mark.underline !== void 0 ? { textDecorationLine: mark.underline ? "underline" : "none" } : {}
|
|
455
457
|
};
|
|
456
458
|
return mark.href && links ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { href: mark.href, target: mark.newTab ? "_blank" : void 0, rel: mark.newTab ? "noopener noreferrer" : void 0, style: { color: "inherit", textDecoration: "underline", ...style }, children: part }, start) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style, children: part }, start);
|
|
@@ -16725,7 +16727,7 @@ function CmsTextToolbar({ layout, color, colorPicker, inlineControls, structureC
|
|
|
16725
16727
|
"aria-label": label,
|
|
16726
16728
|
onMouseDown: (event) => event.preventDefault(),
|
|
16727
16729
|
onClick: () => onLayoutChange({ textAlign: align }),
|
|
16728
|
-
sx: { width: 30, height: 30, p: 0.5, border: 0 },
|
|
16730
|
+
sx: { width: 30, minWidth: 30, height: 30, p: 0.5, border: 0 },
|
|
16729
16731
|
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
16732
|
}
|
|
16731
16733
|
) }, align)) }),
|