@pretextbook/web-editor 0.11.1 → 0.11.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/components/CodeEditor.d.ts +2 -0
- package/dist/components/toc/types.d.ts +6 -0
- package/dist/index.es.js +403 -352
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/sectionUtils.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -13964,16 +13964,21 @@ var dc = {
|
|
|
13964
13964
|
}
|
|
13965
13965
|
}, fc = l(({ content: e, sourceFormat: r, onChange: i, onRebuild: a, onSave: o, onOpenLatexImport: s, onOpenDocinfoEditor: c, onOpenConvertToPretext: l, canConvertToPretext: u, onOpenAssets: d, onShowFullSource: f, onRequestWrapperEdit: p }, h) => {
|
|
13966
13966
|
let _ = y(null), v = y(null), x = y(null), S = y(null), C = y(!1), w = y(0), T = y(null), E = y(null), D = y(p), O = y(null), k = y(null), A = y(!1), [j, ee] = b(!1), [te, ne] = b(!1), M = y(a), N = y(o);
|
|
13967
|
-
g(h, () => ({
|
|
13968
|
-
|
|
13969
|
-
|
|
13970
|
-
|
|
13971
|
-
|
|
13972
|
-
|
|
13973
|
-
|
|
13974
|
-
|
|
13975
|
-
|
|
13976
|
-
|
|
13967
|
+
g(h, () => ({
|
|
13968
|
+
insertAtCursor: (e) => {
|
|
13969
|
+
let t = _.current;
|
|
13970
|
+
if (!t) return;
|
|
13971
|
+
let n = t.getSelection();
|
|
13972
|
+
n && (t.executeEdits("insert-asset", [{
|
|
13973
|
+
range: n,
|
|
13974
|
+
text: e,
|
|
13975
|
+
forceMoveMarkers: !0
|
|
13976
|
+
}]), t.focus());
|
|
13977
|
+
},
|
|
13978
|
+
focus: () => {
|
|
13979
|
+
_.current?.focus();
|
|
13980
|
+
}
|
|
13981
|
+
}), []), m(() => {
|
|
13977
13982
|
M.current = a;
|
|
13978
13983
|
}, [a]), m(() => {
|
|
13979
13984
|
N.current = o;
|
|
@@ -98035,7 +98040,7 @@ function V6(e) {
|
|
|
98035
98040
|
function H6(e) {
|
|
98036
98041
|
let t = e.match(/^\s*<([A-Za-z_][\w.:-]*)\b[^>]*?>/);
|
|
98037
98042
|
if (!t || t.index === void 0) return e;
|
|
98038
|
-
let n = e.slice(t.index + t[0].length), r = RegExp(`\\s*</${
|
|
98043
|
+
let n = e.slice(t.index + t[0].length), r = RegExp(`\\s*</${x8(t[1])}\\s*>\\s*$`);
|
|
98039
98044
|
return z6(n.replace(r, ""));
|
|
98040
98045
|
}
|
|
98041
98046
|
function U6(e, t) {
|
|
@@ -98088,7 +98093,7 @@ function q6(e) {
|
|
|
98088
98093
|
let t = B6(e);
|
|
98089
98094
|
if (!t) return H6(e);
|
|
98090
98095
|
let n = t.children.find((e) => e.type === "element");
|
|
98091
|
-
return n ?
|
|
98096
|
+
return n ? R8(rX({
|
|
98092
98097
|
type: "root",
|
|
98093
98098
|
children: R6(n.children)
|
|
98094
98099
|
})) : e;
|
|
@@ -98141,7 +98146,7 @@ function r8(e, t) {
|
|
|
98141
98146
|
}
|
|
98142
98147
|
function i8(e) {
|
|
98143
98148
|
let { pretextSource: t, pretextError: n } = z3(e.content, "latex");
|
|
98144
|
-
return n || t === void 0 ? null :
|
|
98149
|
+
return n || t === void 0 ? null : U8.has(e.type) ? `<${e.type} xml:id="${e.xmlId}">\n<title>${e.title}</title>\n\n${t}\n</${e.type}>` : t;
|
|
98145
98150
|
}
|
|
98146
98151
|
function a8(e = "New Section") {
|
|
98147
98152
|
let t = F6();
|
|
@@ -98222,6 +98227,9 @@ function u8(e) {
|
|
|
98222
98227
|
return e.trim().replace(/[^A-Za-z0-9_-]/g, "-").replace(/^[^A-Za-z_]+/, "");
|
|
98223
98228
|
}
|
|
98224
98229
|
function d8(e) {
|
|
98230
|
+
return u8(e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, ""));
|
|
98231
|
+
}
|
|
98232
|
+
function f8(e) {
|
|
98225
98233
|
let t = B6(e);
|
|
98226
98234
|
if (!t) return null;
|
|
98227
98235
|
let n = t.children.find((e) => e.type === "element");
|
|
@@ -98232,7 +98240,7 @@ function d8(e) {
|
|
|
98232
98240
|
label: n.attributes?.label ?? ""
|
|
98233
98241
|
};
|
|
98234
98242
|
}
|
|
98235
|
-
function
|
|
98243
|
+
function p8(e, t) {
|
|
98236
98244
|
let n = t.type ?? e.type, r = t.title ?? e.title;
|
|
98237
98245
|
try {
|
|
98238
98246
|
let i = v6(e.content).children.find((e) => e.type === "element");
|
|
@@ -98277,16 +98285,16 @@ function f8(e, t) {
|
|
|
98277
98285
|
};
|
|
98278
98286
|
}
|
|
98279
98287
|
}
|
|
98280
|
-
var
|
|
98281
|
-
function
|
|
98282
|
-
let t =
|
|
98288
|
+
var m8 = /^\uFEFF?[ \t]*---[ \t]*\r?\n([\s\S]*?)\r?\n[ \t]*---[ \t]*(?:\r?\n|$)/;
|
|
98289
|
+
function h8(e) {
|
|
98290
|
+
let t = m8.exec(e);
|
|
98283
98291
|
if (!t) return null;
|
|
98284
98292
|
let n = e.slice(t[0].length), r = "section", i = "", a = "";
|
|
98285
98293
|
for (let e of t[1].split(/\r?\n/)) {
|
|
98286
|
-
let t = /^[ \t]*(xml:id|division|label)[ \t]*:[ \t]*(.*)$/.exec(e);
|
|
98294
|
+
let t = /^[ \t]*(xmlid|xml:id|division|label)[ \t]*:[ \t]*(.*)$/.exec(e);
|
|
98287
98295
|
if (!t) continue;
|
|
98288
98296
|
let n = t[2].trim().replace(/^["']|["']$/g, "");
|
|
98289
|
-
t[1] === "division" ? r = n : t[1] === "xml:id" ? i = n : a = n;
|
|
98297
|
+
t[1] === "division" ? r = n : t[1] === "xmlid" || t[1] === "xml:id" ? i = n : a = n;
|
|
98290
98298
|
}
|
|
98291
98299
|
return {
|
|
98292
98300
|
type: r || "section",
|
|
@@ -98295,29 +98303,29 @@ function m8(e) {
|
|
|
98295
98303
|
body: n
|
|
98296
98304
|
};
|
|
98297
98305
|
}
|
|
98298
|
-
function
|
|
98299
|
-
let t = [`division: ${e.type}`, `
|
|
98306
|
+
function g8(e) {
|
|
98307
|
+
let t = [`division: ${e.type}`, `xmlid: ${e.xmlId}`];
|
|
98300
98308
|
return e.label && t.push(`label: ${e.label}`), `---\n${t.join("\n")}\n---`;
|
|
98301
98309
|
}
|
|
98302
|
-
function
|
|
98310
|
+
function _8(e) {
|
|
98303
98311
|
let t = /^[ \t]*#[ \t]+(.*)$/m.exec(e);
|
|
98304
98312
|
return t ? t[1].trim() : null;
|
|
98305
98313
|
}
|
|
98306
|
-
function
|
|
98314
|
+
function v8(e, t) {
|
|
98307
98315
|
let n = /^[ \t]*#[ \t]+.*$/m.exec(e);
|
|
98308
98316
|
return n ? e.slice(0, n.index) + `# ${t}` + e.slice(n.index + n[0].length) : `# ${t}\n\n${e.replace(/^\s+/, "")}`;
|
|
98309
98317
|
}
|
|
98310
|
-
function
|
|
98311
|
-
let t =
|
|
98318
|
+
function y8(e) {
|
|
98319
|
+
let t = h8(e);
|
|
98312
98320
|
return t ? {
|
|
98313
|
-
title:
|
|
98321
|
+
title: _8(t.body) ?? "",
|
|
98314
98322
|
type: t.type,
|
|
98315
98323
|
xmlId: t.xmlId,
|
|
98316
98324
|
label: t.label
|
|
98317
98325
|
} : null;
|
|
98318
98326
|
}
|
|
98319
|
-
function
|
|
98320
|
-
let n =
|
|
98327
|
+
function b8(e, t) {
|
|
98328
|
+
let n = h8(e.content), r = n ? n.body : e.content, i = n?.type ?? e.type, a = n?.xmlId ?? e.xmlId, o = n?.label ?? "", s = t.type ?? i, c = (t.xmlId === void 0 ? a : t.xmlId ?? "") || e.xmlId, l = t.label === void 0 ? o : t.label ?? "", u = t.title === void 0 ? r : v8(r, t.title), d = `${g8({
|
|
98321
98329
|
type: s,
|
|
98322
98330
|
xmlId: c,
|
|
98323
98331
|
label: l
|
|
@@ -98330,21 +98338,21 @@ function y8(e, t) {
|
|
|
98330
98338
|
content: d
|
|
98331
98339
|
};
|
|
98332
98340
|
}
|
|
98333
|
-
function
|
|
98341
|
+
function x8(e) {
|
|
98334
98342
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
98335
98343
|
}
|
|
98336
|
-
var
|
|
98337
|
-
function
|
|
98338
|
-
let t = e === null ? "ref=\"([^\"]+)\"" : `ref="${
|
|
98344
|
+
var S8 = new Set(["division", ...L6]), C8 = Array.from(S8).join("|");
|
|
98345
|
+
function w8(e) {
|
|
98346
|
+
let t = e === null ? "ref=\"([^\"]+)\"" : `ref="${x8(e)}"`, n = `(?:${C8})`;
|
|
98339
98347
|
return `<plus:${n}\\s[^>]*${t}[^>]*?(?:/>|>\\s*</plus:${n}>)`;
|
|
98340
98348
|
}
|
|
98341
|
-
function
|
|
98342
|
-
let t = [], n = new RegExp(
|
|
98349
|
+
function T8(e) {
|
|
98350
|
+
let t = [], n = new RegExp(w8(null), "g"), r;
|
|
98343
98351
|
for (; (r = n.exec(e)) !== null;) t.push(r[1]);
|
|
98344
98352
|
return t;
|
|
98345
98353
|
}
|
|
98346
|
-
function
|
|
98347
|
-
let t = [], n = `(?:${
|
|
98354
|
+
function E8(e) {
|
|
98355
|
+
let t = [], n = `(?:${C8})`, r = RegExp(`<plus:(${C8})\\s[^>]*ref="([^"]+)"[^>]*?(?:/>|>\\s*</plus:${n}>)`, "g"), i;
|
|
98348
98356
|
for (; (i = r.exec(e)) !== null;) {
|
|
98349
98357
|
let e = i[1], n = e === "division" ? "section" : e;
|
|
98350
98358
|
t.push({
|
|
@@ -98354,7 +98362,7 @@ function T8(e) {
|
|
|
98354
98362
|
}
|
|
98355
98363
|
return t;
|
|
98356
98364
|
}
|
|
98357
|
-
function
|
|
98365
|
+
function D8(e) {
|
|
98358
98366
|
let t = [], n = /<plus:(image|doenet)\b[^>]*\bref="([^"]+)"/g, r;
|
|
98359
98367
|
for (; (r = n.exec(e)) !== null;) t.push({
|
|
98360
98368
|
kind: r[1],
|
|
@@ -98362,15 +98370,15 @@ function E8(e) {
|
|
|
98362
98370
|
});
|
|
98363
98371
|
return t;
|
|
98364
98372
|
}
|
|
98365
|
-
function
|
|
98366
|
-
let i = RegExp(`(<plus:${
|
|
98373
|
+
function O8(e, t, n, r) {
|
|
98374
|
+
let i = RegExp(`(<plus:${x8(t)}\\b[^>]*?\\bref=")${x8(n)}(")`, "g");
|
|
98367
98375
|
return e.replace(i, `$1${r}$2`);
|
|
98368
98376
|
}
|
|
98369
|
-
function
|
|
98370
|
-
let r = RegExp(`<plus:${
|
|
98377
|
+
function k8(e, t, n) {
|
|
98378
|
+
let r = RegExp(`<plus:${x8(t)}\\b[^>]*?\\bref="${x8(n)}"[^>]*/?>`, "g");
|
|
98371
98379
|
return e.replace(r, "");
|
|
98372
98380
|
}
|
|
98373
|
-
function
|
|
98381
|
+
function A8(e, t, n = "pretext") {
|
|
98374
98382
|
let r = `New ${t.charAt(0).toUpperCase() + t.slice(1)}`;
|
|
98375
98383
|
return {
|
|
98376
98384
|
id: e,
|
|
@@ -98378,20 +98386,20 @@ function k8(e, t, n = "pretext") {
|
|
|
98378
98386
|
title: r,
|
|
98379
98387
|
type: t,
|
|
98380
98388
|
sourceFormat: n,
|
|
98381
|
-
content:
|
|
98389
|
+
content: j8(t, n, r, e)
|
|
98382
98390
|
};
|
|
98383
98391
|
}
|
|
98384
|
-
function
|
|
98385
|
-
return t === "latex" ? e === "introduction" || e === "conclusion" ? `% ${n}\n\n` : `\\${e}{${n}}\n\n` : t === "markdown" ? `${
|
|
98392
|
+
function j8(e, t, n, r) {
|
|
98393
|
+
return t === "latex" ? e === "introduction" || e === "conclusion" ? `% ${n}\n\n` : `\\${e}{${n}}\\label{${r}}\n\n` : t === "markdown" ? `${g8({
|
|
98386
98394
|
type: e,
|
|
98387
98395
|
xmlId: r,
|
|
98388
98396
|
label: ""
|
|
98389
98397
|
})}\n# ${n}\n\n` : e === "introduction" || e === "conclusion" ? `<${e} xml:id="${r}">\n\n\t<p>\n\n\t</p>\n\n</${e}>` : `<${e} xml:id="${r}">\n\t<title>${n}</title>\n\n\t<p>\n\n\t</p>\n\n</${e}>`;
|
|
98390
98398
|
}
|
|
98391
|
-
function
|
|
98399
|
+
function M8(e, t, n, r) {
|
|
98392
98400
|
let i = `<plus:${n} ref="${t}"/>`;
|
|
98393
98401
|
if (r !== null) {
|
|
98394
|
-
let t = new RegExp(
|
|
98402
|
+
let t = new RegExp(w8(r)).exec(e);
|
|
98395
98403
|
if (t) {
|
|
98396
98404
|
let n = t.index + t[0].length;
|
|
98397
98405
|
return e.slice(0, n) + "\n" + i + e.slice(n);
|
|
@@ -98400,14 +98408,14 @@ function j8(e, t, n, r) {
|
|
|
98400
98408
|
let a = e.lastIndexOf("</");
|
|
98401
98409
|
return a === -1 ? e + "\n" + i : e.slice(0, a) + i + "\n" + e.slice(a);
|
|
98402
98410
|
}
|
|
98403
|
-
function
|
|
98404
|
-
let n = RegExp(`[ \t]*${
|
|
98411
|
+
function N8(e, t) {
|
|
98412
|
+
let n = RegExp(`[ \t]*${w8(t)}[ \t]*\n?`, "g");
|
|
98405
98413
|
return e.replace(n, "");
|
|
98406
98414
|
}
|
|
98407
|
-
function
|
|
98408
|
-
let r = new RegExp(
|
|
98415
|
+
function P8(e, t, n) {
|
|
98416
|
+
let r = new RegExp(w8(t)).exec(e), i = r ? R8(r[0]) : `<plus:division ref="${t}"/>`, a = N8(e, t);
|
|
98409
98417
|
if (n !== null) {
|
|
98410
|
-
let e = new RegExp(
|
|
98418
|
+
let e = new RegExp(w8(n)).exec(a);
|
|
98411
98419
|
if (e) {
|
|
98412
98420
|
let t = e.index + e[0].length;
|
|
98413
98421
|
return a.slice(0, t) + "\n" + i + a.slice(t);
|
|
@@ -98416,41 +98424,41 @@ function N8(e, t, n) {
|
|
|
98416
98424
|
let o = a.lastIndexOf("</");
|
|
98417
98425
|
return o === -1 ? a + "\n" + i : a.slice(0, o) + i + "\n" + a.slice(o);
|
|
98418
98426
|
}
|
|
98419
|
-
function
|
|
98420
|
-
let i = new RegExp(
|
|
98427
|
+
function F8(e, t, n, r) {
|
|
98428
|
+
let i = new RegExp(w8(t));
|
|
98421
98429
|
return i.test(e) ? e.replace(i, `<plus:${r} ref="${n}"/>`) : e;
|
|
98422
98430
|
}
|
|
98423
|
-
function
|
|
98424
|
-
let n = new RegExp(
|
|
98431
|
+
function I8(e, t) {
|
|
98432
|
+
let n = new RegExp(w8(t));
|
|
98425
98433
|
return e.find((e) => n.test(e.content)) ?? null;
|
|
98426
98434
|
}
|
|
98427
|
-
function
|
|
98435
|
+
function L8(e, t) {
|
|
98428
98436
|
let n = e, r = null;
|
|
98429
|
-
for (let e of t) n =
|
|
98437
|
+
for (let e of t) n = P8(n, e, r), r = e;
|
|
98430
98438
|
return n;
|
|
98431
98439
|
}
|
|
98432
|
-
function
|
|
98440
|
+
function R8(e) {
|
|
98433
98441
|
return e.replace(/<plus:([a-z-]+)((?:\s[^>]*?)?)>\s*<\/plus:\1>/g, (e, t, n) => `<plus:${t}${n}/>`);
|
|
98434
98442
|
}
|
|
98435
|
-
function
|
|
98443
|
+
function z8(e, t) {
|
|
98436
98444
|
let n = /* @__PURE__ */ new Set(), r = [t];
|
|
98437
98445
|
for (; r.length > 0;) {
|
|
98438
98446
|
let t = r.pop();
|
|
98439
98447
|
if (n.has(t)) continue;
|
|
98440
98448
|
n.add(t);
|
|
98441
98449
|
let i = e.find((e) => e.xmlId === t);
|
|
98442
|
-
if (i) for (let e of
|
|
98450
|
+
if (i) for (let e of T8(i.content)) r.push(e);
|
|
98443
98451
|
}
|
|
98444
98452
|
return n;
|
|
98445
98453
|
}
|
|
98446
|
-
function
|
|
98447
|
-
let n =
|
|
98454
|
+
function B8(e, t) {
|
|
98455
|
+
let n = z8(e, t);
|
|
98448
98456
|
return e.filter((e) => !n.has(e.xmlId));
|
|
98449
98457
|
}
|
|
98450
|
-
function
|
|
98458
|
+
function V8(e, t) {
|
|
98451
98459
|
let n = [], r = new Set([t]), i = (t, a) => {
|
|
98452
98460
|
let o = e.find((e) => e.xmlId === t);
|
|
98453
|
-
if (o) for (let s of
|
|
98461
|
+
if (o) for (let s of T8(o.content)) {
|
|
98454
98462
|
if (r.has(s)) continue;
|
|
98455
98463
|
let o = e.find((e) => e.xmlId === s);
|
|
98456
98464
|
o && (r.add(s), n.push({
|
|
@@ -98462,22 +98470,22 @@ function B8(e, t) {
|
|
|
98462
98470
|
};
|
|
98463
98471
|
return i(t, 0), n;
|
|
98464
98472
|
}
|
|
98465
|
-
function
|
|
98466
|
-
let n =
|
|
98467
|
-
for (let e of n) for (let t of
|
|
98473
|
+
function H8(e, t) {
|
|
98474
|
+
let n = B8(e, t), r = new Set(n.map((e) => e.xmlId)), i = /* @__PURE__ */ new Set();
|
|
98475
|
+
for (let e of n) for (let t of T8(e.content)) r.has(t) && i.add(t);
|
|
98468
98476
|
return n.filter((e) => !i.has(e.xmlId));
|
|
98469
98477
|
}
|
|
98470
|
-
var
|
|
98478
|
+
var U8 = new Set([
|
|
98471
98479
|
"book",
|
|
98472
98480
|
"article",
|
|
98473
98481
|
"slideshow"
|
|
98474
98482
|
]);
|
|
98475
|
-
function
|
|
98483
|
+
function W8(e) {
|
|
98476
98484
|
try {
|
|
98477
|
-
let t = v6(e), n = t.children.find((e) => e.type === "element"), r = n?.name === "pretext" ? n.children.find((e) => e.type === "element" &&
|
|
98485
|
+
let t = v6(e), n = t.children.find((e) => e.type === "element"), r = n?.name === "pretext" ? n.children.find((e) => e.type === "element" && U8.has(e.name)) : n && U8.has(n.name) ? n : void 0;
|
|
98478
98486
|
if (!r) return e;
|
|
98479
98487
|
if (!r.attributes.label) {
|
|
98480
|
-
let e =
|
|
98488
|
+
let e = K8(t, "pretext-plus-preview");
|
|
98481
98489
|
return r.attributes.label = e, rX(t);
|
|
98482
98490
|
}
|
|
98483
98491
|
return e;
|
|
@@ -98485,15 +98493,15 @@ function U8(e) {
|
|
|
98485
98493
|
return console.error("Error ensuring label:", t), e;
|
|
98486
98494
|
}
|
|
98487
98495
|
}
|
|
98488
|
-
function W8(e, t) {
|
|
98489
|
-
return e.type === "element" && e.attributes?.label === t ? !0 : "children" in e && e.children ? e.children.some((e) => e.type === "element" ? W8(e, t) : !1) : !1;
|
|
98490
|
-
}
|
|
98491
98496
|
function G8(e, t) {
|
|
98497
|
+
return e.type === "element" && e.attributes?.label === t ? !0 : "children" in e && e.children ? e.children.some((e) => e.type === "element" ? G8(e, t) : !1) : !1;
|
|
98498
|
+
}
|
|
98499
|
+
function K8(e, t) {
|
|
98492
98500
|
let n = t, r = 1;
|
|
98493
|
-
for (;
|
|
98501
|
+
for (; G8(e, n);) n = `${t}-${r}`, r++;
|
|
98494
98502
|
return n;
|
|
98495
98503
|
}
|
|
98496
|
-
function
|
|
98504
|
+
function q8(e, t, n, r) {
|
|
98497
98505
|
let i = t.find((t) => t.xmlId === e);
|
|
98498
98506
|
if (!i) return `<!-- missing division: ${e} -->`;
|
|
98499
98507
|
if (n.has(e)) return `<!-- circular reference: ${e} -->`;
|
|
@@ -98507,25 +98515,25 @@ function K8(e, t, n, r) {
|
|
|
98507
98515
|
let o = new Set(n).add(e);
|
|
98508
98516
|
return a.replace(/<plus:([a-z-]+)\s([^>]*ref="[^"]+"[^>]*?)(?:\/>|>\s*<\/plus:\1>)/g, (e, n, i) => {
|
|
98509
98517
|
let a = /ref="([^"]+)"/.exec(i)?.[1] ?? "";
|
|
98510
|
-
if (!N6.has(n)) return
|
|
98518
|
+
if (!N6.has(n)) return q8(a, t, o, r);
|
|
98511
98519
|
let s = /width="([^"]+)"/.exec(i)?.[1];
|
|
98512
98520
|
return P6(n, a, r, s);
|
|
98513
98521
|
});
|
|
98514
98522
|
}
|
|
98515
|
-
function
|
|
98516
|
-
return
|
|
98523
|
+
function J8(e, t, n = []) {
|
|
98524
|
+
return W8(q8(t, e, /* @__PURE__ */ new Set(), n));
|
|
98517
98525
|
}
|
|
98518
|
-
function
|
|
98519
|
-
return
|
|
98526
|
+
function Y8(e, t) {
|
|
98527
|
+
return W8(`<pretext>\n${t.trim() ? `${t.trim()}\n` : ""}${e}\n</pretext>`);
|
|
98520
98528
|
}
|
|
98521
|
-
function
|
|
98522
|
-
return
|
|
98529
|
+
function X8(e, t, n, r = []) {
|
|
98530
|
+
return Y8(q8(t, e, /* @__PURE__ */ new Set(), r), n);
|
|
98523
98531
|
}
|
|
98524
|
-
var
|
|
98525
|
-
function
|
|
98526
|
-
return
|
|
98532
|
+
var Z8 = new Set(["part", "chapter"]);
|
|
98533
|
+
function Q8(e, t, n, r) {
|
|
98534
|
+
return Y8(U8.has(e) ? t : Z8.has(e) ? `<book>\n<title>${r}</title>\n${t}\n</book>` : `<article>\n<title>${r}</title>\n${t}\n</article>`, n);
|
|
98527
98535
|
}
|
|
98528
|
-
function
|
|
98536
|
+
function $8(e) {
|
|
98529
98537
|
let t = e.trim(), n = t.match(/^<title\b[^>]*>([\s\S]*?)<\/title>\s*/);
|
|
98530
98538
|
return n ? {
|
|
98531
98539
|
title: n[1].trim(),
|
|
@@ -98535,12 +98543,12 @@ function Q8(e) {
|
|
|
98535
98543
|
body: t
|
|
98536
98544
|
};
|
|
98537
98545
|
}
|
|
98538
|
-
function
|
|
98546
|
+
function e5(e, t, n, r) {
|
|
98539
98547
|
let i = n === "book" ? "book" : "article";
|
|
98540
98548
|
return e.map((e) => {
|
|
98541
98549
|
if (e.sourceFormat === "markdown") {
|
|
98542
98550
|
if (!e.title) {
|
|
98543
|
-
let t =
|
|
98551
|
+
let t = y8(e.content)?.title;
|
|
98544
98552
|
if (t) return {
|
|
98545
98553
|
...e,
|
|
98546
98554
|
title: t
|
|
@@ -98549,9 +98557,9 @@ function $8(e, t, n, r) {
|
|
|
98549
98557
|
return e;
|
|
98550
98558
|
}
|
|
98551
98559
|
if (e.sourceFormat !== "pretext") return e;
|
|
98552
|
-
let n =
|
|
98553
|
-
if (e.xmlId === t && !(n &&
|
|
98554
|
-
let { title: t, body: n } =
|
|
98560
|
+
let n = f8(e.content);
|
|
98561
|
+
if (e.xmlId === t && !(n && U8.has(n.type))) {
|
|
98562
|
+
let { title: t, body: n } = $8(e.content), a = e.title || t || r || "Untitled";
|
|
98555
98563
|
return {
|
|
98556
98564
|
...e,
|
|
98557
98565
|
type: i,
|
|
@@ -98567,9 +98575,9 @@ function $8(e, t, n, r) {
|
|
|
98567
98575
|
}
|
|
98568
98576
|
//#endregion
|
|
98569
98577
|
//#region src/assetView.ts
|
|
98570
|
-
function
|
|
98578
|
+
function t5(e, t) {
|
|
98571
98579
|
let n = t ?? [], r = (e, t) => n.find((n) => n.kind === e && n.ref === t), i = [], a = /* @__PURE__ */ new Set();
|
|
98572
|
-
for (let t of e ?? []) for (let { kind: e, ref: n } of
|
|
98580
|
+
for (let t of e ?? []) for (let { kind: e, ref: n } of D8(t.content)) {
|
|
98573
98581
|
let t = `${e}:${n}`;
|
|
98574
98582
|
if (a.has(t)) continue;
|
|
98575
98583
|
a.add(t);
|
|
@@ -98595,7 +98603,7 @@ function e5(e, t) {
|
|
|
98595
98603
|
}
|
|
98596
98604
|
return i;
|
|
98597
98605
|
}
|
|
98598
|
-
function
|
|
98606
|
+
function n5(e, t) {
|
|
98599
98607
|
let n = `${e}-copy`;
|
|
98600
98608
|
if (!t.has(n)) return n;
|
|
98601
98609
|
for (let e = 2;; e++) {
|
|
@@ -98603,10 +98611,10 @@ function t5(e, t) {
|
|
|
98603
98611
|
if (!t.has(r)) return r;
|
|
98604
98612
|
}
|
|
98605
98613
|
}
|
|
98606
|
-
var
|
|
98614
|
+
var r5 = {
|
|
98607
98615
|
image: "Images",
|
|
98608
98616
|
doenet: "Doenet"
|
|
98609
|
-
},
|
|
98617
|
+
}, i5 = ["image", "doenet"].filter((e) => e !== "doenet" || !1), a5 = (e, t) => `<plus:${e} ref="${t}"/>`, o5 = ({ open: r, onClose: i, resolveTarget: a, replaceTarget: o, onLoadAssets: s, onLoadLibraryAssets: c, onAddFromLibrary: l, onUpload: u, onFetchUrl: f, onCreateDoenet: p, onRemoveAsset: h, onDuplicateAsset: g, onAssetAdded: _, onResolveRef: v, onReplaceAsset: x }) => {
|
|
98610
98618
|
let S = q3((e) => e.divisions), C = q3((e) => e.projectAssets) ?? [], w = q3((e) => e.setProjectAssets), T = q3((e) => e.libraryAssets), E = q3((e) => e.openAssetEditor), D = q3((e) => e.openAssetResolver), O = q3((e) => e.removeAssetRefFromDocument), k = !!(s || c), [A, j] = b(null), [ee, te] = b(!1), [ne, M] = b(null), N = C, re = A ?? T ?? N, ie = new Set(N.map((e) => e.id)), [ae, P] = b("in-document"), [oe, F] = b(null), [se, ce] = b("library"), [le, ue] = b("library"), [I, de] = b(null), [fe, pe] = b(!1), [me, he] = b(!1), [L, ge] = b(null), _e = y(null), [ve, ye] = b(""), [be, xe] = b(""), [Se, R] = b(!1), [Ce, we] = b(null), [Te, z] = b(""), [Ee, De] = b(""), [Oe, B] = b(!1), [ke, Ae] = b(null), [je, Me] = b(null), [Ne, Pe] = b(null), [Fe, Ie] = b(null), Le = d(() => {
|
|
98611
98619
|
!s && !c || (te(!0), M(null), Promise.all([s?.() ?? Promise.resolve(null), c?.() ?? Promise.resolve(null)]).then(([e, t]) => {
|
|
98612
98620
|
e !== null && w(e), t !== null && j(t);
|
|
@@ -98629,7 +98637,7 @@ var n5 = {
|
|
|
98629
98637
|
};
|
|
98630
98638
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
98631
98639
|
}, [r, i]), !r) return null;
|
|
98632
|
-
let ze =
|
|
98640
|
+
let ze = t5(S, N), Be = (e, t) => {
|
|
98633
98641
|
if (o) {
|
|
98634
98642
|
x(o, e, !!t?.fromLibrary), i();
|
|
98635
98643
|
return;
|
|
@@ -98638,10 +98646,10 @@ var n5 = {
|
|
|
98638
98646
|
e.ref && v(a.kind, a.ref, e.ref), i();
|
|
98639
98647
|
return;
|
|
98640
98648
|
}
|
|
98641
|
-
e.ref && navigator.clipboard.writeText(
|
|
98649
|
+
e.ref && navigator.clipboard.writeText(a5(e.kind, e.ref)).catch(() => {}), Ie(e);
|
|
98642
98650
|
}, Ve = (e, t) => {
|
|
98643
98651
|
let n = `${e}:${t}`;
|
|
98644
|
-
navigator.clipboard.writeText(
|
|
98652
|
+
navigator.clipboard.writeText(a5(e, t)).catch(() => {}), Me(n), setTimeout(() => Me((e) => e === n ? null : e), 2e3);
|
|
98645
98653
|
}, He = async (e) => {
|
|
98646
98654
|
if (!ie.has(e.id) && l) {
|
|
98647
98655
|
de(e.id);
|
|
@@ -98724,7 +98732,7 @@ var n5 = {
|
|
|
98724
98732
|
className: "pretext-plus-editor__am-empty-text",
|
|
98725
98733
|
children: [
|
|
98726
98734
|
"No ",
|
|
98727
|
-
|
|
98735
|
+
r5[e].toLowerCase(),
|
|
98728
98736
|
" assets in your library."
|
|
98729
98737
|
]
|
|
98730
98738
|
}) : /* @__PURE__ */ t("ul", {
|
|
@@ -98766,7 +98774,7 @@ var n5 = {
|
|
|
98766
98774
|
children: "Add an asset"
|
|
98767
98775
|
})]
|
|
98768
98776
|
});
|
|
98769
|
-
let e =
|
|
98777
|
+
let e = i5.map((e) => ({
|
|
98770
98778
|
kind: e,
|
|
98771
98779
|
rows: ze.filter((t) => t.kind === e)
|
|
98772
98780
|
})).filter((e) => e.rows.length > 0), r = (e) => {
|
|
@@ -98812,7 +98820,7 @@ var n5 = {
|
|
|
98812
98820
|
type: "button",
|
|
98813
98821
|
className: `pretext-plus-editor__am-action-btn${je === r ? " pretext-plus-editor__am-action-btn--done" : ""}`,
|
|
98814
98822
|
onClick: () => Ve(e.kind, e.ref),
|
|
98815
|
-
title: `Copy ${
|
|
98823
|
+
title: `Copy ${a5(e.kind, e.ref)}`,
|
|
98816
98824
|
children: je === r ? "Copied!" : "Copy embed code"
|
|
98817
98825
|
}),
|
|
98818
98826
|
g && e.asset?.url && /* @__PURE__ */ t("button", {
|
|
@@ -98855,7 +98863,7 @@ var n5 = {
|
|
|
98855
98863
|
"aria-hidden": "true",
|
|
98856
98864
|
children: "📁"
|
|
98857
98865
|
}),
|
|
98858
|
-
/* @__PURE__ */ t("span", { children:
|
|
98866
|
+
/* @__PURE__ */ t("span", { children: r5[e] }),
|
|
98859
98867
|
/* @__PURE__ */ t("span", {
|
|
98860
98868
|
className: "pretext-plus-editor__am-kind-count",
|
|
98861
98869
|
children: i.length
|
|
@@ -98886,7 +98894,7 @@ var n5 = {
|
|
|
98886
98894
|
className: "pretext-plus-editor__am-embed-row",
|
|
98887
98895
|
children: [/* @__PURE__ */ t("code", {
|
|
98888
98896
|
className: "pretext-plus-editor__am-embed-code",
|
|
98889
|
-
children:
|
|
98897
|
+
children: a5(e.kind, e.ref)
|
|
98890
98898
|
}), /* @__PURE__ */ t("button", {
|
|
98891
98899
|
type: "button",
|
|
98892
98900
|
className: `pretext-plus-editor__am-action-btn${je === `${e.kind}:${e.ref}` ? " pretext-plus-editor__am-action-btn--done" : ""}`,
|
|
@@ -99175,7 +99183,7 @@ var n5 = {
|
|
|
99175
99183
|
}),
|
|
99176
99184
|
/* @__PURE__ */ n("p", {
|
|
99177
99185
|
className: "pretext-plus-editor__dialog-helper-copy",
|
|
99178
|
-
children: ["The reference ID is used in the embed code: ", /* @__PURE__ */ t("code", { children:
|
|
99186
|
+
children: ["The reference ID is used in the embed code: ", /* @__PURE__ */ t("code", { children: a5("doenet", Ee || "my-activity") })]
|
|
99179
99187
|
}),
|
|
99180
99188
|
ke && /* @__PURE__ */ t("p", {
|
|
99181
99189
|
className: "pretext-plus-editor__am-error",
|
|
@@ -99290,7 +99298,7 @@ var n5 = {
|
|
|
99290
99298
|
] })
|
|
99291
99299
|
})
|
|
99292
99300
|
});
|
|
99293
|
-
},
|
|
99301
|
+
}, s5 = {
|
|
99294
99302
|
automaticLayout: !0,
|
|
99295
99303
|
minimap: { enabled: !1 },
|
|
99296
99304
|
wordWrap: "on",
|
|
@@ -99301,16 +99309,16 @@ var n5 = {
|
|
|
99301
99309
|
bottom: 10
|
|
99302
99310
|
},
|
|
99303
99311
|
scrollBeyondLastLine: !1
|
|
99304
|
-
},
|
|
99312
|
+
}, c5 = 160, l5 = {
|
|
99305
99313
|
image: "image",
|
|
99306
99314
|
doenet: "interactive"
|
|
99307
|
-
},
|
|
99308
|
-
let c = e.ref ?? "", [l, u] = b(e.name), [d, f] = b(c), [p, h] = b(e.source ?? ""), [g, _] = b(!1), [v, x] = b(!1), [S, C] = b(null), [w, T] = b(!1), [E, D] = b(
|
|
99315
|
+
}, u5 = ({ asset: e, projectAssets: r, onClose: i, onSave: a, onReplace: o, onDuplicate: s }) => {
|
|
99316
|
+
let c = e.ref ?? "", [l, u] = b(e.name), [d, f] = b(c), [p, h] = b(e.source ?? ""), [g, _] = b(!1), [v, x] = b(!1), [S, C] = b(null), [w, T] = b(!1), [E, D] = b(c5), O = y(null);
|
|
99309
99317
|
m(() => {
|
|
99310
99318
|
O.current?.scrollTo({ top: 0 });
|
|
99311
99319
|
}, []);
|
|
99312
99320
|
let k = (e) => {
|
|
99313
|
-
let t = () => D(Math.max(
|
|
99321
|
+
let t = () => D(Math.max(c5, e.getContentHeight()));
|
|
99314
99322
|
e.onDidContentSizeChange(t), t();
|
|
99315
99323
|
}, A = `<plus:${e.kind} ref="${d.trim() || c}"/>`, j = () => {
|
|
99316
99324
|
navigator.clipboard.writeText(A).catch(() => {}), T(!0), setTimeout(() => T(!1), 2e3);
|
|
@@ -99452,7 +99460,7 @@ var n5 = {
|
|
|
99452
99460
|
className: "pretext-plus-editor__dialog-helper-copy",
|
|
99453
99461
|
children: [
|
|
99454
99462
|
"Inserted verbatim inside the generated ",
|
|
99455
|
-
/* @__PURE__ */ t("code", { children: `<${
|
|
99463
|
+
/* @__PURE__ */ t("code", { children: `<${l5[e.kind]}>` }),
|
|
99456
99464
|
" element — e.g. ",
|
|
99457
99465
|
/* @__PURE__ */ t("code", { children: "<shortdescription>...</shortdescription>" }),
|
|
99458
99466
|
"."
|
|
@@ -99463,7 +99471,7 @@ var n5 = {
|
|
|
99463
99471
|
style: { height: E },
|
|
99464
99472
|
children: /* @__PURE__ */ t(_r, {
|
|
99465
99473
|
options: {
|
|
99466
|
-
...
|
|
99474
|
+
...s5,
|
|
99467
99475
|
readOnly: ne
|
|
99468
99476
|
},
|
|
99469
99477
|
height: "100%",
|
|
@@ -99510,7 +99518,7 @@ var n5 = {
|
|
|
99510
99518
|
]
|
|
99511
99519
|
})
|
|
99512
99520
|
});
|
|
99513
|
-
},
|
|
99521
|
+
}, d5 = (e) => {
|
|
99514
99522
|
let r = q3((e) => e.showFullPreview), i = q3((e) => e.setShowFullPreview), a = q3((e) => e.title), o = q3((e) => e.updateTitle), s;
|
|
99515
99523
|
return s = e.showPreviewModeToggle === !1 ? null : /* @__PURE__ */ n("label", {
|
|
99516
99524
|
className: "pretext-plus-editor__preview-toggle",
|
|
@@ -99587,11 +99595,30 @@ var n5 = {
|
|
|
99587
99595
|
]
|
|
99588
99596
|
})]
|
|
99589
99597
|
});
|
|
99590
|
-
},
|
|
99598
|
+
}, f5 = {
|
|
99591
99599
|
pretext: "PreTeXt",
|
|
99592
99600
|
latex: "LaTeX",
|
|
99593
99601
|
markdown: "Markdown"
|
|
99594
|
-
},
|
|
99602
|
+
}, p5 = {
|
|
99603
|
+
book: "bk",
|
|
99604
|
+
article: "art",
|
|
99605
|
+
slideshow: "slides",
|
|
99606
|
+
part: "pt",
|
|
99607
|
+
chapter: "ch",
|
|
99608
|
+
section: "sec",
|
|
99609
|
+
subsection: "subsec",
|
|
99610
|
+
subsubsection: "subsubsec",
|
|
99611
|
+
introduction: "intro",
|
|
99612
|
+
conclusion: "conc",
|
|
99613
|
+
worksheet: "ws",
|
|
99614
|
+
handout: "ho",
|
|
99615
|
+
exercises: "ex",
|
|
99616
|
+
references: "ref",
|
|
99617
|
+
glossary: "gloss",
|
|
99618
|
+
solutions: "sol",
|
|
99619
|
+
"reading-questions": "rq",
|
|
99620
|
+
paragraphs: "para"
|
|
99621
|
+
}, m5 = {
|
|
99595
99622
|
book: "Book",
|
|
99596
99623
|
article: "Article",
|
|
99597
99624
|
slideshow: "Slideshow",
|
|
@@ -99610,7 +99637,7 @@ var n5 = {
|
|
|
99610
99637
|
subsection: "Subsection",
|
|
99611
99638
|
subsubsection: "Subsubsection",
|
|
99612
99639
|
paragraphs: "Paragraphs"
|
|
99613
|
-
},
|
|
99640
|
+
}, h5 = [
|
|
99614
99641
|
"part",
|
|
99615
99642
|
"chapter",
|
|
99616
99643
|
"section",
|
|
@@ -99624,7 +99651,7 @@ var n5 = {
|
|
|
99624
99651
|
"solutions",
|
|
99625
99652
|
"reading-questions",
|
|
99626
99653
|
"paragraphs"
|
|
99627
|
-
],
|
|
99654
|
+
], g5 = [
|
|
99628
99655
|
"worksheet",
|
|
99629
99656
|
"handout",
|
|
99630
99657
|
"exercises",
|
|
@@ -99633,25 +99660,29 @@ var n5 = {
|
|
|
99633
99660
|
"solutions",
|
|
99634
99661
|
"reading-questions",
|
|
99635
99662
|
"paragraphs"
|
|
99636
|
-
],
|
|
99663
|
+
], _5 = {
|
|
99637
99664
|
book: ["part", "chapter"],
|
|
99638
|
-
article: ["section", ...
|
|
99665
|
+
article: ["section", ...g5],
|
|
99639
99666
|
slideshow: ["section"],
|
|
99640
99667
|
part: ["chapter"],
|
|
99641
|
-
chapter: ["section", ...
|
|
99642
|
-
section: ["subsection", ...
|
|
99643
|
-
subsection: ["subsubsection", ...
|
|
99644
|
-
subsubsection: [...
|
|
99668
|
+
chapter: ["section", ...g5],
|
|
99669
|
+
section: ["subsection", ...g5],
|
|
99670
|
+
subsection: ["subsubsection", ...g5],
|
|
99671
|
+
subsubsection: [...g5],
|
|
99645
99672
|
worksheet: ["paragraphs"],
|
|
99646
99673
|
handout: ["paragraphs"]
|
|
99647
99674
|
};
|
|
99648
|
-
function
|
|
99649
|
-
return e ?
|
|
99675
|
+
function v5(e) {
|
|
99676
|
+
return e ? _5[e] ?? h5 : h5;
|
|
99650
99677
|
}
|
|
99651
99678
|
//#endregion
|
|
99652
99679
|
//#region src/components/toc/SectionEditForm.tsx
|
|
99653
|
-
|
|
99654
|
-
let
|
|
99680
|
+
function y5(e, t) {
|
|
99681
|
+
let n = p5[e] ?? "sec", r = d8(t);
|
|
99682
|
+
return r ? `${n}-${r}` : n;
|
|
99683
|
+
}
|
|
99684
|
+
var b5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDraftChange: o, onCommit: s, onCancel: c }) => {
|
|
99685
|
+
let l = v5(a), u = y(r);
|
|
99655
99686
|
return m(() => {
|
|
99656
99687
|
i || l.length > 0 && !l.includes(e.type) && o({
|
|
99657
99688
|
...e,
|
|
@@ -99670,10 +99701,17 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
99670
99701
|
children: [/* @__PURE__ */ t("span", { children: "Title" }), /* @__PURE__ */ t("input", {
|
|
99671
99702
|
type: "text",
|
|
99672
99703
|
value: e.title,
|
|
99673
|
-
onChange: (t) =>
|
|
99674
|
-
|
|
99675
|
-
|
|
99676
|
-
|
|
99704
|
+
onChange: (t) => {
|
|
99705
|
+
let n = t.target.value;
|
|
99706
|
+
o(u.current ? {
|
|
99707
|
+
...e,
|
|
99708
|
+
title: n,
|
|
99709
|
+
xmlId: y5(e.type, n)
|
|
99710
|
+
} : {
|
|
99711
|
+
...e,
|
|
99712
|
+
title: n
|
|
99713
|
+
});
|
|
99714
|
+
},
|
|
99677
99715
|
onKeyDown: (e) => {
|
|
99678
99716
|
e.key === "Enter" && s(), e.key === "Escape" && c();
|
|
99679
99717
|
},
|
|
@@ -99688,9 +99726,9 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
99688
99726
|
...e,
|
|
99689
99727
|
sourceFormat: t.target.value
|
|
99690
99728
|
}),
|
|
99691
|
-
children: Object.keys(
|
|
99729
|
+
children: Object.keys(f5).map((e) => /* @__PURE__ */ t("option", {
|
|
99692
99730
|
value: e,
|
|
99693
|
-
children:
|
|
99731
|
+
children: f5[e]
|
|
99694
99732
|
}, e))
|
|
99695
99733
|
})]
|
|
99696
99734
|
}) : void 0,
|
|
@@ -99698,13 +99736,20 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
99698
99736
|
className: "pretext-plus-editor__toc-edit-field",
|
|
99699
99737
|
children: [/* @__PURE__ */ t("span", { children: "Type" }), /* @__PURE__ */ t("select", {
|
|
99700
99738
|
value: e.type,
|
|
99701
|
-
onChange: (t) =>
|
|
99702
|
-
|
|
99703
|
-
|
|
99704
|
-
|
|
99739
|
+
onChange: (t) => {
|
|
99740
|
+
let n = t.target.value;
|
|
99741
|
+
o(u.current ? {
|
|
99742
|
+
...e,
|
|
99743
|
+
type: n,
|
|
99744
|
+
xmlId: y5(n, e.title)
|
|
99745
|
+
} : {
|
|
99746
|
+
...e,
|
|
99747
|
+
type: n
|
|
99748
|
+
});
|
|
99749
|
+
},
|
|
99705
99750
|
children: l.map((e) => /* @__PURE__ */ t("option", {
|
|
99706
99751
|
value: e,
|
|
99707
|
-
children:
|
|
99752
|
+
children: m5[e]
|
|
99708
99753
|
}, e))
|
|
99709
99754
|
})]
|
|
99710
99755
|
}),
|
|
@@ -99714,10 +99759,12 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
99714
99759
|
type: "text",
|
|
99715
99760
|
value: e.xmlId,
|
|
99716
99761
|
placeholder: "unique identifier",
|
|
99717
|
-
onChange: (t) =>
|
|
99718
|
-
|
|
99719
|
-
|
|
99720
|
-
|
|
99762
|
+
onChange: (t) => {
|
|
99763
|
+
u.current = !1, o({
|
|
99764
|
+
...e,
|
|
99765
|
+
xmlId: t.target.value
|
|
99766
|
+
});
|
|
99767
|
+
}
|
|
99721
99768
|
})]
|
|
99722
99769
|
}),
|
|
99723
99770
|
/* @__PURE__ */ n("div", {
|
|
@@ -99736,7 +99783,7 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
99736
99783
|
})
|
|
99737
99784
|
]
|
|
99738
99785
|
});
|
|
99739
|
-
},
|
|
99786
|
+
}, x5 = ({ items: e }) => {
|
|
99740
99787
|
let [r, i] = b(!1), [a, o] = b(null), s = y(null), c = y(null);
|
|
99741
99788
|
m(() => {
|
|
99742
99789
|
if (!r) return;
|
|
@@ -99792,8 +99839,8 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
99792
99839
|
}, e.label))
|
|
99793
99840
|
}), document.body)]
|
|
99794
99841
|
});
|
|
99795
|
-
},
|
|
99796
|
-
let _ = c !== null, v = e.type === "introduction" || e.type === "conclusion" ?
|
|
99842
|
+
}, S5 = ({ division: e, depth: r, isActive: i, hasChildren: a, isExpanded: o, onToggleExpand: s, editDraft: c, onSelect: l, onDraftChange: u, onEditCommit: d, onEditCancel: f, menuItems: p, isNew: m = !1, isRoot: h = !1, parentType: g = null }) => {
|
|
99843
|
+
let _ = c !== null, v = e.type === "introduction" || e.type === "conclusion" ? m5[e.type] : null;
|
|
99797
99844
|
return /* @__PURE__ */ n("li", {
|
|
99798
99845
|
className: [
|
|
99799
99846
|
"pretext-plus-editor__toc-item",
|
|
@@ -99819,7 +99866,7 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
99819
99866
|
className: "pretext-plus-editor__toc-select",
|
|
99820
99867
|
onClick: l,
|
|
99821
99868
|
"aria-current": i ? "true" : void 0,
|
|
99822
|
-
title:
|
|
99869
|
+
title: m5[e.type] ?? e.type,
|
|
99823
99870
|
children: [/* @__PURE__ */ t("span", {
|
|
99824
99871
|
className: "pretext-plus-editor__toc-title",
|
|
99825
99872
|
children: e.title || v || /* @__PURE__ */ t("em", { children: "Untitled" })
|
|
@@ -99830,10 +99877,10 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
99830
99877
|
}),
|
|
99831
99878
|
/* @__PURE__ */ t("div", {
|
|
99832
99879
|
className: "pretext-plus-editor__toc-actions",
|
|
99833
|
-
children: /* @__PURE__ */ t(
|
|
99880
|
+
children: /* @__PURE__ */ t(x5, { items: p })
|
|
99834
99881
|
})
|
|
99835
99882
|
]
|
|
99836
|
-
}), _ && c && /* @__PURE__ */ t(
|
|
99883
|
+
}), _ && c && /* @__PURE__ */ t(b5, {
|
|
99837
99884
|
draft: c,
|
|
99838
99885
|
isNew: m,
|
|
99839
99886
|
isRoot: h,
|
|
@@ -99843,8 +99890,8 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
99843
99890
|
onCancel: f
|
|
99844
99891
|
})]
|
|
99845
99892
|
});
|
|
99846
|
-
},
|
|
99847
|
-
let i = q3((e) => e.divisions), o = q3((e) => e.rootDivisionId), s = q3((e) => e.activeDivisionId), c = q3((e) => e.projectAssets) ?? [], l = q3((e) => e.selectSection), u = q3((e) => e.addSection), d = q3((e) => e.removeSection), f = q3((e) => e.divisionContentChange), p = q3((e) => e.insertAtCursor), m = q3((e) => e.openAssetEditor), h = q3((e) => e.openAssetResolver), g = q3((e) => e.removeAsset), _ = q3((e) => e.removeAssetRefFromDocument), v = q3((e) => e.duplicateAsset), y = q3((e) => e.hasAssetDuplicate), x = q3((e) => e.startSectionEdit), S = q3((e) => e.setEditDraft), C = q3((e) => e.commitSectionEdit), w = q3((e) => e.cancelSectionEdit), T = q3((e) => e.editingId), E = q3((e) => e.editDraft), D = q3((e) => e.editingIsNew), O = i ? i.find((e) => e.xmlId === o) ?? i.find((e) => e.type === "book" || e.type === "article" || e.type === "slideshow") ?? i[0] ?? null : null, k = O && i ?
|
|
99893
|
+
}, C5 = ({ onOpenAssetPicker: r }) => {
|
|
99894
|
+
let i = q3((e) => e.divisions), o = q3((e) => e.rootDivisionId), s = q3((e) => e.activeDivisionId), c = q3((e) => e.projectAssets) ?? [], l = q3((e) => e.selectSection), u = q3((e) => e.addSection), d = q3((e) => e.removeSection), f = q3((e) => e.divisionContentChange), p = q3((e) => e.insertAtCursor), m = q3((e) => e.openAssetEditor), h = q3((e) => e.openAssetResolver), g = q3((e) => e.removeAsset), _ = q3((e) => e.removeAssetRefFromDocument), v = q3((e) => e.duplicateAsset), y = q3((e) => e.hasAssetDuplicate), x = q3((e) => e.startSectionEdit), S = q3((e) => e.setEditDraft), C = q3((e) => e.commitSectionEdit), w = q3((e) => e.cancelSectionEdit), T = q3((e) => e.editingId), E = q3((e) => e.editDraft), D = q3((e) => e.editingIsNew), O = i ? i.find((e) => e.xmlId === o) ?? i.find((e) => e.type === "book" || e.type === "article" || e.type === "slideshow") ?? i[0] ?? null : null, k = O && i ? V8(i, O.xmlId) : [], A = O && i ? H8(i, O.xmlId) : [], j = t5(i, c), ee = i5.map((e) => ({
|
|
99848
99895
|
kind: e,
|
|
99849
99896
|
rows: j.filter((t) => t.kind === e)
|
|
99850
99897
|
})).filter((e) => e.rows.length > 0), [te, ne] = b(!1), [M, N] = b(null), re = async (e) => {
|
|
@@ -99886,19 +99933,19 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
99886
99933
|
let ue = (e, t) => {
|
|
99887
99934
|
if (!i) return;
|
|
99888
99935
|
let n = i.find((e) => e.xmlId === t);
|
|
99889
|
-
n && f(n.xmlId,
|
|
99936
|
+
n && f(n.xmlId, R8(N8(n.content, e)));
|
|
99890
99937
|
}, I = (e, t) => {
|
|
99891
99938
|
if (window.confirm(`Delete "${e.title || "Untitled"}"? This permanently removes the division.`)) {
|
|
99892
99939
|
if (t && i) {
|
|
99893
99940
|
let n = i.find((e) => e.xmlId === t);
|
|
99894
|
-
n && f(n.xmlId,
|
|
99941
|
+
n && f(n.xmlId, R8(N8(n.content, e.xmlId)));
|
|
99895
99942
|
}
|
|
99896
99943
|
d(e.xmlId);
|
|
99897
99944
|
}
|
|
99898
99945
|
}, de = (e) => {
|
|
99899
99946
|
p(`<plus:${e.type} ref="${e.xmlId}"/>`);
|
|
99900
99947
|
}, fe = (e) => {
|
|
99901
|
-
O && f(O.xmlId,
|
|
99948
|
+
O && f(O.xmlId, R8(M8(O.content, e.xmlId, e.type, null)));
|
|
99902
99949
|
}, pe = (e) => e && i?.find((t) => t.xmlId === e)?.type || null, me = (e) => e.status === "unlinked" ? h(e.kind, e.ref) : m(e.kind, e.ref), he = (e, t) => {
|
|
99903
99950
|
navigator.clipboard.writeText(`<plus:${e} ref="${t}"/>`).catch(() => {});
|
|
99904
99951
|
}, L = (e) => {
|
|
@@ -99929,7 +99976,7 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
99929
99976
|
className: "pretext-plus-editor__toc-list",
|
|
99930
99977
|
role: "list",
|
|
99931
99978
|
children: [
|
|
99932
|
-
O && /* @__PURE__ */ t(
|
|
99979
|
+
O && /* @__PURE__ */ t(S5, {
|
|
99933
99980
|
division: O,
|
|
99934
99981
|
depth: 0,
|
|
99935
99982
|
isActive: s === O.xmlId,
|
|
@@ -99955,7 +100002,7 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
99955
100002
|
className: "pretext-plus-editor__toc-no-sections",
|
|
99956
100003
|
children: /* @__PURE__ */ t("span", { children: "No placed divisions" })
|
|
99957
100004
|
}),
|
|
99958
|
-
le.map((e) => /* @__PURE__ */ t(
|
|
100005
|
+
le.map((e) => /* @__PURE__ */ t(S5, {
|
|
99959
100006
|
division: e.division,
|
|
99960
100007
|
depth: e.depth + 1,
|
|
99961
100008
|
isActive: s === e.division.xmlId,
|
|
@@ -99999,8 +100046,8 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
99999
100046
|
}), /* @__PURE__ */ t("ul", {
|
|
100000
100047
|
className: "pretext-plus-editor__toc-list",
|
|
100001
100048
|
children: A.map((e) => {
|
|
100002
|
-
let r = i ?
|
|
100003
|
-
return /* @__PURE__ */ n(a, { children: [/* @__PURE__ */ t(
|
|
100049
|
+
let r = i ? V8(i, e.xmlId) : [], o = new Set(r.map((e) => e.parentXmlId).filter(Boolean));
|
|
100050
|
+
return /* @__PURE__ */ n(a, { children: [/* @__PURE__ */ t(S5, {
|
|
100004
100051
|
division: e,
|
|
100005
100052
|
depth: 0,
|
|
100006
100053
|
isActive: s === e.xmlId,
|
|
@@ -100032,7 +100079,7 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
100032
100079
|
}
|
|
100033
100080
|
],
|
|
100034
100081
|
parentType: null
|
|
100035
|
-
}), P(e.xmlId) && r.map((e) => /* @__PURE__ */ t(
|
|
100082
|
+
}), P(e.xmlId) && r.map((e) => /* @__PURE__ */ t(S5, {
|
|
100036
100083
|
division: e.division,
|
|
100037
100084
|
depth: e.depth + 1,
|
|
100038
100085
|
isActive: s === e.division.xmlId,
|
|
@@ -100103,7 +100150,7 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
100103
100150
|
className: "pretext-plus-editor__toc-assets-groups",
|
|
100104
100151
|
children: ee.map(({ kind: e, rows: r }) => /* @__PURE__ */ n("div", { children: [/* @__PURE__ */ t("div", {
|
|
100105
100152
|
className: "pretext-plus-editor__toc-assets-group-header",
|
|
100106
|
-
children:
|
|
100153
|
+
children: r5[e]
|
|
100107
100154
|
}), /* @__PURE__ */ t("ul", {
|
|
100108
100155
|
className: "pretext-plus-editor__toc-assets-list",
|
|
100109
100156
|
children: r.map((e) => /* @__PURE__ */ n("li", {
|
|
@@ -100145,7 +100192,7 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
100145
100192
|
role: "status",
|
|
100146
100193
|
"aria-label": "Duplicating asset",
|
|
100147
100194
|
title: "Duplicating…"
|
|
100148
|
-
}) : /* @__PURE__ */ t(
|
|
100195
|
+
}) : /* @__PURE__ */ t(x5, { items: L(e) })
|
|
100149
100196
|
})
|
|
100150
100197
|
]
|
|
100151
100198
|
}, e.ref))
|
|
@@ -100160,7 +100207,7 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
100160
100207
|
children: "Manage Assets"
|
|
100161
100208
|
})
|
|
100162
100209
|
] });
|
|
100163
|
-
},
|
|
100210
|
+
}, w5 = ({ isCollapsed: e, onToggleCollapse: r, onOpenAssetPicker: i }) => e ? /* @__PURE__ */ t("div", {
|
|
100164
100211
|
className: "pretext-plus-editor__toc pretext-plus-editor__toc--collapsed",
|
|
100165
100212
|
children: /* @__PURE__ */ t("button", {
|
|
100166
100213
|
type: "button",
|
|
@@ -100188,8 +100235,8 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
100188
100235
|
children: "✕"
|
|
100189
100236
|
})
|
|
100190
100237
|
})]
|
|
100191
|
-
}), /* @__PURE__ */ t(
|
|
100192
|
-
}),
|
|
100238
|
+
}), /* @__PURE__ */ t(C5, { onOpenAssetPicker: i })]
|
|
100239
|
+
}), T5 = class extends i {
|
|
100193
100240
|
state = { error: null };
|
|
100194
100241
|
static getDerivedStateFromError(e) {
|
|
100195
100242
|
return { error: e };
|
|
@@ -100225,8 +100272,8 @@ var _5 = ({ draft: e, isNew: r = !1, isRoot: i = !1, parentType: a = null, onDra
|
|
|
100225
100272
|
]
|
|
100226
100273
|
});
|
|
100227
100274
|
}
|
|
100228
|
-
},
|
|
100229
|
-
function
|
|
100275
|
+
}, E5 = (e, t) => e.kind === t.kind && e.ref === t.ref;
|
|
100276
|
+
function D5(e) {
|
|
100230
100277
|
let t = () => {}, n = { cbs: {
|
|
100231
100278
|
selectDivision: t,
|
|
100232
100279
|
addDivision: t,
|
|
@@ -100312,7 +100359,7 @@ function w5(e) {
|
|
|
100312
100359
|
updateSection: (e, t) => n.cbs.updateDivision(e, t),
|
|
100313
100360
|
divisionContentChange: (e, t) => n.cbs.divisionContentChange?.(e, t),
|
|
100314
100361
|
startSectionEdit: (e, n) => {
|
|
100315
|
-
let { xmlId: r, label: i } = e.sourceFormat === "markdown" ?
|
|
100362
|
+
let { xmlId: r, label: i } = e.sourceFormat === "markdown" ? y8(e.content) ?? {
|
|
100316
100363
|
xmlId: e.xmlId,
|
|
100317
100364
|
label: ""
|
|
100318
100365
|
} : e.sourceFormat === "latex" ? {
|
|
@@ -100387,14 +100434,14 @@ function w5(e) {
|
|
|
100387
100434
|
setProjectAssets: (e) => t({ projectAssets: e }),
|
|
100388
100435
|
addAssetToPool: (e) => t((t) => {
|
|
100389
100436
|
let n = t.projectAssets ?? [];
|
|
100390
|
-
return n.some((t) =>
|
|
100437
|
+
return n.some((t) => E5(t, e)) ? {} : { projectAssets: [...n, e] };
|
|
100391
100438
|
}),
|
|
100392
100439
|
updateAssetInPool: (e) => t((t) => {
|
|
100393
100440
|
let n = t.projectAssets ?? [];
|
|
100394
|
-
return n.some((t) =>
|
|
100441
|
+
return n.some((t) => E5(t, e)) ? { projectAssets: n.map((t) => E5(t, e) ? e : t) } : { projectAssets: [...n, e] };
|
|
100395
100442
|
}),
|
|
100396
|
-
renameAssetInPool: (e, n, r) => t((t) => ({ projectAssets: [...(t.projectAssets ?? []).filter((t) => !(t.kind === e && t.ref === n) && !
|
|
100397
|
-
removeAssetFromPool: (e) => t((t) => ({ projectAssets: (t.projectAssets ?? []).filter((t) => !
|
|
100443
|
+
renameAssetInPool: (e, n, r) => t((t) => ({ projectAssets: [...(t.projectAssets ?? []).filter((t) => !(t.kind === e && t.ref === n) && !E5(t, r)), r] })),
|
|
100444
|
+
removeAssetFromPool: (e) => t((t) => ({ projectAssets: (t.projectAssets ?? []).filter((t) => !E5(t, e)) })),
|
|
100398
100445
|
updateTitle: (e) => n.cbs.updateTitle(e),
|
|
100399
100446
|
feedbackSubmit: (e) => n.cbs.feedbackSubmit?.(e)
|
|
100400
100447
|
})),
|
|
@@ -100405,7 +100452,7 @@ function w5(e) {
|
|
|
100405
100452
|
}
|
|
100406
100453
|
//#endregion
|
|
100407
100454
|
//#region src/store/EditorStoreProvider.tsx
|
|
100408
|
-
function
|
|
100455
|
+
function O5({ store: e, children: n }) {
|
|
100409
100456
|
return /* @__PURE__ */ t(K3.Provider, {
|
|
100410
100457
|
value: e,
|
|
100411
100458
|
children: n
|
|
@@ -100413,10 +100460,10 @@ function T5({ store: e, children: n }) {
|
|
|
100413
100460
|
}
|
|
100414
100461
|
//#endregion
|
|
100415
100462
|
//#region src/components/Editors.tsx
|
|
100416
|
-
var
|
|
100463
|
+
var k5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type === "article" || e.type === "slideshow") ?? e[0] ?? null, A5 = (e) => {
|
|
100417
100464
|
let [n] = b(() => {
|
|
100418
|
-
let t =
|
|
100419
|
-
return
|
|
100465
|
+
let t = k5(e.divisions, e.rootDivisionId), n = e5(e.divisions, t?.xmlId, e.projectType, e.title), r = n.find((e) => e.xmlId === t?.xmlId) ?? t, i = e.activeDivisionId ?? r?.xmlId ?? null, a = n.find((e) => e.xmlId === i) ?? r;
|
|
100466
|
+
return D5({
|
|
100420
100467
|
source: a?.content ?? "",
|
|
100421
100468
|
sourceFormat: a?.sourceFormat ?? "pretext",
|
|
100422
100469
|
title: e.title || r?.title || "Document Title",
|
|
@@ -100429,15 +100476,19 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100429
100476
|
projectAssets: e.projectAssets
|
|
100430
100477
|
});
|
|
100431
100478
|
});
|
|
100432
|
-
return /* @__PURE__ */ t(
|
|
100479
|
+
return /* @__PURE__ */ t(O5, {
|
|
100433
100480
|
store: n.store,
|
|
100434
|
-
children: /* @__PURE__ */ t(
|
|
100481
|
+
children: /* @__PURE__ */ t(j5, {
|
|
100435
100482
|
...e,
|
|
100436
100483
|
bindCallbacks: n.bindCallbacks
|
|
100437
100484
|
})
|
|
100438
100485
|
});
|
|
100439
|
-
},
|
|
100440
|
-
let { bindCallbacks: r } = e, i = q3((e) => e.showFullPreview), a = q3((e) => e.isNarrowScreen), o = q3((e) => e.setIsNarrowScreen), s = q3((e) => e.activeTab), c = q3((e) => e.setActiveTab), l = q3((e) => e.isTocCollapsed), u = q3((e) => e.setIsTocCollapsed), d = q3((e) => e.isLatexDialogOpen), f = q3((e) => e.isConvertDialogOpen), p = q3((e) => e.isDocinfoEditorOpen), h = q3((e) => e.isAssetPickerOpen), g = q3((e) => e.isFullSourceOpen), x = q3((e) => e.editingAssetRef), S = q3((e) => e.openAssetEditor), C = q3((e) => e.closeAssetEditor), w = q3((e) => e.assetResolveTarget), T = q3((e) => e.closeAssetResolver), [E, D] = b(null), O = q3((e) => e.openModal), k = q3((e) => e.closeModal), A = q3((e) => e.syncState), j = q3((e) => e.projectAssets), ee = q3((e) => e.addAssetToPool), te = q3((e) => e.updateAssetInPool), ne = q3((e) => e.renameAssetInPool), M = q3((e) => e.removeAssetFromPool), N = x ? j?.find((e) => e.kind === x.kind && e.ref === x.ref) : void 0, re = q3((e) => e.divisions), ie = v(() => re ?? [], [re]), ae = q3((e) => e.activeDivisionId), P = q3((e) => e.title), oe = q3((e) => e.docinfo), F = q3((e) => e.commonDocinfo), se = q3((e) => e.useCommonDocinfo), ce = q3((e) => e.applyExternalUpdate), le = q3((e) => e.setDivisionContent), ue = q3((e) => e.patchDivision), I = q3((e) => e.addDivisionToPool), de = q3((e) => e.removeDivisionFromPool), fe = q3((e) => e.setActiveDivisionId), pe = q3((e) => e.startSectionEdit), me = q3((e) => e.setTitle), he = q3((e) => e.setDocinfo), L =
|
|
100486
|
+
}, j5 = (e) => {
|
|
100487
|
+
let { bindCallbacks: r } = e, i = q3((e) => e.showFullPreview), a = q3((e) => e.isNarrowScreen), o = q3((e) => e.setIsNarrowScreen), s = q3((e) => e.activeTab), c = q3((e) => e.setActiveTab), l = q3((e) => e.isTocCollapsed), u = q3((e) => e.setIsTocCollapsed), d = q3((e) => e.isLatexDialogOpen), f = q3((e) => e.isConvertDialogOpen), p = q3((e) => e.isDocinfoEditorOpen), h = q3((e) => e.isAssetPickerOpen), g = q3((e) => e.isFullSourceOpen), x = q3((e) => e.editingAssetRef), S = q3((e) => e.openAssetEditor), C = q3((e) => e.closeAssetEditor), w = q3((e) => e.assetResolveTarget), T = q3((e) => e.closeAssetResolver), [E, D] = b(null), O = q3((e) => e.openModal), k = q3((e) => e.closeModal), A = q3((e) => e.syncState), j = q3((e) => e.projectAssets), ee = q3((e) => e.addAssetToPool), te = q3((e) => e.updateAssetInPool), ne = q3((e) => e.renameAssetInPool), M = q3((e) => e.removeAssetFromPool), N = x ? j?.find((e) => e.kind === x.kind && e.ref === x.ref) : void 0, re = q3((e) => e.divisions), ie = v(() => re ?? [], [re]), ae = q3((e) => e.activeDivisionId), P = q3((e) => e.title), oe = q3((e) => e.docinfo), F = q3((e) => e.commonDocinfo), se = q3((e) => e.useCommonDocinfo), ce = q3((e) => e.applyExternalUpdate), le = q3((e) => e.setDivisionContent), ue = q3((e) => e.patchDivision), I = q3((e) => e.addDivisionToPool), de = q3((e) => e.removeDivisionFromPool), fe = q3((e) => e.setActiveDivisionId), pe = q3((e) => e.startSectionEdit), me = q3((e) => e.setTitle), he = q3((e) => e.setDocinfo), L = q3((e) => e.editingId), ge = q3((e) => e.editingIsNew), _e = y(null), ve = y(null), ye = y(!1);
|
|
100488
|
+
m(() => {
|
|
100489
|
+
L && ge ? ye.current = !0 : ye.current && (ye.current = !1, ve.current?.focus());
|
|
100490
|
+
}, [L, ge]);
|
|
100491
|
+
let be = k5(ie, e.rootDivisionId), xe = ie.find((e) => e.xmlId === ae) ?? ie[0] ?? null, Se = xe?.sourceFormat ?? "pretext", R = xe?.content ?? "", Ce = (t, n, r, i) => {
|
|
100441
100492
|
le(t, n), e.onContentChange({
|
|
100442
100493
|
xmlId: t,
|
|
100443
100494
|
sourceContent: n,
|
|
@@ -100445,12 +100496,12 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100445
100496
|
pretextSource: r === "pretext" ? n : void 0,
|
|
100446
100497
|
...i
|
|
100447
100498
|
});
|
|
100448
|
-
},
|
|
100499
|
+
}, we = (t, n) => {
|
|
100449
100500
|
ue(t, n), e.onDivisionUpdate?.(t, n);
|
|
100450
|
-
},
|
|
100501
|
+
}, Te = (e, t) => {
|
|
100451
100502
|
let n = ie.find((t) => t.xmlId === e);
|
|
100452
100503
|
if (!n) {
|
|
100453
|
-
|
|
100504
|
+
we(e, t);
|
|
100454
100505
|
return;
|
|
100455
100506
|
}
|
|
100456
100507
|
let r;
|
|
@@ -100462,116 +100513,116 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100462
100513
|
type: e,
|
|
100463
100514
|
title: i,
|
|
100464
100515
|
xmlId: a,
|
|
100465
|
-
content:
|
|
100516
|
+
content: j8(e, t.sourceFormat, i, a)
|
|
100466
100517
|
};
|
|
100467
|
-
} else r = n.sourceFormat === "markdown" ?
|
|
100518
|
+
} else r = n.sourceFormat === "markdown" ? b8(n, t) : n.sourceFormat === "latex" ? r8(n, t) : p8(n, t);
|
|
100468
100519
|
let i = r.xmlId;
|
|
100469
|
-
if (r.content !== n.content &&
|
|
100520
|
+
if (r.content !== n.content && Ce(n.xmlId, r.sourceFormat === "pretext" ? R8(r.content) : r.content, r.sourceFormat), we(e, {
|
|
100470
100521
|
...t,
|
|
100471
100522
|
xmlId: i
|
|
100472
100523
|
}), i !== n.xmlId || r.type !== n.type) {
|
|
100473
|
-
let e =
|
|
100524
|
+
let e = I8(ie, n.xmlId);
|
|
100474
100525
|
if (e) {
|
|
100475
|
-
let t =
|
|
100476
|
-
t !== e.content &&
|
|
100526
|
+
let t = F8(e.content, n.xmlId, i, r.type);
|
|
100527
|
+
t !== e.content && Ce(e.xmlId, t, e.sourceFormat);
|
|
100477
100528
|
}
|
|
100478
100529
|
}
|
|
100479
|
-
i !== n.xmlId &&
|
|
100480
|
-
},
|
|
100530
|
+
i !== n.xmlId && De(i);
|
|
100531
|
+
}, z = (t) => {
|
|
100481
100532
|
I(t), (e.onDivisionAdd?.(t))?.then((e) => ue(t.xmlId, { id: e })).catch(() => {});
|
|
100482
|
-
},
|
|
100533
|
+
}, Ee = (t) => {
|
|
100483
100534
|
de(t), e.onDivisionRemove?.(t);
|
|
100484
|
-
},
|
|
100535
|
+
}, De = (t) => {
|
|
100485
100536
|
fe(t), e.onDivisionSelect?.(t);
|
|
100486
|
-
},
|
|
100487
|
-
if (!
|
|
100488
|
-
if (
|
|
100489
|
-
let e = z3(
|
|
100537
|
+
}, Oe = v(() => {
|
|
100538
|
+
if (!xe || Se === "pretext") return;
|
|
100539
|
+
if (Se === "latex") return i8(xe) ?? void 0;
|
|
100540
|
+
let e = z3(R, Se);
|
|
100490
100541
|
return e.pretextError ? void 0 : e.pretextSource;
|
|
100491
100542
|
}, [
|
|
100492
|
-
|
|
100493
|
-
|
|
100494
|
-
|
|
100495
|
-
]),
|
|
100496
|
-
if (!
|
|
100497
|
-
let t =
|
|
100498
|
-
if (
|
|
100499
|
-
let e =
|
|
100500
|
-
e && e.xmlId !==
|
|
100501
|
-
...
|
|
100543
|
+
xe,
|
|
100544
|
+
Se,
|
|
100545
|
+
R
|
|
100546
|
+
]), B = (e) => {
|
|
100547
|
+
if (!xe) return;
|
|
100548
|
+
let t = Se === "pretext" ? R8(e || "") : e || "";
|
|
100549
|
+
if (Se === "pretext") {
|
|
100550
|
+
let e = f8(t);
|
|
100551
|
+
e && e.xmlId !== xe.xmlId && (t = R8(p8({
|
|
100552
|
+
...xe,
|
|
100502
100553
|
content: t,
|
|
100503
100554
|
title: e.title,
|
|
100504
100555
|
type: e.type
|
|
100505
100556
|
}, {
|
|
100506
|
-
xmlId:
|
|
100557
|
+
xmlId: xe.xmlId,
|
|
100507
100558
|
label: e.label || null
|
|
100508
100559
|
}).content));
|
|
100509
|
-
} else if (
|
|
100510
|
-
let e =
|
|
100511
|
-
e && e.xmlId !==
|
|
100512
|
-
...
|
|
100560
|
+
} else if (Se === "markdown") {
|
|
100561
|
+
let e = y8(t);
|
|
100562
|
+
e && e.xmlId !== xe.xmlId && (t = b8({
|
|
100563
|
+
...xe,
|
|
100513
100564
|
content: t
|
|
100514
|
-
}, { xmlId:
|
|
100565
|
+
}, { xmlId: xe.xmlId }).content);
|
|
100515
100566
|
}
|
|
100516
|
-
if (t ===
|
|
100517
|
-
if (xe
|
|
100518
|
-
let e =
|
|
100519
|
-
if (e && (
|
|
100567
|
+
if (t === xe.content) return;
|
|
100568
|
+
if (Ce(xe.xmlId, t, Se), Se === "pretext") {
|
|
100569
|
+
let e = f8(t);
|
|
100570
|
+
if (e && (we(xe.xmlId, {
|
|
100520
100571
|
title: e.title,
|
|
100521
100572
|
type: e.type,
|
|
100522
100573
|
label: e.label || null
|
|
100523
|
-
}), e.type !==
|
|
100524
|
-
let t =
|
|
100574
|
+
}), e.type !== xe.type)) {
|
|
100575
|
+
let t = I8(ie, xe.xmlId);
|
|
100525
100576
|
if (t) {
|
|
100526
|
-
let n =
|
|
100527
|
-
n !== t.content &&
|
|
100577
|
+
let n = F8(t.content, xe.xmlId, xe.xmlId, e.type);
|
|
100578
|
+
n !== t.content && Ce(t.xmlId, n, t.sourceFormat);
|
|
100528
100579
|
}
|
|
100529
100580
|
}
|
|
100530
|
-
} else if (
|
|
100531
|
-
let e =
|
|
100532
|
-
if (e && (
|
|
100581
|
+
} else if (Se === "markdown") {
|
|
100582
|
+
let e = y8(t);
|
|
100583
|
+
if (e && (we(xe.xmlId, {
|
|
100533
100584
|
title: e.title,
|
|
100534
100585
|
type: e.type,
|
|
100535
100586
|
label: e.label || null
|
|
100536
|
-
}), e.type !==
|
|
100537
|
-
let t =
|
|
100587
|
+
}), e.type !== xe.type)) {
|
|
100588
|
+
let t = I8(ie, xe.xmlId);
|
|
100538
100589
|
if (t) {
|
|
100539
|
-
let n =
|
|
100540
|
-
n !== t.content &&
|
|
100590
|
+
let n = F8(t.content, xe.xmlId, xe.xmlId, e.type);
|
|
100591
|
+
n !== t.content && Ce(t.xmlId, n, t.sourceFormat);
|
|
100541
100592
|
}
|
|
100542
100593
|
}
|
|
100543
|
-
} else if (
|
|
100594
|
+
} else if (Se === "latex") {
|
|
100544
100595
|
let e = t8(t);
|
|
100545
|
-
e !== null &&
|
|
100596
|
+
e !== null && we(xe.xmlId, { title: e });
|
|
100546
100597
|
}
|
|
100547
100598
|
let n = new Set(ie.map((e) => e.xmlId));
|
|
100548
|
-
for (let { xmlId: e, type: r } of
|
|
100549
|
-
},
|
|
100550
|
-
|
|
100551
|
-
},
|
|
100552
|
-
|
|
100553
|
-
},
|
|
100599
|
+
for (let { xmlId: e, type: r } of E8(t)) n.has(e) || (z(A8(e, r, Se)), n.add(e));
|
|
100600
|
+
}, ke = (e) => {
|
|
100601
|
+
De(e);
|
|
100602
|
+
}, Ae = () => {
|
|
100603
|
+
xe && (u(!1), pe(xe));
|
|
100604
|
+
}, je = (e) => {
|
|
100554
100605
|
let t = W6();
|
|
100555
|
-
if (
|
|
100606
|
+
if (z(t), e) {
|
|
100556
100607
|
let n = ie.find((t) => t.xmlId === e);
|
|
100557
|
-
n &&
|
|
100608
|
+
n && Ce(n.xmlId, R8(M8(n.content, t.xmlId, t.type, null)), n.sourceFormat);
|
|
100558
100609
|
}
|
|
100559
100610
|
fe(t.xmlId), pe(t, { isNew: !0 });
|
|
100560
|
-
},
|
|
100611
|
+
}, Me = (e) => {
|
|
100561
100612
|
ee(e);
|
|
100562
|
-
},
|
|
100613
|
+
}, Ne = (t) => {
|
|
100563
100614
|
M(t), e.onAssetRemove?.(t);
|
|
100564
|
-
},
|
|
100615
|
+
}, Pe = !!(e.onAssetUpload && e.onAssetFetchUrl && e.onAssetUpdate), Fe = !!(e.onAssetRemove && (e.onAssetUpload || e.onAssetAddFromLibrary)), Ie = async (t) => {
|
|
100565
100616
|
if (!e.onAssetUpload || !e.onAssetFetchUrl || !t.ref || !t.url) return;
|
|
100566
|
-
let n = new Set(
|
|
100567
|
-
...await e.onAssetUpload(
|
|
100617
|
+
let n = new Set(t5(ie, j).map((e) => e.ref)), r = n5(t.ref, n), i = await e.onAssetFetchUrl(t.url), a = /\.[^./\\]+$/.exec(i.name)?.[0] ?? "", o = new File([i], `${r}${a}`, { type: i.type }), s = {
|
|
100618
|
+
...await e.onAssetUpload(o),
|
|
100568
100619
|
ref: r,
|
|
100569
100620
|
name: `${t.name} (copy)`,
|
|
100570
100621
|
source: t.source
|
|
100571
100622
|
};
|
|
100572
|
-
await e.onAssetUpdate?.(
|
|
100573
|
-
},
|
|
100574
|
-
if (r) n.ref && t.ref &&
|
|
100623
|
+
await e.onAssetUpdate?.(s), ee(s), S(s.kind, r);
|
|
100624
|
+
}, Le = async (t, n, r) => {
|
|
100625
|
+
if (r) n.ref && t.ref && Re(t.kind, t.ref, n.ref), ee(n);
|
|
100575
100626
|
else {
|
|
100576
100627
|
let r = {
|
|
100577
100628
|
...n,
|
|
@@ -100582,37 +100633,37 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100582
100633
|
await e.onAssetUpdate?.(r), te(r);
|
|
100583
100634
|
}
|
|
100584
100635
|
e.onAssetRemove?.(t), M(t);
|
|
100585
|
-
},
|
|
100636
|
+
}, Re = (e, t, n) => {
|
|
100586
100637
|
if (t !== n) for (let r of ie) {
|
|
100587
|
-
let i =
|
|
100588
|
-
i !== r.content &&
|
|
100638
|
+
let i = O8(r.content, e, t, n);
|
|
100639
|
+
i !== r.content && Ce(r.xmlId, i, r.sourceFormat);
|
|
100589
100640
|
}
|
|
100590
|
-
},
|
|
100641
|
+
}, ze = (e, t) => {
|
|
100591
100642
|
for (let n of ie) {
|
|
100592
|
-
let r =
|
|
100593
|
-
r !== n.content &&
|
|
100643
|
+
let r = k8(n.content, e, t);
|
|
100644
|
+
r !== n.content && Ce(n.xmlId, r, n.sourceFormat);
|
|
100594
100645
|
}
|
|
100595
100646
|
};
|
|
100596
100647
|
m(() => {
|
|
100597
100648
|
let e = () => o(window.innerWidth < 800);
|
|
100598
100649
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
100599
100650
|
}, [o]);
|
|
100600
|
-
let
|
|
100651
|
+
let Be = Se !== "pretext";
|
|
100601
100652
|
_(() => {
|
|
100602
100653
|
r({
|
|
100603
|
-
selectDivision:
|
|
100604
|
-
addDivision: (e) =>
|
|
100605
|
-
removeDivision: (e) =>
|
|
100606
|
-
updateDivision: (e, t) =>
|
|
100654
|
+
selectDivision: ke,
|
|
100655
|
+
addDivision: (e) => je(e),
|
|
100656
|
+
removeDivision: (e) => Ee(e),
|
|
100657
|
+
updateDivision: (e, t) => Te(e, t),
|
|
100607
100658
|
divisionContentChange: (e, t) => {
|
|
100608
|
-
|
|
100659
|
+
Ce(e, t, ie.find((t) => t.xmlId === e)?.sourceFormat ?? "pretext");
|
|
100609
100660
|
},
|
|
100610
|
-
handleDivisionContentChange:
|
|
100611
|
-
assetInsert:
|
|
100612
|
-
assetRemove:
|
|
100613
|
-
assetRefRemove:
|
|
100614
|
-
assetDuplicate:
|
|
100615
|
-
insertContentAtCursor: (e) =>
|
|
100661
|
+
handleDivisionContentChange: B,
|
|
100662
|
+
assetInsert: Me,
|
|
100663
|
+
assetRemove: Ne,
|
|
100664
|
+
assetRefRemove: ze,
|
|
100665
|
+
assetDuplicate: Pe ? Ie : void 0,
|
|
100666
|
+
insertContentAtCursor: (e) => ve.current?.insertAtCursor(e),
|
|
100616
100667
|
updateTitle: (t) => {
|
|
100617
100668
|
me(t), e.onTitleChange?.(t);
|
|
100618
100669
|
},
|
|
@@ -100620,19 +100671,19 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100620
100671
|
});
|
|
100621
100672
|
}), m(() => {
|
|
100622
100673
|
A({
|
|
100623
|
-
source:
|
|
100624
|
-
sourceFormat:
|
|
100674
|
+
source: R,
|
|
100675
|
+
sourceFormat: Se,
|
|
100625
100676
|
libraryAssets: e.libraryAssets,
|
|
100626
100677
|
projectType: e.projectType,
|
|
100627
100678
|
projectUrl: e.projectUrl,
|
|
100628
|
-
rootDivisionId:
|
|
100629
|
-
canConvertToPretext:
|
|
100630
|
-
activeEditorSource:
|
|
100679
|
+
rootDivisionId: be?.xmlId,
|
|
100680
|
+
canConvertToPretext: Oe !== void 0,
|
|
100681
|
+
activeEditorSource: R,
|
|
100631
100682
|
hasFeedback: e.onFeedbackSubmit !== void 0,
|
|
100632
|
-
hasAssetDuplicate:
|
|
100683
|
+
hasAssetDuplicate: Pe
|
|
100633
100684
|
});
|
|
100634
100685
|
});
|
|
100635
|
-
let
|
|
100686
|
+
let Ve = y({
|
|
100636
100687
|
divisions: e.divisions,
|
|
100637
100688
|
projectAssets: e.projectAssets,
|
|
100638
100689
|
title: e.title,
|
|
@@ -100642,14 +100693,14 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100642
100693
|
activeDivisionId: e.activeDivisionId
|
|
100643
100694
|
});
|
|
100644
100695
|
m(() => {
|
|
100645
|
-
let t =
|
|
100696
|
+
let t = Ve.current, n = {}, r = !1;
|
|
100646
100697
|
if (e.projectAssets !== void 0 && e.projectAssets !== t.projectAssets && (n.projectAssets = e.projectAssets, r = !0), e.divisions !== t.divisions) {
|
|
100647
|
-
let t =
|
|
100698
|
+
let t = k5(e.divisions, e.rootDivisionId), i = e5(e.divisions, t?.xmlId, e.projectType, e.title);
|
|
100648
100699
|
n.divisions = i;
|
|
100649
100700
|
let a = i.find((e) => e.xmlId === t?.xmlId) ?? t;
|
|
100650
100701
|
(ae == null || !e.divisions.some((e) => e.xmlId === ae)) && (n.activeDivisionId = a?.xmlId ?? null), !e.title && a?.title && (n.title = a.title), r = !0;
|
|
100651
100702
|
}
|
|
100652
|
-
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 && ce(n),
|
|
100703
|
+
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 && ce(n), Ve.current = {
|
|
100653
100704
|
divisions: e.divisions,
|
|
100654
100705
|
projectAssets: e.projectAssets,
|
|
100655
100706
|
title: e.title,
|
|
@@ -100659,11 +100710,11 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100659
100710
|
activeDivisionId: e.activeDivisionId
|
|
100660
100711
|
};
|
|
100661
100712
|
});
|
|
100662
|
-
let
|
|
100713
|
+
let He = y(null);
|
|
100663
100714
|
m(() => {
|
|
100664
|
-
if (
|
|
100665
|
-
|
|
100666
|
-
let t =
|
|
100715
|
+
if (He.current === e.divisions) return;
|
|
100716
|
+
He.current = e.divisions;
|
|
100717
|
+
let t = k5(e.divisions, e.rootDivisionId), n = e5(e.divisions, t?.xmlId, e.projectType, e.title);
|
|
100667
100718
|
for (let t of n) {
|
|
100668
100719
|
if (t.sourceFormat !== "pretext") continue;
|
|
100669
100720
|
let n = e.divisions.find((e) => e.xmlId === t.xmlId);
|
|
@@ -100675,78 +100726,78 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100675
100726
|
});
|
|
100676
100727
|
}
|
|
100677
100728
|
});
|
|
100678
|
-
let
|
|
100679
|
-
if (!g || !
|
|
100729
|
+
let V = se ? F : oe, Ue = v(() => {
|
|
100730
|
+
if (!g || !be) return "";
|
|
100680
100731
|
try {
|
|
100681
|
-
return
|
|
100732
|
+
return X8(ie, be.xmlId, V, j ?? []);
|
|
100682
100733
|
} catch (e) {
|
|
100683
100734
|
return `<!-- Unable to assemble document source: ${e instanceof Error ? e.message : String(e)} -->`;
|
|
100684
100735
|
}
|
|
100685
100736
|
}, [
|
|
100686
100737
|
g,
|
|
100687
|
-
|
|
100738
|
+
be,
|
|
100688
100739
|
ie,
|
|
100689
|
-
|
|
100740
|
+
V,
|
|
100690
100741
|
j
|
|
100691
|
-
]),
|
|
100692
|
-
e.onSave?.(),
|
|
100693
|
-
},
|
|
100742
|
+
]), We = xe ? Se === "pretext" ? J8(ie, xe.xmlId, j) : Oe : void 0, Ge = xe && We !== void 0 ? Q8(xe.type, We, V, xe.title) : void 0, Ke = () => _e.current?.rebuild(), qe = () => {
|
|
100743
|
+
e.onSave?.(), _e.current?.rebuild();
|
|
100744
|
+
}, Je = (t) => {
|
|
100694
100745
|
let n = t.ctrlKey || t.metaKey;
|
|
100695
|
-
n && t.key === "Enter" && e.onPreviewRebuild ? (t.preventDefault(),
|
|
100696
|
-
},
|
|
100697
|
-
if (!
|
|
100746
|
+
n && t.key === "Enter" && e.onPreviewRebuild ? (t.preventDefault(), Ke()) : n && t.key === "s" && (t.preventDefault(), qe());
|
|
100747
|
+
}, Ye = () => {
|
|
100748
|
+
if (!xe || !Oe) return;
|
|
100698
100749
|
let e = W6(), t = {
|
|
100699
100750
|
id: e.xmlId,
|
|
100700
|
-
xmlId:
|
|
100701
|
-
title:
|
|
100702
|
-
type:
|
|
100703
|
-
sourceFormat:
|
|
100704
|
-
content:
|
|
100751
|
+
xmlId: xe.xmlId,
|
|
100752
|
+
title: xe.title,
|
|
100753
|
+
type: xe.type,
|
|
100754
|
+
sourceFormat: Se,
|
|
100755
|
+
content: xe.content
|
|
100705
100756
|
};
|
|
100706
|
-
|
|
100707
|
-
},
|
|
100708
|
-
ref:
|
|
100709
|
-
content:
|
|
100710
|
-
sourceFormat:
|
|
100711
|
-
onChange:
|
|
100712
|
-
onRebuild: e.onPreviewRebuild ?
|
|
100713
|
-
onSave:
|
|
100757
|
+
z(Se === "markdown" ? b8(t, { xmlId: e.xmlId }) : r8(t, { xmlId: e.xmlId })), Ce(xe.xmlId, R8(Oe), "pretext"), we(xe.xmlId, { sourceFormat: "pretext" });
|
|
100758
|
+
}, Xe = /* @__PURE__ */ t(fc, {
|
|
100759
|
+
ref: ve,
|
|
100760
|
+
content: R,
|
|
100761
|
+
sourceFormat: Se,
|
|
100762
|
+
onChange: B,
|
|
100763
|
+
onRebuild: e.onPreviewRebuild ? Ke : void 0,
|
|
100764
|
+
onSave: qe,
|
|
100714
100765
|
onOpenLatexImport: () => O("isLatexDialogOpen"),
|
|
100715
100766
|
onOpenDocinfoEditor: () => O("isDocinfoEditorOpen"),
|
|
100716
|
-
onOpenConvertToPretext:
|
|
100717
|
-
canConvertToPretext:
|
|
100718
|
-
onOpenAssets: e.projectAssets !== void 0 &&
|
|
100767
|
+
onOpenConvertToPretext: Be && Oe !== void 0 ? () => O("isConvertDialogOpen") : void 0,
|
|
100768
|
+
canConvertToPretext: Oe !== void 0,
|
|
100769
|
+
onOpenAssets: e.projectAssets !== void 0 && Se === "pretext" ? () => O("isAssetPickerOpen") : void 0,
|
|
100719
100770
|
onShowFullSource: () => O("isFullSourceOpen"),
|
|
100720
|
-
onRequestWrapperEdit:
|
|
100721
|
-
}),
|
|
100722
|
-
|
|
100723
|
-
ref:
|
|
100724
|
-
content:
|
|
100771
|
+
onRequestWrapperEdit: Ae
|
|
100772
|
+
}), Ze;
|
|
100773
|
+
Ze = i && e.onPreviewRebuild ? /* @__PURE__ */ t(jR, {
|
|
100774
|
+
ref: _e,
|
|
100775
|
+
content: Ge || "",
|
|
100725
100776
|
title: P,
|
|
100726
100777
|
onRebuild: e.onPreviewRebuild
|
|
100727
100778
|
}) : /* @__PURE__ */ t(OR, {
|
|
100728
|
-
content:
|
|
100729
|
-
canEdit:
|
|
100730
|
-
editDisabledReason:
|
|
100731
|
-
onChange: (e) =>
|
|
100779
|
+
content: R,
|
|
100780
|
+
canEdit: Se === "pretext",
|
|
100781
|
+
editDisabledReason: Se === "markdown" ? "Visual editing is not available for Markdown documents." : Se === "latex" ? "Visual editing is not available for LaTeX documents." : "",
|
|
100782
|
+
onChange: (e) => B(e)
|
|
100732
100783
|
});
|
|
100733
|
-
let
|
|
100784
|
+
let Qe = /* @__PURE__ */ t(w5, {
|
|
100734
100785
|
isCollapsed: l,
|
|
100735
100786
|
onToggleCollapse: () => u((e) => !e),
|
|
100736
100787
|
onOpenAssetPicker: e.projectAssets === void 0 ? void 0 : () => O("isAssetPickerOpen")
|
|
100737
|
-
}),
|
|
100738
|
-
return
|
|
100788
|
+
}), $e = "pretext-plus-tab-editor", et = "pretext-plus-tab-preview", tt = "pretext-plus-tabpanel", nt;
|
|
100789
|
+
return nt = a ? /* @__PURE__ */ n("div", {
|
|
100739
100790
|
className: "pretext-plus-editor__tabs",
|
|
100740
|
-
children: [
|
|
100791
|
+
children: [Qe, /* @__PURE__ */ n("div", {
|
|
100741
100792
|
className: "pretext-plus-editor__tabs-main",
|
|
100742
100793
|
children: [/* @__PURE__ */ n("div", {
|
|
100743
100794
|
className: "pretext-plus-editor__tab-list",
|
|
100744
100795
|
role: "tablist",
|
|
100745
100796
|
children: [/* @__PURE__ */ t("button", {
|
|
100746
100797
|
type: "button",
|
|
100747
|
-
id:
|
|
100798
|
+
id: $e,
|
|
100748
100799
|
role: "tab",
|
|
100749
|
-
"aria-controls":
|
|
100800
|
+
"aria-controls": tt,
|
|
100750
100801
|
"aria-selected": s === "editor",
|
|
100751
100802
|
tabIndex: s === "editor" ? 0 : -1,
|
|
100752
100803
|
className: `pretext-plus-editor__tab-button ${s === "editor" ? "is-active" : ""}`,
|
|
@@ -100754,9 +100805,9 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100754
100805
|
children: "Editor"
|
|
100755
100806
|
}), /* @__PURE__ */ t("button", {
|
|
100756
100807
|
type: "button",
|
|
100757
|
-
id:
|
|
100808
|
+
id: et,
|
|
100758
100809
|
role: "tab",
|
|
100759
|
-
"aria-controls":
|
|
100810
|
+
"aria-controls": tt,
|
|
100760
100811
|
"aria-selected": s === "preview",
|
|
100761
100812
|
tabIndex: s === "preview" ? 0 : -1,
|
|
100762
100813
|
className: `pretext-plus-editor__tab-button ${s === "preview" ? "is-active" : ""}`,
|
|
@@ -100764,25 +100815,25 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100764
100815
|
children: "Preview"
|
|
100765
100816
|
})]
|
|
100766
100817
|
}), /* @__PURE__ */ t("div", {
|
|
100767
|
-
id:
|
|
100818
|
+
id: tt,
|
|
100768
100819
|
className: "pretext-plus-editor__tab-panel",
|
|
100769
100820
|
role: "tabpanel",
|
|
100770
|
-
"aria-labelledby": s === "editor" ?
|
|
100821
|
+
"aria-labelledby": s === "editor" ? $e : et,
|
|
100771
100822
|
children: /* @__PURE__ */ t("div", {
|
|
100772
100823
|
style: { height: "100%" },
|
|
100773
|
-
children: s === "editor" ?
|
|
100824
|
+
children: s === "editor" ? Xe : Ze
|
|
100774
100825
|
})
|
|
100775
100826
|
})]
|
|
100776
100827
|
})]
|
|
100777
100828
|
}) : /* @__PURE__ */ n("div", {
|
|
100778
100829
|
className: "pretext-plus-editor__sectioned-layout",
|
|
100779
|
-
children: [
|
|
100830
|
+
children: [Qe, /* @__PURE__ */ n(Rt, {
|
|
100780
100831
|
orientation: "horizontal",
|
|
100781
100832
|
className: "pretext-plus-editor__splitter",
|
|
100782
100833
|
children: [
|
|
100783
100834
|
/* @__PURE__ */ t(Vt, {
|
|
100784
100835
|
className: "pretext-plus-editor__editor-panel",
|
|
100785
|
-
children:
|
|
100836
|
+
children: Xe
|
|
100786
100837
|
}),
|
|
100787
100838
|
/* @__PURE__ */ t(Wt, {
|
|
100788
100839
|
className: "pretext-plus-editor__resize-handle",
|
|
@@ -100790,14 +100841,14 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100790
100841
|
}),
|
|
100791
100842
|
/* @__PURE__ */ t(Vt, {
|
|
100792
100843
|
className: "pretext-plus-editor__preview-panel",
|
|
100793
|
-
children:
|
|
100844
|
+
children: Ze
|
|
100794
100845
|
})
|
|
100795
100846
|
]
|
|
100796
100847
|
})]
|
|
100797
100848
|
}), /* @__PURE__ */ n("div", {
|
|
100798
100849
|
className: "pretext-plus-editor",
|
|
100799
|
-
onKeyDown:
|
|
100800
|
-
children: [/* @__PURE__ */ t(
|
|
100850
|
+
onKeyDown: Je,
|
|
100851
|
+
children: [/* @__PURE__ */ t(d5, {
|
|
100801
100852
|
onSaveButton: e.onSaveButton,
|
|
100802
100853
|
saveButtonLabel: e.saveButtonLabel,
|
|
100803
100854
|
onCancelButton: e.onCancelButton,
|
|
@@ -100806,16 +100857,16 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100806
100857
|
}), /* @__PURE__ */ n("div", {
|
|
100807
100858
|
className: "pretext-plus-editor__editor-displays",
|
|
100808
100859
|
children: [
|
|
100809
|
-
/* @__PURE__ */ t(
|
|
100810
|
-
resetKeys: [
|
|
100811
|
-
children:
|
|
100860
|
+
/* @__PURE__ */ t(T5, {
|
|
100861
|
+
resetKeys: [R, ae],
|
|
100862
|
+
children: nt
|
|
100812
100863
|
}),
|
|
100813
100864
|
d ? /* @__PURE__ */ t(Y3, { onClose: () => k("isLatexDialogOpen") }) : null,
|
|
100814
|
-
f &&
|
|
100815
|
-
sourceContent:
|
|
100816
|
-
sourceFormat:
|
|
100817
|
-
pretextSource:
|
|
100818
|
-
onConfirm:
|
|
100865
|
+
f && xe && Oe ? /* @__PURE__ */ t($3, {
|
|
100866
|
+
sourceContent: R,
|
|
100867
|
+
sourceFormat: Se,
|
|
100868
|
+
pretextSource: Oe,
|
|
100869
|
+
onConfirm: Ye,
|
|
100819
100870
|
onClose: () => k("isConvertDialogOpen")
|
|
100820
100871
|
}) : null,
|
|
100821
100872
|
p ? /* @__PURE__ */ t(d6, {
|
|
@@ -100830,8 +100881,8 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100830
100881
|
commonDocinfo: t.commonDocinfo,
|
|
100831
100882
|
useCommonDocinfo: t.useCommonDocinfo
|
|
100832
100883
|
}), e.onCommonDocinfoChange?.(t.commonDocinfo), e.onUseCommonDocinfoChange?.(t.useCommonDocinfo);
|
|
100833
|
-
let n =
|
|
100834
|
-
|
|
100884
|
+
let n = be ?? xe;
|
|
100885
|
+
Ce(n?.xmlId ?? "", n?.content ?? "", n?.sourceFormat ?? "pretext", {
|
|
100835
100886
|
docinfo: t.docinfo,
|
|
100836
100887
|
commonDocinfo: t.commonDocinfo,
|
|
100837
100888
|
useCommonDocinfo: t.useCommonDocinfo
|
|
@@ -100839,7 +100890,7 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100839
100890
|
}
|
|
100840
100891
|
}
|
|
100841
100892
|
}) : null,
|
|
100842
|
-
(h || w || E) && e.projectAssets !== void 0 ? /* @__PURE__ */ t(
|
|
100893
|
+
(h || w || E) && e.projectAssets !== void 0 ? /* @__PURE__ */ t(o5, {
|
|
100843
100894
|
open: h || !!w || !!E,
|
|
100844
100895
|
resolveTarget: w,
|
|
100845
100896
|
replaceTarget: E,
|
|
@@ -100852,26 +100903,26 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100852
100903
|
onUpload: e.onAssetUpload,
|
|
100853
100904
|
onFetchUrl: e.onAssetFetchUrl,
|
|
100854
100905
|
onCreateDoenet: e.onCreateDoenet,
|
|
100855
|
-
onRemoveAsset: e.onAssetRemove ?
|
|
100856
|
-
onDuplicateAsset:
|
|
100857
|
-
onAssetAdded:
|
|
100858
|
-
onResolveRef:
|
|
100859
|
-
onReplaceAsset:
|
|
100906
|
+
onRemoveAsset: e.onAssetRemove ? Ne : void 0,
|
|
100907
|
+
onDuplicateAsset: Pe ? Ie : void 0,
|
|
100908
|
+
onAssetAdded: Me,
|
|
100909
|
+
onResolveRef: Re,
|
|
100910
|
+
onReplaceAsset: Le
|
|
100860
100911
|
}) : null,
|
|
100861
100912
|
g ? /* @__PURE__ */ t(p6, {
|
|
100862
|
-
source:
|
|
100913
|
+
source: Ue,
|
|
100863
100914
|
onClose: () => k("isFullSourceOpen")
|
|
100864
100915
|
}) : null,
|
|
100865
|
-
N ? /* @__PURE__ */ t(
|
|
100916
|
+
N ? /* @__PURE__ */ t(u5, {
|
|
100866
100917
|
asset: N,
|
|
100867
100918
|
projectAssets: j ?? [],
|
|
100868
100919
|
onClose: C,
|
|
100869
|
-
onReplace:
|
|
100920
|
+
onReplace: Fe ? (e) => {
|
|
100870
100921
|
C(), D(e);
|
|
100871
100922
|
} : void 0,
|
|
100872
|
-
onDuplicate:
|
|
100923
|
+
onDuplicate: Pe ? (e) => Ie(e) : void 0,
|
|
100873
100924
|
onSave: async (t, n) => {
|
|
100874
|
-
t.ref && t.ref !== n ? (
|
|
100925
|
+
t.ref && t.ref !== n ? (Re(t.kind, n, t.ref), ne(t.kind, n, t)) : te(t), await e.onAssetUpdate?.(t);
|
|
100875
100926
|
}
|
|
100876
100927
|
}, `${N.kind}:${N.ref}`) : null
|
|
100877
100928
|
]
|
|
@@ -100879,6 +100930,6 @@ var E5 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
100879
100930
|
});
|
|
100880
100931
|
};
|
|
100881
100932
|
//#endregion
|
|
100882
|
-
export { fc as CodeEditor, d6 as DocinfoEditor,
|
|
100933
|
+
export { fc as CodeEditor, d6 as DocinfoEditor, A5 as Editors, V3 as FeedbackLink, jR as FullPreview, OR as VisualEditor, X8 as assembleFullProjectSource, J8 as assembleProjectSource, V8 as buildDivisionTree, I3 as convertLatexToPretext, K6 as createConclusion, G6 as createIntroduction, s8 as createLatexConclusion, o8 as createLatexIntroduction, a8 as createNewLatexSection, W6 as createNewSection, z3 as derivePretextContent, F3 as detectSourceFormat, Q6 as ensureLatexSectionWrapper, Y6 as ensureSectionWrapper, f8 as extractDivisionMetadata, t8 as extractLatexDivisionTitle, I8 as findDivisionParent, H8 as getOrphanRoots, B8 as getOrphanedDivisions, l8 as getSectionAttributes, M8 as insertDivisionRef, c8 as mergeTwoSections, P8 as moveDivisionRef, R8 as normalizeSelfClosingRefs, T8 as parseDivisionRefs, AR as postToIframe, N8 as removeDivisionRef, F8 as renameDivisionRef, L8 as reorderDivisionRefs, Z6 as rewrapLatexSection, J6 as rewrapSection, X6 as stripLatexSectionWrapper, q6 as stripSectionWrapper, U6 as updateDivisionTitle, e8 as updateLatexSectionTitle, p8 as updateSectionMetadata, Q8 as wrapDivisionForPreview };
|
|
100883
100934
|
|
|
100884
100935
|
//# sourceMappingURL=index.es.js.map
|