@drghaliasri/butex 6.1.1 → 6.1.3
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/document2.d.mts +1 -1
- package/dist/document2.d.ts +1 -1
- package/dist/document2.js +1 -1
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +1 -1
- package/dist/document2.mjs.map +1 -1
- package/dist/react-document2.js +149 -70
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +341 -262
- package/dist/react-document2.mjs.map +1 -1
- package/dist/react.js +20 -0
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +20 -0
- package/dist/react.mjs.map +1 -1
- package/package.json +2 -2
package/dist/react-document2.js
CHANGED
|
@@ -33,6 +33,26 @@ __export(react_document2_entry_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(react_document2_entry_exports);
|
|
35
35
|
|
|
36
|
+
// src/react/matrixPickerCss.ts
|
|
37
|
+
var MATRIX_PICKER_CSS = `
|
|
38
|
+
.butex-widget .matrix-grid-picker,
|
|
39
|
+
.butex-widget .matrix-grid-cell {
|
|
40
|
+
box-sizing: border-box;
|
|
41
|
+
}
|
|
42
|
+
`.trim();
|
|
43
|
+
var MATRIX_PICKER_STYLE_ID = "butex-matrix-picker-css";
|
|
44
|
+
function injectMatrixPickerCss(doc) {
|
|
45
|
+
const d = doc ?? (typeof document !== "undefined" ? document : void 0);
|
|
46
|
+
if (!d || d.getElementById(MATRIX_PICKER_STYLE_ID)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const style = d.createElement("style");
|
|
50
|
+
style.id = MATRIX_PICKER_STYLE_ID;
|
|
51
|
+
style.textContent = MATRIX_PICKER_CSS;
|
|
52
|
+
d.head.appendChild(style);
|
|
53
|
+
}
|
|
54
|
+
injectMatrixPickerCss();
|
|
55
|
+
|
|
36
56
|
// src/react-document2/ArticleMetaPanel.tsx
|
|
37
57
|
var import_react = require("react");
|
|
38
58
|
|
|
@@ -9360,7 +9380,7 @@ function toDocumentJson2(document2) {
|
|
|
9360
9380
|
}
|
|
9361
9381
|
|
|
9362
9382
|
// src/document2/keys.ts
|
|
9363
|
-
var DOCUMENT2_KEY_PATTERN = /^[\p{L}\p{M}
|
|
9383
|
+
var DOCUMENT2_KEY_PATTERN = /^[\p{L}\p{M}\p{Nd}:._-]+$/u;
|
|
9364
9384
|
function normalizeDocument2Key(key) {
|
|
9365
9385
|
return key.normalize("NFC").trim();
|
|
9366
9386
|
}
|
|
@@ -10220,7 +10240,7 @@ var DOCUMENT2_MESSAGES = {
|
|
|
10220
10240
|
editInternalRef: "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0631\u062C\u0639 \u0627\u0644\u062F\u0627\u062E\u0644\u064A",
|
|
10221
10241
|
deleteInternalRef: "\u062D\u0630\u0641 \u0627\u0644\u0645\u0631\u062C\u0639 \u0627\u0644\u062F\u0627\u062E\u0644\u064A",
|
|
10222
10242
|
labelsTitle: "\u0627\u0644\u062A\u0633\u0645\u064A\u0627\u062A \u0648\u0627\u0644\u0645\u0631\u0627\u062C\u0639 \u0627\u0644\u062F\u0627\u062E\u0644\u064A\u0629",
|
|
10223
|
-
labelsHelp: "\u0627\u0644\u062A\u0633\u0645\u064A\u0627\u062A \u0644\u0644\u0645\u0631\u0627\u062C\u0639 \u062F\u0627\u062E\u0644 \u0627\u0644\u0645\u0633\u062A\u0646\u062F\u061B \
|
|
10243
|
+
labelsHelp: "\u0627\u0644\u062A\u0633\u0645\u064A\u0627\u062A \u0644\u0644\u0645\u0631\u0627\u062C\u0639 \u062F\u0627\u062E\u0644 \u0627\u0644\u0645\u0633\u062A\u0646\u062F\u061B \u0648\u0627\u0644\u0627\u0642\u062A\u0628\u0627\u0633\u0627\u062A \u062A\u0633\u062A\u0646\u062F \u0625\u0644\u0649 \u0642\u0627\u0626\u0645\u0629 \u0627\u0644\u0645\u0631\u0627\u062C\u0639.",
|
|
10224
10244
|
captionToggle: "\u062A\u0639\u0644\u064A\u0642",
|
|
10225
10245
|
labelToggle: "\u062A\u0633\u0645\u064A\u0629",
|
|
10226
10246
|
centerParagraph: "\u062A\u0648\u0633\u064A\u0637 \u0627\u0644\u0641\u0642\u0631\u0629",
|
|
@@ -10427,6 +10447,15 @@ function document2Messages(locale) {
|
|
|
10427
10447
|
return DOCUMENT2_MESSAGES[locale];
|
|
10428
10448
|
}
|
|
10429
10449
|
|
|
10450
|
+
// src/react-document2/xelatexTextValidation.ts
|
|
10451
|
+
var XELATEX_UNSUPPORTED_EMOJI_PATTERN = /[\p{Emoji_Presentation}\p{Emoji_Modifier}\p{Regional_Indicator}\uFE0F\u20E3]/u;
|
|
10452
|
+
function hasXeLatexUnsupportedEmoji(value) {
|
|
10453
|
+
return XELATEX_UNSUPPORTED_EMOJI_PATTERN.test(value);
|
|
10454
|
+
}
|
|
10455
|
+
function unsupportedEmojiMessage(uiLocale) {
|
|
10456
|
+
return uiLocale === "ar" ? "\u0647\u0630\u0627 \u0627\u0644\u0631\u0645\u0632 \u0627\u0644\u062A\u0639\u0628\u064A\u0631\u064A \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645." : "This emoji is not supported.";
|
|
10457
|
+
}
|
|
10458
|
+
|
|
10430
10459
|
// src/react-document2/ArticleMetaPanel.tsx
|
|
10431
10460
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
10432
10461
|
var HIJRI_DAYS = Array.from({ length: 30 }, (_, index) => index + 1);
|
|
@@ -10434,6 +10463,20 @@ var HIJRI_YEARS = Array.from(
|
|
|
10434
10463
|
{ length: HIJRI_YEAR_MAX - HIJRI_YEAR_MIN + 1 },
|
|
10435
10464
|
(_, index) => HIJRI_YEAR_MIN + index
|
|
10436
10465
|
);
|
|
10466
|
+
var UNSUPPORTED_EMOJI_STYLE = {
|
|
10467
|
+
borderColor: "var(--butex-document2-error)",
|
|
10468
|
+
background: "var(--butex-document2-error-bg)"
|
|
10469
|
+
};
|
|
10470
|
+
function UnsupportedEmojiWarning({
|
|
10471
|
+
id,
|
|
10472
|
+
show,
|
|
10473
|
+
uiLocale
|
|
10474
|
+
}) {
|
|
10475
|
+
if (!show) {
|
|
10476
|
+
return null;
|
|
10477
|
+
}
|
|
10478
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { id, className: "butex-document2-widget__field-error", children: unsupportedEmojiMessage(uiLocale) });
|
|
10479
|
+
}
|
|
10437
10480
|
function HijriDateMenu({
|
|
10438
10481
|
label,
|
|
10439
10482
|
value,
|
|
@@ -10511,6 +10554,12 @@ function ArticleMetaPanel({
|
|
|
10511
10554
|
const localRef = (0, import_react.useRef)(null);
|
|
10512
10555
|
const resolvedRef = panelRef ?? localRef;
|
|
10513
10556
|
const formattedDate = formatHijriDate(meta.date, { locale: uiLocale, digitForm });
|
|
10557
|
+
const titleUnsupportedEmoji = hasXeLatexUnsupportedEmoji(meta.title);
|
|
10558
|
+
const authorsUnsupportedEmoji = hasXeLatexUnsupportedEmoji(meta.authors);
|
|
10559
|
+
const abstractUnsupportedEmoji = hasXeLatexUnsupportedEmoji(meta.abstract);
|
|
10560
|
+
const titleErrorId = "butex-document2-meta-title-unsupported-emoji";
|
|
10561
|
+
const authorsErrorId = "butex-document2-meta-authors-unsupported-emoji";
|
|
10562
|
+
const abstractErrorId = "butex-document2-meta-abstract-unsupported-emoji";
|
|
10514
10563
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
10515
10564
|
"section",
|
|
10516
10565
|
{
|
|
@@ -10537,12 +10586,16 @@ function ArticleMetaPanel({
|
|
|
10537
10586
|
{
|
|
10538
10587
|
ref: titleInputRef,
|
|
10539
10588
|
value: meta.title,
|
|
10589
|
+
"aria-invalid": titleUnsupportedEmoji ? true : void 0,
|
|
10590
|
+
"aria-describedby": titleUnsupportedEmoji ? titleErrorId : void 0,
|
|
10591
|
+
style: titleUnsupportedEmoji ? UNSUPPORTED_EMOJI_STYLE : void 0,
|
|
10540
10592
|
onChange: (event) => {
|
|
10541
10593
|
const value = event.currentTarget.value;
|
|
10542
10594
|
onChange({ title: value });
|
|
10543
10595
|
}
|
|
10544
10596
|
}
|
|
10545
|
-
)
|
|
10597
|
+
),
|
|
10598
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(UnsupportedEmojiWarning, { id: titleErrorId, show: titleUnsupportedEmoji, uiLocale })
|
|
10546
10599
|
] }),
|
|
10547
10600
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "butex-document2-widget__article-meta-field", children: [
|
|
10548
10601
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: messages.articleAuthors }),
|
|
@@ -10551,12 +10604,16 @@ function ArticleMetaPanel({
|
|
|
10551
10604
|
{
|
|
10552
10605
|
rows: 2,
|
|
10553
10606
|
value: meta.authors,
|
|
10607
|
+
"aria-invalid": authorsUnsupportedEmoji ? true : void 0,
|
|
10608
|
+
"aria-describedby": authorsUnsupportedEmoji ? authorsErrorId : void 0,
|
|
10609
|
+
style: authorsUnsupportedEmoji ? UNSUPPORTED_EMOJI_STYLE : void 0,
|
|
10554
10610
|
onChange: (event) => {
|
|
10555
10611
|
const value = event.currentTarget.value;
|
|
10556
10612
|
onChange({ authors: value });
|
|
10557
10613
|
}
|
|
10558
10614
|
}
|
|
10559
|
-
)
|
|
10615
|
+
),
|
|
10616
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(UnsupportedEmojiWarning, { id: authorsErrorId, show: authorsUnsupportedEmoji, uiLocale })
|
|
10560
10617
|
] }),
|
|
10561
10618
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-document2-widget__article-meta-field", children: [
|
|
10562
10619
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: messages.articleDate }),
|
|
@@ -10607,12 +10664,16 @@ function ArticleMetaPanel({
|
|
|
10607
10664
|
{
|
|
10608
10665
|
rows: 3,
|
|
10609
10666
|
value: meta.abstract,
|
|
10667
|
+
"aria-invalid": abstractUnsupportedEmoji ? true : void 0,
|
|
10668
|
+
"aria-describedby": abstractUnsupportedEmoji ? abstractErrorId : void 0,
|
|
10669
|
+
style: abstractUnsupportedEmoji ? UNSUPPORTED_EMOJI_STYLE : void 0,
|
|
10610
10670
|
onChange: (event) => {
|
|
10611
10671
|
const value = event.currentTarget.value;
|
|
10612
10672
|
onChange({ abstract: value });
|
|
10613
10673
|
}
|
|
10614
10674
|
}
|
|
10615
|
-
)
|
|
10675
|
+
),
|
|
10676
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(UnsupportedEmojiWarning, { id: abstractErrorId, show: abstractUnsupportedEmoji, uiLocale })
|
|
10616
10677
|
] })
|
|
10617
10678
|
] }),
|
|
10618
10679
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "butex-document2-widget__article-meta-fixed", dir: "rtl", children: BUTEX_CLOSING_HAMDALA })
|
|
@@ -11485,74 +11546,92 @@ function InlineField({
|
|
|
11485
11546
|
const backwardArrowKey = documentDirection === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
11486
11547
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "butex-document2-widget__inline-field", dir: documentDirection, "data-document-direction": documentDirection, children: field.tokens.map((token) => {
|
|
11487
11548
|
if (token.kind === "text") {
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
|
|
11513
|
-
|
|
11514
|
-
|
|
11515
|
-
|
|
11516
|
-
if (!collapsed) {
|
|
11517
|
-
return;
|
|
11518
|
-
}
|
|
11519
|
-
if (event.key === forwardArrowKey && element.selectionStart === element.value.length) {
|
|
11520
|
-
const next = adjacentIslandId(token.id, 1);
|
|
11521
|
-
if (next) {
|
|
11522
|
-
event.preventDefault();
|
|
11523
|
-
if (next.kind === "math") {
|
|
11524
|
-
focusMathToken(next.id);
|
|
11525
|
-
} else if (next.kind === "cite") {
|
|
11526
|
-
focusCiteToken(next.id);
|
|
11527
|
-
} else {
|
|
11528
|
-
focusRefToken(next.id);
|
|
11529
|
-
}
|
|
11549
|
+
const unsupportedEmoji = hasXeLatexUnsupportedEmoji(token.text);
|
|
11550
|
+
const errorId = `butex-document2-unsupported-emoji-${token.id}`;
|
|
11551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react3.Fragment, { children: [
|
|
11552
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
11553
|
+
"textarea",
|
|
11554
|
+
{
|
|
11555
|
+
className: "butex-document2-widget__inline-text",
|
|
11556
|
+
value: token.text,
|
|
11557
|
+
"data-bold": token.style?.bold === true ? "true" : void 0,
|
|
11558
|
+
"data-italic": token.style?.italic === true ? "true" : void 0,
|
|
11559
|
+
"data-underline": token.style?.underline === true ? "true" : void 0,
|
|
11560
|
+
dir: documentDirection,
|
|
11561
|
+
"aria-label": messages.text,
|
|
11562
|
+
"aria-invalid": unsupportedEmoji ? true : void 0,
|
|
11563
|
+
"aria-describedby": unsupportedEmoji ? errorId : void 0,
|
|
11564
|
+
rows: 1,
|
|
11565
|
+
"data-field-id": field.id,
|
|
11566
|
+
"data-text-token-id": token.id,
|
|
11567
|
+
style: unsupportedEmoji ? {
|
|
11568
|
+
borderColor: "var(--butex-document2-error)",
|
|
11569
|
+
background: "var(--butex-document2-error-bg)"
|
|
11570
|
+
} : void 0,
|
|
11571
|
+
ref: (element) => {
|
|
11572
|
+
if (element) {
|
|
11573
|
+
textRefs.current.set(token.id, element);
|
|
11574
|
+
fitTextareaHeight(element);
|
|
11575
|
+
} else {
|
|
11576
|
+
textRefs.current.delete(token.id);
|
|
11530
11577
|
}
|
|
11531
|
-
}
|
|
11532
|
-
|
|
11533
|
-
|
|
11534
|
-
|
|
11535
|
-
|
|
11536
|
-
|
|
11537
|
-
|
|
11538
|
-
|
|
11539
|
-
|
|
11540
|
-
|
|
11578
|
+
},
|
|
11579
|
+
onChange: (event) => {
|
|
11580
|
+
onTextChange(field.id, token.id, event.currentTarget.value);
|
|
11581
|
+
fitTextareaHeight(event.currentTarget);
|
|
11582
|
+
},
|
|
11583
|
+
onKeyDown: (event) => {
|
|
11584
|
+
const element = event.currentTarget;
|
|
11585
|
+
const collapsed = element.selectionStart === element.selectionEnd;
|
|
11586
|
+
if (!collapsed) {
|
|
11587
|
+
return;
|
|
11588
|
+
}
|
|
11589
|
+
if (event.key === forwardArrowKey && element.selectionStart === element.value.length) {
|
|
11590
|
+
const next = adjacentIslandId(token.id, 1);
|
|
11591
|
+
if (next) {
|
|
11592
|
+
event.preventDefault();
|
|
11593
|
+
if (next.kind === "math") {
|
|
11594
|
+
focusMathToken(next.id);
|
|
11595
|
+
} else if (next.kind === "cite") {
|
|
11596
|
+
focusCiteToken(next.id);
|
|
11597
|
+
} else {
|
|
11598
|
+
focusRefToken(next.id);
|
|
11599
|
+
}
|
|
11600
|
+
}
|
|
11601
|
+
} else if (event.key === backwardArrowKey && element.selectionStart === 0) {
|
|
11602
|
+
const previous = adjacentIslandId(token.id, -1);
|
|
11603
|
+
if (previous) {
|
|
11604
|
+
event.preventDefault();
|
|
11605
|
+
if (previous.kind === "math") {
|
|
11606
|
+
focusMathToken(previous.id);
|
|
11607
|
+
} else if (previous.kind === "cite") {
|
|
11608
|
+
focusCiteToken(previous.id);
|
|
11609
|
+
} else {
|
|
11610
|
+
focusRefToken(previous.id);
|
|
11611
|
+
}
|
|
11541
11612
|
}
|
|
11542
11613
|
}
|
|
11543
|
-
}
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11551
|
-
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11614
|
+
},
|
|
11615
|
+
onFocus: (event) => rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus),
|
|
11616
|
+
onClick: (event) => rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus),
|
|
11617
|
+
onKeyUp: (event) => {
|
|
11618
|
+
rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus);
|
|
11619
|
+
fitTextareaHeight(event.currentTarget);
|
|
11620
|
+
},
|
|
11621
|
+
onSelect: (event) => rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus),
|
|
11622
|
+
onBlur: () => onFieldBlur?.()
|
|
11623
|
+
}
|
|
11624
|
+
),
|
|
11625
|
+
unsupportedEmoji ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
11626
|
+
"p",
|
|
11627
|
+
{
|
|
11628
|
+
id: errorId,
|
|
11629
|
+
className: "butex-document2-widget__field-error",
|
|
11630
|
+
style: { flexBasis: "100%" },
|
|
11631
|
+
children: unsupportedEmojiMessage(uiLocale)
|
|
11632
|
+
}
|
|
11633
|
+
) : null
|
|
11634
|
+
] }, token.id);
|
|
11556
11635
|
}
|
|
11557
11636
|
if (token.kind === "cite") {
|
|
11558
11637
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|