@pretextbook/web-editor 0.5.0 → 0.5.2
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.es.js +39 -30
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/sectionUtils.d.ts +10 -4
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -95241,7 +95241,20 @@ function $6(e, t) {
|
|
|
95241
95241
|
for (let e of n) for (let t of B6(e.content)) r.has(t) && i.add(t);
|
|
95242
95242
|
return n.filter((e) => !i.has(e.xmlId));
|
|
95243
95243
|
}
|
|
95244
|
-
|
|
95244
|
+
var e8 = new Set([
|
|
95245
|
+
"book",
|
|
95246
|
+
"article",
|
|
95247
|
+
"slideshow"
|
|
95248
|
+
]);
|
|
95249
|
+
function t8(e) {
|
|
95250
|
+
try {
|
|
95251
|
+
let t = t6(e), n = t.children.find((e) => e.type === "element"), r = n?.name === "pretext" ? n.children.find((e) => e.type === "element") : n;
|
|
95252
|
+
return r && !r.attributes.label && !r.attributes.xmlId ? (r.attributes.label = "preview", qY(t)) : e;
|
|
95253
|
+
} catch (t) {
|
|
95254
|
+
return console.error("Error ensuring label:", t), e;
|
|
95255
|
+
}
|
|
95256
|
+
}
|
|
95257
|
+
function n8(e, t, n) {
|
|
95245
95258
|
let r = t.find((t) => t.xmlId === e);
|
|
95246
95259
|
if (!r) return `<!-- missing division: ${e} -->`;
|
|
95247
95260
|
if (n.has(e)) return `<!-- circular reference: ${e} -->`;
|
|
@@ -95253,23 +95266,19 @@ function e8(e, t, n) {
|
|
|
95253
95266
|
}
|
|
95254
95267
|
if (r.sourceFormat !== "pretext") return i;
|
|
95255
95268
|
let a = new Set(n).add(e);
|
|
95256
|
-
return i.replace(/<plus:[a-z-]+\s[^>]*ref="([^"]+)"[^>]*?(?:\/>|>\s*<\/plus:[a-z-]+>)/g, (e, n) =>
|
|
95269
|
+
return i.replace(/<plus:[a-z-]+\s[^>]*ref="([^"]+)"[^>]*?(?:\/>|>\s*<\/plus:[a-z-]+>)/g, (e, n) => n8(n, t, a));
|
|
95257
95270
|
}
|
|
95258
|
-
function
|
|
95259
|
-
return
|
|
95271
|
+
function r8(e, t) {
|
|
95272
|
+
return t8(n8(t, e, /* @__PURE__ */ new Set()));
|
|
95260
95273
|
}
|
|
95261
|
-
var
|
|
95262
|
-
|
|
95263
|
-
|
|
95264
|
-
"
|
|
95265
|
-
]);
|
|
95266
|
-
function i8(e, t, n) {
|
|
95267
|
-
let r = r8.has(e) ? t : n8.has(e) ? `<book>\n${t}\n</book>` : `<article>\n${t}\n</article>`;
|
|
95268
|
-
return `<pretext>\n${n.trim() ? `${n.trim()}\n` : ""}${r}\n</pretext>`;
|
|
95274
|
+
var i8 = new Set(["part", "chapter"]);
|
|
95275
|
+
function a8(e, t, n, r) {
|
|
95276
|
+
let i = e8.has(e) ? t : i8.has(e) ? `<book>\n<title>${r}</title>\n${t}\n</book>` : `<article>\n<title>${r}</title>\n${t}\n</article>`;
|
|
95277
|
+
return t8(`<pretext>\n${n.trim() ? `${n.trim()}\n` : ""}${i}\n</pretext>`);
|
|
95269
95278
|
}
|
|
95270
95279
|
//#endregion
|
|
95271
95280
|
//#region src/components/toc/ArticleToc.tsx
|
|
95272
|
-
var
|
|
95281
|
+
var o8 = ({ onOpenAssetPicker: r }) => {
|
|
95273
95282
|
let i = b3((e) => e.divisions), o = b3((e) => e.rootDivisionId), s = b3((e) => e.activeDivisionId), c = b3((e) => e.selectSection), l = b3((e) => e.removeSection), u = b3((e) => e.divisionContentChange), d = b3((e) => e.insertAtCursor), f = b3((e) => e.startSectionEdit), p = b3((e) => e.setEditDraft), h = b3((e) => e.commitSectionEdit), g = b3((e) => e.cancelSectionEdit), _ = b3((e) => e.editingId), v = b3((e) => e.editDraft), y = i ? i.find((e) => e.xmlId === o) ?? i.find((e) => e.type === "book" || e.type === "article" || e.type === "slideshow") ?? i[0] ?? null : null, x = y && i ? Q6(i, y.xmlId) : [], S = y && i ? $6(i, y.xmlId) : [], [C, w] = b(/* @__PURE__ */ new Set()), T = (e) => !C.has(e), E = (e) => {
|
|
95274
95283
|
w((t) => {
|
|
95275
95284
|
let n = new Set(t);
|
|
@@ -95454,7 +95463,7 @@ var a8 = ({ onOpenAssetPicker: r }) => {
|
|
|
95454
95463
|
children: "Manage Assets"
|
|
95455
95464
|
})
|
|
95456
95465
|
] });
|
|
95457
|
-
},
|
|
95466
|
+
}, s8 = ({ isCollapsed: e, onToggleCollapse: r, onOpenAssetPicker: i }) => e ? /* @__PURE__ */ t("div", {
|
|
95458
95467
|
className: "pretext-plus-editor__toc pretext-plus-editor__toc--collapsed",
|
|
95459
95468
|
children: /* @__PURE__ */ t("button", {
|
|
95460
95469
|
type: "button",
|
|
@@ -95482,8 +95491,8 @@ var a8 = ({ onOpenAssetPicker: r }) => {
|
|
|
95482
95491
|
children: "✕"
|
|
95483
95492
|
})
|
|
95484
95493
|
})]
|
|
95485
|
-
}), /* @__PURE__ */ t(
|
|
95486
|
-
}),
|
|
95494
|
+
}), /* @__PURE__ */ t(o8, { onOpenAssetPicker: i })]
|
|
95495
|
+
}), c8 = class extends i {
|
|
95487
95496
|
state = { error: null };
|
|
95488
95497
|
static getDerivedStateFromError(e) {
|
|
95489
95498
|
return { error: e };
|
|
@@ -95522,7 +95531,7 @@ var a8 = ({ onOpenAssetPicker: r }) => {
|
|
|
95522
95531
|
};
|
|
95523
95532
|
//#endregion
|
|
95524
95533
|
//#region src/store/editorStore.ts
|
|
95525
|
-
function
|
|
95534
|
+
function l8(e) {
|
|
95526
95535
|
let t = () => {}, n = { cbs: {
|
|
95527
95536
|
selectDivision: t,
|
|
95528
95537
|
addDivision: t,
|
|
@@ -95642,7 +95651,7 @@ function c8(e) {
|
|
|
95642
95651
|
}
|
|
95643
95652
|
//#endregion
|
|
95644
95653
|
//#region src/store/EditorStoreProvider.tsx
|
|
95645
|
-
function
|
|
95654
|
+
function u8({ store: e, children: n }) {
|
|
95646
95655
|
return /* @__PURE__ */ t(y3.Provider, {
|
|
95647
95656
|
value: e,
|
|
95648
95657
|
children: n
|
|
@@ -95650,10 +95659,10 @@ function l8({ store: e, children: n }) {
|
|
|
95650
95659
|
}
|
|
95651
95660
|
//#endregion
|
|
95652
95661
|
//#region src/components/Editors.tsx
|
|
95653
|
-
var
|
|
95662
|
+
var d8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type === "article" || e.type === "slideshow") ?? e[0] ?? null, f8 = (e) => {
|
|
95654
95663
|
let [n] = b(() => {
|
|
95655
|
-
let t =
|
|
95656
|
-
return
|
|
95664
|
+
let t = d8(e.divisions, e.rootDivisionId), n = e.activeDivisionId ?? t?.xmlId ?? null, r = e.divisions.find((e) => e.xmlId === n) ?? t;
|
|
95665
|
+
return l8({
|
|
95657
95666
|
source: r?.content ?? "",
|
|
95658
95667
|
sourceFormat: r?.sourceFormat ?? "pretext",
|
|
95659
95668
|
title: e.title ?? "Document Title",
|
|
@@ -95665,15 +95674,15 @@ var u8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95665
95674
|
activeDivisionId: n
|
|
95666
95675
|
});
|
|
95667
95676
|
});
|
|
95668
|
-
return /* @__PURE__ */ t(
|
|
95677
|
+
return /* @__PURE__ */ t(u8, {
|
|
95669
95678
|
store: n.store,
|
|
95670
|
-
children: /* @__PURE__ */ t(
|
|
95679
|
+
children: /* @__PURE__ */ t(p8, {
|
|
95671
95680
|
...e,
|
|
95672
95681
|
bindCallbacks: n.bindCallbacks
|
|
95673
95682
|
})
|
|
95674
95683
|
});
|
|
95675
|
-
},
|
|
95676
|
-
let { bindCallbacks: r } = e, i = b3((e) => e.showFullPreview), a = b3((e) => e.isNarrowScreen), o = b3((e) => e.setIsNarrowScreen), s = b3((e) => e.activeTab), c = b3((e) => e.setActiveTab), l = b3((e) => e.isTocCollapsed), u = b3((e) => e.setIsTocCollapsed), d = b3((e) => e.isLatexDialogOpen), f = b3((e) => e.isConvertDialogOpen), p = b3((e) => e.isDocinfoEditorOpen), h = b3((e) => e.isAssetPickerOpen), g = b3((e) => e.openModal), b = b3((e) => e.closeModal), x = b3((e) => e.syncState), S = b3((e) => e.divisions) ?? [], C = b3((e) => e.activeDivisionId), w = b3((e) => e.title), T = b3((e) => e.docinfo), E = b3((e) => e.commonDocinfo), D = b3((e) => e.useCommonDocinfo), O = b3((e) => e.applyExternalUpdate), k = b3((e) => e.setDivisionContent), A = b3((e) => e.patchDivision), j = b3((e) => e.addDivisionToPool), ee = b3((e) => e.removeDivisionFromPool), te = b3((e) => e.setActiveDivisionId), ne = b3((e) => e.setTitle), M = b3((e) => e.setDocinfo), N = y(null), re = y(null), ie =
|
|
95684
|
+
}, p8 = (e) => {
|
|
95685
|
+
let { bindCallbacks: r } = e, i = b3((e) => e.showFullPreview), a = b3((e) => e.isNarrowScreen), o = b3((e) => e.setIsNarrowScreen), s = b3((e) => e.activeTab), c = b3((e) => e.setActiveTab), l = b3((e) => e.isTocCollapsed), u = b3((e) => e.setIsTocCollapsed), d = b3((e) => e.isLatexDialogOpen), f = b3((e) => e.isConvertDialogOpen), p = b3((e) => e.isDocinfoEditorOpen), h = b3((e) => e.isAssetPickerOpen), g = b3((e) => e.openModal), b = b3((e) => e.closeModal), x = b3((e) => e.syncState), S = b3((e) => e.divisions) ?? [], C = b3((e) => e.activeDivisionId), w = b3((e) => e.title), T = b3((e) => e.docinfo), E = b3((e) => e.commonDocinfo), D = b3((e) => e.useCommonDocinfo), O = b3((e) => e.applyExternalUpdate), k = b3((e) => e.setDivisionContent), A = b3((e) => e.patchDivision), j = b3((e) => e.addDivisionToPool), ee = b3((e) => e.removeDivisionFromPool), te = b3((e) => e.setActiveDivisionId), ne = b3((e) => e.setTitle), M = b3((e) => e.setDocinfo), N = y(null), re = y(null), ie = d8(S, e.rootDivisionId), ae = S.find((e) => e.xmlId === C) ?? S[0] ?? null, P = ae?.sourceFormat ?? "pretext", oe = ae?.content ?? "", F = (t, n, r, i) => {
|
|
95677
95686
|
k(t, n), e.onContentChange({
|
|
95678
95687
|
xmlId: t,
|
|
95679
95688
|
sourceContent: n,
|
|
@@ -95783,7 +95792,7 @@ var u8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95783
95792
|
let t = ge.current, n = {}, r = !1;
|
|
95784
95793
|
if (e.divisions !== t.divisions) {
|
|
95785
95794
|
n.divisions = e.divisions;
|
|
95786
|
-
let t =
|
|
95795
|
+
let t = d8(e.divisions, e.rootDivisionId);
|
|
95787
95796
|
(C == null || !e.divisions.some((e) => e.xmlId === C)) && (n.activeDivisionId = t?.xmlId ?? null), r = !0;
|
|
95788
95797
|
}
|
|
95789
95798
|
e.title !== void 0 && e.title !== t.title && (n.title = e.title, r = !0), e.docinfo !== void 0 && e.docinfo !== t.docinfo && (n.docinfo = e.docinfo, r = !0), e.commonDocinfo !== void 0 && e.commonDocinfo !== t.commonDocinfo && (n.commonDocinfo = e.commonDocinfo, r = !0), e.useCommonDocinfo !== void 0 && e.useCommonDocinfo !== t.useCommonDocinfo && (n.useCommonDocinfo = e.useCommonDocinfo, r = !0), e.activeDivisionId !== void 0 && e.activeDivisionId !== t.activeDivisionId && (n.activeDivisionId = e.activeDivisionId, r = !0), r && O(n), ge.current = {
|
|
@@ -95795,7 +95804,7 @@ var u8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95795
95804
|
activeDivisionId: e.activeDivisionId
|
|
95796
95805
|
};
|
|
95797
95806
|
});
|
|
95798
|
-
let _e = D ? E : T, ve = ae ? P === "pretext" ? ae.
|
|
95807
|
+
let _e = D ? E : T, ve = ae ? P === "pretext" ? r8(S, ae.xmlId) : I === void 0 ? void 0 : `<${ae.type} xml:id="${ae.xmlId}">\n<title>${ae.title}</title>\n\n${I}\n</${ae.type}>` : void 0, ye = ae && ve !== void 0 ? a8(ae.type, ve, _e, ae.title) : void 0, be = () => N.current?.rebuild(), xe = () => {
|
|
95799
95808
|
e.onSave?.(), N.current?.rebuild();
|
|
95800
95809
|
}, Se = (t) => {
|
|
95801
95810
|
let n = t.ctrlKey || t.metaKey;
|
|
@@ -95835,7 +95844,7 @@ var u8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95835
95844
|
editDisabledReason: P === "markdown" ? "Visual editing is not available for Markdown documents." : P === "latex" ? "Visual editing is not available for LaTeX documents." : "",
|
|
95836
95845
|
onChange: (e) => de(e)
|
|
95837
95846
|
});
|
|
95838
|
-
let Te = /* @__PURE__ */ t(
|
|
95847
|
+
let Te = /* @__PURE__ */ t(s8, {
|
|
95839
95848
|
isCollapsed: l,
|
|
95840
95849
|
onToggleCollapse: () => u((e) => !e),
|
|
95841
95850
|
onOpenAssetPicker: e.projectAssets === void 0 ? void 0 : () => g("isAssetPickerOpen")
|
|
@@ -95923,7 +95932,7 @@ var u8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95923
95932
|
}), /* @__PURE__ */ n("div", {
|
|
95924
95933
|
className: "pretext-plus-editor__editor-displays",
|
|
95925
95934
|
children: [
|
|
95926
|
-
/* @__PURE__ */ t(
|
|
95935
|
+
/* @__PURE__ */ t(c8, {
|
|
95927
95936
|
resetKeys: [oe, C],
|
|
95928
95937
|
children: B
|
|
95929
95938
|
}),
|
|
@@ -95973,6 +95982,6 @@ var u8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95973
95982
|
});
|
|
95974
95983
|
};
|
|
95975
95984
|
//#endregion
|
|
95976
|
-
export { nc as CodeEditor, R3 as DocinfoEditor,
|
|
95985
|
+
export { nc as CodeEditor, R3 as DocinfoEditor, f8 as Editors, m3 as FeedbackLink, xR as FullPreview, vR as VisualEditor, r8 as assembleProjectSource, Q6 as buildDivisionTree, l3 as convertLatexToPretext, S6 as createConclusion, x6 as createIntroduction, N6 as createLatexConclusion, M6 as createLatexIntroduction, j6 as createNewLatexSection, b6 as createNewSection, f3 as derivePretextContent, c3 as detectSourceFormat, O6 as ensureLatexSectionWrapper, T6 as ensureSectionWrapper, I6 as extractDivisionMetadata, A6 as extractLatexDivisionTitle, q6 as findDivisionParent, $6 as getOrphanRoots, Z6 as getOrphanedDivisions, F6 as getSectionAttributes, U6 as insertDivisionRef, P6 as mergeTwoSections, G6 as moveDivisionRef, Y6 as normalizeSelfClosingRefs, B6 as parseDivisionRefs, bR as postToIframe, W6 as removeDivisionRef, K6 as renameDivisionRef, J6 as reorderDivisionRefs, D6 as rewrapLatexSection, w6 as rewrapSection, E6 as stripLatexSectionWrapper, C6 as stripSectionWrapper, y6 as updateDivisionTitle, k6 as updateLatexSectionTitle, L6 as updateSectionMetadata, a8 as wrapDivisionForPreview };
|
|
95977
95986
|
|
|
95978
95987
|
//# sourceMappingURL=index.es.js.map
|