@pretextbook/web-editor 0.13.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.
@@ -151,7 +151,7 @@ export declare function updateLatexDivisionMetadata(division: Division, changes:
151
151
  * Returns `null` when the conversion fails, so callers can disable the convert
152
152
  * action / fall back.
153
153
  */
154
- export declare function latexDivisionToTaggedPretext(division: Pick<Division, "content" | "type" | "xmlId" | "title">): string | null;
154
+ export declare function latexDivisionToTaggedPretext(division: Pick<Division, "source" | "type" | "xmlId" | "title">): string | null;
155
155
  /** Create a new blank LaTeX section as a `Division`. */
156
156
  export declare function createNewLatexSection(title?: string): DocumentSection;
157
157
  /** Create a blank LaTeX introduction. */
@@ -217,7 +217,7 @@ export declare function extractDivisionMetadata(content: string): {
217
217
  * Pass `null` for `xmlId` or `label` to remove the attribute entirely.
218
218
  * Omit a key (or pass `undefined`) to leave it unchanged.
219
219
  *
220
- * Returns a new `DocumentSection` with updated `content`, `title`, and `type`.
220
+ * Returns a new `DocumentSection` with updated `source`, `title`, and `type`.
221
221
  */
222
222
  export declare function updateSectionMetadata(section: DocumentSection, changes: {
223
223
  title?: string;
@@ -248,6 +248,7 @@ export declare function parseMarkdownFrontmatter(content: string): {
248
248
  type: DivisionType;
249
249
  xmlId: string;
250
250
  label: string;
251
+ title: string;
251
252
  body: string;
252
253
  } | null;
253
254
  /** Build a `---`-fenced frontmatter block for a markdown division. */
@@ -255,15 +256,23 @@ export declare function buildMarkdownFrontmatter(meta: {
255
256
  type: DivisionType;
256
257
  xmlId: string;
257
258
  label: string;
259
+ title?: string;
258
260
  }): string;
259
- /** Extract a markdown division's leading `# heading` text, or `null` if none. */
261
+ /**
262
+ * Extract a markdown division's leading `# heading` text, or `null` if none.
263
+ * Legacy fallback only — titles now live in frontmatter's `title` key; see
264
+ * {@link extractMarkdownDivisionMetadata}. Kept so documents saved before the
265
+ * frontmatter-title migration still show a real title instead of "Untitled".
266
+ */
260
267
  export declare function deriveMarkdownTitle(body: string): string | null;
261
268
  /**
262
269
  * Derive a markdown division's title, type, `xml:id`, and `label` directly from
263
- * its source — the frontmatter for the structural metadata and the leading
264
- * `# heading` for the title. Markdown analogue of {@link extractDivisionMetadata};
265
- * returns `null` when the frontmatter is absent/malformed (both common
266
- * mid-edit), so callers can skip the update rather than clobber metadata.
270
+ * its source — all from the frontmatter block. Markdown analogue of
271
+ * {@link extractDivisionMetadata}; returns `null` when the frontmatter is
272
+ * absent/malformed (both common mid-edit), so callers can skip the update
273
+ * rather than clobber metadata. When the frontmatter carries no `title` (a
274
+ * document predating the migration to a frontmatter title), falls back to the
275
+ * body's leading `# heading`.
267
276
  */
268
277
  export declare function extractMarkdownDivisionMetadata(content: string): {
269
278
  title: string;
@@ -273,12 +282,12 @@ export declare function extractMarkdownDivisionMetadata(content: string): {
273
282
  } | null;
274
283
  /**
275
284
  * Update the title, type (`division`), `xml:id`, and `label` of a markdown
276
- * division. Structural metadata is rewritten in the frontmatter block; a title
277
- * change rewrites the body's leading `# heading`. Markdown analogue of
278
- * {@link updateSectionMetadata} (which is XML-only and would wrongly inject a
279
- * `<title>` element). Pass `null`/empty for `label` to clear it; omit a key to
280
- * leave it unchanged. The `xml:id` is never cleared — it is the division's
281
- * identity — so an empty value falls back to the record's existing id.
285
+ * division all rewritten in the frontmatter block; the body is left
286
+ * untouched. Markdown analogue of {@link updateSectionMetadata} (which is
287
+ * XML-only and would wrongly inject a `<title>` element). Pass `null`/empty
288
+ * for `label` to clear it; omit a key to leave it unchanged. The `xml:id` is
289
+ * never cleared — it is the division's identity — so an empty value falls
290
+ * back to the record's existing id.
282
291
  */
283
292
  export declare function updateMarkdownDivisionMetadata(division: Division, changes: {
284
293
  title?: string;
@@ -6,8 +6,8 @@ export type AssetKind = "image" | "doenet";
6
6
  export interface Asset {
7
7
  /** Stable server-assigned identifier (hidden from users). */
8
8
  id: string;
9
- /** Human-readable display name shown in the library UI. */
10
- name: string;
9
+ /** Human-readable display title shown in the library UI. */
10
+ title: string;
11
11
  /** Short reference used when authoring references, e.g. `"euler-painting"`.
12
12
  * Authors write e.g. `<plus:image ref="euler-painting"/>` and the build system
13
13
  * resolves it to the necessary core PreTeXt markup based upon the kind of
@@ -77,7 +77,7 @@ export interface FeedbackSubmission {
77
77
  }
78
78
  /**
79
79
  * Represents the full content state of the editor at any point in time.
80
- * When `sourceFormat` is `"pretext"`, `pretextSource` mirrors `sourceContent`.
80
+ * When `sourceFormat` is `"pretext"`, `pretextSource` mirrors `source`.
81
81
  * When `sourceFormat` is `"latex"`, `pretextSource` holds the result of
82
82
  * converting the LaTeX source, or `pretextError` holds a description of why
83
83
  * conversion failed.
@@ -87,11 +87,11 @@ export interface FeedbackSubmission {
87
87
  */
88
88
  export interface EditorContentState {
89
89
  /** The raw source string as typed/loaded by the user. */
90
- sourceContent: string;
91
- /** The format of `sourceContent`. */
90
+ source: string;
91
+ /** The format of `source`. */
92
92
  sourceFormat: SourceFormat;
93
93
  /**
94
- * The PreTeXt XML derived from `sourceContent`.
94
+ * The PreTeXt XML derived from `source`.
95
95
  * Present when conversion succeeded (or when the source is already PreTeXt).
96
96
  */
97
97
  pretextSource?: string;
@@ -4,7 +4,7 @@ import type { SourceFormat } from "./editor";
4
4
  * section, worksheet, etc. — is a `Division`. Divisions are stored as a flat
5
5
  * pool of records on the host (Rails) side; hierarchy is expressed by
6
6
  * embedding `<plus:division ref="xml-id"/>` placeholder tags inside a parent
7
- * division's `content`.
7
+ * division's `source`.
8
8
  *
9
9
  * Type-specific aliases (`<plus:chapter ref="..."/>`, `<plus:section ref="..."/>`)
10
10
  * are accepted by the editor as equivalent to `<plus:division ref="..."/>`.
@@ -59,7 +59,7 @@ export interface Division {
59
59
  * child refs as `::section{ref="child-id"}` leaf directives, and LaTeX as
60
60
  * `\plus{section}{child-id}` macros.
61
61
  */
62
- content: string;
62
+ source: string;
63
63
  }
64
64
  /**
65
65
  * @deprecated Use `DivisionType` instead. This alias will be removed in a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pretextbook/web-editor",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "private": false,
5
5
  "description": "A web-based editor for PreTeXt documents, with simple preview functionality",
6
6
  "keywords": [
@@ -51,8 +51,8 @@
51
51
  "@monaco-editor/react": "^4.8.0-rc.3",
52
52
  "@pretextbook/completions": "^0.0.3",
53
53
  "@pretextbook/format": "^0.2.0",
54
- "@pretextbook/latex-pretext": "^0.0.11",
55
- "@pretextbook/remark-pretext": "^0.0.9",
54
+ "@pretextbook/latex-pretext": "^0.0.12",
55
+ "@pretextbook/remark-pretext": "^0.0.10",
56
56
  "@pretextbook/visual-editor": "^0.0.6",
57
57
  "@tailwindcss/vite": "^4.1.18",
58
58
  "constrained-editor-plugin": "^1.4.0",