@pretextbook/import 0.12.0 → 0.13.0
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/convert-worker.cjs +1 -1
- package/dist/convert-worker.js +1 -1
- package/dist/{engine-routing-08ynicii.cjs → engine-routing-ClG81Gp5.cjs} +1 -1
- package/dist/{engine-routing-Bu0zM4aw.js → engine-routing-UEp8JP8x.js} +7 -7
- package/dist/index.cjs +12 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +413 -343
- package/dist/lib/paste/place-markup.d.ts +26 -4
- package/dist/react.cjs +1 -1
- package/dist/react.js +17 -17
- package/dist/{upload-BnRj1gU1.cjs → upload-B1HDv3IB.cjs} +4 -4
- package/dist/{upload-H_OCZBBn.js → upload-DJuIYze6.js} +65 -64
- package/package.json +1 -1
|
@@ -15,6 +15,26 @@ export declare function firstDivisionTag(markup: string): string | undefined;
|
|
|
15
15
|
* left as-is because the editor places it after the existing content there.
|
|
16
16
|
*/
|
|
17
17
|
export declare function reindentForContext(text: string, baseIndent: string, skipFirst: boolean): string;
|
|
18
|
+
/** Tags dropped from the generated `<p>` content model, and why — see above. */
|
|
19
|
+
export declare const PARAGRAPH_CONTENT_EXCLUSIONS: readonly string[];
|
|
20
|
+
/**
|
|
21
|
+
* Wrap every run of loose paragraph content in `markup` in a `<p>`.
|
|
22
|
+
*
|
|
23
|
+
* Converters do not always do this themselves. `unified-latex`'s PreTeXt
|
|
24
|
+
* conversion wraps paragraphs only when the source has more than one of them,
|
|
25
|
+
* so pasting a single paragraph — the commonest paste there is — yields bare
|
|
26
|
+
* text, and pasting `Intro \begin{theorem}…\end{theorem} outro` yields text on
|
|
27
|
+
* either side of a block with no paragraph around either. Both are invalid
|
|
28
|
+
* where the insertion point is not already inside a `<p>`.
|
|
29
|
+
*
|
|
30
|
+
* The rule is the schema's: content that may sit inside a `<p>` accumulates
|
|
31
|
+
* into one, and content that may not ends the run and passes through untouched.
|
|
32
|
+
* A run is only given a `<p>` if it holds real text or an element — a run of
|
|
33
|
+
* whitespace and comments between two blocks is left as it was. Markup that is
|
|
34
|
+
* already correctly wrapped therefore comes through unchanged, which is what
|
|
35
|
+
* lets this run unconditionally on the block-context path.
|
|
36
|
+
*/
|
|
37
|
+
export declare function wrapLooseParagraphs(markup: string): string;
|
|
18
38
|
export interface PlacementContext {
|
|
19
39
|
/** The insertion point sits inside a `<p>`, so only inline content fits. */
|
|
20
40
|
inline: boolean;
|
|
@@ -33,9 +53,11 @@ export interface PlacedMarkup {
|
|
|
33
53
|
*
|
|
34
54
|
* Two adjustments, both about context rather than conversion. Inside a
|
|
35
55
|
* paragraph the converter's own wrapping `<p>` is one paragraph too many, so it
|
|
36
|
-
* is unwrapped
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
56
|
+
* is unwrapped; outside one, loose text that never got a `<p>` is given one.
|
|
57
|
+
* What cannot be repaired here at all is block content landing inside a
|
|
58
|
+
* paragraph — a division, or several paragraphs pasted into the middle of one.
|
|
59
|
+
* The honest thing is to insert it and say so, leaving the author to move it,
|
|
60
|
+
* rather than silently emitting invalid markup or refusing a paste they asked
|
|
61
|
+
* for.
|
|
40
62
|
*/
|
|
41
63
|
export declare function placeConvertedMarkup(converted: string, context: PlacementContext): PlacedMarkup;
|
package/dist/react.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),I=require("./upload-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),I=require("./upload-B1HDv3IB.cjs"),A=require("./engine-routing-ClG81Gp5.cjs");var ge={exports:{}},oe={};var Ie;function Ke(){if(Ie)return oe;Ie=1;var r=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function u(m,p,d){var y=null;if(d!==void 0&&(y=""+d),p.key!==void 0&&(y=""+p.key),"key"in p){d={};for(var R in p)R!=="key"&&(d[R]=p[R])}else d=p;return p=d.ref,{$$typeof:r,type:m,key:y,ref:p!==void 0?p:null,props:d}}return oe.Fragment=i,oe.jsx=u,oe.jsxs=u,oe}var ce={};var De;function Ve(){return De||(De=1,process.env.NODE_ENV!=="production"&&(function(){function r(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===G?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case K:return"Fragment";case V:return"Profiler";case C:return"StrictMode";case ne:return"Suspense";case ie:return"SuspenseList";case ve:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case D:return"Portal";case P:return t.displayName||"Context";case b:return(t._context.displayName||"Context")+".Consumer";case _:var l=t.render;return t=t.displayName,t||(t=l.displayName||l.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case de:return l=t.displayName||null,l!==null?l:r(t.type)||"Memo";case ae:l=t._payload,t=t._init;try{return r(t(l))}catch{}}return null}function i(t){return""+t}function u(t){try{i(t);var l=!1}catch{l=!0}if(l){l=console;var f=l.error,g=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return f.call(l,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",g),i(t)}}function m(t){if(t===K)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===ae)return"<...>";try{var l=r(t);return l?"<"+l+">":"<...>"}catch{return"<...>"}}function p(){var t=J.A;return t===null?null:t.getOwner()}function d(){return Error("react-stack-top-frame")}function y(t){if(ue.call(t,"key")){var l=Object.getOwnPropertyDescriptor(t,"key").get;if(l&&l.isReactWarning)return!1}return t.key!==void 0}function R(t,l){function f(){le||(le=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",l))}f.isReactWarning=!0,Object.defineProperty(t,"key",{get:f,configurable:!0})}function h(){var t=r(this.type);return xe[t]||(xe[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function k(t,l,f,g,B,O){var v=f.ref;return t={$$typeof:T,type:t,key:l,props:f,_owner:g},(v!==void 0?v:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:h}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:B}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:O}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function E(t,l,f,g,B,O){var v=l.children;if(v!==void 0)if(g)if(me(v)){for(g=0;g<v.length;g++)w(v[g]);Object.freeze&&Object.freeze(v)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else w(v);if(ue.call(l,"key")){v=r(t);var L=Object.keys(l).filter(function(se){return se!=="key"});g=0<L.length?"{key: someKey, "+L.join(": ..., ")+": ...}":"{key: someKey}",te[v+g]||(L=0<L.length?"{"+L.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
package/dist/react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import He, { useState as h, useRef as ge, useEffect as Ze, useMemo as H } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { D as ot, a as ct, b as it, d as dt, q as De, k as ut, n as Oe, r as mt, l as Le, u as xt } from "./engine-routing-
|
|
2
|
+
import { Z as Ue, a9 as Qe, a4 as et, D as tt, n as st, k as rt, h as nt, j as Ye, N as at, H as lt } from "./upload-DJuIYze6.js";
|
|
3
|
+
import { D as ot, a as ct, b as it, d as dt, q as De, k as ut, n as Oe, r as mt, l as Le, u as xt } from "./engine-routing-UEp8JP8x.js";
|
|
4
4
|
var be = { exports: {} }, le = {};
|
|
5
5
|
var Ie;
|
|
6
6
|
function pt() {
|
|
@@ -31,12 +31,12 @@ function ht() {
|
|
|
31
31
|
function r(t) {
|
|
32
32
|
if (t == null) return null;
|
|
33
33
|
if (typeof t == "function")
|
|
34
|
-
return t.$$typeof ===
|
|
34
|
+
return t.$$typeof === K ? null : t.displayName || t.name || null;
|
|
35
35
|
if (typeof t == "string") return t;
|
|
36
36
|
switch (t) {
|
|
37
37
|
case W:
|
|
38
38
|
return "Fragment";
|
|
39
|
-
case
|
|
39
|
+
case q:
|
|
40
40
|
return "Profiler";
|
|
41
41
|
case C:
|
|
42
42
|
return "StrictMode";
|
|
@@ -221,7 +221,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
221
221
|
function j(t) {
|
|
222
222
|
return typeof t == "object" && t !== null && t.$$typeof === S;
|
|
223
223
|
}
|
|
224
|
-
var A = He, S = /* @__PURE__ */ Symbol.for("react.transitional.element"), F = /* @__PURE__ */ Symbol.for("react.portal"), W = /* @__PURE__ */ Symbol.for("react.fragment"), C = /* @__PURE__ */ Symbol.for("react.strict_mode"),
|
|
224
|
+
var A = He, S = /* @__PURE__ */ Symbol.for("react.transitional.element"), F = /* @__PURE__ */ Symbol.for("react.portal"), W = /* @__PURE__ */ Symbol.for("react.fragment"), C = /* @__PURE__ */ Symbol.for("react.strict_mode"), q = /* @__PURE__ */ Symbol.for("react.profiler"), b = /* @__PURE__ */ Symbol.for("react.consumer"), R = /* @__PURE__ */ Symbol.for("react.context"), _ = /* @__PURE__ */ Symbol.for("react.forward_ref"), re = /* @__PURE__ */ Symbol.for("react.suspense"), ce = /* @__PURE__ */ Symbol.for("react.suspense_list"), ie = /* @__PURE__ */ Symbol.for("react.memo"), ne = /* @__PURE__ */ Symbol.for("react.lazy"), ve = /* @__PURE__ */ Symbol.for("react.activity"), K = /* @__PURE__ */ Symbol.for("react.client.reference"), V = A.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, de = Object.prototype.hasOwnProperty, ue = Array.isArray, U = console.createTask ? console.createTask : function() {
|
|
225
225
|
return null;
|
|
226
226
|
};
|
|
227
227
|
A = {
|
|
@@ -356,9 +356,9 @@ function Rt({
|
|
|
356
356
|
engines: P,
|
|
357
357
|
insertTarget: p
|
|
358
358
|
}) {
|
|
359
|
-
const E = P && P.length > 0 ? P : [jt], T = ge(null), [w, j] = h({ name: "upload" }), [A, S] = h(!1), [F, W] = h(u), [C,
|
|
359
|
+
const E = P && P.length > 0 ? P : [jt], T = ge(null), [w, j] = h({ name: "upload" }), [A, S] = h(!1), [F, W] = h(u), [C, q] = h(null), [b, R] = h(null), [_, re] = h([]), [ce, ie] = h(/* @__PURE__ */ new Set()), [ne, ve] = h(E[0].id), [K, V] = h(null), [de, ue] = h(x), [U, ae] = h(!1), [me, Z] = h(/* @__PURE__ */ new Set()), [Q, ee] = h(null), [t, l] = h(
|
|
360
360
|
"auto"
|
|
361
|
-
), [f, g] = h(null), [Y, D] = h({}), [v, O] = h(!1), L = ge(!1), te = E.find((n) => n.id === ne) ?? E[0], Te = it(E), B =
|
|
361
|
+
), [f, g] = h(null), [Y, D] = h({}), [v, O] = h(!1), L = ge(!1), te = E.find((n) => n.id === ne) ?? E[0], Te = it(E), B = K ? dt(E, K.name) : void 0, Se = B ? te.id === B.id : !1, xe = B ? Se ? De(E, K.name) ?? null : B : null, G = w.name === "review" ? w.result : null, pe = H(
|
|
362
362
|
() => G && (C !== null || b !== null || _.length > 0) ? Qe(G, {
|
|
363
363
|
splitLevel: C ?? void 0,
|
|
364
364
|
targetTag: b ?? void 0,
|
|
@@ -394,7 +394,7 @@ function Rt({
|
|
|
394
394
|
L.current = !0, te.cancel?.(), j(
|
|
395
395
|
n ? { name: "sources", prepared: n } : { name: "upload" }
|
|
396
396
|
);
|
|
397
|
-
},
|
|
397
|
+
}, qe = async (n) => {
|
|
398
398
|
L.current = !1, j({ name: "processing" }), await Ee();
|
|
399
399
|
try {
|
|
400
400
|
const a = Ce(n).extraRoots.map((o) => ({
|
|
@@ -452,11 +452,11 @@ function Rt({
|
|
|
452
452
|
});
|
|
453
453
|
}
|
|
454
454
|
}, Re = () => {
|
|
455
|
-
ue(x), ae(!1), Z(/* @__PURE__ */ new Set()), ie(/* @__PURE__ */ new Set()),
|
|
455
|
+
ue(x), ae(!1), Z(/* @__PURE__ */ new Set()), ie(/* @__PURE__ */ new Set()), q(null), R(null), re([]);
|
|
456
456
|
}, we = () => {
|
|
457
457
|
j({ name: "upload" }), Re(), ee(null), V(null);
|
|
458
458
|
}, _e = () => {
|
|
459
|
-
|
|
459
|
+
K && xe && ye(K, xe);
|
|
460
460
|
};
|
|
461
461
|
function Ae(n, m) {
|
|
462
462
|
return [...n].sort((a, N) => a === m ? -1 : N === m ? 1 : a.localeCompare(N));
|
|
@@ -465,7 +465,7 @@ function Rt({
|
|
|
465
465
|
const a = Le(n, m), N = m === "converted" ? n.projectLayout.mainSourcePath : n.sourcePath, o = Ae(Object.keys(a), N)[0];
|
|
466
466
|
Z(o ? /* @__PURE__ */ new Set([o]) : /* @__PURE__ */ new Set());
|
|
467
467
|
}
|
|
468
|
-
function
|
|
468
|
+
function Ke(n) {
|
|
469
469
|
Z((m) => {
|
|
470
470
|
const a = new Set(m);
|
|
471
471
|
return a.has(n) ? a.delete(n) : a.add(n), a;
|
|
@@ -655,7 +655,7 @@ function Rt({
|
|
|
655
655
|
"button",
|
|
656
656
|
{
|
|
657
657
|
type: "button",
|
|
658
|
-
onClick: () =>
|
|
658
|
+
onClick: () => qe(n),
|
|
659
659
|
className: "rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600",
|
|
660
660
|
children: "Continue"
|
|
661
661
|
}
|
|
@@ -858,7 +858,7 @@ function Rt({
|
|
|
858
858
|
"button",
|
|
859
859
|
{
|
|
860
860
|
type: "button",
|
|
861
|
-
onClick: () =>
|
|
861
|
+
onClick: () => q(k),
|
|
862
862
|
"aria-pressed": N === k,
|
|
863
863
|
className: N === k ? "rounded bg-blue-700 px-3 py-1 text-sm font-medium text-white" : "rounded border border-slate-300 px-3 py-1 text-sm text-slate-700 hover:bg-slate-50",
|
|
864
864
|
children: k === 0 ? "One file" : `${k} level${k === 1 ? "" : "s"}`
|
|
@@ -892,7 +892,7 @@ function Rt({
|
|
|
892
892
|
"button",
|
|
893
893
|
{
|
|
894
894
|
type: "button",
|
|
895
|
-
onClick: () =>
|
|
895
|
+
onClick: () => Ke(s),
|
|
896
896
|
className: "flex w-full items-center gap-2 bg-slate-100 px-4 py-2 text-left font-mono text-xs text-slate-700 hover:bg-slate-200",
|
|
897
897
|
children: [
|
|
898
898
|
/* @__PURE__ */ e.jsx("span", { className: "shrink-0 text-slate-400", children: k ? "▾" : "▸" }),
|
|
@@ -1241,7 +1241,7 @@ function At({
|
|
|
1241
1241
|
[r]
|
|
1242
1242
|
), y = ge(null), [P, p] = h(!1), [E, T] = h(!1), [w, j] = h(
|
|
1243
1243
|
[]
|
|
1244
|
-
), [A, S] = h(d), [F, W] = h(!1), C = c || E,
|
|
1244
|
+
), [A, S] = h(d), [F, W] = h(!1), C = c || E, q = async (b) => {
|
|
1245
1245
|
T(!0);
|
|
1246
1246
|
try {
|
|
1247
1247
|
const _ = await Ue(b, u ?? {
|
|
@@ -1299,7 +1299,7 @@ function At({
|
|
|
1299
1299
|
if (b.preventDefault(), p(!1), C)
|
|
1300
1300
|
return;
|
|
1301
1301
|
const R = b.dataTransfer.files?.[0];
|
|
1302
|
-
R &&
|
|
1302
|
+
R && q(R);
|
|
1303
1303
|
},
|
|
1304
1304
|
children: [
|
|
1305
1305
|
/* @__PURE__ */ e.jsx("p", { children: i.dropHint }),
|
|
@@ -1332,7 +1332,7 @@ function At({
|
|
|
1332
1332
|
accept: ".tex,.md,.markdown,.ptx,.xml,.zip,.gz,.tar.gz,.tgz",
|
|
1333
1333
|
onChange: (b) => {
|
|
1334
1334
|
const R = b.currentTarget.files?.[0];
|
|
1335
|
-
R &&
|
|
1335
|
+
R && q(R), b.currentTarget.value = "";
|
|
1336
1336
|
}
|
|
1337
1337
|
}
|
|
1338
1338
|
)
|