@pretextbook/web-editor 0.12.0 → 0.14.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/README.md +1 -1
- package/dist/components/AssetManagerModal.d.ts +1 -1
- package/dist/components/ConvertToPretextDialog.d.ts +3 -3
- package/dist/components/Editors.d.ts +1 -1
- package/dist/components/toc/SectionEditForm.d.ts +1 -1
- package/dist/components/toc/types.d.ts +6 -0
- package/dist/contentConversion.d.ts +6 -5
- package/dist/index.es.js +2124 -1912
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +23 -23
- package/dist/index.js.map +1 -1
- package/dist/sectionUtils.d.ts +29 -16
- package/dist/types/editor.d.ts +21 -20
- package/dist/types/sections.d.ts +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ export interface AssetManagerModalProps {
|
|
|
35
35
|
*/
|
|
36
36
|
onFetchUrl?: (url: string) => Promise<File>;
|
|
37
37
|
/** Create a new Doenet activity; host returns the created asset. */
|
|
38
|
-
onCreateDoenet?: (
|
|
38
|
+
onCreateDoenet?: (title: string, ref: string) => Promise<Asset>;
|
|
39
39
|
/** Remove an asset from the project. */
|
|
40
40
|
onRemoveAsset?: (asset: Asset) => void;
|
|
41
41
|
/**
|
|
@@ -2,8 +2,8 @@ import type { SourceFormat } from "../types/editor";
|
|
|
2
2
|
import "./dialog.css";
|
|
3
3
|
interface ConvertToPretextDialogProps {
|
|
4
4
|
/** The current source to display (read-only) on the left. */
|
|
5
|
-
|
|
6
|
-
/** The format of `
|
|
5
|
+
source: string;
|
|
6
|
+
/** The format of `source` — used for the left-panel label and Monaco language. */
|
|
7
7
|
sourceFormat: SourceFormat;
|
|
8
8
|
/** The already-converted PreTeXt to display (read-only) on the right. */
|
|
9
9
|
pretextSource: string;
|
|
@@ -16,5 +16,5 @@ interface ConvertToPretextDialogProps {
|
|
|
16
16
|
* Confirmation dialog shown before converting a non-PreTeXt division into a
|
|
17
17
|
* new PreTeXt division. Displays both sources side-by-side for review.
|
|
18
18
|
*/
|
|
19
|
-
declare const ConvertToPretextDialog: ({
|
|
19
|
+
declare const ConvertToPretextDialog: ({ source, sourceFormat, pretextSource, onConfirm, onClose, }: ConvertToPretextDialogProps) => import("react").JSX.Element;
|
|
20
20
|
export default ConvertToPretextDialog;
|
|
@@ -151,7 +151,7 @@ export interface editorProps {
|
|
|
151
151
|
*/
|
|
152
152
|
onAssetFetchUrl?: (url: string) => Promise<File>;
|
|
153
153
|
/** Called when the user creates a new Doenet activity. */
|
|
154
|
-
onCreateDoenet?: (
|
|
154
|
+
onCreateDoenet?: (title: string, ref: string) => Promise<Asset>;
|
|
155
155
|
/** Called when the user removes an asset from the project. */
|
|
156
156
|
onAssetRemove?: (asset: Asset) => void;
|
|
157
157
|
/** Called when the user saves edits to an asset's content (e.g. its `source`). */
|
|
@@ -4,7 +4,7 @@ interface SectionEditFormProps {
|
|
|
4
4
|
draft: EditDraft;
|
|
5
5
|
/** True only while editing a division that hasn't been saved yet — only then is `sourceFormat` choosable. */
|
|
6
6
|
isNew?: boolean;
|
|
7
|
-
/** The root division
|
|
7
|
+
/** The root division: its Type dropdown offers article/book instead of the parent-restricted list, since it has no parent. */
|
|
8
8
|
isRoot?: boolean;
|
|
9
9
|
/** The type of the division this one is (or would be) nested under; `null` if unplaced. Determines which types are offered below. */
|
|
10
10
|
parentType?: DivisionType | null;
|
|
@@ -17,6 +17,12 @@ export declare const TYPE_LABELS: Record<string, string>;
|
|
|
17
17
|
*/
|
|
18
18
|
export declare const DIVISION_ID_PREFIXES: Record<DivisionType, string>;
|
|
19
19
|
export declare const TYPE_FULL_LABELS: Record<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* Root document types the author can switch between from the TOC's root
|
|
22
|
+
* "Edit properties" form. Slideshow exists as a division type but isn't
|
|
23
|
+
* offered as a switch target yet.
|
|
24
|
+
*/
|
|
25
|
+
export declare const SWITCHABLE_ROOT_TYPES: DivisionType[];
|
|
20
26
|
/** Division types that can be freely reordered (not positionally constrained). */
|
|
21
27
|
export declare const REGULAR_DIVISION_TYPES: DivisionType[];
|
|
22
28
|
/** Returns true for division types that can be freely reordered. */
|
|
@@ -13,7 +13,8 @@ export interface DerivedPretextResult {
|
|
|
13
13
|
* 1. Empty/whitespace-only → `"pretext"` (safe default).
|
|
14
14
|
* 2. Starts with `<` → `"pretext"` (XML document).
|
|
15
15
|
* 3. Contains any {@link LATEX_FORMAT_MARKERS} → `"latex"`.
|
|
16
|
-
* 4. First non-blank line starts with a Markdown ATX heading
|
|
16
|
+
* 4. First non-blank line starts with a Markdown ATX heading, or the document
|
|
17
|
+
* opens with a YAML frontmatter block → `"markdown"`.
|
|
17
18
|
* 5. Otherwise → `"pretext"`.
|
|
18
19
|
*/
|
|
19
20
|
export declare function detectSourceFormat(source: string): SourceFormat;
|
|
@@ -41,7 +42,7 @@ export declare function convertMarkdownToPretext(markdownContent: string): strin
|
|
|
41
42
|
*/
|
|
42
43
|
export declare function getConversionErrorMessage(error: unknown): string;
|
|
43
44
|
/**
|
|
44
|
-
* Derives PreTeXt content from `
|
|
45
|
+
* Derives PreTeXt content from `source` according to `sourceFormat`.
|
|
45
46
|
*
|
|
46
47
|
* - If `sourceFormat` is `"pretext"`, the content is returned as-is.
|
|
47
48
|
* - If `sourceFormat` is `"latex"`, the content is converted via
|
|
@@ -51,8 +52,8 @@ export declare function getConversionErrorMessage(error: unknown): string;
|
|
|
51
52
|
* {@link convertMarkdownToPretext}. Conversion errors are caught and returned
|
|
52
53
|
* as `pretextError` so callers never need a try/catch.
|
|
53
54
|
*
|
|
54
|
-
* @param
|
|
55
|
-
* @param sourceFormat - The format of `
|
|
55
|
+
* @param source - The raw source string.
|
|
56
|
+
* @param sourceFormat - The format of `source`.
|
|
56
57
|
* @returns A {@link DerivedPretextResult} with either `pretextSource` or `pretextError`.
|
|
57
58
|
*/
|
|
58
|
-
export declare function derivePretextContent(
|
|
59
|
+
export declare function derivePretextContent(source: string, sourceFormat: SourceFormat): DerivedPretextResult;
|