@pretextbook/web-editor 0.5.3 → 0.5.4
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 +1481 -1387
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/sectionUtils.d.ts +19 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -93362,982 +93362,133 @@ var x3 = ({ label: e, context: n, className: r }) => {
|
|
|
93362
93362
|
]
|
|
93363
93363
|
})
|
|
93364
93364
|
});
|
|
93365
|
-
}, z3 =
|
|
93366
|
-
|
|
93367
|
-
|
|
93368
|
-
|
|
93369
|
-
|
|
93370
|
-
|
|
93371
|
-
|
|
93372
|
-
let e
|
|
93373
|
-
|
|
93374
|
-
|
|
93375
|
-
|
|
93376
|
-
|
|
93377
|
-
}
|
|
93378
|
-
|
|
93379
|
-
|
|
93380
|
-
|
|
93381
|
-
|
|
93382
|
-
|
|
93383
|
-
|
|
93384
|
-
|
|
93385
|
-
|
|
93386
|
-
|
|
93387
|
-
|
|
93388
|
-
|
|
93389
|
-
|
|
93390
|
-
|
|
93391
|
-
|
|
93392
|
-
|
|
93393
|
-
|
|
93394
|
-
|
|
93395
|
-
|
|
93396
|
-
|
|
93397
|
-
i,
|
|
93398
|
-
De
|
|
93399
|
-
]), !r) return null;
|
|
93400
|
-
let Oe = H3(h), B = (e) => {
|
|
93401
|
-
s(e), i();
|
|
93402
|
-
}, ke = (e, t) => {
|
|
93403
|
-
let n = `${e}:${t}`;
|
|
93404
|
-
navigator.clipboard.writeText(`<plus:${e} ref="${t}"/>`).catch(() => {}), Ee(n), setTimeout(() => Ee((e) => e === n ? null : e), 2e3);
|
|
93405
|
-
}, Ae = async (e) => {
|
|
93406
|
-
if (!j.has(e.id) && c) {
|
|
93407
|
-
oe(e.id);
|
|
93408
|
-
try {
|
|
93409
|
-
await c(e);
|
|
93410
|
-
} finally {
|
|
93411
|
-
oe(null);
|
|
93365
|
+
}, z3 = /* @__PURE__ */ M(((e, t) => {
|
|
93366
|
+
var n = Object.defineProperty, r = Object.getOwnPropertyDescriptor, i = Object.getOwnPropertyNames, a = Object.prototype.hasOwnProperty, o = (e, t) => {
|
|
93367
|
+
for (var r in t) n(e, r, {
|
|
93368
|
+
get: t[r],
|
|
93369
|
+
enumerable: !0
|
|
93370
|
+
});
|
|
93371
|
+
}, s = (e, t, o, s) => {
|
|
93372
|
+
if (t && typeof t == "object" || typeof t == "function") for (let c of i(t)) !a.call(e, c) && c !== o && n(e, c, {
|
|
93373
|
+
get: () => t[c],
|
|
93374
|
+
enumerable: !(s = r(t, c)) || s.enumerable
|
|
93375
|
+
});
|
|
93376
|
+
return e;
|
|
93377
|
+
}, c = (e) => s(n({}, "__esModule", { value: !0 }), e), l = {};
|
|
93378
|
+
o(l, {
|
|
93379
|
+
XmlCdata: () => E,
|
|
93380
|
+
XmlComment: () => D,
|
|
93381
|
+
XmlDeclaration: () => O,
|
|
93382
|
+
XmlDocument: () => A,
|
|
93383
|
+
XmlDocumentType: () => j,
|
|
93384
|
+
XmlElement: () => k,
|
|
93385
|
+
XmlError: () => ee,
|
|
93386
|
+
XmlNode: () => w,
|
|
93387
|
+
XmlProcessingInstruction: () => te,
|
|
93388
|
+
XmlText: () => T,
|
|
93389
|
+
parseXml: () => re
|
|
93390
|
+
}), t.exports = c(l);
|
|
93391
|
+
var u = "", d = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, f = class {
|
|
93392
|
+
constructor(e) {
|
|
93393
|
+
if (this.k = this.u(e, !0), this.d = 0, this.length = e.length, this.l = this.k !== this.length, this.h = e, this.l) {
|
|
93394
|
+
let t = [];
|
|
93395
|
+
for (let n = 0, r = 0; r < this.k; ++r) t[r] = n, n += e.codePointAt(n) > 65535 ? 2 : 1;
|
|
93396
|
+
this.A = t;
|
|
93412
93397
|
}
|
|
93413
93398
|
}
|
|
93414
|
-
B(
|
|
93415
|
-
|
|
93416
|
-
if (l) {
|
|
93417
|
-
I(null), le(!0);
|
|
93418
|
-
try {
|
|
93419
|
-
B(await l(e));
|
|
93420
|
-
} catch (e) {
|
|
93421
|
-
I(e instanceof Error ? e.message : "Upload failed."), le(!1);
|
|
93422
|
-
}
|
|
93399
|
+
get B() {
|
|
93400
|
+
return this.d >= this.k;
|
|
93423
93401
|
}
|
|
93424
|
-
|
|
93425
|
-
|
|
93426
|
-
|
|
93427
|
-
|
|
93428
|
-
|
|
93429
|
-
|
|
93430
|
-
|
|
93431
|
-
|
|
93432
|
-
|
|
93433
|
-
|
|
93434
|
-
|
|
93435
|
-
|
|
93436
|
-
|
|
93437
|
-
|
|
93438
|
-
|
|
93439
|
-
|
|
93440
|
-
}
|
|
93441
|
-
|
|
93442
|
-
|
|
93443
|
-
|
|
93444
|
-
|
|
93445
|
-
|
|
93446
|
-
|
|
93447
|
-
} catch (e) {
|
|
93448
|
-
Te(e instanceof Error ? e.message : "Failed to create activity."), Ce(!1);
|
|
93402
|
+
u(e, t = this.l) {
|
|
93403
|
+
return t ? e.replace(d, "_").length : e.length;
|
|
93404
|
+
}
|
|
93405
|
+
p(e = 1) {
|
|
93406
|
+
this.d = Math.min(this.k, this.d + e);
|
|
93407
|
+
}
|
|
93408
|
+
f(e = this.d) {
|
|
93409
|
+
return this.l ? this.A[e] ?? Infinity : e;
|
|
93410
|
+
}
|
|
93411
|
+
G(e = 1) {
|
|
93412
|
+
let t = this.m(e);
|
|
93413
|
+
return this.p(e), t;
|
|
93414
|
+
}
|
|
93415
|
+
v(e) {
|
|
93416
|
+
let t = this.f(), n = this.h.slice(t, t + e);
|
|
93417
|
+
return this.p(this.u(n)), n;
|
|
93418
|
+
}
|
|
93419
|
+
w(e) {
|
|
93420
|
+
let { length: t, l: n, h: r } = this, i = this.f(), a = i;
|
|
93421
|
+
if (n) for (; a < t;) {
|
|
93422
|
+
let t = r[a], n = t >= "\ud800" && t <= "\udbff";
|
|
93423
|
+
if (n && (t += r[a + 1]), !e(t)) break;
|
|
93424
|
+
a += n ? 2 : 1;
|
|
93449
93425
|
}
|
|
93450
|
-
|
|
93451
|
-
|
|
93452
|
-
|
|
93453
|
-
|
|
93454
|
-
|
|
93455
|
-
|
|
93456
|
-
|
|
93457
|
-
|
|
93458
|
-
|
|
93459
|
-
|
|
93460
|
-
|
|
93461
|
-
|
|
93462
|
-
|
|
93463
|
-
|
|
93464
|
-
|
|
93465
|
-
|
|
93466
|
-
|
|
93467
|
-
|
|
93468
|
-
|
|
93469
|
-
|
|
93470
|
-
|
|
93471
|
-
|
|
93472
|
-
|
|
93473
|
-
|
|
93474
|
-
|
|
93475
|
-
|
|
93476
|
-
|
|
93477
|
-
|
|
93478
|
-
|
|
93479
|
-
|
|
93480
|
-
|
|
93481
|
-
|
|
93482
|
-
|
|
93483
|
-
|
|
93484
|
-
|
|
93485
|
-
|
|
93486
|
-
|
|
93487
|
-
|
|
93488
|
-
|
|
93489
|
-
|
|
93490
|
-
|
|
93491
|
-
|
|
93492
|
-
|
|
93493
|
-
|
|
93494
|
-
|
|
93495
|
-
|
|
93496
|
-
|
|
93497
|
-
|
|
93498
|
-
|
|
93499
|
-
|
|
93500
|
-
|
|
93501
|
-
|
|
93502
|
-
|
|
93503
|
-
|
|
93504
|
-
|
|
93505
|
-
|
|
93506
|
-
|
|
93507
|
-
|
|
93508
|
-
}
|
|
93509
|
-
|
|
93510
|
-
|
|
93511
|
-
|
|
93512
|
-
|
|
93513
|
-
|
|
93514
|
-
|
|
93515
|
-
|
|
93516
|
-
"aria-modal": "true",
|
|
93517
|
-
"aria-label": "Asset manager",
|
|
93518
|
-
children: [
|
|
93519
|
-
/* @__PURE__ */ n("div", {
|
|
93520
|
-
className: "pretext-plus-editor__dialog-header",
|
|
93521
|
-
children: [/* @__PURE__ */ t("h2", {
|
|
93522
|
-
className: "pretext-plus-editor__dialog-title",
|
|
93523
|
-
children: "Assets"
|
|
93524
|
-
}), /* @__PURE__ */ t("button", {
|
|
93525
|
-
type: "button",
|
|
93526
|
-
className: "pretext-plus-editor__dialog-close",
|
|
93527
|
-
onClick: i,
|
|
93528
|
-
"aria-label": "Close",
|
|
93529
|
-
children: "✕"
|
|
93530
|
-
})]
|
|
93531
|
-
}),
|
|
93532
|
-
/* @__PURE__ */ n("div", {
|
|
93533
|
-
className: "pretext-plus-editor__dialog-tab-bar",
|
|
93534
|
-
children: [/* @__PURE__ */ n("button", {
|
|
93535
|
-
type: "button",
|
|
93536
|
-
className: `pretext-plus-editor__dialog-tab${ee === "in-document" ? " pretext-plus-editor__dialog-tab--active" : ""}`,
|
|
93537
|
-
onClick: () => te("in-document"),
|
|
93538
|
-
children: ["In Document", Oe.length > 0 && /* @__PURE__ */ t("span", {
|
|
93539
|
-
className: "pretext-plus-editor__asset-tab-count",
|
|
93540
|
-
children: Oe.length
|
|
93541
|
-
})]
|
|
93542
|
-
}), /* @__PURE__ */ t("button", {
|
|
93543
|
-
type: "button",
|
|
93544
|
-
className: `pretext-plus-editor__dialog-tab${ee === "add" ? " pretext-plus-editor__dialog-tab--active" : ""}`,
|
|
93545
|
-
onClick: () => {
|
|
93546
|
-
te("add"), M(null);
|
|
93547
|
-
},
|
|
93548
|
-
children: "Add Asset"
|
|
93549
|
-
})]
|
|
93550
|
-
}),
|
|
93551
|
-
/* @__PURE__ */ t("div", {
|
|
93552
|
-
className: "pretext-plus-editor__dialog-content pretext-plus-editor__dialog-content--single",
|
|
93553
|
-
children: ee === "in-document" ? (() => {
|
|
93554
|
-
if (Oe.length === 0) return /* @__PURE__ */ n("div", {
|
|
93555
|
-
className: "pretext-plus-editor__am-placeholder",
|
|
93556
|
-
children: [/* @__PURE__ */ t("p", { children: "No assets referenced in this document yet." }), /* @__PURE__ */ t("button", {
|
|
93557
|
-
type: "button",
|
|
93558
|
-
className: "pretext-plus-editor__dialog-button",
|
|
93559
|
-
onClick: () => {
|
|
93560
|
-
te("add"), M(null);
|
|
93561
|
-
},
|
|
93562
|
-
children: "Add an asset"
|
|
93563
|
-
})]
|
|
93564
|
-
});
|
|
93565
|
-
let e = V3.reduce((e, t) => (e[t] = Oe.filter((e) => e.kind === t).map((e) => ({
|
|
93566
|
-
ref: e.ref,
|
|
93567
|
-
asset: k.find((t) => t.kind === e.kind && t.ref === e.ref)
|
|
93568
|
-
})), e), {
|
|
93569
|
-
image: [],
|
|
93570
|
-
doenet: []
|
|
93571
|
-
});
|
|
93572
|
-
return /* @__PURE__ */ t("div", {
|
|
93573
|
-
className: "pretext-plus-editor__am-in-doc",
|
|
93574
|
-
children: V3.filter((t) => e[t].length > 0).map((r) => /* @__PURE__ */ n("div", {
|
|
93575
|
-
className: "pretext-plus-editor__am-kind-group",
|
|
93576
|
-
children: [/* @__PURE__ */ n("div", {
|
|
93577
|
-
className: "pretext-plus-editor__am-kind-header",
|
|
93578
|
-
children: [
|
|
93579
|
-
/* @__PURE__ */ t("span", {
|
|
93580
|
-
"aria-hidden": "true",
|
|
93581
|
-
children: "📁"
|
|
93582
|
-
}),
|
|
93583
|
-
/* @__PURE__ */ t("span", { children: B3[r] }),
|
|
93584
|
-
/* @__PURE__ */ t("span", {
|
|
93585
|
-
className: "pretext-plus-editor__am-kind-count",
|
|
93586
|
-
children: e[r].length
|
|
93587
|
-
})
|
|
93588
|
-
]
|
|
93589
|
-
}), /* @__PURE__ */ t("ul", {
|
|
93590
|
-
className: "pretext-plus-editor__am-list",
|
|
93591
|
-
children: e[r].map(({ ref: e, asset: a }) => {
|
|
93592
|
-
let o = `${r}:${e}`;
|
|
93593
|
-
return /* @__PURE__ */ n("li", {
|
|
93594
|
-
className: "pretext-plus-editor__am-doc-row",
|
|
93595
|
-
children: [/* @__PURE__ */ n("div", {
|
|
93596
|
-
className: "pretext-plus-editor__am-row-info",
|
|
93597
|
-
children: [/* @__PURE__ */ t("span", {
|
|
93598
|
-
className: "pretext-plus-editor__am-row-name",
|
|
93599
|
-
children: a?.name ?? e
|
|
93600
|
-
}), /* @__PURE__ */ t("span", {
|
|
93601
|
-
className: "pretext-plus-editor__am-row-ref",
|
|
93602
|
-
children: e
|
|
93603
|
-
})]
|
|
93604
|
-
}), /* @__PURE__ */ n("div", {
|
|
93605
|
-
className: "pretext-plus-editor__am-row-actions",
|
|
93606
|
-
children: [
|
|
93607
|
-
a && /* @__PURE__ */ t("button", {
|
|
93608
|
-
type: "button",
|
|
93609
|
-
className: "pretext-plus-editor__am-action-btn",
|
|
93610
|
-
onClick: () => B(a),
|
|
93611
|
-
title: `Insert <plus:${r} ref="${e}"/>`,
|
|
93612
|
-
children: "Insert"
|
|
93613
|
-
}),
|
|
93614
|
-
/* @__PURE__ */ t("button", {
|
|
93615
|
-
type: "button",
|
|
93616
|
-
className: `pretext-plus-editor__am-action-btn${z === o ? " pretext-plus-editor__am-action-btn--done" : ""}`,
|
|
93617
|
-
onClick: () => ke(r, e),
|
|
93618
|
-
title: `Copy <plus:${r} ref="${e}"/>`,
|
|
93619
|
-
children: z === o ? "Copied!" : "Copy"
|
|
93620
|
-
}),
|
|
93621
|
-
p && a && /* @__PURE__ */ t("button", {
|
|
93622
|
-
type: "button",
|
|
93623
|
-
className: "pretext-plus-editor__am-action-btn pretext-plus-editor__am-action-btn--danger",
|
|
93624
|
-
onClick: () => {
|
|
93625
|
-
p(a), i();
|
|
93626
|
-
},
|
|
93627
|
-
title: "Remove from project",
|
|
93628
|
-
children: "Remove"
|
|
93629
|
-
})
|
|
93630
|
-
]
|
|
93631
|
-
})]
|
|
93632
|
-
}, e);
|
|
93633
|
-
})
|
|
93634
|
-
})]
|
|
93635
|
-
}, r))
|
|
93636
|
-
});
|
|
93637
|
-
})() : ne === null ? /* @__PURE__ */ n("div", {
|
|
93638
|
-
className: "pretext-plus-editor__am-kind-picker",
|
|
93639
|
-
children: [/* @__PURE__ */ t("p", {
|
|
93640
|
-
className: "pretext-plus-editor__am-kind-picker-label",
|
|
93641
|
-
children: "What kind of asset?"
|
|
93642
|
-
}), /* @__PURE__ */ n("div", {
|
|
93643
|
-
className: "pretext-plus-editor__am-kind-cards",
|
|
93644
|
-
children: [/* @__PURE__ */ n("button", {
|
|
93645
|
-
type: "button",
|
|
93646
|
-
className: "pretext-plus-editor__am-kind-card",
|
|
93647
|
-
onClick: () => {
|
|
93648
|
-
M("image"), re("library");
|
|
93649
|
-
},
|
|
93650
|
-
children: [
|
|
93651
|
-
/* @__PURE__ */ t("span", {
|
|
93652
|
-
className: "pretext-plus-editor__am-kind-card-icon",
|
|
93653
|
-
"aria-hidden": "true",
|
|
93654
|
-
children: "🖼️"
|
|
93655
|
-
}),
|
|
93656
|
-
/* @__PURE__ */ t("span", {
|
|
93657
|
-
className: "pretext-plus-editor__am-kind-card-label",
|
|
93658
|
-
children: "Image"
|
|
93659
|
-
}),
|
|
93660
|
-
/* @__PURE__ */ t("span", {
|
|
93661
|
-
className: "pretext-plus-editor__am-kind-card-hint",
|
|
93662
|
-
children: "PNG, JPEG, SVG, etc."
|
|
93663
|
-
})
|
|
93664
|
-
]
|
|
93665
|
-
}), /* @__PURE__ */ n("button", {
|
|
93666
|
-
type: "button",
|
|
93667
|
-
className: "pretext-plus-editor__am-kind-card",
|
|
93668
|
-
onClick: () => {
|
|
93669
|
-
M("doenet"), ae("library");
|
|
93670
|
-
},
|
|
93671
|
-
children: [
|
|
93672
|
-
/* @__PURE__ */ t("span", {
|
|
93673
|
-
className: "pretext-plus-editor__am-kind-card-icon",
|
|
93674
|
-
"aria-hidden": "true",
|
|
93675
|
-
children: /* @__PURE__ */ t("img", {
|
|
93676
|
-
src: z3,
|
|
93677
|
-
alt: "Doenet"
|
|
93678
|
-
})
|
|
93679
|
-
}),
|
|
93680
|
-
/* @__PURE__ */ t("span", {
|
|
93681
|
-
className: "pretext-plus-editor__am-kind-card-label",
|
|
93682
|
-
children: "Doenet"
|
|
93683
|
-
}),
|
|
93684
|
-
/* @__PURE__ */ t("span", {
|
|
93685
|
-
className: "pretext-plus-editor__am-kind-card-hint",
|
|
93686
|
-
children: "Interactive activity"
|
|
93687
|
-
})
|
|
93688
|
-
]
|
|
93689
|
-
})]
|
|
93690
|
-
})]
|
|
93691
|
-
}) : ne === "image" ? /* @__PURE__ */ n("div", {
|
|
93692
|
-
className: "pretext-plus-editor__am-configure",
|
|
93693
|
-
children: [
|
|
93694
|
-
/* @__PURE__ */ t("button", {
|
|
93695
|
-
type: "button",
|
|
93696
|
-
className: "pretext-plus-editor__am-back-btn",
|
|
93697
|
-
onClick: () => M(null),
|
|
93698
|
-
children: "← Back"
|
|
93699
|
-
}),
|
|
93700
|
-
/* @__PURE__ */ n("div", {
|
|
93701
|
-
className: "pretext-plus-editor__dialog-tab-bar pretext-plus-editor__am-sub-tabs",
|
|
93702
|
-
children: [
|
|
93703
|
-
/* @__PURE__ */ t("button", {
|
|
93704
|
-
type: "button",
|
|
93705
|
-
className: `pretext-plus-editor__dialog-tab${N === "library" ? " pretext-plus-editor__dialog-tab--active" : ""}`,
|
|
93706
|
-
onClick: () => re("library"),
|
|
93707
|
-
children: "Library"
|
|
93708
|
-
}),
|
|
93709
|
-
l && /* @__PURE__ */ t("button", {
|
|
93710
|
-
type: "button",
|
|
93711
|
-
className: `pretext-plus-editor__dialog-tab${N === "upload" ? " pretext-plus-editor__dialog-tab--active" : ""}`,
|
|
93712
|
-
onClick: () => re("upload"),
|
|
93713
|
-
children: "Upload"
|
|
93714
|
-
}),
|
|
93715
|
-
/* @__PURE__ */ t("button", {
|
|
93716
|
-
type: "button",
|
|
93717
|
-
className: `pretext-plus-editor__dialog-tab${N === "url" ? " pretext-plus-editor__dialog-tab--active" : ""}`,
|
|
93718
|
-
onClick: () => re("url"),
|
|
93719
|
-
children: "External URL"
|
|
93720
|
-
})
|
|
93721
|
-
]
|
|
93722
|
-
}),
|
|
93723
|
-
/* @__PURE__ */ n("div", {
|
|
93724
|
-
className: "pretext-plus-editor__am-configure-body",
|
|
93725
|
-
children: [
|
|
93726
|
-
N === "library" && Pe("image"),
|
|
93727
|
-
N === "upload" && l && /* @__PURE__ */ n("div", {
|
|
93728
|
-
className: "pretext-plus-editor__am-upload",
|
|
93729
|
-
children: [/* @__PURE__ */ n("div", {
|
|
93730
|
-
className: [
|
|
93731
|
-
"pretext-plus-editor__am-drop-zone",
|
|
93732
|
-
F ? "pretext-plus-editor__am-drop-zone--active" : "",
|
|
93733
|
-
ce ? "pretext-plus-editor__am-drop-zone--uploading" : ""
|
|
93734
|
-
].filter(Boolean).join(" "),
|
|
93735
|
-
onDragOver: (e) => {
|
|
93736
|
-
e.preventDefault(), se(!0);
|
|
93737
|
-
},
|
|
93738
|
-
onDragLeave: () => se(!1),
|
|
93739
|
-
onDrop: (e) => {
|
|
93740
|
-
e.preventDefault(), se(!1);
|
|
93741
|
-
let t = e.dataTransfer.files[0];
|
|
93742
|
-
t && je(t);
|
|
93743
|
-
},
|
|
93744
|
-
onClick: () => !ce && de.current?.click(),
|
|
93745
|
-
role: "button",
|
|
93746
|
-
tabIndex: 0,
|
|
93747
|
-
onKeyDown: (e) => {
|
|
93748
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), de.current?.click());
|
|
93749
|
-
},
|
|
93750
|
-
"aria-label": "Upload image — click or drag and drop",
|
|
93751
|
-
children: [/* @__PURE__ */ t("input", {
|
|
93752
|
-
ref: de,
|
|
93753
|
-
type: "file",
|
|
93754
|
-
accept: "image/*",
|
|
93755
|
-
className: "pretext-plus-editor__dialog-file-input",
|
|
93756
|
-
onChange: (e) => {
|
|
93757
|
-
let t = e.target.files?.[0];
|
|
93758
|
-
t && je(t);
|
|
93759
|
-
}
|
|
93760
|
-
}), ce ? /* @__PURE__ */ t("p", {
|
|
93761
|
-
className: "pretext-plus-editor__am-drop-text",
|
|
93762
|
-
children: "Uploading…"
|
|
93763
|
-
}) : /* @__PURE__ */ n(e, { children: [
|
|
93764
|
-
/* @__PURE__ */ t("span", {
|
|
93765
|
-
className: "pretext-plus-editor__am-drop-icon",
|
|
93766
|
-
"aria-hidden": "true",
|
|
93767
|
-
children: "↑"
|
|
93768
|
-
}),
|
|
93769
|
-
/* @__PURE__ */ t("p", {
|
|
93770
|
-
className: "pretext-plus-editor__am-drop-text",
|
|
93771
|
-
children: "Drag & drop an image, or click to browse"
|
|
93772
|
-
}),
|
|
93773
|
-
/* @__PURE__ */ t("p", {
|
|
93774
|
-
className: "pretext-plus-editor__dialog-helper-copy",
|
|
93775
|
-
children: "PNG, JPEG, GIF, SVG, WebP"
|
|
93776
|
-
})
|
|
93777
|
-
] })]
|
|
93778
|
-
}), ue && /* @__PURE__ */ t("p", {
|
|
93779
|
-
className: "pretext-plus-editor__am-error",
|
|
93780
|
-
children: ue
|
|
93781
|
-
})]
|
|
93782
|
-
}),
|
|
93783
|
-
N === "url" && /* @__PURE__ */ n("div", {
|
|
93784
|
-
className: "pretext-plus-editor__am-url-form",
|
|
93785
|
-
children: [
|
|
93786
|
-
/* @__PURE__ */ t("label", {
|
|
93787
|
-
className: "pretext-plus-editor__dialog-label",
|
|
93788
|
-
htmlFor: "am-url-value",
|
|
93789
|
-
children: "Image URL"
|
|
93790
|
-
}),
|
|
93791
|
-
/* @__PURE__ */ t("input", {
|
|
93792
|
-
id: "am-url-value",
|
|
93793
|
-
type: "url",
|
|
93794
|
-
className: "pretext-plus-editor__am-input",
|
|
93795
|
-
placeholder: "https://example.com/image.png",
|
|
93796
|
-
value: fe,
|
|
93797
|
-
onChange: (e) => pe(e.target.value),
|
|
93798
|
-
disabled: L,
|
|
93799
|
-
autoFocus: !0
|
|
93800
|
-
}),
|
|
93801
|
-
/* @__PURE__ */ n("label", {
|
|
93802
|
-
className: "pretext-plus-editor__dialog-label",
|
|
93803
|
-
htmlFor: "am-url-name",
|
|
93804
|
-
children: ["Name ", /* @__PURE__ */ t("span", {
|
|
93805
|
-
className: "pretext-plus-editor__dialog-helper-copy",
|
|
93806
|
-
children: "(optional)"
|
|
93807
|
-
})]
|
|
93808
|
-
}),
|
|
93809
|
-
/* @__PURE__ */ t("input", {
|
|
93810
|
-
id: "am-url-name",
|
|
93811
|
-
type: "text",
|
|
93812
|
-
className: "pretext-plus-editor__am-input",
|
|
93813
|
-
placeholder: "My image",
|
|
93814
|
-
value: me,
|
|
93815
|
-
onChange: (e) => he(e.target.value),
|
|
93816
|
-
disabled: L
|
|
93817
|
-
}),
|
|
93818
|
-
_e && /* @__PURE__ */ t("p", {
|
|
93819
|
-
className: "pretext-plus-editor__am-error",
|
|
93820
|
-
children: _e
|
|
93821
|
-
}),
|
|
93822
|
-
fe.trim() && /* @__PURE__ */ t("img", {
|
|
93823
|
-
src: fe.trim(),
|
|
93824
|
-
alt: "Preview",
|
|
93825
|
-
className: "pretext-plus-editor__am-url-preview",
|
|
93826
|
-
onError: (e) => {
|
|
93827
|
-
e.currentTarget.style.display = "none";
|
|
93828
|
-
}
|
|
93829
|
-
}),
|
|
93830
|
-
/* @__PURE__ */ t("button", {
|
|
93831
|
-
type: "button",
|
|
93832
|
-
className: "pretext-plus-editor__dialog-button",
|
|
93833
|
-
onClick: Me,
|
|
93834
|
-
disabled: !fe.trim() || L,
|
|
93835
|
-
children: L ? "Adding…" : u ? "Add to Library & Insert" : "Insert"
|
|
93836
|
-
})
|
|
93837
|
-
]
|
|
93838
|
-
})
|
|
93839
|
-
]
|
|
93840
|
-
})
|
|
93841
|
-
]
|
|
93842
|
-
}) : /* @__PURE__ */ n("div", {
|
|
93843
|
-
className: "pretext-plus-editor__am-configure",
|
|
93844
|
-
children: [
|
|
93845
|
-
/* @__PURE__ */ t("button", {
|
|
93846
|
-
type: "button",
|
|
93847
|
-
className: "pretext-plus-editor__am-back-btn",
|
|
93848
|
-
onClick: () => M(null),
|
|
93849
|
-
children: "← Back"
|
|
93850
|
-
}),
|
|
93851
|
-
/* @__PURE__ */ n("div", {
|
|
93852
|
-
className: "pretext-plus-editor__dialog-tab-bar pretext-plus-editor__am-sub-tabs",
|
|
93853
|
-
children: [/* @__PURE__ */ t("button", {
|
|
93854
|
-
type: "button",
|
|
93855
|
-
className: `pretext-plus-editor__dialog-tab${ie === "library" ? " pretext-plus-editor__dialog-tab--active" : ""}`,
|
|
93856
|
-
onClick: () => ae("library"),
|
|
93857
|
-
children: "Library"
|
|
93858
|
-
}), /* @__PURE__ */ t("button", {
|
|
93859
|
-
type: "button",
|
|
93860
|
-
className: `pretext-plus-editor__dialog-tab${ie === "create" ? " pretext-plus-editor__dialog-tab--active" : ""}`,
|
|
93861
|
-
onClick: () => ae("create"),
|
|
93862
|
-
children: "Create New"
|
|
93863
|
-
})]
|
|
93864
|
-
}),
|
|
93865
|
-
/* @__PURE__ */ n("div", {
|
|
93866
|
-
className: "pretext-plus-editor__am-configure-body",
|
|
93867
|
-
children: [ie === "library" && Pe("doenet"), ie === "create" && /* @__PURE__ */ n("div", {
|
|
93868
|
-
className: "pretext-plus-editor__am-create-form",
|
|
93869
|
-
children: [
|
|
93870
|
-
/* @__PURE__ */ t("label", {
|
|
93871
|
-
className: "pretext-plus-editor__dialog-label",
|
|
93872
|
-
htmlFor: "am-doenet-name",
|
|
93873
|
-
children: "Name"
|
|
93874
|
-
}),
|
|
93875
|
-
/* @__PURE__ */ t("input", {
|
|
93876
|
-
id: "am-doenet-name",
|
|
93877
|
-
type: "text",
|
|
93878
|
-
className: "pretext-plus-editor__am-input",
|
|
93879
|
-
placeholder: "My Activity",
|
|
93880
|
-
value: ye,
|
|
93881
|
-
onChange: (e) => be(e.target.value),
|
|
93882
|
-
disabled: R,
|
|
93883
|
-
autoFocus: !0
|
|
93884
|
-
}),
|
|
93885
|
-
/* @__PURE__ */ t("label", {
|
|
93886
|
-
className: "pretext-plus-editor__dialog-label",
|
|
93887
|
-
htmlFor: "am-doenet-ref",
|
|
93888
|
-
children: "Reference ID"
|
|
93889
|
-
}),
|
|
93890
|
-
/* @__PURE__ */ t("input", {
|
|
93891
|
-
id: "am-doenet-ref",
|
|
93892
|
-
type: "text",
|
|
93893
|
-
className: "pretext-plus-editor__am-input",
|
|
93894
|
-
placeholder: "my-activity",
|
|
93895
|
-
value: xe,
|
|
93896
|
-
onChange: (e) => Se(e.target.value),
|
|
93897
|
-
disabled: R
|
|
93898
|
-
}),
|
|
93899
|
-
/* @__PURE__ */ n("p", {
|
|
93900
|
-
className: "pretext-plus-editor__dialog-helper-copy",
|
|
93901
|
-
children: ["The reference ID is used in the inserted tag: ", /* @__PURE__ */ t("code", { children: `<plus:doenet ref="${xe || "my-activity"}"/>` })]
|
|
93902
|
-
}),
|
|
93903
|
-
we && /* @__PURE__ */ t("p", {
|
|
93904
|
-
className: "pretext-plus-editor__am-error",
|
|
93905
|
-
children: we
|
|
93906
|
-
}),
|
|
93907
|
-
/* @__PURE__ */ t("button", {
|
|
93908
|
-
type: "button",
|
|
93909
|
-
className: "pretext-plus-editor__dialog-button",
|
|
93910
|
-
onClick: Ne,
|
|
93911
|
-
disabled: !ye.trim() || !xe.trim() || R,
|
|
93912
|
-
children: R ? "Creating…" : f ? "Create & Insert" : "Insert"
|
|
93913
|
-
})
|
|
93914
|
-
]
|
|
93915
|
-
})]
|
|
93916
|
-
})
|
|
93917
|
-
]
|
|
93918
|
-
})
|
|
93919
|
-
}),
|
|
93920
|
-
/* @__PURE__ */ t("div", {
|
|
93921
|
-
className: "pretext-plus-editor__dialog-actions",
|
|
93922
|
-
children: /* @__PURE__ */ t("button", {
|
|
93923
|
-
type: "button",
|
|
93924
|
-
className: "pretext-plus-editor__dialog-button pretext-plus-editor__dialog-button--secondary",
|
|
93925
|
-
onClick: i,
|
|
93926
|
-
children: "Close"
|
|
93927
|
-
})
|
|
93928
|
-
})
|
|
93929
|
-
]
|
|
93930
|
-
})
|
|
93931
|
-
});
|
|
93932
|
-
}, W3 = (e) => {
|
|
93933
|
-
let r = b3((e) => e.showFullPreview), i = b3((e) => e.setShowFullPreview), a = b3((e) => e.title), o = b3((e) => e.updateTitle), s;
|
|
93934
|
-
return s = e.showPreviewModeToggle === !1 ? null : /* @__PURE__ */ n("label", {
|
|
93935
|
-
className: "pretext-plus-editor__preview-toggle",
|
|
93936
|
-
children: [
|
|
93937
|
-
/* @__PURE__ */ t("input", {
|
|
93938
|
-
type: "checkbox",
|
|
93939
|
-
checked: !r,
|
|
93940
|
-
onChange: () => i(!r),
|
|
93941
|
-
className: "pretext-plus-editor__preview-toggle-input"
|
|
93942
|
-
}),
|
|
93943
|
-
/* @__PURE__ */ n("div", {
|
|
93944
|
-
className: "pretext-plus-editor__preview-toggle-container",
|
|
93945
|
-
children: [
|
|
93946
|
-
/* @__PURE__ */ t("span", {
|
|
93947
|
-
className: "pretext-plus-editor__preview-toggle-label",
|
|
93948
|
-
children: "Simple"
|
|
93949
|
-
}),
|
|
93950
|
-
/* @__PURE__ */ t("span", {
|
|
93951
|
-
className: `pretext-plus-editor__preview-toggle-slider ${r ? "pretext-plus-editor__preview-toggle-slider--active" : ""}`,
|
|
93952
|
-
children: /* @__PURE__ */ t("span", { className: `pretext-plus-editor__preview-toggle-dot ${r ? "pretext-plus-editor__preview-toggle-dot--active" : ""}` })
|
|
93953
|
-
}),
|
|
93954
|
-
/* @__PURE__ */ t("span", {
|
|
93955
|
-
className: "pretext-plus-editor__preview-toggle-label",
|
|
93956
|
-
children: "Full"
|
|
93957
|
-
})
|
|
93958
|
-
]
|
|
93959
|
-
}),
|
|
93960
|
-
/* @__PURE__ */ t("span", {
|
|
93961
|
-
className: "pretext-plus-editor__preview-toggle-caption",
|
|
93962
|
-
children: "Preview Mode"
|
|
93963
|
-
}),
|
|
93964
|
-
/* @__PURE__ */ t("input", {
|
|
93965
|
-
type: "checkbox",
|
|
93966
|
-
checked: r,
|
|
93967
|
-
onChange: () => i(!r),
|
|
93968
|
-
className: "pretext-plus-editor__preview-toggle-input"
|
|
93969
|
-
})
|
|
93970
|
-
]
|
|
93971
|
-
}), /* @__PURE__ */ n("div", {
|
|
93972
|
-
className: "pretext-plus-editor__menu-bar",
|
|
93973
|
-
children: [/* @__PURE__ */ t("div", {
|
|
93974
|
-
className: "pretext-plus-editor__menu-left",
|
|
93975
|
-
children: /* @__PURE__ */ n("label", {
|
|
93976
|
-
className: "pretext-plus-editor__title-label",
|
|
93977
|
-
children: [
|
|
93978
|
-
"Title",
|
|
93979
|
-
" ",
|
|
93980
|
-
/* @__PURE__ */ t("input", {
|
|
93981
|
-
className: "pretext-plus-editor__title-input",
|
|
93982
|
-
type: "text",
|
|
93983
|
-
value: a,
|
|
93984
|
-
onChange: (e) => o(e.target.value)
|
|
93985
|
-
})
|
|
93986
|
-
]
|
|
93987
|
-
})
|
|
93988
|
-
}), /* @__PURE__ */ n("div", {
|
|
93989
|
-
className: "pretext-plus-editor__menu-right",
|
|
93990
|
-
children: [
|
|
93991
|
-
e.onSaveButton && /* @__PURE__ */ t("button", {
|
|
93992
|
-
className: "pretext-plus-editor__button pretext-plus-editor__button--save",
|
|
93993
|
-
onClick: e.onSaveButton,
|
|
93994
|
-
children: e.saveButtonLabel || "Save"
|
|
93995
|
-
}),
|
|
93996
|
-
e.onCancelButton && /* @__PURE__ */ t("button", {
|
|
93997
|
-
className: "pretext-plus-editor__button pretext-plus-editor__button--cancel",
|
|
93998
|
-
onClick: e.onCancelButton,
|
|
93999
|
-
children: e.cancelButtonLabel || "Cancel"
|
|
94000
|
-
}),
|
|
94001
|
-
/* @__PURE__ */ t(x3, {
|
|
94002
|
-
label: "Give feedback",
|
|
94003
|
-
context: "main-editor"
|
|
94004
|
-
}),
|
|
94005
|
-
s
|
|
94006
|
-
]
|
|
94007
|
-
})]
|
|
94008
|
-
});
|
|
94009
|
-
}, G3 = {
|
|
94010
|
-
book: "Book",
|
|
94011
|
-
article: "Article",
|
|
94012
|
-
slideshow: "Slideshow",
|
|
94013
|
-
part: "Part",
|
|
94014
|
-
chapter: "Chapter",
|
|
94015
|
-
section: "Section",
|
|
94016
|
-
worksheet: "Worksheet",
|
|
94017
|
-
handout: "Handout",
|
|
94018
|
-
exercises: "Exercises",
|
|
94019
|
-
references: "References",
|
|
94020
|
-
glossary: "Glossary",
|
|
94021
|
-
solutions: "Solutions",
|
|
94022
|
-
"reading-questions": "Reading Questions",
|
|
94023
|
-
introduction: "Introduction",
|
|
94024
|
-
conclusion: "Conclusion"
|
|
94025
|
-
}, K3 = [
|
|
94026
|
-
"part",
|
|
94027
|
-
"chapter",
|
|
94028
|
-
"section",
|
|
94029
|
-
"worksheet",
|
|
94030
|
-
"handout",
|
|
94031
|
-
"exercises",
|
|
94032
|
-
"references",
|
|
94033
|
-
"glossary",
|
|
94034
|
-
"solutions",
|
|
94035
|
-
"reading-questions"
|
|
94036
|
-
], q3 = ({ draft: r, isLatex: i, isRoot: a = !1, onDraftChange: o, onCommit: s, onCancel: c }) => /* @__PURE__ */ n("div", {
|
|
94037
|
-
className: "pretext-plus-editor__toc-edit-form",
|
|
94038
|
-
children: [
|
|
94039
|
-
/* @__PURE__ */ n("label", {
|
|
94040
|
-
className: "pretext-plus-editor__toc-edit-field",
|
|
94041
|
-
children: [/* @__PURE__ */ t("span", { children: "Title" }), /* @__PURE__ */ t("input", {
|
|
94042
|
-
type: "text",
|
|
94043
|
-
value: r.title,
|
|
94044
|
-
onChange: (e) => o({
|
|
94045
|
-
...r,
|
|
94046
|
-
title: e.target.value
|
|
94047
|
-
}),
|
|
94048
|
-
onKeyDown: (e) => {
|
|
94049
|
-
e.key === "Enter" && s(), e.key === "Escape" && c();
|
|
94050
|
-
},
|
|
94051
|
-
autoFocus: !0
|
|
94052
|
-
})]
|
|
94053
|
-
}),
|
|
94054
|
-
!i && /* @__PURE__ */ n(e, { children: [
|
|
94055
|
-
!a && /* @__PURE__ */ n("label", {
|
|
94056
|
-
className: "pretext-plus-editor__toc-edit-field",
|
|
94057
|
-
children: [/* @__PURE__ */ t("span", { children: "Type" }), /* @__PURE__ */ t("select", {
|
|
94058
|
-
value: r.type,
|
|
94059
|
-
onChange: (e) => o({
|
|
94060
|
-
...r,
|
|
94061
|
-
type: e.target.value
|
|
94062
|
-
}),
|
|
94063
|
-
children: K3.map((e) => /* @__PURE__ */ t("option", {
|
|
94064
|
-
value: e,
|
|
94065
|
-
children: G3[e]
|
|
94066
|
-
}, e))
|
|
94067
|
-
})]
|
|
94068
|
-
}),
|
|
94069
|
-
/* @__PURE__ */ n("label", {
|
|
94070
|
-
className: "pretext-plus-editor__toc-edit-field",
|
|
94071
|
-
children: [/* @__PURE__ */ t("span", { children: "xml:id" }), /* @__PURE__ */ t("input", {
|
|
94072
|
-
type: "text",
|
|
94073
|
-
value: r.xmlId,
|
|
94074
|
-
placeholder: "optional",
|
|
94075
|
-
onChange: (e) => o({
|
|
94076
|
-
...r,
|
|
94077
|
-
xmlId: e.target.value
|
|
94078
|
-
})
|
|
94079
|
-
})]
|
|
94080
|
-
}),
|
|
94081
|
-
/* @__PURE__ */ n("label", {
|
|
94082
|
-
className: "pretext-plus-editor__toc-edit-field",
|
|
94083
|
-
children: [/* @__PURE__ */ t("span", { children: "label" }), /* @__PURE__ */ t("input", {
|
|
94084
|
-
type: "text",
|
|
94085
|
-
value: r.label,
|
|
94086
|
-
placeholder: "optional",
|
|
94087
|
-
onChange: (e) => o({
|
|
94088
|
-
...r,
|
|
94089
|
-
label: e.target.value
|
|
94090
|
-
})
|
|
94091
|
-
})]
|
|
94092
|
-
})
|
|
94093
|
-
] }),
|
|
94094
|
-
/* @__PURE__ */ n("div", {
|
|
94095
|
-
className: "pretext-plus-editor__toc-edit-actions",
|
|
94096
|
-
children: [/* @__PURE__ */ t("button", {
|
|
94097
|
-
type: "button",
|
|
94098
|
-
className: "pretext-plus-editor__toc-edit-save",
|
|
94099
|
-
onClick: s,
|
|
94100
|
-
children: "Save"
|
|
94101
|
-
}), /* @__PURE__ */ t("button", {
|
|
94102
|
-
type: "button",
|
|
94103
|
-
className: "pretext-plus-editor__toc-edit-cancel",
|
|
94104
|
-
onClick: c,
|
|
94105
|
-
children: "Cancel"
|
|
94106
|
-
})]
|
|
94107
|
-
})
|
|
94108
|
-
]
|
|
94109
|
-
});
|
|
94110
|
-
//#endregion
|
|
94111
|
-
//#region src/components/toc/DivisionMenu.tsx
|
|
94112
|
-
function J3(e) {
|
|
94113
|
-
let t = e?.parentElement ?? null;
|
|
94114
|
-
for (; t;) {
|
|
94115
|
-
let { overflowY: e } = getComputedStyle(t);
|
|
94116
|
-
if ((e === "auto" || e === "scroll") && t.scrollHeight > t.clientHeight) return t;
|
|
94117
|
-
t = t.parentElement;
|
|
94118
|
-
}
|
|
94119
|
-
return null;
|
|
94120
|
-
}
|
|
94121
|
-
var Y3 = ({ items: e }) => {
|
|
94122
|
-
let [r, i] = b(!1), [a, o] = b("below"), s = y(null), c = y(null);
|
|
94123
|
-
m(() => {
|
|
94124
|
-
if (!r) return;
|
|
94125
|
-
let e = (e) => {
|
|
94126
|
-
s.current && !s.current.contains(e.target) && i(!1);
|
|
94127
|
-
}, t = (e) => {
|
|
94128
|
-
e.key === "Escape" && i(!1);
|
|
94129
|
-
};
|
|
94130
|
-
return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
|
|
94131
|
-
document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
|
|
94132
|
-
};
|
|
94133
|
-
}, [r]), _(() => {
|
|
94134
|
-
if (!r) return;
|
|
94135
|
-
let e = c.current, t = s.current;
|
|
94136
|
-
if (!e || !t) return;
|
|
94137
|
-
let n = J3(t) ?? document.documentElement, i = e.getBoundingClientRect(), a = n.getBoundingClientRect(), l = t.getBoundingClientRect(), u = a.bottom - l.bottom, d = l.top - a.top;
|
|
94138
|
-
o(i.height > u && d > u ? "above" : "below");
|
|
94139
|
-
}, [r]);
|
|
94140
|
-
let l = (e) => {
|
|
94141
|
-
i(!1), e();
|
|
94142
|
-
};
|
|
94143
|
-
return /* @__PURE__ */ n("div", {
|
|
94144
|
-
ref: s,
|
|
94145
|
-
className: "pretext-plus-editor__toc-div-menu",
|
|
94146
|
-
children: [/* @__PURE__ */ t("button", {
|
|
94147
|
-
type: "button",
|
|
94148
|
-
className: "pretext-plus-editor__toc-div-menu-trigger",
|
|
94149
|
-
onClick: (e) => {
|
|
94150
|
-
e.stopPropagation(), i((e) => (e || o("below"), !e));
|
|
94151
|
-
},
|
|
94152
|
-
"aria-haspopup": "true",
|
|
94153
|
-
"aria-expanded": r,
|
|
94154
|
-
title: "More options",
|
|
94155
|
-
children: "⋮"
|
|
94156
|
-
}), r && /* @__PURE__ */ t("div", {
|
|
94157
|
-
ref: c,
|
|
94158
|
-
className: ["pretext-plus-editor__toc-div-menu-popup", a === "above" ? "pretext-plus-editor__toc-div-menu-popup--above" : "pretext-plus-editor__toc-div-menu-popup--below"].join(" "),
|
|
94159
|
-
children: e.map((e) => /* @__PURE__ */ t("button", {
|
|
94160
|
-
type: "button",
|
|
94161
|
-
className: ["pretext-plus-editor__toc-div-menu-item", e.danger ? "pretext-plus-editor__toc-div-menu-item--danger" : ""].filter(Boolean).join(" "),
|
|
94162
|
-
onClick: () => l(e.onClick),
|
|
94163
|
-
children: e.label
|
|
94164
|
-
}, e.label))
|
|
94165
|
-
})]
|
|
94166
|
-
});
|
|
94167
|
-
}, X3 = ({ division: e, depth: r, isActive: i, hasChildren: a, isExpanded: o, onToggleExpand: s, editDraft: c, onSelect: l, onDraftChange: u, onEditCommit: d, onEditCancel: f, menuItems: p, isLatex: m, isRoot: h = !1 }) => {
|
|
94168
|
-
let g = c !== null;
|
|
94169
|
-
return /* @__PURE__ */ n("li", {
|
|
94170
|
-
className: [
|
|
94171
|
-
"pretext-plus-editor__toc-item",
|
|
94172
|
-
`pretext-plus-editor__toc-item--${e.type}`,
|
|
94173
|
-
i ? "pretext-plus-editor__toc-item--active" : "",
|
|
94174
|
-
g ? "pretext-plus-editor__toc-item--editing" : ""
|
|
94175
|
-
].filter(Boolean).join(" "),
|
|
94176
|
-
children: [/* @__PURE__ */ n("div", {
|
|
94177
|
-
className: "pretext-plus-editor__toc-item-row",
|
|
94178
|
-
style: r > 0 ? { paddingLeft: `${r * 14}px` } : void 0,
|
|
94179
|
-
children: [
|
|
94180
|
-
/* @__PURE__ */ t("button", {
|
|
94181
|
-
type: "button",
|
|
94182
|
-
className: "pretext-plus-editor__toc-expand-btn",
|
|
94183
|
-
onClick: s,
|
|
94184
|
-
"aria-label": o ? "Collapse" : "Expand",
|
|
94185
|
-
tabIndex: a ? 0 : -1,
|
|
94186
|
-
style: { visibility: a ? "visible" : "hidden" },
|
|
94187
|
-
children: o ? "▾" : "▸"
|
|
94188
|
-
}),
|
|
94189
|
-
/* @__PURE__ */ t("button", {
|
|
94190
|
-
type: "button",
|
|
94191
|
-
className: "pretext-plus-editor__toc-select",
|
|
94192
|
-
onClick: l,
|
|
94193
|
-
"aria-current": i ? "true" : void 0,
|
|
94194
|
-
title: G3[e.type] ?? e.type,
|
|
94195
|
-
children: /* @__PURE__ */ t("span", {
|
|
94196
|
-
className: "pretext-plus-editor__toc-title",
|
|
94197
|
-
children: e.title || /* @__PURE__ */ t("em", { children: "Untitled" })
|
|
94198
|
-
})
|
|
94199
|
-
}),
|
|
94200
|
-
/* @__PURE__ */ t("div", {
|
|
94201
|
-
className: "pretext-plus-editor__toc-actions",
|
|
94202
|
-
children: /* @__PURE__ */ t(Y3, { items: p })
|
|
94203
|
-
})
|
|
94204
|
-
]
|
|
94205
|
-
}), g && c && /* @__PURE__ */ t(q3, {
|
|
94206
|
-
draft: c,
|
|
94207
|
-
isLatex: m,
|
|
94208
|
-
isRoot: h,
|
|
94209
|
-
onDraftChange: u,
|
|
94210
|
-
onCommit: d,
|
|
94211
|
-
onCancel: f
|
|
94212
|
-
})]
|
|
94213
|
-
});
|
|
94214
|
-
}, Z3 = /* @__PURE__ */ M(((e, t) => {
|
|
94215
|
-
var n = Object.defineProperty, r = Object.getOwnPropertyDescriptor, i = Object.getOwnPropertyNames, a = Object.prototype.hasOwnProperty, o = (e, t) => {
|
|
94216
|
-
for (var r in t) n(e, r, {
|
|
94217
|
-
get: t[r],
|
|
94218
|
-
enumerable: !0
|
|
94219
|
-
});
|
|
94220
|
-
}, s = (e, t, o, s) => {
|
|
94221
|
-
if (t && typeof t == "object" || typeof t == "function") for (let c of i(t)) !a.call(e, c) && c !== o && n(e, c, {
|
|
94222
|
-
get: () => t[c],
|
|
94223
|
-
enumerable: !(s = r(t, c)) || s.enumerable
|
|
94224
|
-
});
|
|
94225
|
-
return e;
|
|
94226
|
-
}, c = (e) => s(n({}, "__esModule", { value: !0 }), e), l = {};
|
|
94227
|
-
o(l, {
|
|
94228
|
-
XmlCdata: () => E,
|
|
94229
|
-
XmlComment: () => D,
|
|
94230
|
-
XmlDeclaration: () => O,
|
|
94231
|
-
XmlDocument: () => A,
|
|
94232
|
-
XmlDocumentType: () => j,
|
|
94233
|
-
XmlElement: () => k,
|
|
94234
|
-
XmlError: () => ee,
|
|
94235
|
-
XmlNode: () => w,
|
|
94236
|
-
XmlProcessingInstruction: () => te,
|
|
94237
|
-
XmlText: () => T,
|
|
94238
|
-
parseXml: () => re
|
|
94239
|
-
}), t.exports = c(l);
|
|
94240
|
-
var u = "", d = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, f = class {
|
|
94241
|
-
constructor(e) {
|
|
94242
|
-
if (this.k = this.u(e, !0), this.d = 0, this.length = e.length, this.l = this.k !== this.length, this.h = e, this.l) {
|
|
94243
|
-
let t = [];
|
|
94244
|
-
for (let n = 0, r = 0; r < this.k; ++r) t[r] = n, n += e.codePointAt(n) > 65535 ? 2 : 1;
|
|
94245
|
-
this.A = t;
|
|
94246
|
-
}
|
|
94247
|
-
}
|
|
94248
|
-
get B() {
|
|
94249
|
-
return this.d >= this.k;
|
|
94250
|
-
}
|
|
94251
|
-
u(e, t = this.l) {
|
|
94252
|
-
return t ? e.replace(d, "_").length : e.length;
|
|
94253
|
-
}
|
|
94254
|
-
p(e = 1) {
|
|
94255
|
-
this.d = Math.min(this.k, this.d + e);
|
|
94256
|
-
}
|
|
94257
|
-
f(e = this.d) {
|
|
94258
|
-
return this.l ? this.A[e] ?? Infinity : e;
|
|
94259
|
-
}
|
|
94260
|
-
G(e = 1) {
|
|
94261
|
-
let t = this.m(e);
|
|
94262
|
-
return this.p(e), t;
|
|
94263
|
-
}
|
|
94264
|
-
v(e) {
|
|
94265
|
-
let t = this.f(), n = this.h.slice(t, t + e);
|
|
94266
|
-
return this.p(this.u(n)), n;
|
|
94267
|
-
}
|
|
94268
|
-
w(e) {
|
|
94269
|
-
let { length: t, l: n, h: r } = this, i = this.f(), a = i;
|
|
94270
|
-
if (n) for (; a < t;) {
|
|
94271
|
-
let t = r[a], n = t >= "\ud800" && t <= "\udbff";
|
|
94272
|
-
if (n && (t += r[a + 1]), !e(t)) break;
|
|
94273
|
-
a += n ? 2 : 1;
|
|
94274
|
-
}
|
|
94275
|
-
else for (; a < t && e(r[a]);) ++a;
|
|
94276
|
-
return this.v(a - i);
|
|
94277
|
-
}
|
|
94278
|
-
b(e) {
|
|
94279
|
-
let { length: t } = e, n = this.f();
|
|
94280
|
-
return e === this.h.slice(n, n + t) ? (this.p(t === 1 ? 1 : this.u(e)), e) : u;
|
|
94281
|
-
}
|
|
94282
|
-
x(e) {
|
|
94283
|
-
let t = this.h.slice(this.f()).search(e);
|
|
94284
|
-
return t > 0 ? this.v(t) : u;
|
|
94285
|
-
}
|
|
94286
|
-
s(e) {
|
|
94287
|
-
let t = this.f(), n = this.h.indexOf(e, t);
|
|
94288
|
-
return n > 0 ? this.v(n - t) : u;
|
|
94289
|
-
}
|
|
94290
|
-
m(e = 1) {
|
|
94291
|
-
let { d: t, h: n } = this;
|
|
94292
|
-
return this.l ? n.slice(this.f(t), this.f(t + e)) : n.slice(t, t + e);
|
|
94293
|
-
}
|
|
94294
|
-
n(e = 0) {
|
|
94295
|
-
this.d = e >= 0 ? Math.min(this.k, e) : Math.max(0, this.d + e);
|
|
94296
|
-
}
|
|
94297
|
-
}, p = /["&<]/, m = /['&<]/, h = /\r\n|[\n\r\t]/g, g = /<|&|]]>/, _ = Object.freeze(Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
94298
|
-
amp: "&",
|
|
94299
|
-
apos: "'",
|
|
94300
|
-
gt: ">",
|
|
94301
|
-
lt: "<",
|
|
94302
|
-
quot: "\""
|
|
94303
|
-
}));
|
|
94304
|
-
function v(e) {
|
|
94305
|
-
let t = e.codePointAt(0);
|
|
94306
|
-
return t >= 97 && t <= 122 || t >= 65 && t <= 90 || t >= 48 && t <= 57 || t === 45 || t === 46 || t === 183 || t >= 768 && t <= 879 || t === 8255 || t === 8256 || y(e, t);
|
|
94307
|
-
}
|
|
94308
|
-
function y(e, t = e.codePointAt(0)) {
|
|
94309
|
-
return t >= 97 && t <= 122 || t >= 65 && t <= 90 || t === 58 || t === 95 || t >= 192 && t <= 214 || t >= 216 && t <= 246 || t >= 248 && t <= 767 || t >= 880 && t <= 893 || t >= 895 && t <= 8191 || t === 8204 || t === 8205 || t >= 8304 && t <= 8591 || t >= 11264 && t <= 12271 || t >= 12289 && t <= 55295 || t >= 63744 && t <= 64975 || t >= 65008 && t <= 65533 || t >= 65536 && t <= 983039;
|
|
94310
|
-
}
|
|
94311
|
-
function b(e) {
|
|
94312
|
-
return e === "#" || v(e);
|
|
94313
|
-
}
|
|
94314
|
-
function x(e) {
|
|
94315
|
-
let t = e.codePointAt(0);
|
|
94316
|
-
return t === 32 || t === 9 || t === 10 || t === 13;
|
|
94317
|
-
}
|
|
94318
|
-
function S(e) {
|
|
94319
|
-
return e >= 32 && e <= 55295 || e === 10 || e === 9 || e === 13 || e >= 57344 && e <= 65533 || e >= 65536 && e <= 1114111;
|
|
94320
|
-
}
|
|
94321
|
-
var C = class e {
|
|
94322
|
-
constructor() {
|
|
94323
|
-
this.parent = null, this.start = -1, this.end = -1;
|
|
94324
|
-
}
|
|
94325
|
-
get document() {
|
|
94326
|
-
return this.parent?.document ?? null;
|
|
94327
|
-
}
|
|
94328
|
-
get isRootNode() {
|
|
94329
|
-
return this.parent !== null && this.parent === this.document && this.type === e.TYPE_ELEMENT;
|
|
94330
|
-
}
|
|
94331
|
-
get preserveWhitespace() {
|
|
94332
|
-
return !!this.parent?.preserveWhitespace;
|
|
94333
|
-
}
|
|
94334
|
-
get type() {
|
|
94335
|
-
return "";
|
|
94336
|
-
}
|
|
94337
|
-
toJSON() {
|
|
94338
|
-
let e = { type: this.type };
|
|
94339
|
-
return this.isRootNode && (e.isRootNode = !0), this.preserveWhitespace && (e.preserveWhitespace = !0), this.start !== -1 && (e.start = this.start, e.end = this.end), e;
|
|
94340
|
-
}
|
|
93426
|
+
else for (; a < t && e(r[a]);) ++a;
|
|
93427
|
+
return this.v(a - i);
|
|
93428
|
+
}
|
|
93429
|
+
b(e) {
|
|
93430
|
+
let { length: t } = e, n = this.f();
|
|
93431
|
+
return e === this.h.slice(n, n + t) ? (this.p(t === 1 ? 1 : this.u(e)), e) : u;
|
|
93432
|
+
}
|
|
93433
|
+
x(e) {
|
|
93434
|
+
let t = this.h.slice(this.f()).search(e);
|
|
93435
|
+
return t > 0 ? this.v(t) : u;
|
|
93436
|
+
}
|
|
93437
|
+
s(e) {
|
|
93438
|
+
let t = this.f(), n = this.h.indexOf(e, t);
|
|
93439
|
+
return n > 0 ? this.v(n - t) : u;
|
|
93440
|
+
}
|
|
93441
|
+
m(e = 1) {
|
|
93442
|
+
let { d: t, h: n } = this;
|
|
93443
|
+
return this.l ? n.slice(this.f(t), this.f(t + e)) : n.slice(t, t + e);
|
|
93444
|
+
}
|
|
93445
|
+
n(e = 0) {
|
|
93446
|
+
this.d = e >= 0 ? Math.min(this.k, e) : Math.max(0, this.d + e);
|
|
93447
|
+
}
|
|
93448
|
+
}, p = /["&<]/, m = /['&<]/, h = /\r\n|[\n\r\t]/g, g = /<|&|]]>/, _ = Object.freeze(Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
93449
|
+
amp: "&",
|
|
93450
|
+
apos: "'",
|
|
93451
|
+
gt: ">",
|
|
93452
|
+
lt: "<",
|
|
93453
|
+
quot: "\""
|
|
93454
|
+
}));
|
|
93455
|
+
function v(e) {
|
|
93456
|
+
let t = e.codePointAt(0);
|
|
93457
|
+
return t >= 97 && t <= 122 || t >= 65 && t <= 90 || t >= 48 && t <= 57 || t === 45 || t === 46 || t === 183 || t >= 768 && t <= 879 || t === 8255 || t === 8256 || y(e, t);
|
|
93458
|
+
}
|
|
93459
|
+
function y(e, t = e.codePointAt(0)) {
|
|
93460
|
+
return t >= 97 && t <= 122 || t >= 65 && t <= 90 || t === 58 || t === 95 || t >= 192 && t <= 214 || t >= 216 && t <= 246 || t >= 248 && t <= 767 || t >= 880 && t <= 893 || t >= 895 && t <= 8191 || t === 8204 || t === 8205 || t >= 8304 && t <= 8591 || t >= 11264 && t <= 12271 || t >= 12289 && t <= 55295 || t >= 63744 && t <= 64975 || t >= 65008 && t <= 65533 || t >= 65536 && t <= 983039;
|
|
93461
|
+
}
|
|
93462
|
+
function b(e) {
|
|
93463
|
+
return e === "#" || v(e);
|
|
93464
|
+
}
|
|
93465
|
+
function x(e) {
|
|
93466
|
+
let t = e.codePointAt(0);
|
|
93467
|
+
return t === 32 || t === 9 || t === 10 || t === 13;
|
|
93468
|
+
}
|
|
93469
|
+
function S(e) {
|
|
93470
|
+
return e >= 32 && e <= 55295 || e === 10 || e === 9 || e === 13 || e >= 57344 && e <= 65533 || e >= 65536 && e <= 1114111;
|
|
93471
|
+
}
|
|
93472
|
+
var C = class e {
|
|
93473
|
+
constructor() {
|
|
93474
|
+
this.parent = null, this.start = -1, this.end = -1;
|
|
93475
|
+
}
|
|
93476
|
+
get document() {
|
|
93477
|
+
return this.parent?.document ?? null;
|
|
93478
|
+
}
|
|
93479
|
+
get isRootNode() {
|
|
93480
|
+
return this.parent !== null && this.parent === this.document && this.type === e.TYPE_ELEMENT;
|
|
93481
|
+
}
|
|
93482
|
+
get preserveWhitespace() {
|
|
93483
|
+
return !!this.parent?.preserveWhitespace;
|
|
93484
|
+
}
|
|
93485
|
+
get type() {
|
|
93486
|
+
return "";
|
|
93487
|
+
}
|
|
93488
|
+
toJSON() {
|
|
93489
|
+
let e = { type: this.type };
|
|
93490
|
+
return this.isRootNode && (e.isRootNode = !0), this.preserveWhitespace && (e.preserveWhitespace = !0), this.start !== -1 && (e.start = this.start, e.end = this.end), e;
|
|
93491
|
+
}
|
|
94341
93492
|
};
|
|
94342
93493
|
C.TYPE_CDATA = "cdata", C.TYPE_COMMENT = "comment", C.TYPE_DOCUMENT = "document", C.TYPE_DOCUMENT_TYPE = "doctype", C.TYPE_ELEMENT = "element", C.TYPE_PROCESSING_INSTRUCTION = "pi", C.TYPE_TEXT = "text", C.TYPE_XML_DECLARATION = "xmldecl";
|
|
94343
93494
|
var w = C, T = class extends w {
|
|
@@ -94715,7 +93866,7 @@ var Y3 = ({ items: e }) => {
|
|
|
94715
93866
|
}));
|
|
94716
93867
|
//#endregion
|
|
94717
93868
|
//#region node_modules/vfile-location/lib/index.js
|
|
94718
|
-
function
|
|
93869
|
+
function B3(e) {
|
|
94719
93870
|
let t = String(e), n = [];
|
|
94720
93871
|
return {
|
|
94721
93872
|
toOffset: i,
|
|
@@ -94727,7 +93878,7 @@ function Q3(e) {
|
|
|
94727
93878
|
for (;;) {
|
|
94728
93879
|
let i = n[r];
|
|
94729
93880
|
if (i === void 0) {
|
|
94730
|
-
let e =
|
|
93881
|
+
let e = V3(t, n[r - 1]);
|
|
94731
93882
|
i = e === -1 ? t.length + 1 : e + 1, n[r] = i;
|
|
94732
93883
|
}
|
|
94733
93884
|
if (i > e) return {
|
|
@@ -94742,7 +93893,7 @@ function Q3(e) {
|
|
|
94742
93893
|
function i(e) {
|
|
94743
93894
|
if (e && typeof e.line == "number" && typeof e.column == "number" && !Number.isNaN(e.line) && !Number.isNaN(e.column)) {
|
|
94744
93895
|
for (; n.length < e.line;) {
|
|
94745
|
-
let e = n[n.length - 1], r =
|
|
93896
|
+
let e = n[n.length - 1], r = V3(t, e), i = r === -1 ? t.length + 1 : r + 1;
|
|
94746
93897
|
if (e === i) break;
|
|
94747
93898
|
n.push(i);
|
|
94748
93899
|
}
|
|
@@ -94751,17 +93902,17 @@ function Q3(e) {
|
|
|
94751
93902
|
}
|
|
94752
93903
|
}
|
|
94753
93904
|
}
|
|
94754
|
-
function
|
|
93905
|
+
function V3(e, t) {
|
|
94755
93906
|
let n = e.indexOf("\r", t), r = e.indexOf("\n", t);
|
|
94756
93907
|
return r === -1 ? n : n === -1 || n + 1 === r ? r : n < r ? n : r;
|
|
94757
93908
|
}
|
|
94758
93909
|
//#endregion
|
|
94759
93910
|
//#region node_modules/xast-util-from-xml/lib/index.js
|
|
94760
|
-
var
|
|
94761
|
-
function
|
|
94762
|
-
let t =
|
|
93911
|
+
var H3 = z3();
|
|
93912
|
+
function U3(e) {
|
|
93913
|
+
let t = B3(e), n;
|
|
94763
93914
|
try {
|
|
94764
|
-
n = (0,
|
|
93915
|
+
n = (0, H3.parseXml)(String(e), {
|
|
94765
93916
|
includeOffsets: !0,
|
|
94766
93917
|
preserveCdata: !0,
|
|
94767
93918
|
preserveComments: !0,
|
|
@@ -94777,28 +93928,28 @@ function t6(e) {
|
|
|
94777
93928
|
});
|
|
94778
93929
|
throw r.fatal = !0, r.url = "https://github.com/syntax-tree/xast-util-from-xml#throws", r;
|
|
94779
93930
|
}
|
|
94780
|
-
let r = { location: t }, i =
|
|
94781
|
-
return
|
|
93931
|
+
let r = { location: t }, i = K3(n, r);
|
|
93932
|
+
return $3(n, i, r), i;
|
|
94782
93933
|
}
|
|
94783
|
-
function
|
|
93934
|
+
function W3(e) {
|
|
94784
93935
|
return {
|
|
94785
93936
|
type: "cdata",
|
|
94786
93937
|
value: e.text
|
|
94787
93938
|
};
|
|
94788
93939
|
}
|
|
94789
|
-
function
|
|
93940
|
+
function G3(e) {
|
|
94790
93941
|
return {
|
|
94791
93942
|
type: "comment",
|
|
94792
93943
|
value: e.content
|
|
94793
93944
|
};
|
|
94794
93945
|
}
|
|
94795
|
-
function
|
|
93946
|
+
function K3(e, t) {
|
|
94796
93947
|
return {
|
|
94797
93948
|
type: "root",
|
|
94798
|
-
children:
|
|
93949
|
+
children: Q3(e.children, t)
|
|
94799
93950
|
};
|
|
94800
93951
|
}
|
|
94801
|
-
function
|
|
93952
|
+
function q3(e) {
|
|
94802
93953
|
return {
|
|
94803
93954
|
type: "doctype",
|
|
94804
93955
|
name: e.name,
|
|
@@ -94806,8 +93957,8 @@ function a6(e) {
|
|
|
94806
93957
|
system: e.systemId || void 0
|
|
94807
93958
|
};
|
|
94808
93959
|
}
|
|
94809
|
-
function
|
|
94810
|
-
let n =
|
|
93960
|
+
function J3(e, t) {
|
|
93961
|
+
let n = Q3(e.children, t);
|
|
94811
93962
|
return {
|
|
94812
93963
|
type: "element",
|
|
94813
93964
|
name: e.name,
|
|
@@ -94815,20 +93966,20 @@ function o6(e, t) {
|
|
|
94815
93966
|
children: n
|
|
94816
93967
|
};
|
|
94817
93968
|
}
|
|
94818
|
-
function
|
|
93969
|
+
function Y3(e) {
|
|
94819
93970
|
return {
|
|
94820
93971
|
type: "instruction",
|
|
94821
93972
|
name: e.name,
|
|
94822
93973
|
value: e.content
|
|
94823
93974
|
};
|
|
94824
93975
|
}
|
|
94825
|
-
function
|
|
93976
|
+
function X3(e) {
|
|
94826
93977
|
return {
|
|
94827
93978
|
type: "text",
|
|
94828
93979
|
value: e.text
|
|
94829
93980
|
};
|
|
94830
93981
|
}
|
|
94831
|
-
function
|
|
93982
|
+
function Z3(e) {
|
|
94832
93983
|
let t = [];
|
|
94833
93984
|
return e.version && t.push("version=\"" + e.version + "\""), e.encoding && t.push("encoding=\"" + e.encoding + "\""), e.standalone && t.push("standalone=\"" + e.standalone + "\""), {
|
|
94834
93985
|
type: "instruction",
|
|
@@ -94836,15 +93987,15 @@ function l6(e) {
|
|
|
94836
93987
|
value: t.join(" ")
|
|
94837
93988
|
};
|
|
94838
93989
|
}
|
|
94839
|
-
function
|
|
93990
|
+
function Q3(e, t) {
|
|
94840
93991
|
let n = [], r = -1;
|
|
94841
93992
|
for (; ++r < e.length;) {
|
|
94842
93993
|
let i = e[r], a;
|
|
94843
|
-
i.type === "cdata" ? a =
|
|
93994
|
+
i.type === "cdata" ? a = W3(i) : i.type === "comment" ? a = G3(i) : i.type === "doctype" ? a = q3(i) : i.type === "element" ? a = J3(i, t) : i.type === "pi" ? a = Y3(i) : i.type === "text" ? a = X3(i) : i.type === "xmldecl" && (a = Z3(i)), a && ($3(i, a, t), n.push(a));
|
|
94844
93995
|
}
|
|
94845
93996
|
return n;
|
|
94846
93997
|
}
|
|
94847
|
-
function
|
|
93998
|
+
function $3(e, t, n) {
|
|
94848
93999
|
let r = e.start === -1 ? void 0 : n.location.toPoint(e.start), i = e.end === -1 ? void 0 : n.location.toPoint(e.end);
|
|
94849
94000
|
r && i && (t.position = {
|
|
94850
94001
|
start: r,
|
|
@@ -94853,14 +94004,14 @@ function d6(e, t, n) {
|
|
|
94853
94004
|
}
|
|
94854
94005
|
//#endregion
|
|
94855
94006
|
//#region src/sectionUtils.ts
|
|
94856
|
-
function
|
|
94007
|
+
function e6() {
|
|
94857
94008
|
return `sec-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
94858
94009
|
}
|
|
94859
|
-
function
|
|
94010
|
+
function t6(e) {
|
|
94860
94011
|
let t = e.children.find((e) => e.type === "element" && e.name === "title");
|
|
94861
94012
|
return t ? t.children.filter((e) => e.type === "text").map((e) => e.value).join("").trim() : "";
|
|
94862
94013
|
}
|
|
94863
|
-
var
|
|
94014
|
+
var n6 = new Set([
|
|
94864
94015
|
"book",
|
|
94865
94016
|
"article",
|
|
94866
94017
|
"slideshow",
|
|
@@ -94879,7 +94030,7 @@ var m6 = new Set([
|
|
|
94879
94030
|
"conclusion"
|
|
94880
94031
|
])
|
|
94881
94032
|
]);
|
|
94882
|
-
function
|
|
94033
|
+
function r6(e) {
|
|
94883
94034
|
let t = 0, n = e.length;
|
|
94884
94035
|
for (; t < n;) {
|
|
94885
94036
|
let n = e[t];
|
|
@@ -94893,24 +94044,24 @@ function h6(e) {
|
|
|
94893
94044
|
}
|
|
94894
94045
|
return e.slice(t, n);
|
|
94895
94046
|
}
|
|
94896
|
-
function
|
|
94047
|
+
function i6(e) {
|
|
94897
94048
|
return e.replace(/^(?:[ \t]*\r?\n)+/, "").replace(/(?:\r?\n[ \t]*)+$/, "");
|
|
94898
94049
|
}
|
|
94899
|
-
function
|
|
94050
|
+
function a6(e) {
|
|
94900
94051
|
try {
|
|
94901
|
-
return
|
|
94052
|
+
return U3(e);
|
|
94902
94053
|
} catch {
|
|
94903
94054
|
return null;
|
|
94904
94055
|
}
|
|
94905
94056
|
}
|
|
94906
|
-
function
|
|
94057
|
+
function o6(e) {
|
|
94907
94058
|
let t = e.match(/^\s*<([A-Za-z_][\w.:-]*)\b[^>]*?>/);
|
|
94908
94059
|
if (!t || t.index === void 0) return e;
|
|
94909
|
-
let n = e.slice(t.index + t[0].length), r = RegExp(`\\s*</${
|
|
94910
|
-
return
|
|
94060
|
+
let n = e.slice(t.index + t[0].length), r = RegExp(`\\s*</${E6(t[1])}\\s*>\\s*$`);
|
|
94061
|
+
return i6(n.replace(r, ""));
|
|
94911
94062
|
}
|
|
94912
|
-
function
|
|
94913
|
-
let n =
|
|
94063
|
+
function s6(e, t) {
|
|
94064
|
+
let n = a6(e);
|
|
94914
94065
|
if (!n) return e;
|
|
94915
94066
|
let r = n.children.find((e) => e.type === "element");
|
|
94916
94067
|
if (!r) return e;
|
|
@@ -94925,8 +94076,8 @@ function y6(e, t) {
|
|
|
94925
94076
|
};
|
|
94926
94077
|
return i === -1 ? r.children.unshift(a) : r.children.splice(i, 1, a), qY(n);
|
|
94927
94078
|
}
|
|
94928
|
-
function
|
|
94929
|
-
let t =
|
|
94079
|
+
function c6(e = "New Section") {
|
|
94080
|
+
let t = e6();
|
|
94930
94081
|
return {
|
|
94931
94082
|
id: t,
|
|
94932
94083
|
xmlId: t,
|
|
@@ -94936,8 +94087,8 @@ function b6(e = "New Section") {
|
|
|
94936
94087
|
sourceFormat: "pretext"
|
|
94937
94088
|
};
|
|
94938
94089
|
}
|
|
94939
|
-
function
|
|
94940
|
-
let e =
|
|
94090
|
+
function l6() {
|
|
94091
|
+
let e = e6();
|
|
94941
94092
|
return {
|
|
94942
94093
|
id: e,
|
|
94943
94094
|
xmlId: e,
|
|
@@ -94947,8 +94098,8 @@ function x6() {
|
|
|
94947
94098
|
sourceFormat: "pretext"
|
|
94948
94099
|
};
|
|
94949
94100
|
}
|
|
94950
|
-
function
|
|
94951
|
-
let e =
|
|
94101
|
+
function u6() {
|
|
94102
|
+
let e = e6();
|
|
94952
94103
|
return {
|
|
94953
94104
|
id: e,
|
|
94954
94105
|
xmlId: e,
|
|
@@ -94958,38 +94109,38 @@ function S6() {
|
|
|
94958
94109
|
sourceFormat: "pretext"
|
|
94959
94110
|
};
|
|
94960
94111
|
}
|
|
94961
|
-
function
|
|
94962
|
-
let t =
|
|
94963
|
-
if (!t) return
|
|
94112
|
+
function d6(e) {
|
|
94113
|
+
let t = a6(e);
|
|
94114
|
+
if (!t) return o6(e);
|
|
94964
94115
|
let n = t.children.find((e) => e.type === "element");
|
|
94965
|
-
return n ?
|
|
94116
|
+
return n ? B6(qY({
|
|
94966
94117
|
type: "root",
|
|
94967
|
-
children:
|
|
94118
|
+
children: r6(n.children)
|
|
94968
94119
|
})) : e;
|
|
94969
94120
|
}
|
|
94970
|
-
function
|
|
94971
|
-
return `<${t}>\n${
|
|
94121
|
+
function f6(e, t) {
|
|
94122
|
+
return `<${t}>\n${i6(e)}\n</${t}>`;
|
|
94972
94123
|
}
|
|
94973
|
-
function
|
|
94974
|
-
return e.trimStart().startsWith(`<${t}`) ? e :
|
|
94124
|
+
function p6(e, t) {
|
|
94125
|
+
return e.trimStart().startsWith(`<${t}`) ? e : f6(e, t);
|
|
94975
94126
|
}
|
|
94976
|
-
function
|
|
94127
|
+
function m6(e, t) {
|
|
94977
94128
|
if (t === "introduction" || t === "conclusion") return e;
|
|
94978
94129
|
let n = e.trimStart();
|
|
94979
94130
|
return n.startsWith("\\begin{section}") ? n.replace(/^\\begin\{section\}\s*\n?/, "").replace(/\n?\\end\{section\}\s*$/, "") : e.replace(/^\\section\*?\{[^}]*\}\s*\n?/, "");
|
|
94980
94131
|
}
|
|
94981
|
-
function
|
|
94132
|
+
function h6(e, t, n, r) {
|
|
94982
94133
|
return t === "introduction" || t === "conclusion" ? e : r?.trimStart().startsWith("\\begin{section}") ? `\\begin{section}\n\n${e}\n\n\\end{section}` : `\\section{${n}}\n\n${e}`;
|
|
94983
94134
|
}
|
|
94984
|
-
function
|
|
94135
|
+
function g6(e, t, n, r) {
|
|
94985
94136
|
if (t === "introduction" || t === "conclusion") return e;
|
|
94986
94137
|
let i = e.trimStart();
|
|
94987
|
-
return i.startsWith("\\section") || i.startsWith("\\begin{section}") ? e :
|
|
94138
|
+
return i.startsWith("\\section") || i.startsWith("\\begin{section}") ? e : h6(e, t, n, r);
|
|
94988
94139
|
}
|
|
94989
|
-
function
|
|
94140
|
+
function _6(e, t) {
|
|
94990
94141
|
return /\\section[*]?\{/.test(e) ? e.replace(/^(\\section\*?\{)[^}]*/, (e, n) => `${n}${t}`) : e.includes("\\begin{section}") ? /\\title\{/.test(e) ? e.replace(/\\title\{[^}]*\}/, `\\title{${t}}`) : e.replace("\\begin{section}", `\\begin{section}\n\n\\title{${t}}\n\n`) : e;
|
|
94991
94142
|
}
|
|
94992
|
-
function
|
|
94143
|
+
function v6(e) {
|
|
94993
94144
|
let t = /^\\section\*?\{([^}]*)\}/.exec(e);
|
|
94994
94145
|
if (t) return t[1].trim();
|
|
94995
94146
|
if (e.includes("\\begin{section}")) {
|
|
@@ -94998,8 +94149,8 @@ function A6(e) {
|
|
|
94998
94149
|
}
|
|
94999
94150
|
return null;
|
|
95000
94151
|
}
|
|
95001
|
-
function
|
|
95002
|
-
let t =
|
|
94152
|
+
function y6(e = "New Section") {
|
|
94153
|
+
let t = e6();
|
|
95003
94154
|
return {
|
|
95004
94155
|
id: t,
|
|
95005
94156
|
xmlId: t,
|
|
@@ -95009,8 +94160,8 @@ function j6(e = "New Section") {
|
|
|
95009
94160
|
sourceFormat: "latex"
|
|
95010
94161
|
};
|
|
95011
94162
|
}
|
|
95012
|
-
function
|
|
95013
|
-
let e =
|
|
94163
|
+
function b6() {
|
|
94164
|
+
let e = e6();
|
|
95014
94165
|
return {
|
|
95015
94166
|
id: e,
|
|
95016
94167
|
xmlId: e,
|
|
@@ -95020,8 +94171,8 @@ function M6() {
|
|
|
95020
94171
|
sourceFormat: "latex"
|
|
95021
94172
|
};
|
|
95022
94173
|
}
|
|
95023
|
-
function
|
|
95024
|
-
let e =
|
|
94174
|
+
function x6() {
|
|
94175
|
+
let e = e6();
|
|
95025
94176
|
return {
|
|
95026
94177
|
id: e,
|
|
95027
94178
|
xmlId: e,
|
|
@@ -95031,369 +94182,1247 @@ function N6() {
|
|
|
95031
94182
|
sourceFormat: "latex"
|
|
95032
94183
|
};
|
|
95033
94184
|
}
|
|
95034
|
-
function
|
|
94185
|
+
function S6(e, t, n) {
|
|
95035
94186
|
if (n) {
|
|
95036
|
-
let n =
|
|
94187
|
+
let n = m6(t.content, t.type);
|
|
95037
94188
|
return {
|
|
95038
94189
|
...e,
|
|
95039
94190
|
content: e.content.trimEnd() + "\n\n" + n.trimStart()
|
|
95040
94191
|
};
|
|
95041
|
-
}
|
|
95042
|
-
let r =
|
|
95043
|
-
if (!a || !o) return {
|
|
95044
|
-
...e,
|
|
95045
|
-
content: e.content + "\n\n" + t.content
|
|
95046
|
-
};
|
|
95047
|
-
let s = o.children.filter((e) => !(e.type === "element" && e.name === "title")), c = {
|
|
95048
|
-
...a,
|
|
95049
|
-
children: [...a.children, ...s]
|
|
94192
|
+
}
|
|
94193
|
+
let r = a6(e.content), i = a6(t.content), a = r?.children.find((e) => e.type === "element"), o = i?.children.find((e) => e.type === "element");
|
|
94194
|
+
if (!a || !o) return {
|
|
94195
|
+
...e,
|
|
94196
|
+
content: e.content + "\n\n" + t.content
|
|
94197
|
+
};
|
|
94198
|
+
let s = o.children.filter((e) => !(e.type === "element" && e.name === "title")), c = {
|
|
94199
|
+
...a,
|
|
94200
|
+
children: [...a.children, ...s]
|
|
94201
|
+
};
|
|
94202
|
+
return {
|
|
94203
|
+
...e,
|
|
94204
|
+
content: qY({
|
|
94205
|
+
type: "root",
|
|
94206
|
+
children: [c]
|
|
94207
|
+
})
|
|
94208
|
+
};
|
|
94209
|
+
}
|
|
94210
|
+
function C6(e) {
|
|
94211
|
+
try {
|
|
94212
|
+
let t = U3(e).children.find((e) => e.type === "element");
|
|
94213
|
+
return t ? {
|
|
94214
|
+
xmlId: t.attributes?.["xml:id"] ?? "",
|
|
94215
|
+
label: t.attributes?.label ?? ""
|
|
94216
|
+
} : {
|
|
94217
|
+
xmlId: "",
|
|
94218
|
+
label: ""
|
|
94219
|
+
};
|
|
94220
|
+
} catch {
|
|
94221
|
+
return {
|
|
94222
|
+
xmlId: "",
|
|
94223
|
+
label: ""
|
|
94224
|
+
};
|
|
94225
|
+
}
|
|
94226
|
+
}
|
|
94227
|
+
function w6(e) {
|
|
94228
|
+
let t = a6(e);
|
|
94229
|
+
if (!t) return null;
|
|
94230
|
+
let n = t.children.find((e) => e.type === "element");
|
|
94231
|
+
return !n || !n6.has(n.name) ? null : {
|
|
94232
|
+
title: t6(n),
|
|
94233
|
+
type: n.name,
|
|
94234
|
+
xmlId: n.attributes?.["xml:id"] ?? "",
|
|
94235
|
+
label: n.attributes?.label ?? ""
|
|
94236
|
+
};
|
|
94237
|
+
}
|
|
94238
|
+
function T6(e, t) {
|
|
94239
|
+
let n = t.type ?? e.type, r = t.title ?? e.title;
|
|
94240
|
+
try {
|
|
94241
|
+
let i = U3(e.content).children.find((e) => e.type === "element");
|
|
94242
|
+
if (!i) return {
|
|
94243
|
+
...e,
|
|
94244
|
+
title: r,
|
|
94245
|
+
type: n
|
|
94246
|
+
};
|
|
94247
|
+
let a = {
|
|
94248
|
+
...i,
|
|
94249
|
+
name: n,
|
|
94250
|
+
attributes: { ...i.attributes }
|
|
94251
|
+
};
|
|
94252
|
+
t.xmlId !== void 0 && (t.xmlId === null || t.xmlId === "" ? delete a.attributes["xml:id"] : a.attributes["xml:id"] = t.xmlId), t.label !== void 0 && (t.label === null || t.label === "" ? delete a.attributes.label : a.attributes.label = t.label);
|
|
94253
|
+
let o = a.children.findIndex((e) => e.type === "element" && e.name === "title"), s = {
|
|
94254
|
+
type: "element",
|
|
94255
|
+
name: "title",
|
|
94256
|
+
attributes: {},
|
|
94257
|
+
children: [{
|
|
94258
|
+
type: "text",
|
|
94259
|
+
value: r
|
|
94260
|
+
}]
|
|
94261
|
+
};
|
|
94262
|
+
o === -1 ? a.children = [s, ...a.children] : a.children = [
|
|
94263
|
+
...a.children.slice(0, o),
|
|
94264
|
+
s,
|
|
94265
|
+
...a.children.slice(o + 1)
|
|
94266
|
+
];
|
|
94267
|
+
let c = qY({
|
|
94268
|
+
type: "root",
|
|
94269
|
+
children: [a]
|
|
94270
|
+
}), l = t.xmlId !== void 0 && t.xmlId !== null && t.xmlId !== "" ? t.xmlId : e.xmlId;
|
|
94271
|
+
return {
|
|
94272
|
+
...e,
|
|
94273
|
+
title: r,
|
|
94274
|
+
type: n,
|
|
94275
|
+
xmlId: l,
|
|
94276
|
+
content: c
|
|
94277
|
+
};
|
|
94278
|
+
} catch {
|
|
94279
|
+
return {
|
|
94280
|
+
...e,
|
|
94281
|
+
title: r,
|
|
94282
|
+
type: n
|
|
94283
|
+
};
|
|
94284
|
+
}
|
|
94285
|
+
}
|
|
94286
|
+
function E6(e) {
|
|
94287
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
94288
|
+
}
|
|
94289
|
+
var D6 = new Set(["division", ...n6]), O6 = Array.from(D6).join("|");
|
|
94290
|
+
function k6(e) {
|
|
94291
|
+
let t = e === null ? "ref=\"([^\"]+)\"" : `ref="${E6(e)}"`, n = `(?:${O6})`;
|
|
94292
|
+
return `<plus:${n}\\s[^>]*${t}[^>]*?(?:/>|>\\s*</plus:${n}>)`;
|
|
94293
|
+
}
|
|
94294
|
+
function A6(e) {
|
|
94295
|
+
let t = [], n = new RegExp(k6(null), "g"), r;
|
|
94296
|
+
for (; (r = n.exec(e)) !== null;) t.push(r[1]);
|
|
94297
|
+
return t;
|
|
94298
|
+
}
|
|
94299
|
+
function j6(e) {
|
|
94300
|
+
let t = [], n = `(?:${O6})`, r = RegExp(`<plus:(${O6})\\s[^>]*ref="([^"]+)"[^>]*?(?:/>|>\\s*</plus:${n}>)`, "g"), i;
|
|
94301
|
+
for (; (i = r.exec(e)) !== null;) {
|
|
94302
|
+
let e = i[1], n = e === "division" ? "section" : e;
|
|
94303
|
+
t.push({
|
|
94304
|
+
type: n,
|
|
94305
|
+
xmlId: i[2]
|
|
94306
|
+
});
|
|
94307
|
+
}
|
|
94308
|
+
return t;
|
|
94309
|
+
}
|
|
94310
|
+
function M6(e) {
|
|
94311
|
+
let t = [], n = /<plus:(image|doenet)\b[^>]*\bref="([^"]+)"/g, r;
|
|
94312
|
+
for (; (r = n.exec(e)) !== null;) t.push({
|
|
94313
|
+
kind: r[1],
|
|
94314
|
+
ref: r[2]
|
|
94315
|
+
});
|
|
94316
|
+
return t;
|
|
94317
|
+
}
|
|
94318
|
+
function N6(e, t, n = "pretext") {
|
|
94319
|
+
let r = `New ${t.charAt(0).toUpperCase() + t.slice(1)}`;
|
|
94320
|
+
return {
|
|
94321
|
+
id: e,
|
|
94322
|
+
xmlId: e,
|
|
94323
|
+
title: r,
|
|
94324
|
+
type: t,
|
|
94325
|
+
sourceFormat: n,
|
|
94326
|
+
content: n === "pretext" ? `<${t} xml:id="${e}">\n<title>${r}</title>\n\n<p></p>\n\n</${t}>` : `\\section{${r}}\n\n`
|
|
94327
|
+
};
|
|
94328
|
+
}
|
|
94329
|
+
function P6(e, t, n, r) {
|
|
94330
|
+
let i = `<plus:${n} ref="${t}"/>`;
|
|
94331
|
+
if (r !== null) {
|
|
94332
|
+
let t = new RegExp(k6(r)).exec(e);
|
|
94333
|
+
if (t) {
|
|
94334
|
+
let n = t.index + t[0].length;
|
|
94335
|
+
return e.slice(0, n) + "\n" + i + e.slice(n);
|
|
94336
|
+
}
|
|
94337
|
+
}
|
|
94338
|
+
let a = e.lastIndexOf("</");
|
|
94339
|
+
return a === -1 ? e + "\n" + i : e.slice(0, a) + i + "\n" + e.slice(a);
|
|
94340
|
+
}
|
|
94341
|
+
function F6(e, t) {
|
|
94342
|
+
let n = RegExp(`[ \t]*${k6(t)}[ \t]*\n?`, "g");
|
|
94343
|
+
return e.replace(n, "");
|
|
94344
|
+
}
|
|
94345
|
+
function I6(e, t, n) {
|
|
94346
|
+
let r = new RegExp(k6(t)).exec(e), i = r ? B6(r[0]) : `<plus:division ref="${t}"/>`, a = F6(e, t);
|
|
94347
|
+
if (n !== null) {
|
|
94348
|
+
let e = new RegExp(k6(n)).exec(a);
|
|
94349
|
+
if (e) {
|
|
94350
|
+
let t = e.index + e[0].length;
|
|
94351
|
+
return a.slice(0, t) + "\n" + i + a.slice(t);
|
|
94352
|
+
}
|
|
94353
|
+
}
|
|
94354
|
+
let o = a.lastIndexOf("</");
|
|
94355
|
+
return o === -1 ? a + "\n" + i : a.slice(0, o) + i + "\n" + a.slice(o);
|
|
94356
|
+
}
|
|
94357
|
+
function L6(e, t, n, r) {
|
|
94358
|
+
let i = new RegExp(k6(t));
|
|
94359
|
+
return i.test(e) ? e.replace(i, `<plus:${r} ref="${n}"/>`) : e;
|
|
94360
|
+
}
|
|
94361
|
+
function R6(e, t) {
|
|
94362
|
+
let n = new RegExp(k6(t));
|
|
94363
|
+
return e.find((e) => n.test(e.content)) ?? null;
|
|
94364
|
+
}
|
|
94365
|
+
function z6(e, t) {
|
|
94366
|
+
let n = e, r = null;
|
|
94367
|
+
for (let e of t) n = I6(n, e, r), r = e;
|
|
94368
|
+
return n;
|
|
94369
|
+
}
|
|
94370
|
+
function B6(e) {
|
|
94371
|
+
return e.replace(/<plus:([a-z-]+)((?:\s[^>]*?)?)>\s*<\/plus:\1>/g, (e, t, n) => `<plus:${t}${n}/>`);
|
|
94372
|
+
}
|
|
94373
|
+
function V6(e, t) {
|
|
94374
|
+
let n = /* @__PURE__ */ new Set(), r = [t];
|
|
94375
|
+
for (; r.length > 0;) {
|
|
94376
|
+
let t = r.pop();
|
|
94377
|
+
if (n.has(t)) continue;
|
|
94378
|
+
n.add(t);
|
|
94379
|
+
let i = e.find((e) => e.xmlId === t);
|
|
94380
|
+
if (i) for (let e of A6(i.content)) r.push(e);
|
|
94381
|
+
}
|
|
94382
|
+
return n;
|
|
94383
|
+
}
|
|
94384
|
+
function H6(e, t) {
|
|
94385
|
+
let n = V6(e, t);
|
|
94386
|
+
return e.filter((e) => !n.has(e.xmlId));
|
|
94387
|
+
}
|
|
94388
|
+
function U6(e, t) {
|
|
94389
|
+
let n = [], r = new Set([t]), i = (t, a) => {
|
|
94390
|
+
let o = e.find((e) => e.xmlId === t);
|
|
94391
|
+
if (o) for (let s of A6(o.content)) {
|
|
94392
|
+
if (r.has(s)) continue;
|
|
94393
|
+
let o = e.find((e) => e.xmlId === s);
|
|
94394
|
+
o && (r.add(s), n.push({
|
|
94395
|
+
division: o,
|
|
94396
|
+
depth: a,
|
|
94397
|
+
parentXmlId: t
|
|
94398
|
+
}), i(s, a + 1));
|
|
94399
|
+
}
|
|
94400
|
+
};
|
|
94401
|
+
return i(t, 0), n;
|
|
94402
|
+
}
|
|
94403
|
+
function W6(e, t) {
|
|
94404
|
+
let n = H6(e, t), r = new Set(n.map((e) => e.xmlId)), i = /* @__PURE__ */ new Set();
|
|
94405
|
+
for (let e of n) for (let t of A6(e.content)) r.has(t) && i.add(t);
|
|
94406
|
+
return n.filter((e) => !i.has(e.xmlId));
|
|
94407
|
+
}
|
|
94408
|
+
var G6 = new Set([
|
|
94409
|
+
"book",
|
|
94410
|
+
"article",
|
|
94411
|
+
"slideshow"
|
|
94412
|
+
]);
|
|
94413
|
+
function K6(e) {
|
|
94414
|
+
try {
|
|
94415
|
+
let t = U3(e), n = t.children.find((e) => e.type === "element"), r = n?.name === "pretext" ? n.children.find((e) => e.type === "element" && G6.has(e.name)) : n && G6.has(n.name) ? n : void 0;
|
|
94416
|
+
if (!r) return e;
|
|
94417
|
+
if (!r.attributes.label) {
|
|
94418
|
+
let e = J6(t, "pretext-plus-preview");
|
|
94419
|
+
return r.attributes.label = e, qY(t);
|
|
94420
|
+
}
|
|
94421
|
+
return e;
|
|
94422
|
+
} catch (t) {
|
|
94423
|
+
return console.error("Error ensuring label:", t), e;
|
|
94424
|
+
}
|
|
94425
|
+
}
|
|
94426
|
+
function q6(e, t) {
|
|
94427
|
+
return e.type === "element" && e.attributes?.label === t ? !0 : "children" in e && e.children ? e.children.some((e) => e.type === "element" ? q6(e, t) : !1) : !1;
|
|
94428
|
+
}
|
|
94429
|
+
function J6(e, t) {
|
|
94430
|
+
let n = t, r = 1;
|
|
94431
|
+
for (; q6(e, n);) n = `${t}-${r}`, r++;
|
|
94432
|
+
return n;
|
|
94433
|
+
}
|
|
94434
|
+
function Y6(e, t, n) {
|
|
94435
|
+
let r = t.find((t) => t.xmlId === e);
|
|
94436
|
+
if (!r) return `<!-- missing division: ${e} -->`;
|
|
94437
|
+
if (n.has(e)) return `<!-- circular reference: ${e} -->`;
|
|
94438
|
+
let i;
|
|
94439
|
+
if (r.sourceFormat === "pretext") i = r.content;
|
|
94440
|
+
else {
|
|
94441
|
+
let { pretextSource: e, pretextError: t } = f3(r.sourceFormat === "latex" ? m6(r.content, r.type) : d6(r.content), r.sourceFormat), n = e ?? `<!-- conversion error: ${t} -->`;
|
|
94442
|
+
i = `<${r.type} xml:id="${r.xmlId}">\n<title>${r.title}</title>\n\n${n}\n</${r.type}>`;
|
|
94443
|
+
}
|
|
94444
|
+
if (r.sourceFormat !== "pretext") return i;
|
|
94445
|
+
let a = new Set(n).add(e);
|
|
94446
|
+
return i.replace(/<plus:[a-z-]+\s[^>]*ref="([^"]+)"[^>]*?(?:\/>|>\s*<\/plus:[a-z-]+>)/g, (e, n) => Y6(n, t, a));
|
|
94447
|
+
}
|
|
94448
|
+
function X6(e, t) {
|
|
94449
|
+
return K6(Y6(t, e, /* @__PURE__ */ new Set()));
|
|
94450
|
+
}
|
|
94451
|
+
function Z6(e, t) {
|
|
94452
|
+
return K6(`<pretext>\n${t.trim() ? `${t.trim()}\n` : ""}${e}\n</pretext>`);
|
|
94453
|
+
}
|
|
94454
|
+
function Q6(e, t, n) {
|
|
94455
|
+
return Z6(Y6(t, e, /* @__PURE__ */ new Set()), n);
|
|
94456
|
+
}
|
|
94457
|
+
var $6 = new Set(["part", "chapter"]);
|
|
94458
|
+
function e8(e, t, n, r) {
|
|
94459
|
+
return Z6(G6.has(e) ? t : $6.has(e) ? `<book>\n<title>${r}</title>\n${t}\n</book>` : `<article>\n<title>${r}</title>\n${t}\n</article>`, n);
|
|
94460
|
+
}
|
|
94461
|
+
//#endregion
|
|
94462
|
+
//#region src/assets/doenet.png
|
|
94463
|
+
var t8 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAJZ0lEQVR4nJxXe3BU1Rn/nXNf+8oueUgSdpckEALhpc1KJBEskkGc0Uqp2o6C7VSqM/5RGWsHnTLMOI51qgxCyzhtRx1ktFOslZZaC8UkFC2CKCEkaCSKCXmHbDabTbLZ+zj3dM7dDYZACuM3c7Kbc/d+v+91vu93ZFynaJqGmpoasUhFRQUpKioieXl5RDwbHBzkFy5c4KdPn+Z1dXW8trYWqVTqelX/fwmFQnjppZdILBaTOeca59zNOfdanAeSjAfFsjifIfYyz7ShoSF5165dwshr6ifTPVAUBVu3bsWWLVtkt9stm4C3JYU153TUdJiIxBnCHJAzSqwZFF1hFQ1lKuoWunFYBcZ0XTd37NjBnn32Wa7r+vUbILzev38/XbZsmWICvmOj+NmxJB5JceSKFyhACPnmZS4WB+z0B1wEsWoPXr3Vg1dUipFTp06Z69evtzs7O69tQGlpKerr66VwOKx2GLj57QR2xRnmSAChxAF3XiKYYkBm2WJxgAHcT9FxXwBPlKg43t3dbaxZs4a1tLRMb4Dw/KOPPhLg2idJPPDuCJ4ngCoRECntOSgBodMYkAHn4pOJxZ19864sbL3Fgzd7e3v16upq1t7efqUBIufHjh0TYRfgDx4YwXYZoBIBBLicAZ6IQmpwgPq6vlTnuqgUUCQpYdn2+ZRtxgpKDO2GAm5lDLE4YAH2PVl4qtKDN5uamvTKykp7oiakCQO2bduGDRs2iLAv2zeMP0qAIpN0lakEhI0Mk/i5s7IiS2ADfXQNH/Z9vyoizZsdouFgEKXhEKksCcs50S6tpbObaXkFoh6cWhGOnjOwqkjByQXB/G4RnCNHjnwTARH61tZWWXa7A7+L4nCCYY7wWIArBMRuPqGunZnlunHxIpxsOI2hsaS9duWt9KplDaCruxuvd8THXKWLWCYC3OSAj6Lj8VzUcCM1VFZWZomidCLwzDPPkJUrV2ofjuKxFh3fmww+1vE1vf8GzbOovNxRHiwsRHFwFqGUwjAMcM4hvk8Wv98Po6tN7s+aaVBJcmpDuDrO4RdZme+VTyiKwg4ePAgiOlxvb6/sy84OvHgRH5sceQpJg4sUDDd+LG+umOfJyclxlIvcvbdvH07++zCGo1EQShGcOxer778PVatWXTLCsiw8/2Fj0rfkZktEweTpKEgE8S15qDTGRmIFBQWWtHbtWmzatEn5bBx3ndFx/4T3ctoAwhlDwciAmp+fD9M08eKTv8TZunpYyWQaybaRHBxE84f/xbjNsPCmm5xtEZXmjm6GmUEnAOIPJ44hWp6M1iKv1tLQ0MDo6tWrnd5yzkANzRw1YjOin6jVgsff8y640Ozr6+tzPDpaW4vOs2edyiotzsbP183HD28vguyiTjHV/nkf+np7HAOGhobQ+/VXNPb5GQk2m3x8SauO2wWUwJbFYBH/dBiIOB1OhO/To+rDFeVaTm4uVFW9lONktBu27TiEEYsiOv9OxHu6IUs9YLAgU/GbHqBwFrKzs/Hrnz6gjo+Pq/86foy1hBePkUCO42CXiQqBGYlECC0uLiYMkOM2Qg66bWMJNVwFhYVwuVyXFdjc4tmYNcsP07LQ3zWIt178Lere/Cv0pOWEuGpxPrw5+ZcVpNvtxr2rb5OyO7/QnOZFAIElMMVElXNzc4luw8udugPM0QTJz5lxRWULKYmsQM2Ko2j94jzOdSYwOs6gyhSFOR5UL7wB2YurkB8MX/Vo5stESqTxRX+QdRu+vLy8MTnTKS51RDXLzwe+jF9VicfjwXceegru9/+CsvOnkK1wyJKEpOKDd9FtmHfrndO1BgyamdxNETkajfJwVtYoSXdNRZTKVyY1hoeH1UAgcMULPp8PkfUPwzA2YmBgABKlmJeff6nlMcac3jAhomY+aTyD3pyQrmampcBSKcaiFwe5LJhMSUmJM89HbJSIozK2cFnqT7VH6fyARxapEErEmqxYfL+0nxlGQjXPHDcOAsvmdpRLbCBUpntDRdzgaQsCFF0yYLa3t3NZ0KhVq1bZYQUNZ3UUi/6tBLKR+u49yabxJJG5TVSJQpEoUQiZ6A+O55JEQYiUnoTplivC6DScTPsVQwneTCuemJghBY3ia2NjI6f19fXOfpmGuskjVVhK3R5IXh+nLg+I6uJQNUDVOFc0bksKGJEcUKHcBLiVXg4XMBnD6OCAOGFpspKZjsKOMhX/ETCCP1JBIOPxOFvowmHBZOw0s3Hm+ejgAN566G7v/sd/4h6+2EdSKZ2nUroDGLvYh5Rp8bHkONcty/FQ1Fm8vw+GaeLEa7vVdx79ka//8ybKJhEVhSCxyIVDIyMj7NChQ5AFe927dy/bvHnzWJUHrx4ZwxanIXHwoY42KRm9SJlh2KfffkNpPfyuKobLTT94UD/zt31a6MaIGetoo8l4TPJk57Li5SvZZwf/LociVSx24Tw1RhNo/+B9ecmCpRbLRKbajT0aReK1N95go6OjTmPCzp07BWk0V3jwiqBRLBMFJ9y2jVQ8RtUZObbIi1ixnk5qjCehZedwy7KI4vbYQ53t0nB/H7FS49RfNIdVPPJEisoylj76pD7BjnwUPbd58XuBtX37dn7Z+X/uuecEC9baDFTvGcJbFFDFUBr6rEHWXG6eV1ZuD35+RhLMKW/OPLu38VPJNzPfUaJ4fDwZixL/7BK750yD5JtdbLtyZ9oDX35BAwuWOJyAAdaPZ2DDPA1HX3jhhdTTTz+NywwQY1lQskgkop1M4qF/jOA3gpLJGQomZ3gh+YaYkimcMF1kaTBMpWR3Z+FXyz3Y29zc7FCyiYvLZaQ0HA7j+PHjUjAYFEZs+GealCoTvPDbkFIbsO7KwjYB3t/fr1dVVbG2trZLmFfQ8vLyctTV1UmFhYXq1waq3xnGzoSN8DS0nGQM4JOpOcvQcpHze/34RamGD/r7+4077riDNTU1XYZ31YtJcXExDhw4QJcuXaoYNvxHk3jsRBKbDA6/AKWZVFzlYuIYI47acjf2iIJzUQw3Nzcb69atsyd7PiHS1QyIx+PYs2cPJ4TYVbdU6vM98onlbrwumIxMMJ6y4U5y+BjgnHGRZj9F51wVR1Z48Yf1fmyZ70I9M/TRHTt2mBs3buRibnwrEXWxe/dukkgkpl5OZ2Qup6Gpl1Px25dffpmISF5Lpr2cThWv1wvBH6dez8UUFBN14nouWrtgu6LJXI/8LwAA//98WriRDELEmAAAAABJRU5ErkJggg==", n8 = {
|
|
94464
|
+
image: "Images",
|
|
94465
|
+
doenet: "Doenet"
|
|
94466
|
+
}, r8 = ["image", "doenet"];
|
|
94467
|
+
function i8(e) {
|
|
94468
|
+
let t = /* @__PURE__ */ new Set(), n = [];
|
|
94469
|
+
for (let { kind: r, ref: i } of M6(e)) {
|
|
94470
|
+
let e = `${r}:${i}`;
|
|
94471
|
+
t.has(e) || (t.add(e), n.push({
|
|
94472
|
+
kind: r,
|
|
94473
|
+
ref: i
|
|
94474
|
+
}));
|
|
94475
|
+
}
|
|
94476
|
+
return n;
|
|
94477
|
+
}
|
|
94478
|
+
var a8 = ({ open: r, onClose: i, onLoadAssets: a, onLoadLibraryAssets: o, onInsert: s, onAddFromLibrary: c, onUpload: l, onAddUrl: u, onCreateDoenet: f, onRemoveAsset: p }) => {
|
|
94479
|
+
let h = b3((e) => e.activeEditorSource), g = b3((e) => e.projectAssets) ?? [], _ = b3((e) => e.libraryAssets), v = !!(a || o), [x, S] = b(null), [C, w] = b(null), [T, E] = b(!1), [D, O] = b(null), k = x ?? g, A = C ?? _ ?? k, j = new Set(k.map((e) => e.id)), [ee, te] = b("in-document"), [ne, M] = b(null), [N, re] = b("library"), [ie, ae] = b("library"), [P, oe] = b(null), [F, se] = b(!1), [ce, le] = b(!1), [ue, I] = b(null), de = y(null), [fe, pe] = b(""), [me, he] = b(""), [L, ge] = b(!1), [_e, ve] = b(null), [ye, be] = b(""), [xe, Se] = b(""), [R, Ce] = b(!1), [we, Te] = b(null), [z, Ee] = b(null), De = d(() => {
|
|
94480
|
+
!a && !o || (E(!0), O(null), Promise.all([a?.() ?? Promise.resolve(null), o?.() ?? Promise.resolve(null)]).then(([e, t]) => {
|
|
94481
|
+
e !== null && S(e), t !== null && w(t);
|
|
94482
|
+
}).catch((e) => {
|
|
94483
|
+
O(e instanceof Error ? e.message : "Failed to load assets.");
|
|
94484
|
+
}).finally(() => E(!1)));
|
|
94485
|
+
}, [a, o]);
|
|
94486
|
+
if (m(() => {
|
|
94487
|
+
if (!r) return;
|
|
94488
|
+
De();
|
|
94489
|
+
let e = (e) => {
|
|
94490
|
+
e.key === "Escape" && i();
|
|
94491
|
+
};
|
|
94492
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
94493
|
+
}, [
|
|
94494
|
+
r,
|
|
94495
|
+
i,
|
|
94496
|
+
De
|
|
94497
|
+
]), !r) return null;
|
|
94498
|
+
let Oe = i8(h), B = (e) => {
|
|
94499
|
+
s(e), i();
|
|
94500
|
+
}, ke = (e, t) => {
|
|
94501
|
+
let n = `${e}:${t}`;
|
|
94502
|
+
navigator.clipboard.writeText(`<plus:${e} ref="${t}"/>`).catch(() => {}), Ee(n), setTimeout(() => Ee((e) => e === n ? null : e), 2e3);
|
|
94503
|
+
}, Ae = async (e) => {
|
|
94504
|
+
if (!j.has(e.id) && c) {
|
|
94505
|
+
oe(e.id);
|
|
94506
|
+
try {
|
|
94507
|
+
await c(e);
|
|
94508
|
+
} finally {
|
|
94509
|
+
oe(null);
|
|
94510
|
+
}
|
|
94511
|
+
}
|
|
94512
|
+
B(e);
|
|
94513
|
+
}, je = async (e) => {
|
|
94514
|
+
if (l) {
|
|
94515
|
+
I(null), le(!0);
|
|
94516
|
+
try {
|
|
94517
|
+
B(await l(e));
|
|
94518
|
+
} catch (e) {
|
|
94519
|
+
I(e instanceof Error ? e.message : "Upload failed."), le(!1);
|
|
94520
|
+
}
|
|
94521
|
+
}
|
|
94522
|
+
}, Me = async () => {
|
|
94523
|
+
let e = fe.trim();
|
|
94524
|
+
if (!e) return;
|
|
94525
|
+
let t = me.trim() || e;
|
|
94526
|
+
if (u) {
|
|
94527
|
+
ve(null), ge(!0);
|
|
94528
|
+
try {
|
|
94529
|
+
B(await u(e, t));
|
|
94530
|
+
} catch (e) {
|
|
94531
|
+
ve(e instanceof Error ? e.message : "Failed to add URL."), ge(!1);
|
|
94532
|
+
}
|
|
94533
|
+
} else B({
|
|
94534
|
+
id: `url-${Date.now()}`,
|
|
94535
|
+
name: t,
|
|
94536
|
+
ref: e.split("/").pop() ?? "image",
|
|
94537
|
+
kind: "image"
|
|
94538
|
+
});
|
|
94539
|
+
}, Ne = async () => {
|
|
94540
|
+
let e = ye.trim(), t = xe.trim();
|
|
94541
|
+
if (!(!e || !t)) if (f) {
|
|
94542
|
+
Te(null), Ce(!0);
|
|
94543
|
+
try {
|
|
94544
|
+
B(await f(e, t));
|
|
94545
|
+
} catch (e) {
|
|
94546
|
+
Te(e instanceof Error ? e.message : "Failed to create activity."), Ce(!1);
|
|
94547
|
+
}
|
|
94548
|
+
} else B({
|
|
94549
|
+
id: `doenet-${Date.now()}`,
|
|
94550
|
+
name: e,
|
|
94551
|
+
ref: t,
|
|
94552
|
+
kind: "doenet"
|
|
94553
|
+
});
|
|
94554
|
+
}, Pe = (e) => {
|
|
94555
|
+
let r = A.filter((t) => t.kind === e);
|
|
94556
|
+
return /* @__PURE__ */ n("div", {
|
|
94557
|
+
className: "pretext-plus-editor__am-library",
|
|
94558
|
+
children: [v && /* @__PURE__ */ n("div", {
|
|
94559
|
+
className: "pretext-plus-editor__am-toolbar",
|
|
94560
|
+
children: [D && /* @__PURE__ */ t("span", {
|
|
94561
|
+
className: "pretext-plus-editor__asset-load-error",
|
|
94562
|
+
children: D
|
|
94563
|
+
}), /* @__PURE__ */ t("button", {
|
|
94564
|
+
type: "button",
|
|
94565
|
+
className: "pretext-plus-editor__asset-library-refresh",
|
|
94566
|
+
onClick: De,
|
|
94567
|
+
disabled: T,
|
|
94568
|
+
children: T ? "Loading…" : "Refresh"
|
|
94569
|
+
})]
|
|
94570
|
+
}), T && r.length === 0 ? /* @__PURE__ */ t("p", {
|
|
94571
|
+
className: "pretext-plus-editor__am-empty-text",
|
|
94572
|
+
children: "Loading…"
|
|
94573
|
+
}) : r.length === 0 ? /* @__PURE__ */ n("p", {
|
|
94574
|
+
className: "pretext-plus-editor__am-empty-text",
|
|
94575
|
+
children: [
|
|
94576
|
+
"No ",
|
|
94577
|
+
n8[e].toLowerCase(),
|
|
94578
|
+
" assets in your library."
|
|
94579
|
+
]
|
|
94580
|
+
}) : /* @__PURE__ */ t("ul", {
|
|
94581
|
+
className: "pretext-plus-editor__am-list",
|
|
94582
|
+
children: r.map((e) => {
|
|
94583
|
+
let r = j.has(e.id), i = P === e.id;
|
|
94584
|
+
return /* @__PURE__ */ t("li", { children: /* @__PURE__ */ n("button", {
|
|
94585
|
+
type: "button",
|
|
94586
|
+
className: ["pretext-plus-editor__am-lib-row", r ? "pretext-plus-editor__am-lib-row--in-project" : ""].filter(Boolean).join(" "),
|
|
94587
|
+
onClick: () => Ae(e),
|
|
94588
|
+
disabled: i || !e.ref,
|
|
94589
|
+
title: e.ref ? r ? `Insert "${e.ref}"` : `Add to project & insert "${e.ref}"` : "Asset has no reference — cannot insert",
|
|
94590
|
+
children: [/* @__PURE__ */ n("div", {
|
|
94591
|
+
className: "pretext-plus-editor__am-row-info",
|
|
94592
|
+
children: [/* @__PURE__ */ t("span", {
|
|
94593
|
+
className: "pretext-plus-editor__am-row-name",
|
|
94594
|
+
children: e.name
|
|
94595
|
+
}), /* @__PURE__ */ t("span", {
|
|
94596
|
+
className: "pretext-plus-editor__am-row-ref",
|
|
94597
|
+
children: i ? "Adding…" : e.ref
|
|
94598
|
+
})]
|
|
94599
|
+
}), r && /* @__PURE__ */ t("span", {
|
|
94600
|
+
className: "pretext-plus-editor__am-badge",
|
|
94601
|
+
children: "✓"
|
|
94602
|
+
})]
|
|
94603
|
+
}) }, e.id);
|
|
94604
|
+
})
|
|
94605
|
+
})]
|
|
94606
|
+
});
|
|
95050
94607
|
};
|
|
95051
|
-
return {
|
|
95052
|
-
|
|
95053
|
-
|
|
95054
|
-
|
|
95055
|
-
|
|
94608
|
+
return /* @__PURE__ */ t("div", {
|
|
94609
|
+
className: "pretext-plus-editor__dialog-overlay",
|
|
94610
|
+
onClick: (e) => e.target === e.currentTarget && i(),
|
|
94611
|
+
children: /* @__PURE__ */ n("div", {
|
|
94612
|
+
className: "pretext-plus-editor__dialog pretext-plus-editor__dialog--asset-manager",
|
|
94613
|
+
role: "dialog",
|
|
94614
|
+
"aria-modal": "true",
|
|
94615
|
+
"aria-label": "Asset manager",
|
|
94616
|
+
children: [
|
|
94617
|
+
/* @__PURE__ */ n("div", {
|
|
94618
|
+
className: "pretext-plus-editor__dialog-header",
|
|
94619
|
+
children: [/* @__PURE__ */ t("h2", {
|
|
94620
|
+
className: "pretext-plus-editor__dialog-title",
|
|
94621
|
+
children: "Assets"
|
|
94622
|
+
}), /* @__PURE__ */ t("button", {
|
|
94623
|
+
type: "button",
|
|
94624
|
+
className: "pretext-plus-editor__dialog-close",
|
|
94625
|
+
onClick: i,
|
|
94626
|
+
"aria-label": "Close",
|
|
94627
|
+
children: "✕"
|
|
94628
|
+
})]
|
|
94629
|
+
}),
|
|
94630
|
+
/* @__PURE__ */ n("div", {
|
|
94631
|
+
className: "pretext-plus-editor__dialog-tab-bar",
|
|
94632
|
+
children: [/* @__PURE__ */ n("button", {
|
|
94633
|
+
type: "button",
|
|
94634
|
+
className: `pretext-plus-editor__dialog-tab${ee === "in-document" ? " pretext-plus-editor__dialog-tab--active" : ""}`,
|
|
94635
|
+
onClick: () => te("in-document"),
|
|
94636
|
+
children: ["In Document", Oe.length > 0 && /* @__PURE__ */ t("span", {
|
|
94637
|
+
className: "pretext-plus-editor__asset-tab-count",
|
|
94638
|
+
children: Oe.length
|
|
94639
|
+
})]
|
|
94640
|
+
}), /* @__PURE__ */ t("button", {
|
|
94641
|
+
type: "button",
|
|
94642
|
+
className: `pretext-plus-editor__dialog-tab${ee === "add" ? " pretext-plus-editor__dialog-tab--active" : ""}`,
|
|
94643
|
+
onClick: () => {
|
|
94644
|
+
te("add"), M(null);
|
|
94645
|
+
},
|
|
94646
|
+
children: "Add Asset"
|
|
94647
|
+
})]
|
|
94648
|
+
}),
|
|
94649
|
+
/* @__PURE__ */ t("div", {
|
|
94650
|
+
className: "pretext-plus-editor__dialog-content pretext-plus-editor__dialog-content--single",
|
|
94651
|
+
children: ee === "in-document" ? (() => {
|
|
94652
|
+
if (Oe.length === 0) return /* @__PURE__ */ n("div", {
|
|
94653
|
+
className: "pretext-plus-editor__am-placeholder",
|
|
94654
|
+
children: [/* @__PURE__ */ t("p", { children: "No assets referenced in this document yet." }), /* @__PURE__ */ t("button", {
|
|
94655
|
+
type: "button",
|
|
94656
|
+
className: "pretext-plus-editor__dialog-button",
|
|
94657
|
+
onClick: () => {
|
|
94658
|
+
te("add"), M(null);
|
|
94659
|
+
},
|
|
94660
|
+
children: "Add an asset"
|
|
94661
|
+
})]
|
|
94662
|
+
});
|
|
94663
|
+
let e = r8.reduce((e, t) => (e[t] = Oe.filter((e) => e.kind === t).map((e) => ({
|
|
94664
|
+
ref: e.ref,
|
|
94665
|
+
asset: k.find((t) => t.kind === e.kind && t.ref === e.ref)
|
|
94666
|
+
})), e), {
|
|
94667
|
+
image: [],
|
|
94668
|
+
doenet: []
|
|
94669
|
+
});
|
|
94670
|
+
return /* @__PURE__ */ t("div", {
|
|
94671
|
+
className: "pretext-plus-editor__am-in-doc",
|
|
94672
|
+
children: r8.filter((t) => e[t].length > 0).map((r) => /* @__PURE__ */ n("div", {
|
|
94673
|
+
className: "pretext-plus-editor__am-kind-group",
|
|
94674
|
+
children: [/* @__PURE__ */ n("div", {
|
|
94675
|
+
className: "pretext-plus-editor__am-kind-header",
|
|
94676
|
+
children: [
|
|
94677
|
+
/* @__PURE__ */ t("span", {
|
|
94678
|
+
"aria-hidden": "true",
|
|
94679
|
+
children: "📁"
|
|
94680
|
+
}),
|
|
94681
|
+
/* @__PURE__ */ t("span", { children: n8[r] }),
|
|
94682
|
+
/* @__PURE__ */ t("span", {
|
|
94683
|
+
className: "pretext-plus-editor__am-kind-count",
|
|
94684
|
+
children: e[r].length
|
|
94685
|
+
})
|
|
94686
|
+
]
|
|
94687
|
+
}), /* @__PURE__ */ t("ul", {
|
|
94688
|
+
className: "pretext-plus-editor__am-list",
|
|
94689
|
+
children: e[r].map(({ ref: e, asset: a }) => {
|
|
94690
|
+
let o = `${r}:${e}`;
|
|
94691
|
+
return /* @__PURE__ */ n("li", {
|
|
94692
|
+
className: "pretext-plus-editor__am-doc-row",
|
|
94693
|
+
children: [/* @__PURE__ */ n("div", {
|
|
94694
|
+
className: "pretext-plus-editor__am-row-info",
|
|
94695
|
+
children: [/* @__PURE__ */ t("span", {
|
|
94696
|
+
className: "pretext-plus-editor__am-row-name",
|
|
94697
|
+
children: a?.name ?? e
|
|
94698
|
+
}), /* @__PURE__ */ t("span", {
|
|
94699
|
+
className: "pretext-plus-editor__am-row-ref",
|
|
94700
|
+
children: e
|
|
94701
|
+
})]
|
|
94702
|
+
}), /* @__PURE__ */ n("div", {
|
|
94703
|
+
className: "pretext-plus-editor__am-row-actions",
|
|
94704
|
+
children: [
|
|
94705
|
+
a && /* @__PURE__ */ t("button", {
|
|
94706
|
+
type: "button",
|
|
94707
|
+
className: "pretext-plus-editor__am-action-btn",
|
|
94708
|
+
onClick: () => B(a),
|
|
94709
|
+
title: `Insert <plus:${r} ref="${e}"/>`,
|
|
94710
|
+
children: "Insert"
|
|
94711
|
+
}),
|
|
94712
|
+
/* @__PURE__ */ t("button", {
|
|
94713
|
+
type: "button",
|
|
94714
|
+
className: `pretext-plus-editor__am-action-btn${z === o ? " pretext-plus-editor__am-action-btn--done" : ""}`,
|
|
94715
|
+
onClick: () => ke(r, e),
|
|
94716
|
+
title: `Copy <plus:${r} ref="${e}"/>`,
|
|
94717
|
+
children: z === o ? "Copied!" : "Copy"
|
|
94718
|
+
}),
|
|
94719
|
+
p && a && /* @__PURE__ */ t("button", {
|
|
94720
|
+
type: "button",
|
|
94721
|
+
className: "pretext-plus-editor__am-action-btn pretext-plus-editor__am-action-btn--danger",
|
|
94722
|
+
onClick: () => {
|
|
94723
|
+
p(a), i();
|
|
94724
|
+
},
|
|
94725
|
+
title: "Remove from project",
|
|
94726
|
+
children: "Remove"
|
|
94727
|
+
})
|
|
94728
|
+
]
|
|
94729
|
+
})]
|
|
94730
|
+
}, e);
|
|
94731
|
+
})
|
|
94732
|
+
})]
|
|
94733
|
+
}, r))
|
|
94734
|
+
});
|
|
94735
|
+
})() : ne === null ? /* @__PURE__ */ n("div", {
|
|
94736
|
+
className: "pretext-plus-editor__am-kind-picker",
|
|
94737
|
+
children: [/* @__PURE__ */ t("p", {
|
|
94738
|
+
className: "pretext-plus-editor__am-kind-picker-label",
|
|
94739
|
+
children: "What kind of asset?"
|
|
94740
|
+
}), /* @__PURE__ */ n("div", {
|
|
94741
|
+
className: "pretext-plus-editor__am-kind-cards",
|
|
94742
|
+
children: [/* @__PURE__ */ n("button", {
|
|
94743
|
+
type: "button",
|
|
94744
|
+
className: "pretext-plus-editor__am-kind-card",
|
|
94745
|
+
onClick: () => {
|
|
94746
|
+
M("image"), re("library");
|
|
94747
|
+
},
|
|
94748
|
+
children: [
|
|
94749
|
+
/* @__PURE__ */ t("span", {
|
|
94750
|
+
className: "pretext-plus-editor__am-kind-card-icon",
|
|
94751
|
+
"aria-hidden": "true",
|
|
94752
|
+
children: "🖼️"
|
|
94753
|
+
}),
|
|
94754
|
+
/* @__PURE__ */ t("span", {
|
|
94755
|
+
className: "pretext-plus-editor__am-kind-card-label",
|
|
94756
|
+
children: "Image"
|
|
94757
|
+
}),
|
|
94758
|
+
/* @__PURE__ */ t("span", {
|
|
94759
|
+
className: "pretext-plus-editor__am-kind-card-hint",
|
|
94760
|
+
children: "PNG, JPEG, SVG, etc."
|
|
94761
|
+
})
|
|
94762
|
+
]
|
|
94763
|
+
}), /* @__PURE__ */ n("button", {
|
|
94764
|
+
type: "button",
|
|
94765
|
+
className: "pretext-plus-editor__am-kind-card",
|
|
94766
|
+
onClick: () => {
|
|
94767
|
+
M("doenet"), ae("library");
|
|
94768
|
+
},
|
|
94769
|
+
children: [
|
|
94770
|
+
/* @__PURE__ */ t("span", {
|
|
94771
|
+
className: "pretext-plus-editor__am-kind-card-icon",
|
|
94772
|
+
"aria-hidden": "true",
|
|
94773
|
+
children: /* @__PURE__ */ t("img", {
|
|
94774
|
+
src: t8,
|
|
94775
|
+
alt: "Doenet"
|
|
94776
|
+
})
|
|
94777
|
+
}),
|
|
94778
|
+
/* @__PURE__ */ t("span", {
|
|
94779
|
+
className: "pretext-plus-editor__am-kind-card-label",
|
|
94780
|
+
children: "Doenet"
|
|
94781
|
+
}),
|
|
94782
|
+
/* @__PURE__ */ t("span", {
|
|
94783
|
+
className: "pretext-plus-editor__am-kind-card-hint",
|
|
94784
|
+
children: "Interactive activity"
|
|
94785
|
+
})
|
|
94786
|
+
]
|
|
94787
|
+
})]
|
|
94788
|
+
})]
|
|
94789
|
+
}) : ne === "image" ? /* @__PURE__ */ n("div", {
|
|
94790
|
+
className: "pretext-plus-editor__am-configure",
|
|
94791
|
+
children: [
|
|
94792
|
+
/* @__PURE__ */ t("button", {
|
|
94793
|
+
type: "button",
|
|
94794
|
+
className: "pretext-plus-editor__am-back-btn",
|
|
94795
|
+
onClick: () => M(null),
|
|
94796
|
+
children: "← Back"
|
|
94797
|
+
}),
|
|
94798
|
+
/* @__PURE__ */ n("div", {
|
|
94799
|
+
className: "pretext-plus-editor__dialog-tab-bar pretext-plus-editor__am-sub-tabs",
|
|
94800
|
+
children: [
|
|
94801
|
+
/* @__PURE__ */ t("button", {
|
|
94802
|
+
type: "button",
|
|
94803
|
+
className: `pretext-plus-editor__dialog-tab${N === "library" ? " pretext-plus-editor__dialog-tab--active" : ""}`,
|
|
94804
|
+
onClick: () => re("library"),
|
|
94805
|
+
children: "Library"
|
|
94806
|
+
}),
|
|
94807
|
+
l && /* @__PURE__ */ t("button", {
|
|
94808
|
+
type: "button",
|
|
94809
|
+
className: `pretext-plus-editor__dialog-tab${N === "upload" ? " pretext-plus-editor__dialog-tab--active" : ""}`,
|
|
94810
|
+
onClick: () => re("upload"),
|
|
94811
|
+
children: "Upload"
|
|
94812
|
+
}),
|
|
94813
|
+
/* @__PURE__ */ t("button", {
|
|
94814
|
+
type: "button",
|
|
94815
|
+
className: `pretext-plus-editor__dialog-tab${N === "url" ? " pretext-plus-editor__dialog-tab--active" : ""}`,
|
|
94816
|
+
onClick: () => re("url"),
|
|
94817
|
+
children: "External URL"
|
|
94818
|
+
})
|
|
94819
|
+
]
|
|
94820
|
+
}),
|
|
94821
|
+
/* @__PURE__ */ n("div", {
|
|
94822
|
+
className: "pretext-plus-editor__am-configure-body",
|
|
94823
|
+
children: [
|
|
94824
|
+
N === "library" && Pe("image"),
|
|
94825
|
+
N === "upload" && l && /* @__PURE__ */ n("div", {
|
|
94826
|
+
className: "pretext-plus-editor__am-upload",
|
|
94827
|
+
children: [/* @__PURE__ */ n("div", {
|
|
94828
|
+
className: [
|
|
94829
|
+
"pretext-plus-editor__am-drop-zone",
|
|
94830
|
+
F ? "pretext-plus-editor__am-drop-zone--active" : "",
|
|
94831
|
+
ce ? "pretext-plus-editor__am-drop-zone--uploading" : ""
|
|
94832
|
+
].filter(Boolean).join(" "),
|
|
94833
|
+
onDragOver: (e) => {
|
|
94834
|
+
e.preventDefault(), se(!0);
|
|
94835
|
+
},
|
|
94836
|
+
onDragLeave: () => se(!1),
|
|
94837
|
+
onDrop: (e) => {
|
|
94838
|
+
e.preventDefault(), se(!1);
|
|
94839
|
+
let t = e.dataTransfer.files[0];
|
|
94840
|
+
t && je(t);
|
|
94841
|
+
},
|
|
94842
|
+
onClick: () => !ce && de.current?.click(),
|
|
94843
|
+
role: "button",
|
|
94844
|
+
tabIndex: 0,
|
|
94845
|
+
onKeyDown: (e) => {
|
|
94846
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), de.current?.click());
|
|
94847
|
+
},
|
|
94848
|
+
"aria-label": "Upload image — click or drag and drop",
|
|
94849
|
+
children: [/* @__PURE__ */ t("input", {
|
|
94850
|
+
ref: de,
|
|
94851
|
+
type: "file",
|
|
94852
|
+
accept: "image/*",
|
|
94853
|
+
className: "pretext-plus-editor__dialog-file-input",
|
|
94854
|
+
onChange: (e) => {
|
|
94855
|
+
let t = e.target.files?.[0];
|
|
94856
|
+
t && je(t);
|
|
94857
|
+
}
|
|
94858
|
+
}), ce ? /* @__PURE__ */ t("p", {
|
|
94859
|
+
className: "pretext-plus-editor__am-drop-text",
|
|
94860
|
+
children: "Uploading…"
|
|
94861
|
+
}) : /* @__PURE__ */ n(e, { children: [
|
|
94862
|
+
/* @__PURE__ */ t("span", {
|
|
94863
|
+
className: "pretext-plus-editor__am-drop-icon",
|
|
94864
|
+
"aria-hidden": "true",
|
|
94865
|
+
children: "↑"
|
|
94866
|
+
}),
|
|
94867
|
+
/* @__PURE__ */ t("p", {
|
|
94868
|
+
className: "pretext-plus-editor__am-drop-text",
|
|
94869
|
+
children: "Drag & drop an image, or click to browse"
|
|
94870
|
+
}),
|
|
94871
|
+
/* @__PURE__ */ t("p", {
|
|
94872
|
+
className: "pretext-plus-editor__dialog-helper-copy",
|
|
94873
|
+
children: "PNG, JPEG, GIF, SVG, WebP"
|
|
94874
|
+
})
|
|
94875
|
+
] })]
|
|
94876
|
+
}), ue && /* @__PURE__ */ t("p", {
|
|
94877
|
+
className: "pretext-plus-editor__am-error",
|
|
94878
|
+
children: ue
|
|
94879
|
+
})]
|
|
94880
|
+
}),
|
|
94881
|
+
N === "url" && /* @__PURE__ */ n("div", {
|
|
94882
|
+
className: "pretext-plus-editor__am-url-form",
|
|
94883
|
+
children: [
|
|
94884
|
+
/* @__PURE__ */ t("label", {
|
|
94885
|
+
className: "pretext-plus-editor__dialog-label",
|
|
94886
|
+
htmlFor: "am-url-value",
|
|
94887
|
+
children: "Image URL"
|
|
94888
|
+
}),
|
|
94889
|
+
/* @__PURE__ */ t("input", {
|
|
94890
|
+
id: "am-url-value",
|
|
94891
|
+
type: "url",
|
|
94892
|
+
className: "pretext-plus-editor__am-input",
|
|
94893
|
+
placeholder: "https://example.com/image.png",
|
|
94894
|
+
value: fe,
|
|
94895
|
+
onChange: (e) => pe(e.target.value),
|
|
94896
|
+
disabled: L,
|
|
94897
|
+
autoFocus: !0
|
|
94898
|
+
}),
|
|
94899
|
+
/* @__PURE__ */ n("label", {
|
|
94900
|
+
className: "pretext-plus-editor__dialog-label",
|
|
94901
|
+
htmlFor: "am-url-name",
|
|
94902
|
+
children: ["Name ", /* @__PURE__ */ t("span", {
|
|
94903
|
+
className: "pretext-plus-editor__dialog-helper-copy",
|
|
94904
|
+
children: "(optional)"
|
|
94905
|
+
})]
|
|
94906
|
+
}),
|
|
94907
|
+
/* @__PURE__ */ t("input", {
|
|
94908
|
+
id: "am-url-name",
|
|
94909
|
+
type: "text",
|
|
94910
|
+
className: "pretext-plus-editor__am-input",
|
|
94911
|
+
placeholder: "My image",
|
|
94912
|
+
value: me,
|
|
94913
|
+
onChange: (e) => he(e.target.value),
|
|
94914
|
+
disabled: L
|
|
94915
|
+
}),
|
|
94916
|
+
_e && /* @__PURE__ */ t("p", {
|
|
94917
|
+
className: "pretext-plus-editor__am-error",
|
|
94918
|
+
children: _e
|
|
94919
|
+
}),
|
|
94920
|
+
fe.trim() && /* @__PURE__ */ t("img", {
|
|
94921
|
+
src: fe.trim(),
|
|
94922
|
+
alt: "Preview",
|
|
94923
|
+
className: "pretext-plus-editor__am-url-preview",
|
|
94924
|
+
onError: (e) => {
|
|
94925
|
+
e.currentTarget.style.display = "none";
|
|
94926
|
+
}
|
|
94927
|
+
}),
|
|
94928
|
+
/* @__PURE__ */ t("button", {
|
|
94929
|
+
type: "button",
|
|
94930
|
+
className: "pretext-plus-editor__dialog-button",
|
|
94931
|
+
onClick: Me,
|
|
94932
|
+
disabled: !fe.trim() || L,
|
|
94933
|
+
children: L ? "Adding…" : u ? "Add to Library & Insert" : "Insert"
|
|
94934
|
+
})
|
|
94935
|
+
]
|
|
94936
|
+
})
|
|
94937
|
+
]
|
|
94938
|
+
})
|
|
94939
|
+
]
|
|
94940
|
+
}) : /* @__PURE__ */ n("div", {
|
|
94941
|
+
className: "pretext-plus-editor__am-configure",
|
|
94942
|
+
children: [
|
|
94943
|
+
/* @__PURE__ */ t("button", {
|
|
94944
|
+
type: "button",
|
|
94945
|
+
className: "pretext-plus-editor__am-back-btn",
|
|
94946
|
+
onClick: () => M(null),
|
|
94947
|
+
children: "← Back"
|
|
94948
|
+
}),
|
|
94949
|
+
/* @__PURE__ */ n("div", {
|
|
94950
|
+
className: "pretext-plus-editor__dialog-tab-bar pretext-plus-editor__am-sub-tabs",
|
|
94951
|
+
children: [/* @__PURE__ */ t("button", {
|
|
94952
|
+
type: "button",
|
|
94953
|
+
className: `pretext-plus-editor__dialog-tab${ie === "library" ? " pretext-plus-editor__dialog-tab--active" : ""}`,
|
|
94954
|
+
onClick: () => ae("library"),
|
|
94955
|
+
children: "Library"
|
|
94956
|
+
}), /* @__PURE__ */ t("button", {
|
|
94957
|
+
type: "button",
|
|
94958
|
+
className: `pretext-plus-editor__dialog-tab${ie === "create" ? " pretext-plus-editor__dialog-tab--active" : ""}`,
|
|
94959
|
+
onClick: () => ae("create"),
|
|
94960
|
+
children: "Create New"
|
|
94961
|
+
})]
|
|
94962
|
+
}),
|
|
94963
|
+
/* @__PURE__ */ n("div", {
|
|
94964
|
+
className: "pretext-plus-editor__am-configure-body",
|
|
94965
|
+
children: [ie === "library" && Pe("doenet"), ie === "create" && /* @__PURE__ */ n("div", {
|
|
94966
|
+
className: "pretext-plus-editor__am-create-form",
|
|
94967
|
+
children: [
|
|
94968
|
+
/* @__PURE__ */ t("label", {
|
|
94969
|
+
className: "pretext-plus-editor__dialog-label",
|
|
94970
|
+
htmlFor: "am-doenet-name",
|
|
94971
|
+
children: "Name"
|
|
94972
|
+
}),
|
|
94973
|
+
/* @__PURE__ */ t("input", {
|
|
94974
|
+
id: "am-doenet-name",
|
|
94975
|
+
type: "text",
|
|
94976
|
+
className: "pretext-plus-editor__am-input",
|
|
94977
|
+
placeholder: "My Activity",
|
|
94978
|
+
value: ye,
|
|
94979
|
+
onChange: (e) => be(e.target.value),
|
|
94980
|
+
disabled: R,
|
|
94981
|
+
autoFocus: !0
|
|
94982
|
+
}),
|
|
94983
|
+
/* @__PURE__ */ t("label", {
|
|
94984
|
+
className: "pretext-plus-editor__dialog-label",
|
|
94985
|
+
htmlFor: "am-doenet-ref",
|
|
94986
|
+
children: "Reference ID"
|
|
94987
|
+
}),
|
|
94988
|
+
/* @__PURE__ */ t("input", {
|
|
94989
|
+
id: "am-doenet-ref",
|
|
94990
|
+
type: "text",
|
|
94991
|
+
className: "pretext-plus-editor__am-input",
|
|
94992
|
+
placeholder: "my-activity",
|
|
94993
|
+
value: xe,
|
|
94994
|
+
onChange: (e) => Se(e.target.value),
|
|
94995
|
+
disabled: R
|
|
94996
|
+
}),
|
|
94997
|
+
/* @__PURE__ */ n("p", {
|
|
94998
|
+
className: "pretext-plus-editor__dialog-helper-copy",
|
|
94999
|
+
children: ["The reference ID is used in the inserted tag: ", /* @__PURE__ */ t("code", { children: `<plus:doenet ref="${xe || "my-activity"}"/>` })]
|
|
95000
|
+
}),
|
|
95001
|
+
we && /* @__PURE__ */ t("p", {
|
|
95002
|
+
className: "pretext-plus-editor__am-error",
|
|
95003
|
+
children: we
|
|
95004
|
+
}),
|
|
95005
|
+
/* @__PURE__ */ t("button", {
|
|
95006
|
+
type: "button",
|
|
95007
|
+
className: "pretext-plus-editor__dialog-button",
|
|
95008
|
+
onClick: Ne,
|
|
95009
|
+
disabled: !ye.trim() || !xe.trim() || R,
|
|
95010
|
+
children: R ? "Creating…" : f ? "Create & Insert" : "Insert"
|
|
95011
|
+
})
|
|
95012
|
+
]
|
|
95013
|
+
})]
|
|
95014
|
+
})
|
|
95015
|
+
]
|
|
95016
|
+
})
|
|
95017
|
+
}),
|
|
95018
|
+
/* @__PURE__ */ t("div", {
|
|
95019
|
+
className: "pretext-plus-editor__dialog-actions",
|
|
95020
|
+
children: /* @__PURE__ */ t("button", {
|
|
95021
|
+
type: "button",
|
|
95022
|
+
className: "pretext-plus-editor__dialog-button pretext-plus-editor__dialog-button--secondary",
|
|
95023
|
+
onClick: i,
|
|
95024
|
+
children: "Close"
|
|
95025
|
+
})
|
|
95026
|
+
})
|
|
95027
|
+
]
|
|
95056
95028
|
})
|
|
95057
|
-
};
|
|
95058
|
-
}
|
|
95059
|
-
function F6(e) {
|
|
95060
|
-
try {
|
|
95061
|
-
let t = t6(e).children.find((e) => e.type === "element");
|
|
95062
|
-
return t ? {
|
|
95063
|
-
xmlId: t.attributes?.["xml:id"] ?? "",
|
|
95064
|
-
label: t.attributes?.label ?? ""
|
|
95065
|
-
} : {
|
|
95066
|
-
xmlId: "",
|
|
95067
|
-
label: ""
|
|
95068
|
-
};
|
|
95069
|
-
} catch {
|
|
95070
|
-
return {
|
|
95071
|
-
xmlId: "",
|
|
95072
|
-
label: ""
|
|
95073
|
-
};
|
|
95074
|
-
}
|
|
95075
|
-
}
|
|
95076
|
-
function I6(e) {
|
|
95077
|
-
let t = _6(e);
|
|
95078
|
-
if (!t) return null;
|
|
95079
|
-
let n = t.children.find((e) => e.type === "element");
|
|
95080
|
-
return !n || !m6.has(n.name) ? null : {
|
|
95081
|
-
title: p6(n),
|
|
95082
|
-
type: n.name,
|
|
95083
|
-
xmlId: n.attributes?.["xml:id"] ?? "",
|
|
95084
|
-
label: n.attributes?.label ?? ""
|
|
95085
|
-
};
|
|
95086
|
-
}
|
|
95087
|
-
function L6(e, t) {
|
|
95088
|
-
let n = t.type ?? e.type, r = t.title ?? e.title;
|
|
95089
|
-
try {
|
|
95090
|
-
let i = t6(e.content).children.find((e) => e.type === "element");
|
|
95091
|
-
if (!i) return {
|
|
95092
|
-
...e,
|
|
95093
|
-
title: r,
|
|
95094
|
-
type: n
|
|
95095
|
-
};
|
|
95096
|
-
let a = {
|
|
95097
|
-
...i,
|
|
95098
|
-
name: n,
|
|
95099
|
-
attributes: { ...i.attributes }
|
|
95100
|
-
};
|
|
95101
|
-
t.xmlId !== void 0 && (t.xmlId === null || t.xmlId === "" ? delete a.attributes["xml:id"] : a.attributes["xml:id"] = t.xmlId), t.label !== void 0 && (t.label === null || t.label === "" ? delete a.attributes.label : a.attributes.label = t.label);
|
|
95102
|
-
let o = a.children.findIndex((e) => e.type === "element" && e.name === "title"), s = {
|
|
95103
|
-
type: "element",
|
|
95104
|
-
name: "title",
|
|
95105
|
-
attributes: {},
|
|
95106
|
-
children: [{
|
|
95107
|
-
type: "text",
|
|
95108
|
-
value: r
|
|
95109
|
-
}]
|
|
95110
|
-
};
|
|
95111
|
-
o === -1 ? a.children = [s, ...a.children] : a.children = [
|
|
95112
|
-
...a.children.slice(0, o),
|
|
95113
|
-
s,
|
|
95114
|
-
...a.children.slice(o + 1)
|
|
95115
|
-
];
|
|
95116
|
-
let c = qY({
|
|
95117
|
-
type: "root",
|
|
95118
|
-
children: [a]
|
|
95119
|
-
}), l = t.xmlId !== void 0 && t.xmlId !== null && t.xmlId !== "" ? t.xmlId : e.xmlId;
|
|
95120
|
-
return {
|
|
95121
|
-
...e,
|
|
95122
|
-
title: r,
|
|
95123
|
-
type: n,
|
|
95124
|
-
xmlId: l,
|
|
95125
|
-
content: c
|
|
95126
|
-
};
|
|
95127
|
-
} catch {
|
|
95128
|
-
return {
|
|
95129
|
-
...e,
|
|
95130
|
-
title: r,
|
|
95131
|
-
type: n
|
|
95132
|
-
};
|
|
95133
|
-
}
|
|
95134
|
-
}
|
|
95135
|
-
function R6(e) {
|
|
95136
|
-
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
95137
|
-
}
|
|
95138
|
-
function z6(e) {
|
|
95139
|
-
return `<plus:[a-z-]+\\s[^>]*${e === null ? "ref=\"([^\"]+)\"" : `ref="${R6(e)}"`}[^>]*?(?:/>|>\\s*</plus:[a-z-]+>)`;
|
|
95140
|
-
}
|
|
95141
|
-
function B6(e) {
|
|
95142
|
-
let t = [], n = new RegExp(z6(null), "g"), r;
|
|
95143
|
-
for (; (r = n.exec(e)) !== null;) t.push(r[1]);
|
|
95144
|
-
return t;
|
|
95145
|
-
}
|
|
95146
|
-
function V6(e) {
|
|
95147
|
-
let t = [], n = /<plus:([a-z-]+)\s[^>]*ref="([^"]+)"[^>]*?(?:\/>|>\s*<\/plus:[a-z-]+>)/g, r;
|
|
95148
|
-
for (; (r = n.exec(e)) !== null;) t.push({
|
|
95149
|
-
type: r[1],
|
|
95150
|
-
xmlId: r[2]
|
|
95151
95029
|
});
|
|
95152
|
-
|
|
95153
|
-
|
|
95154
|
-
|
|
95155
|
-
|
|
95156
|
-
|
|
95157
|
-
|
|
95158
|
-
|
|
95159
|
-
|
|
95160
|
-
|
|
95161
|
-
|
|
95162
|
-
|
|
95163
|
-
|
|
95164
|
-
|
|
95165
|
-
|
|
95166
|
-
|
|
95167
|
-
|
|
95168
|
-
|
|
95169
|
-
|
|
95170
|
-
|
|
95171
|
-
|
|
95172
|
-
|
|
95173
|
-
|
|
95174
|
-
|
|
95175
|
-
|
|
95176
|
-
|
|
95177
|
-
|
|
95178
|
-
|
|
95179
|
-
|
|
95180
|
-
|
|
95181
|
-
|
|
95182
|
-
|
|
95183
|
-
|
|
95184
|
-
|
|
95185
|
-
|
|
95186
|
-
|
|
95187
|
-
|
|
95188
|
-
|
|
95189
|
-
|
|
95190
|
-
|
|
95191
|
-
|
|
95192
|
-
|
|
95193
|
-
|
|
95194
|
-
|
|
95195
|
-
|
|
95196
|
-
|
|
95197
|
-
|
|
95198
|
-
|
|
95199
|
-
|
|
95200
|
-
|
|
95201
|
-
|
|
95202
|
-
|
|
95203
|
-
|
|
95204
|
-
|
|
95205
|
-
}
|
|
95206
|
-
|
|
95207
|
-
|
|
95208
|
-
}
|
|
95209
|
-
|
|
95210
|
-
|
|
95211
|
-
|
|
95212
|
-
|
|
95213
|
-
|
|
95214
|
-
|
|
95215
|
-
|
|
95216
|
-
|
|
95030
|
+
}, o8 = (e) => {
|
|
95031
|
+
let r = b3((e) => e.showFullPreview), i = b3((e) => e.setShowFullPreview), a = b3((e) => e.title), o = b3((e) => e.updateTitle), s;
|
|
95032
|
+
return s = e.showPreviewModeToggle === !1 ? null : /* @__PURE__ */ n("label", {
|
|
95033
|
+
className: "pretext-plus-editor__preview-toggle",
|
|
95034
|
+
children: [
|
|
95035
|
+
/* @__PURE__ */ t("input", {
|
|
95036
|
+
type: "checkbox",
|
|
95037
|
+
checked: !r,
|
|
95038
|
+
onChange: () => i(!r),
|
|
95039
|
+
className: "pretext-plus-editor__preview-toggle-input"
|
|
95040
|
+
}),
|
|
95041
|
+
/* @__PURE__ */ n("div", {
|
|
95042
|
+
className: "pretext-plus-editor__preview-toggle-container",
|
|
95043
|
+
children: [
|
|
95044
|
+
/* @__PURE__ */ t("span", {
|
|
95045
|
+
className: "pretext-plus-editor__preview-toggle-label",
|
|
95046
|
+
children: "Simple"
|
|
95047
|
+
}),
|
|
95048
|
+
/* @__PURE__ */ t("span", {
|
|
95049
|
+
className: `pretext-plus-editor__preview-toggle-slider ${r ? "pretext-plus-editor__preview-toggle-slider--active" : ""}`,
|
|
95050
|
+
children: /* @__PURE__ */ t("span", { className: `pretext-plus-editor__preview-toggle-dot ${r ? "pretext-plus-editor__preview-toggle-dot--active" : ""}` })
|
|
95051
|
+
}),
|
|
95052
|
+
/* @__PURE__ */ t("span", {
|
|
95053
|
+
className: "pretext-plus-editor__preview-toggle-label",
|
|
95054
|
+
children: "Full"
|
|
95055
|
+
})
|
|
95056
|
+
]
|
|
95057
|
+
}),
|
|
95058
|
+
/* @__PURE__ */ t("span", {
|
|
95059
|
+
className: "pretext-plus-editor__preview-toggle-caption",
|
|
95060
|
+
children: "Preview Mode"
|
|
95061
|
+
}),
|
|
95062
|
+
/* @__PURE__ */ t("input", {
|
|
95063
|
+
type: "checkbox",
|
|
95064
|
+
checked: r,
|
|
95065
|
+
onChange: () => i(!r),
|
|
95066
|
+
className: "pretext-plus-editor__preview-toggle-input"
|
|
95067
|
+
})
|
|
95068
|
+
]
|
|
95069
|
+
}), /* @__PURE__ */ n("div", {
|
|
95070
|
+
className: "pretext-plus-editor__menu-bar",
|
|
95071
|
+
children: [/* @__PURE__ */ t("div", {
|
|
95072
|
+
className: "pretext-plus-editor__menu-left",
|
|
95073
|
+
children: /* @__PURE__ */ n("label", {
|
|
95074
|
+
className: "pretext-plus-editor__title-label",
|
|
95075
|
+
children: [
|
|
95076
|
+
"Title",
|
|
95077
|
+
" ",
|
|
95078
|
+
/* @__PURE__ */ t("input", {
|
|
95079
|
+
className: "pretext-plus-editor__title-input",
|
|
95080
|
+
type: "text",
|
|
95081
|
+
value: a,
|
|
95082
|
+
onChange: (e) => o(e.target.value)
|
|
95083
|
+
})
|
|
95084
|
+
]
|
|
95085
|
+
})
|
|
95086
|
+
}), /* @__PURE__ */ n("div", {
|
|
95087
|
+
className: "pretext-plus-editor__menu-right",
|
|
95088
|
+
children: [
|
|
95089
|
+
e.onSaveButton && /* @__PURE__ */ t("button", {
|
|
95090
|
+
className: "pretext-plus-editor__button pretext-plus-editor__button--save",
|
|
95091
|
+
onClick: e.onSaveButton,
|
|
95092
|
+
children: e.saveButtonLabel || "Save"
|
|
95093
|
+
}),
|
|
95094
|
+
e.onCancelButton && /* @__PURE__ */ t("button", {
|
|
95095
|
+
className: "pretext-plus-editor__button pretext-plus-editor__button--cancel",
|
|
95096
|
+
onClick: e.onCancelButton,
|
|
95097
|
+
children: e.cancelButtonLabel || "Cancel"
|
|
95098
|
+
}),
|
|
95099
|
+
/* @__PURE__ */ t(x3, {
|
|
95100
|
+
label: "Give feedback",
|
|
95101
|
+
context: "main-editor"
|
|
95102
|
+
}),
|
|
95103
|
+
s
|
|
95104
|
+
]
|
|
95105
|
+
})]
|
|
95106
|
+
});
|
|
95107
|
+
}, s8 = {
|
|
95108
|
+
book: "Book",
|
|
95109
|
+
article: "Article",
|
|
95110
|
+
slideshow: "Slideshow",
|
|
95111
|
+
part: "Part",
|
|
95112
|
+
chapter: "Chapter",
|
|
95113
|
+
section: "Section",
|
|
95114
|
+
worksheet: "Worksheet",
|
|
95115
|
+
handout: "Handout",
|
|
95116
|
+
exercises: "Exercises",
|
|
95117
|
+
references: "References",
|
|
95118
|
+
glossary: "Glossary",
|
|
95119
|
+
solutions: "Solutions",
|
|
95120
|
+
"reading-questions": "Reading Questions",
|
|
95121
|
+
introduction: "Introduction",
|
|
95122
|
+
conclusion: "Conclusion"
|
|
95123
|
+
}, c8 = [
|
|
95124
|
+
"part",
|
|
95125
|
+
"chapter",
|
|
95126
|
+
"section",
|
|
95127
|
+
"worksheet",
|
|
95128
|
+
"handout",
|
|
95129
|
+
"exercises",
|
|
95130
|
+
"references",
|
|
95131
|
+
"glossary",
|
|
95132
|
+
"solutions",
|
|
95133
|
+
"reading-questions"
|
|
95134
|
+
], l8 = ({ draft: r, isLatex: i, isRoot: a = !1, onDraftChange: o, onCommit: s, onCancel: c }) => /* @__PURE__ */ n("div", {
|
|
95135
|
+
className: "pretext-plus-editor__toc-edit-form",
|
|
95136
|
+
children: [
|
|
95137
|
+
/* @__PURE__ */ n("label", {
|
|
95138
|
+
className: "pretext-plus-editor__toc-edit-field",
|
|
95139
|
+
children: [/* @__PURE__ */ t("span", { children: "Title" }), /* @__PURE__ */ t("input", {
|
|
95140
|
+
type: "text",
|
|
95141
|
+
value: r.title,
|
|
95142
|
+
onChange: (e) => o({
|
|
95143
|
+
...r,
|
|
95144
|
+
title: e.target.value
|
|
95145
|
+
}),
|
|
95146
|
+
onKeyDown: (e) => {
|
|
95147
|
+
e.key === "Enter" && s(), e.key === "Escape" && c();
|
|
95148
|
+
},
|
|
95149
|
+
autoFocus: !0
|
|
95150
|
+
})]
|
|
95151
|
+
}),
|
|
95152
|
+
!i && /* @__PURE__ */ n(e, { children: [
|
|
95153
|
+
!a && /* @__PURE__ */ n("label", {
|
|
95154
|
+
className: "pretext-plus-editor__toc-edit-field",
|
|
95155
|
+
children: [/* @__PURE__ */ t("span", { children: "Type" }), /* @__PURE__ */ t("select", {
|
|
95156
|
+
value: r.type,
|
|
95157
|
+
onChange: (e) => o({
|
|
95158
|
+
...r,
|
|
95159
|
+
type: e.target.value
|
|
95160
|
+
}),
|
|
95161
|
+
children: c8.map((e) => /* @__PURE__ */ t("option", {
|
|
95162
|
+
value: e,
|
|
95163
|
+
children: s8[e]
|
|
95164
|
+
}, e))
|
|
95165
|
+
})]
|
|
95166
|
+
}),
|
|
95167
|
+
/* @__PURE__ */ n("label", {
|
|
95168
|
+
className: "pretext-plus-editor__toc-edit-field",
|
|
95169
|
+
children: [/* @__PURE__ */ t("span", { children: "xml:id" }), /* @__PURE__ */ t("input", {
|
|
95170
|
+
type: "text",
|
|
95171
|
+
value: r.xmlId,
|
|
95172
|
+
placeholder: "optional",
|
|
95173
|
+
onChange: (e) => o({
|
|
95174
|
+
...r,
|
|
95175
|
+
xmlId: e.target.value
|
|
95176
|
+
})
|
|
95177
|
+
})]
|
|
95178
|
+
}),
|
|
95179
|
+
/* @__PURE__ */ n("label", {
|
|
95180
|
+
className: "pretext-plus-editor__toc-edit-field",
|
|
95181
|
+
children: [/* @__PURE__ */ t("span", { children: "label" }), /* @__PURE__ */ t("input", {
|
|
95182
|
+
type: "text",
|
|
95183
|
+
value: r.label,
|
|
95184
|
+
placeholder: "optional",
|
|
95185
|
+
onChange: (e) => o({
|
|
95186
|
+
...r,
|
|
95187
|
+
label: e.target.value
|
|
95188
|
+
})
|
|
95189
|
+
})]
|
|
95190
|
+
})
|
|
95191
|
+
] }),
|
|
95192
|
+
/* @__PURE__ */ n("div", {
|
|
95193
|
+
className: "pretext-plus-editor__toc-edit-actions",
|
|
95194
|
+
children: [/* @__PURE__ */ t("button", {
|
|
95195
|
+
type: "button",
|
|
95196
|
+
className: "pretext-plus-editor__toc-edit-save",
|
|
95197
|
+
onClick: s,
|
|
95198
|
+
children: "Save"
|
|
95199
|
+
}), /* @__PURE__ */ t("button", {
|
|
95200
|
+
type: "button",
|
|
95201
|
+
className: "pretext-plus-editor__toc-edit-cancel",
|
|
95202
|
+
onClick: c,
|
|
95203
|
+
children: "Cancel"
|
|
95204
|
+
})]
|
|
95205
|
+
})
|
|
95206
|
+
]
|
|
95207
|
+
});
|
|
95208
|
+
//#endregion
|
|
95209
|
+
//#region src/components/toc/DivisionMenu.tsx
|
|
95210
|
+
function u8(e) {
|
|
95211
|
+
let t = e?.parentElement ?? null;
|
|
95212
|
+
for (; t;) {
|
|
95213
|
+
let { overflowY: e } = getComputedStyle(t);
|
|
95214
|
+
if ((e === "auto" || e === "scroll") && t.scrollHeight > t.clientHeight) return t;
|
|
95215
|
+
t = t.parentElement;
|
|
95217
95216
|
}
|
|
95218
|
-
return
|
|
95219
|
-
}
|
|
95220
|
-
function Z6(e, t) {
|
|
95221
|
-
let n = X6(e, t);
|
|
95222
|
-
return e.filter((e) => !n.has(e.xmlId));
|
|
95217
|
+
return null;
|
|
95223
95218
|
}
|
|
95224
|
-
|
|
95225
|
-
let
|
|
95226
|
-
|
|
95227
|
-
if (
|
|
95228
|
-
|
|
95229
|
-
|
|
95230
|
-
|
|
95231
|
-
|
|
95232
|
-
|
|
95233
|
-
|
|
95234
|
-
|
|
95235
|
-
}
|
|
95219
|
+
var d8 = ({ items: e }) => {
|
|
95220
|
+
let [r, i] = b(!1), [a, o] = b("below"), s = y(null), c = y(null);
|
|
95221
|
+
m(() => {
|
|
95222
|
+
if (!r) return;
|
|
95223
|
+
let e = (e) => {
|
|
95224
|
+
s.current && !s.current.contains(e.target) && i(!1);
|
|
95225
|
+
}, t = (e) => {
|
|
95226
|
+
e.key === "Escape" && i(!1);
|
|
95227
|
+
};
|
|
95228
|
+
return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
|
|
95229
|
+
document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
|
|
95230
|
+
};
|
|
95231
|
+
}, [r]), _(() => {
|
|
95232
|
+
if (!r) return;
|
|
95233
|
+
let e = c.current, t = s.current;
|
|
95234
|
+
if (!e || !t) return;
|
|
95235
|
+
let n = u8(t) ?? document.documentElement, i = e.getBoundingClientRect(), a = n.getBoundingClientRect(), l = t.getBoundingClientRect(), u = a.bottom - l.bottom, d = l.top - a.top;
|
|
95236
|
+
o(i.height > u && d > u ? "above" : "below");
|
|
95237
|
+
}, [r]);
|
|
95238
|
+
let l = (e) => {
|
|
95239
|
+
i(!1), e();
|
|
95236
95240
|
};
|
|
95237
|
-
return
|
|
95238
|
-
|
|
95239
|
-
|
|
95240
|
-
|
|
95241
|
-
|
|
95242
|
-
|
|
95243
|
-
|
|
95244
|
-
|
|
95245
|
-
|
|
95246
|
-
|
|
95247
|
-
|
|
95248
|
-
|
|
95249
|
-
|
|
95250
|
-
|
|
95251
|
-
|
|
95252
|
-
|
|
95253
|
-
|
|
95254
|
-
|
|
95255
|
-
|
|
95241
|
+
return /* @__PURE__ */ n("div", {
|
|
95242
|
+
ref: s,
|
|
95243
|
+
className: "pretext-plus-editor__toc-div-menu",
|
|
95244
|
+
children: [/* @__PURE__ */ t("button", {
|
|
95245
|
+
type: "button",
|
|
95246
|
+
className: "pretext-plus-editor__toc-div-menu-trigger",
|
|
95247
|
+
onClick: (e) => {
|
|
95248
|
+
e.stopPropagation(), i((e) => (e || o("below"), !e));
|
|
95249
|
+
},
|
|
95250
|
+
"aria-haspopup": "true",
|
|
95251
|
+
"aria-expanded": r,
|
|
95252
|
+
title: "More options",
|
|
95253
|
+
children: "⋮"
|
|
95254
|
+
}), r && /* @__PURE__ */ t("div", {
|
|
95255
|
+
ref: c,
|
|
95256
|
+
className: ["pretext-plus-editor__toc-div-menu-popup", a === "above" ? "pretext-plus-editor__toc-div-menu-popup--above" : "pretext-plus-editor__toc-div-menu-popup--below"].join(" "),
|
|
95257
|
+
children: e.map((e) => /* @__PURE__ */ t("button", {
|
|
95258
|
+
type: "button",
|
|
95259
|
+
className: ["pretext-plus-editor__toc-div-menu-item", e.danger ? "pretext-plus-editor__toc-div-menu-item--danger" : ""].filter(Boolean).join(" "),
|
|
95260
|
+
onClick: () => l(e.onClick),
|
|
95261
|
+
children: e.label
|
|
95262
|
+
}, e.label))
|
|
95263
|
+
})]
|
|
95264
|
+
});
|
|
95265
|
+
}, f8 = ({ division: e, depth: r, isActive: i, hasChildren: a, isExpanded: o, onToggleExpand: s, editDraft: c, onSelect: l, onDraftChange: u, onEditCommit: d, onEditCancel: f, menuItems: p, isLatex: m, isRoot: h = !1 }) => {
|
|
95266
|
+
let g = c !== null;
|
|
95267
|
+
return /* @__PURE__ */ n("li", {
|
|
95268
|
+
className: [
|
|
95269
|
+
"pretext-plus-editor__toc-item",
|
|
95270
|
+
`pretext-plus-editor__toc-item--${e.type}`,
|
|
95271
|
+
i ? "pretext-plus-editor__toc-item--active" : "",
|
|
95272
|
+
g ? "pretext-plus-editor__toc-item--editing" : ""
|
|
95273
|
+
].filter(Boolean).join(" "),
|
|
95274
|
+
children: [/* @__PURE__ */ n("div", {
|
|
95275
|
+
className: "pretext-plus-editor__toc-item-row",
|
|
95276
|
+
style: r > 0 ? { paddingLeft: `${r * 14}px` } : void 0,
|
|
95277
|
+
children: [
|
|
95278
|
+
/* @__PURE__ */ t("button", {
|
|
95279
|
+
type: "button",
|
|
95280
|
+
className: "pretext-plus-editor__toc-expand-btn",
|
|
95281
|
+
onClick: s,
|
|
95282
|
+
"aria-label": o ? "Collapse" : "Expand",
|
|
95283
|
+
tabIndex: a ? 0 : -1,
|
|
95284
|
+
style: { visibility: a ? "visible" : "hidden" },
|
|
95285
|
+
children: o ? "▾" : "▸"
|
|
95286
|
+
}),
|
|
95287
|
+
/* @__PURE__ */ t("button", {
|
|
95288
|
+
type: "button",
|
|
95289
|
+
className: "pretext-plus-editor__toc-select",
|
|
95290
|
+
onClick: l,
|
|
95291
|
+
"aria-current": i ? "true" : void 0,
|
|
95292
|
+
title: s8[e.type] ?? e.type,
|
|
95293
|
+
children: /* @__PURE__ */ t("span", {
|
|
95294
|
+
className: "pretext-plus-editor__toc-title",
|
|
95295
|
+
children: e.title || /* @__PURE__ */ t("em", { children: "Untitled" })
|
|
95296
|
+
})
|
|
95297
|
+
}),
|
|
95298
|
+
/* @__PURE__ */ t("div", {
|
|
95299
|
+
className: "pretext-plus-editor__toc-actions",
|
|
95300
|
+
children: /* @__PURE__ */ t(d8, { items: p })
|
|
95301
|
+
})
|
|
95302
|
+
]
|
|
95303
|
+
}), g && c && /* @__PURE__ */ t(l8, {
|
|
95304
|
+
draft: c,
|
|
95305
|
+
isLatex: m,
|
|
95306
|
+
isRoot: h,
|
|
95307
|
+
onDraftChange: u,
|
|
95308
|
+
onCommit: d,
|
|
95309
|
+
onCancel: f
|
|
95310
|
+
})]
|
|
95311
|
+
});
|
|
95312
|
+
}, p8 = {
|
|
95313
|
+
image: "Images",
|
|
95314
|
+
doenet: "Doenet"
|
|
95315
|
+
}, m8 = ["image", "doenet"], h8 = ({ onOpenAssetPicker: r }) => {
|
|
95316
|
+
let i = b3((e) => e.divisions), o = b3((e) => e.rootDivisionId), s = b3((e) => e.activeDivisionId), c = b3((e) => e.projectAssets) ?? [], l = b3((e) => e.selectSection), u = b3((e) => e.removeSection), d = b3((e) => e.divisionContentChange), f = b3((e) => e.insertAtCursor), p = b3((e) => e.startSectionEdit), h = b3((e) => e.setEditDraft), g = b3((e) => e.commitSectionEdit), _ = b3((e) => e.cancelSectionEdit), v = b3((e) => e.editingId), y = b3((e) => e.editDraft), x = i ? i.find((e) => e.xmlId === o) ?? i.find((e) => e.type === "book" || e.type === "article" || e.type === "slideshow") ?? i[0] ?? null : null, S = x && i ? U6(i, x.xmlId) : [], C = x && i ? W6(i, x.xmlId) : [], w = (() => {
|
|
95317
|
+
if (!i) return [];
|
|
95318
|
+
let e = /* @__PURE__ */ new Set(), t = [];
|
|
95319
|
+
for (let n of i) for (let r of M6(n.content)) {
|
|
95320
|
+
let n = `${r.kind}:${r.ref}`;
|
|
95321
|
+
e.has(n) || (e.add(n), t.push(r));
|
|
95256
95322
|
}
|
|
95257
|
-
return
|
|
95258
|
-
}
|
|
95259
|
-
|
|
95260
|
-
|
|
95261
|
-
}
|
|
95262
|
-
|
|
95263
|
-
return e.type === "element" && e.attributes?.label === t ? !0 : "children" in e && e.children ? e.children.some((e) => e.type === "element" ? n8(e, t) : !1) : !1;
|
|
95264
|
-
}
|
|
95265
|
-
function r8(e, t) {
|
|
95266
|
-
let n = t, r = 1;
|
|
95267
|
-
for (; n8(e, n);) n = `${t}-${r}`, r++;
|
|
95268
|
-
return n;
|
|
95269
|
-
}
|
|
95270
|
-
function i8(e, t, n) {
|
|
95271
|
-
let r = t.find((t) => t.xmlId === e);
|
|
95272
|
-
if (!r) return `<!-- missing division: ${e} -->`;
|
|
95273
|
-
if (n.has(e)) return `<!-- circular reference: ${e} -->`;
|
|
95274
|
-
let i;
|
|
95275
|
-
if (r.sourceFormat === "pretext") i = r.content;
|
|
95276
|
-
else {
|
|
95277
|
-
let { pretextSource: e, pretextError: t } = f3(r.sourceFormat === "latex" ? E6(r.content, r.type) : C6(r.content), r.sourceFormat), n = e ?? `<!-- conversion error: ${t} -->`;
|
|
95278
|
-
i = `<${r.type} xml:id="${r.xmlId}">\n<title>${r.title}</title>\n\n${n}\n</${r.type}>`;
|
|
95279
|
-
}
|
|
95280
|
-
if (r.sourceFormat !== "pretext") return i;
|
|
95281
|
-
let a = new Set(n).add(e);
|
|
95282
|
-
return i.replace(/<plus:[a-z-]+\s[^>]*ref="([^"]+)"[^>]*?(?:\/>|>\s*<\/plus:[a-z-]+>)/g, (e, n) => i8(n, t, a));
|
|
95283
|
-
}
|
|
95284
|
-
function a8(e, t) {
|
|
95285
|
-
return t8(i8(t, e, /* @__PURE__ */ new Set()));
|
|
95286
|
-
}
|
|
95287
|
-
function o8(e, t) {
|
|
95288
|
-
return t8(`<pretext>\n${t.trim() ? `${t.trim()}\n` : ""}${e}\n</pretext>`);
|
|
95289
|
-
}
|
|
95290
|
-
function s8(e, t, n) {
|
|
95291
|
-
return o8(i8(t, e, /* @__PURE__ */ new Set()), n);
|
|
95292
|
-
}
|
|
95293
|
-
var c8 = new Set(["part", "chapter"]);
|
|
95294
|
-
function l8(e, t, n, r) {
|
|
95295
|
-
return o8(e8.has(e) ? t : c8.has(e) ? `<book>\n<title>${r}</title>\n${t}\n</book>` : `<article>\n<title>${r}</title>\n${t}\n</article>`, n);
|
|
95296
|
-
}
|
|
95297
|
-
//#endregion
|
|
95298
|
-
//#region src/components/toc/ArticleToc.tsx
|
|
95299
|
-
var u8 = ({ onOpenAssetPicker: r }) => {
|
|
95300
|
-
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) => {
|
|
95301
|
-
w((t) => {
|
|
95323
|
+
return t;
|
|
95324
|
+
})(), T = m8.map((e) => ({
|
|
95325
|
+
kind: e,
|
|
95326
|
+
items: w.filter((t) => t.kind === e)
|
|
95327
|
+
})).filter((e) => e.items.length > 0), [E, D] = b(!1), [O, k] = b(/* @__PURE__ */ new Set()), A = (e) => !O.has(e), j = (e) => {
|
|
95328
|
+
k((t) => {
|
|
95302
95329
|
let n = new Set(t);
|
|
95303
95330
|
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
95304
95331
|
});
|
|
95305
95332
|
};
|
|
95306
95333
|
m(() => {
|
|
95307
|
-
if (!s || !
|
|
95308
|
-
let e = new Map(
|
|
95309
|
-
t.add(
|
|
95334
|
+
if (!s || !x) return;
|
|
95335
|
+
let e = new Map(S.map((e) => [e.division.xmlId, e])), t = /* @__PURE__ */ new Set();
|
|
95336
|
+
t.add(x.xmlId);
|
|
95310
95337
|
let n = s;
|
|
95311
95338
|
for (; n;) {
|
|
95312
95339
|
let r = e.get(n);
|
|
95313
95340
|
if (!r?.parentXmlId) break;
|
|
95314
95341
|
t.add(r.parentXmlId), n = r.parentXmlId;
|
|
95315
95342
|
}
|
|
95316
|
-
|
|
95343
|
+
k((e) => {
|
|
95317
95344
|
if ([...t].every((t) => !e.has(t))) return e;
|
|
95318
95345
|
let n = new Set(e);
|
|
95319
95346
|
return t.forEach((e) => n.delete(e)), n;
|
|
95320
95347
|
});
|
|
95321
95348
|
}, [s]);
|
|
95322
|
-
let
|
|
95323
|
-
if (
|
|
95349
|
+
let ee = new Set(S.map((e) => e.parentXmlId).filter(Boolean)), te = [];
|
|
95350
|
+
if (x) {
|
|
95324
95351
|
let e = /* @__PURE__ */ new Set();
|
|
95325
|
-
|
|
95326
|
-
for (let t of
|
|
95352
|
+
A(x.xmlId) && e.add(x.xmlId);
|
|
95353
|
+
for (let t of S) t.parentXmlId && e.has(t.parentXmlId) && (te.push(t), A(t.division.xmlId) && e.add(t.division.xmlId));
|
|
95327
95354
|
}
|
|
95328
|
-
let
|
|
95355
|
+
let ne = (e, t) => {
|
|
95329
95356
|
if (!i) return;
|
|
95330
95357
|
let n = i.find((e) => e.xmlId === t);
|
|
95331
|
-
n &&
|
|
95332
|
-
},
|
|
95358
|
+
n && d(n.xmlId, B6(F6(n.content, e)));
|
|
95359
|
+
}, M = (e, t) => {
|
|
95333
95360
|
if (window.confirm(`Delete "${e.title || "Untitled"}"? This permanently removes the division.`)) {
|
|
95334
95361
|
if (t && i) {
|
|
95335
95362
|
let n = i.find((e) => e.xmlId === t);
|
|
95336
|
-
n &&
|
|
95363
|
+
n && d(n.xmlId, B6(F6(n.content, e.xmlId)));
|
|
95337
95364
|
}
|
|
95338
|
-
|
|
95365
|
+
u(e.xmlId);
|
|
95339
95366
|
}
|
|
95340
|
-
},
|
|
95341
|
-
|
|
95342
|
-
},
|
|
95343
|
-
|
|
95367
|
+
}, N = (e) => {
|
|
95368
|
+
f(`<plus:${e.type} ref="${e.xmlId}"/>`);
|
|
95369
|
+
}, re = (e) => {
|
|
95370
|
+
x && d(x.xmlId, B6(P6(x.content, e.xmlId, e.type, null)));
|
|
95371
|
+
}, ie = (e, t) => {
|
|
95372
|
+
f(`<plus:${e} ref="${t}"/>`);
|
|
95344
95373
|
};
|
|
95345
95374
|
return /* @__PURE__ */ n(e, { children: [
|
|
95346
95375
|
/* @__PURE__ */ n("ul", {
|
|
95347
95376
|
className: "pretext-plus-editor__toc-list",
|
|
95348
95377
|
role: "list",
|
|
95349
95378
|
children: [
|
|
95350
|
-
|
|
95351
|
-
division:
|
|
95379
|
+
x && /* @__PURE__ */ t(f8, {
|
|
95380
|
+
division: x,
|
|
95352
95381
|
depth: 0,
|
|
95353
|
-
isActive: s ===
|
|
95354
|
-
hasChildren:
|
|
95355
|
-
isExpanded:
|
|
95356
|
-
onToggleExpand: () =>
|
|
95357
|
-
editDraft:
|
|
95358
|
-
onSelect: () =>
|
|
95359
|
-
onDraftChange:
|
|
95360
|
-
onEditCommit:
|
|
95361
|
-
onEditCancel:
|
|
95382
|
+
isActive: s === x.xmlId,
|
|
95383
|
+
hasChildren: ee.has(x.xmlId),
|
|
95384
|
+
isExpanded: A(x.xmlId),
|
|
95385
|
+
onToggleExpand: () => j(x.xmlId),
|
|
95386
|
+
editDraft: v === x.xmlId ? y : null,
|
|
95387
|
+
onSelect: () => l(x.xmlId),
|
|
95388
|
+
onDraftChange: h,
|
|
95389
|
+
onEditCommit: g,
|
|
95390
|
+
onEditCancel: _,
|
|
95362
95391
|
menuItems: [{
|
|
95363
95392
|
label: "Edit properties",
|
|
95364
|
-
onClick: () =>
|
|
95393
|
+
onClick: () => p(x)
|
|
95365
95394
|
}],
|
|
95366
|
-
isLatex:
|
|
95395
|
+
isLatex: x.sourceFormat === "latex",
|
|
95367
95396
|
isRoot: !0
|
|
95368
95397
|
}),
|
|
95369
|
-
|
|
95398
|
+
te.length === 0 && x && A(x.xmlId) && /* @__PURE__ */ t("li", {
|
|
95370
95399
|
className: "pretext-plus-editor__toc-no-sections",
|
|
95371
95400
|
children: /* @__PURE__ */ t("span", { children: "No placed divisions" })
|
|
95372
95401
|
}),
|
|
95373
|
-
|
|
95402
|
+
te.map((e) => /* @__PURE__ */ t(f8, {
|
|
95374
95403
|
division: e.division,
|
|
95375
95404
|
depth: e.depth + 1,
|
|
95376
95405
|
isActive: s === e.division.xmlId,
|
|
95377
|
-
hasChildren:
|
|
95378
|
-
isExpanded:
|
|
95379
|
-
onToggleExpand: () =>
|
|
95380
|
-
editDraft:
|
|
95381
|
-
onSelect: () =>
|
|
95382
|
-
onDraftChange:
|
|
95383
|
-
onEditCommit:
|
|
95384
|
-
onEditCancel:
|
|
95406
|
+
hasChildren: ee.has(e.division.xmlId),
|
|
95407
|
+
isExpanded: A(e.division.xmlId),
|
|
95408
|
+
onToggleExpand: () => j(e.division.xmlId),
|
|
95409
|
+
editDraft: v === e.division.xmlId ? y : null,
|
|
95410
|
+
onSelect: () => l(e.division.xmlId),
|
|
95411
|
+
onDraftChange: h,
|
|
95412
|
+
onEditCommit: g,
|
|
95413
|
+
onEditCancel: _,
|
|
95385
95414
|
menuItems: [
|
|
95386
95415
|
{
|
|
95387
95416
|
label: "Edit properties",
|
|
95388
|
-
onClick: () =>
|
|
95417
|
+
onClick: () => p(e.division)
|
|
95389
95418
|
},
|
|
95390
95419
|
{
|
|
95391
95420
|
label: "Remove from document",
|
|
95392
|
-
onClick: () =>
|
|
95421
|
+
onClick: () => ne(e.division.xmlId, e.parentXmlId)
|
|
95393
95422
|
},
|
|
95394
95423
|
{
|
|
95395
95424
|
label: "Delete from project",
|
|
95396
|
-
onClick: () =>
|
|
95425
|
+
onClick: () => M(e.division, e.parentXmlId),
|
|
95397
95426
|
danger: !0
|
|
95398
95427
|
}
|
|
95399
95428
|
],
|
|
@@ -95401,71 +95430,71 @@ var u8 = ({ onOpenAssetPicker: r }) => {
|
|
|
95401
95430
|
}, e.division.xmlId))
|
|
95402
95431
|
]
|
|
95403
95432
|
}),
|
|
95404
|
-
|
|
95433
|
+
C.length > 0 && /* @__PURE__ */ n("div", {
|
|
95405
95434
|
className: "pretext-plus-editor__toc-orphans",
|
|
95406
95435
|
children: [/* @__PURE__ */ t("div", {
|
|
95407
95436
|
className: "pretext-plus-editor__toc-orphans-heading",
|
|
95408
95437
|
children: "Unplaced divisions"
|
|
95409
95438
|
}), /* @__PURE__ */ t("ul", {
|
|
95410
95439
|
className: "pretext-plus-editor__toc-list",
|
|
95411
|
-
children:
|
|
95412
|
-
let r = i ?
|
|
95413
|
-
return /* @__PURE__ */ n(a, { children: [/* @__PURE__ */ t(
|
|
95440
|
+
children: C.map((e) => {
|
|
95441
|
+
let r = i ? U6(i, e.xmlId) : [], o = new Set(r.map((e) => e.parentXmlId).filter(Boolean));
|
|
95442
|
+
return /* @__PURE__ */ n(a, { children: [/* @__PURE__ */ t(f8, {
|
|
95414
95443
|
division: e,
|
|
95415
95444
|
depth: 0,
|
|
95416
95445
|
isActive: s === e.xmlId,
|
|
95417
95446
|
hasChildren: o.has(e.xmlId),
|
|
95418
|
-
isExpanded:
|
|
95419
|
-
onToggleExpand: () =>
|
|
95420
|
-
editDraft:
|
|
95421
|
-
onSelect: () =>
|
|
95422
|
-
onDraftChange:
|
|
95423
|
-
onEditCommit:
|
|
95424
|
-
onEditCancel:
|
|
95447
|
+
isExpanded: A(e.xmlId),
|
|
95448
|
+
onToggleExpand: () => j(e.xmlId),
|
|
95449
|
+
editDraft: v === e.xmlId ? y : null,
|
|
95450
|
+
onSelect: () => l(e.xmlId),
|
|
95451
|
+
onDraftChange: h,
|
|
95452
|
+
onEditCommit: g,
|
|
95453
|
+
onEditCancel: _,
|
|
95425
95454
|
menuItems: [
|
|
95426
95455
|
{
|
|
95427
95456
|
label: "Edit properties",
|
|
95428
|
-
onClick: () =>
|
|
95457
|
+
onClick: () => p(e)
|
|
95429
95458
|
},
|
|
95430
95459
|
{
|
|
95431
95460
|
label: "Place in document",
|
|
95432
|
-
onClick: () =>
|
|
95461
|
+
onClick: () => re(e)
|
|
95433
95462
|
},
|
|
95434
95463
|
{
|
|
95435
95464
|
label: "Insert at cursor",
|
|
95436
|
-
onClick: () =>
|
|
95465
|
+
onClick: () => N(e)
|
|
95437
95466
|
},
|
|
95438
95467
|
{
|
|
95439
95468
|
label: "Delete from project",
|
|
95440
|
-
onClick: () =>
|
|
95469
|
+
onClick: () => M(e, null),
|
|
95441
95470
|
danger: !0
|
|
95442
95471
|
}
|
|
95443
95472
|
],
|
|
95444
95473
|
isLatex: e.sourceFormat === "latex"
|
|
95445
|
-
}),
|
|
95474
|
+
}), A(e.xmlId) && r.map((e) => /* @__PURE__ */ t(f8, {
|
|
95446
95475
|
division: e.division,
|
|
95447
95476
|
depth: e.depth + 1,
|
|
95448
95477
|
isActive: s === e.division.xmlId,
|
|
95449
95478
|
hasChildren: o.has(e.division.xmlId),
|
|
95450
|
-
isExpanded:
|
|
95451
|
-
onToggleExpand: () =>
|
|
95452
|
-
editDraft:
|
|
95453
|
-
onSelect: () =>
|
|
95454
|
-
onDraftChange:
|
|
95455
|
-
onEditCommit:
|
|
95456
|
-
onEditCancel:
|
|
95479
|
+
isExpanded: A(e.division.xmlId),
|
|
95480
|
+
onToggleExpand: () => j(e.division.xmlId),
|
|
95481
|
+
editDraft: v === e.division.xmlId ? y : null,
|
|
95482
|
+
onSelect: () => l(e.division.xmlId),
|
|
95483
|
+
onDraftChange: h,
|
|
95484
|
+
onEditCommit: g,
|
|
95485
|
+
onEditCancel: _,
|
|
95457
95486
|
menuItems: [
|
|
95458
95487
|
{
|
|
95459
95488
|
label: "Edit properties",
|
|
95460
|
-
onClick: () =>
|
|
95489
|
+
onClick: () => p(e.division)
|
|
95461
95490
|
},
|
|
95462
95491
|
{
|
|
95463
95492
|
label: "Insert at cursor",
|
|
95464
|
-
onClick: () =>
|
|
95493
|
+
onClick: () => N(e.division)
|
|
95465
95494
|
},
|
|
95466
95495
|
{
|
|
95467
95496
|
label: "Delete from project",
|
|
95468
|
-
onClick: () =>
|
|
95497
|
+
onClick: () => M(e.division, e.parentXmlId),
|
|
95469
95498
|
danger: !0
|
|
95470
95499
|
}
|
|
95471
95500
|
],
|
|
@@ -95474,6 +95503,71 @@ var u8 = ({ onOpenAssetPicker: r }) => {
|
|
|
95474
95503
|
})
|
|
95475
95504
|
})]
|
|
95476
95505
|
}),
|
|
95506
|
+
/* @__PURE__ */ n("div", {
|
|
95507
|
+
className: "pretext-plus-editor__toc-assets",
|
|
95508
|
+
children: [/* @__PURE__ */ t("div", {
|
|
95509
|
+
className: "pretext-plus-editor__toc-assets-header",
|
|
95510
|
+
children: /* @__PURE__ */ n("button", {
|
|
95511
|
+
type: "button",
|
|
95512
|
+
className: "pretext-plus-editor__toc-assets-toggle",
|
|
95513
|
+
onClick: () => D((e) => !e),
|
|
95514
|
+
"aria-expanded": E,
|
|
95515
|
+
children: [
|
|
95516
|
+
/* @__PURE__ */ t("span", {
|
|
95517
|
+
className: "pretext-plus-editor__toc-assets-chevron",
|
|
95518
|
+
children: E ? "▾" : "▸"
|
|
95519
|
+
}),
|
|
95520
|
+
/* @__PURE__ */ t("span", { children: "Assets" }),
|
|
95521
|
+
w.length > 0 && /* @__PURE__ */ t("span", {
|
|
95522
|
+
className: "pretext-plus-editor__toc-assets-count",
|
|
95523
|
+
children: w.length
|
|
95524
|
+
})
|
|
95525
|
+
]
|
|
95526
|
+
})
|
|
95527
|
+
}), E && /* @__PURE__ */ t("div", {
|
|
95528
|
+
className: "pretext-plus-editor__toc-assets-body",
|
|
95529
|
+
children: w.length === 0 ? /* @__PURE__ */ n("p", {
|
|
95530
|
+
className: "pretext-plus-editor__toc-assets-empty",
|
|
95531
|
+
children: [
|
|
95532
|
+
"No assets referenced in this document.",
|
|
95533
|
+
" ",
|
|
95534
|
+
r && /* @__PURE__ */ t("button", {
|
|
95535
|
+
type: "button",
|
|
95536
|
+
className: "pretext-plus-editor__toc-assets-add-link",
|
|
95537
|
+
onClick: r,
|
|
95538
|
+
children: "Add one"
|
|
95539
|
+
})
|
|
95540
|
+
]
|
|
95541
|
+
}) : /* @__PURE__ */ t("div", {
|
|
95542
|
+
className: "pretext-plus-editor__toc-assets-groups",
|
|
95543
|
+
children: T.map(({ kind: e, items: r }) => /* @__PURE__ */ n("div", { children: [/* @__PURE__ */ t("div", {
|
|
95544
|
+
className: "pretext-plus-editor__toc-assets-group-header",
|
|
95545
|
+
children: p8[e]
|
|
95546
|
+
}), /* @__PURE__ */ t("ul", {
|
|
95547
|
+
className: "pretext-plus-editor__toc-assets-list",
|
|
95548
|
+
children: r.map(({ ref: r }) => /* @__PURE__ */ n("li", {
|
|
95549
|
+
className: "pretext-plus-editor__toc-asset-item",
|
|
95550
|
+
children: [/* @__PURE__ */ n("div", {
|
|
95551
|
+
className: "pretext-plus-editor__toc-asset-name",
|
|
95552
|
+
children: [/* @__PURE__ */ t("span", {
|
|
95553
|
+
className: "pretext-plus-editor__toc-asset-label",
|
|
95554
|
+
children: c.find((t) => t.kind === e && t.ref === r)?.name ?? r
|
|
95555
|
+
}), /* @__PURE__ */ t("span", {
|
|
95556
|
+
className: "pretext-plus-editor__toc-asset-filename",
|
|
95557
|
+
children: r
|
|
95558
|
+
})]
|
|
95559
|
+
}), /* @__PURE__ */ t("button", {
|
|
95560
|
+
type: "button",
|
|
95561
|
+
className: "pretext-plus-editor__toc-action-btn",
|
|
95562
|
+
onClick: () => ie(e, r),
|
|
95563
|
+
title: `Insert <plus:${e} ref="${r}"/> at cursor`,
|
|
95564
|
+
children: "Insert"
|
|
95565
|
+
})]
|
|
95566
|
+
}, r))
|
|
95567
|
+
})] }, e))
|
|
95568
|
+
})
|
|
95569
|
+
})]
|
|
95570
|
+
}),
|
|
95477
95571
|
r && /* @__PURE__ */ t("button", {
|
|
95478
95572
|
type: "button",
|
|
95479
95573
|
className: "pretext-plus-editor__toc-assets-btn",
|
|
@@ -95481,7 +95575,7 @@ var u8 = ({ onOpenAssetPicker: r }) => {
|
|
|
95481
95575
|
children: "Manage Assets"
|
|
95482
95576
|
})
|
|
95483
95577
|
] });
|
|
95484
|
-
},
|
|
95578
|
+
}, g8 = ({ isCollapsed: e, onToggleCollapse: r, onOpenAssetPicker: i }) => e ? /* @__PURE__ */ t("div", {
|
|
95485
95579
|
className: "pretext-plus-editor__toc pretext-plus-editor__toc--collapsed",
|
|
95486
95580
|
children: /* @__PURE__ */ t("button", {
|
|
95487
95581
|
type: "button",
|
|
@@ -95509,8 +95603,8 @@ var u8 = ({ onOpenAssetPicker: r }) => {
|
|
|
95509
95603
|
children: "✕"
|
|
95510
95604
|
})
|
|
95511
95605
|
})]
|
|
95512
|
-
}), /* @__PURE__ */ t(
|
|
95513
|
-
}),
|
|
95606
|
+
}), /* @__PURE__ */ t(h8, { onOpenAssetPicker: i })]
|
|
95607
|
+
}), _8 = class extends i {
|
|
95514
95608
|
state = { error: null };
|
|
95515
95609
|
static getDerivedStateFromError(e) {
|
|
95516
95610
|
return { error: e };
|
|
@@ -95549,7 +95643,7 @@ var u8 = ({ onOpenAssetPicker: r }) => {
|
|
|
95549
95643
|
};
|
|
95550
95644
|
//#endregion
|
|
95551
95645
|
//#region src/store/editorStore.ts
|
|
95552
|
-
function
|
|
95646
|
+
function v8(e) {
|
|
95553
95647
|
let t = () => {}, n = { cbs: {
|
|
95554
95648
|
selectDivision: t,
|
|
95555
95649
|
addDivision: t,
|
|
@@ -95629,7 +95723,7 @@ function p8(e) {
|
|
|
95629
95723
|
updateSection: (e, t) => n.cbs.updateDivision(e, t),
|
|
95630
95724
|
divisionContentChange: (e, t) => n.cbs.divisionContentChange?.(e, t),
|
|
95631
95725
|
startSectionEdit: (e) => {
|
|
95632
|
-
let { xmlId: n, label: r } =
|
|
95726
|
+
let { xmlId: n, label: r } = C6(e.content);
|
|
95633
95727
|
t({
|
|
95634
95728
|
editingId: e.xmlId,
|
|
95635
95729
|
editDraft: {
|
|
@@ -95669,7 +95763,7 @@ function p8(e) {
|
|
|
95669
95763
|
}
|
|
95670
95764
|
//#endregion
|
|
95671
95765
|
//#region src/store/EditorStoreProvider.tsx
|
|
95672
|
-
function
|
|
95766
|
+
function y8({ store: e, children: n }) {
|
|
95673
95767
|
return /* @__PURE__ */ t(y3.Provider, {
|
|
95674
95768
|
value: e,
|
|
95675
95769
|
children: n
|
|
@@ -95677,10 +95771,10 @@ function m8({ store: e, children: n }) {
|
|
|
95677
95771
|
}
|
|
95678
95772
|
//#endregion
|
|
95679
95773
|
//#region src/components/Editors.tsx
|
|
95680
|
-
var
|
|
95774
|
+
var b8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type === "article" || e.type === "slideshow") ?? e[0] ?? null, x8 = (e) => {
|
|
95681
95775
|
let [n] = b(() => {
|
|
95682
|
-
let t =
|
|
95683
|
-
return
|
|
95776
|
+
let t = b8(e.divisions, e.rootDivisionId), n = e.activeDivisionId ?? t?.xmlId ?? null, r = e.divisions.find((e) => e.xmlId === n) ?? t;
|
|
95777
|
+
return v8({
|
|
95684
95778
|
source: r?.content ?? "",
|
|
95685
95779
|
sourceFormat: r?.sourceFormat ?? "pretext",
|
|
95686
95780
|
title: e.title ?? "Document Title",
|
|
@@ -95692,15 +95786,15 @@ var h8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95692
95786
|
activeDivisionId: n
|
|
95693
95787
|
});
|
|
95694
95788
|
});
|
|
95695
|
-
return /* @__PURE__ */ t(
|
|
95789
|
+
return /* @__PURE__ */ t(y8, {
|
|
95696
95790
|
store: n.store,
|
|
95697
|
-
children: /* @__PURE__ */ t(
|
|
95791
|
+
children: /* @__PURE__ */ t(S8, {
|
|
95698
95792
|
...e,
|
|
95699
95793
|
bindCallbacks: n.bindCallbacks
|
|
95700
95794
|
})
|
|
95701
95795
|
});
|
|
95702
|
-
},
|
|
95703
|
-
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 =
|
|
95796
|
+
}, S8 = (e) => {
|
|
95797
|
+
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 = b8(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) => {
|
|
95704
95798
|
k(t, n), e.onContentChange({
|
|
95705
95799
|
xmlId: t,
|
|
95706
95800
|
sourceContent: n,
|
|
@@ -95726,10 +95820,10 @@ var h8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95726
95820
|
oe
|
|
95727
95821
|
]), de = (e) => {
|
|
95728
95822
|
if (!ae) return;
|
|
95729
|
-
let t = P === "pretext" ?
|
|
95823
|
+
let t = P === "pretext" ? B6(e || "") : e || "";
|
|
95730
95824
|
if (t === ae.content) return;
|
|
95731
95825
|
if (F(ae.xmlId, t, P), P === "pretext") {
|
|
95732
|
-
let e =
|
|
95826
|
+
let e = w6(t);
|
|
95733
95827
|
if (e) {
|
|
95734
95828
|
se(ae.xmlId, {
|
|
95735
95829
|
title: e.title,
|
|
@@ -95739,24 +95833,24 @@ var h8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95739
95833
|
});
|
|
95740
95834
|
let t = e.xmlId || ae.xmlId;
|
|
95741
95835
|
if (t !== ae.xmlId || e.type !== ae.type) {
|
|
95742
|
-
let n =
|
|
95836
|
+
let n = R6(S, ae.xmlId);
|
|
95743
95837
|
if (n) {
|
|
95744
|
-
let r =
|
|
95838
|
+
let r = L6(n.content, ae.xmlId, t, e.type);
|
|
95745
95839
|
r !== n.content && F(n.xmlId, r, n.sourceFormat);
|
|
95746
95840
|
}
|
|
95747
95841
|
}
|
|
95748
95842
|
e.xmlId && e.xmlId !== ae.xmlId && ue(e.xmlId);
|
|
95749
95843
|
}
|
|
95750
95844
|
} else if (P === "latex" && ae.type === "section") {
|
|
95751
|
-
let e =
|
|
95845
|
+
let e = v6(t);
|
|
95752
95846
|
e !== null && se(ae.xmlId, { title: e });
|
|
95753
95847
|
}
|
|
95754
95848
|
let n = new Set(S.map((e) => e.xmlId));
|
|
95755
|
-
for (let { xmlId: e, type: r } of
|
|
95849
|
+
for (let { xmlId: e, type: r } of j6(t)) n.has(e) || (ce(N6(e, r, P)), n.add(e));
|
|
95756
95850
|
}, fe = (e) => {
|
|
95757
95851
|
ue(e);
|
|
95758
95852
|
}, pe = () => {
|
|
95759
|
-
let e =
|
|
95853
|
+
let e = c6();
|
|
95760
95854
|
ce(e), te(e.xmlId);
|
|
95761
95855
|
}, me = (e) => e.ref ? `<plus:${e.kind} ref="${e.ref}"/>` : "", he = (t) => {
|
|
95762
95856
|
let n = me(t);
|
|
@@ -95810,7 +95904,7 @@ var h8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95810
95904
|
let t = ge.current, n = {}, r = !1;
|
|
95811
95905
|
if (e.divisions !== t.divisions) {
|
|
95812
95906
|
n.divisions = e.divisions;
|
|
95813
|
-
let t =
|
|
95907
|
+
let t = b8(e.divisions, e.rootDivisionId);
|
|
95814
95908
|
(C == null || !e.divisions.some((e) => e.xmlId === C)) && (n.activeDivisionId = t?.xmlId ?? null), r = !0;
|
|
95815
95909
|
}
|
|
95816
95910
|
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 = {
|
|
@@ -95822,14 +95916,14 @@ var h8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95822
95916
|
activeDivisionId: e.activeDivisionId
|
|
95823
95917
|
};
|
|
95824
95918
|
});
|
|
95825
|
-
let _e = D ? E : T, ve = ae ? P === "pretext" ?
|
|
95919
|
+
let _e = D ? E : T, ve = ae ? P === "pretext" ? X6(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 ? e8(ae.type, ve, _e, ae.title) : void 0, be = () => N.current?.rebuild(), xe = () => {
|
|
95826
95920
|
e.onSave?.(), N.current?.rebuild();
|
|
95827
95921
|
}, Se = (t) => {
|
|
95828
95922
|
let n = t.ctrlKey || t.metaKey;
|
|
95829
95923
|
n && t.key === "Enter" && e.onPreviewRebuild ? (t.preventDefault(), be()) : n && t.key === "s" && (t.preventDefault(), xe());
|
|
95830
95924
|
}, R = () => {
|
|
95831
95925
|
if (!ae || !I) return;
|
|
95832
|
-
let e =
|
|
95926
|
+
let e = c6(), t = B6(f6(I, ae.type));
|
|
95833
95927
|
ce({
|
|
95834
95928
|
id: e.xmlId,
|
|
95835
95929
|
xmlId: e.xmlId,
|
|
@@ -95862,7 +95956,7 @@ var h8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95862
95956
|
editDisabledReason: P === "markdown" ? "Visual editing is not available for Markdown documents." : P === "latex" ? "Visual editing is not available for LaTeX documents." : "",
|
|
95863
95957
|
onChange: (e) => de(e)
|
|
95864
95958
|
});
|
|
95865
|
-
let Te = /* @__PURE__ */ t(
|
|
95959
|
+
let Te = /* @__PURE__ */ t(g8, {
|
|
95866
95960
|
isCollapsed: l,
|
|
95867
95961
|
onToggleCollapse: () => u((e) => !e),
|
|
95868
95962
|
onOpenAssetPicker: e.projectAssets === void 0 ? void 0 : () => g("isAssetPickerOpen")
|
|
@@ -95929,7 +96023,7 @@ var h8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95929
96023
|
}), /* @__PURE__ */ n("div", {
|
|
95930
96024
|
className: "pretext-plus-editor",
|
|
95931
96025
|
onKeyDown: Se,
|
|
95932
|
-
children: [/* @__PURE__ */ t(
|
|
96026
|
+
children: [/* @__PURE__ */ t(o8, {
|
|
95933
96027
|
onSaveButton: e.onSaveButton,
|
|
95934
96028
|
saveButtonLabel: e.saveButtonLabel,
|
|
95935
96029
|
onCancelButton: e.onCancelButton,
|
|
@@ -95938,7 +96032,7 @@ var h8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95938
96032
|
}), /* @__PURE__ */ n("div", {
|
|
95939
96033
|
className: "pretext-plus-editor__editor-displays",
|
|
95940
96034
|
children: [
|
|
95941
|
-
/* @__PURE__ */ t(
|
|
96035
|
+
/* @__PURE__ */ t(_8, {
|
|
95942
96036
|
resetKeys: [oe, C],
|
|
95943
96037
|
children: Oe
|
|
95944
96038
|
}),
|
|
@@ -95971,7 +96065,7 @@ var h8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95971
96065
|
}
|
|
95972
96066
|
}
|
|
95973
96067
|
}) : null,
|
|
95974
|
-
h && e.projectAssets !== void 0 ? /* @__PURE__ */ t(
|
|
96068
|
+
h && e.projectAssets !== void 0 ? /* @__PURE__ */ t(a8, {
|
|
95975
96069
|
open: h,
|
|
95976
96070
|
onClose: () => b("isAssetPickerOpen"),
|
|
95977
96071
|
onLoadAssets: e.onLoadAssets,
|
|
@@ -95988,6 +96082,6 @@ var h8 = (e, t) => e.find((e) => t ? e.xmlId === t : e.type === "book" || e.type
|
|
|
95988
96082
|
});
|
|
95989
96083
|
};
|
|
95990
96084
|
//#endregion
|
|
95991
|
-
export { nc as CodeEditor, R3 as DocinfoEditor,
|
|
96085
|
+
export { nc as CodeEditor, R3 as DocinfoEditor, x8 as Editors, m3 as FeedbackLink, xR as FullPreview, vR as VisualEditor, Q6 as assembleFullProjectSource, X6 as assembleProjectSource, U6 as buildDivisionTree, l3 as convertLatexToPretext, u6 as createConclusion, l6 as createIntroduction, x6 as createLatexConclusion, b6 as createLatexIntroduction, y6 as createNewLatexSection, c6 as createNewSection, f3 as derivePretextContent, c3 as detectSourceFormat, g6 as ensureLatexSectionWrapper, p6 as ensureSectionWrapper, w6 as extractDivisionMetadata, v6 as extractLatexDivisionTitle, R6 as findDivisionParent, W6 as getOrphanRoots, H6 as getOrphanedDivisions, C6 as getSectionAttributes, P6 as insertDivisionRef, S6 as mergeTwoSections, I6 as moveDivisionRef, B6 as normalizeSelfClosingRefs, A6 as parseDivisionRefs, bR as postToIframe, F6 as removeDivisionRef, L6 as renameDivisionRef, z6 as reorderDivisionRefs, h6 as rewrapLatexSection, f6 as rewrapSection, m6 as stripLatexSectionWrapper, d6 as stripSectionWrapper, s6 as updateDivisionTitle, _6 as updateLatexSectionTitle, T6 as updateSectionMetadata, e8 as wrapDivisionForPreview };
|
|
95992
96086
|
|
|
95993
96087
|
//# sourceMappingURL=index.es.js.map
|