@pretextbook/web-editor 0.14.0 → 0.15.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.
@@ -21,12 +21,12 @@ export interface AssetManagerModalProps {
21
21
  * takes over from this asset (handled by `onReplaceAsset`).
22
22
  */
23
23
  replaceTarget?: Asset | null;
24
- onLoadAssets?: () => Promise<Asset[]>;
25
- onLoadLibraryAssets?: () => Promise<Asset[]>;
26
- /** Associate a library asset with the current project. */
27
- onAddFromLibrary?: (asset: Asset) => Promise<void> | void;
28
- /** Upload an image file; host returns the created asset. */
29
- onUpload?: (file: File) => Promise<Asset>;
24
+ /**
25
+ * Upload an image file; host returns the created asset. `title` is the
26
+ * human-readable title the user entered distinct from `file.name` — and
27
+ * should be persisted as the asset's title.
28
+ */
29
+ onUpload?: (file: File, title?: string) => Promise<Asset>;
30
30
  /**
31
31
  * Fetch an external URL on the user's behalf (server-side, to avoid CORS)
32
32
  * and return the raw file bytes. Must not create a persisted asset — the
@@ -50,12 +50,10 @@ export interface AssetManagerModalProps {
50
50
  /** Rewrite in-document `<plus:KIND ref="oldRef"/>` placeholders to `newRef`. */
51
51
  onResolveRef: (kind: AssetKind, oldRef: string, newRef: string) => void;
52
52
  /**
53
- * Replace `oldAsset` with the user's chosen `newAsset`. `fromLibrary` is true
54
- * when `newAsset` is an existing library asset (so it keeps its own ref and
55
- * the document is re-pointed), false when freshly created (so it adopts the
56
- * old asset's ref).
53
+ * Replace `oldAsset` with the user's freshly created `newAsset`, which adopts
54
+ * the old asset's ref so the document's references don't move.
57
55
  */
58
- onReplaceAsset: (oldAsset: Asset, newAsset: Asset, fromLibrary: boolean) => void;
56
+ onReplaceAsset: (oldAsset: Asset, newAsset: Asset) => void;
59
57
  }
60
- declare const AssetManagerModal: ({ open, onClose, resolveTarget, replaceTarget, onLoadAssets, onLoadLibraryAssets, onAddFromLibrary, onUpload, onFetchUrl, onCreateDoenet, onRemoveAsset, onDuplicateAsset, onAssetAdded, onResolveRef, onReplaceAsset, }: AssetManagerModalProps) => import("react").JSX.Element | null;
58
+ declare const AssetManagerModal: ({ open, onClose, resolveTarget, replaceTarget, onUpload, onFetchUrl, onCreateDoenet, onRemoveAsset, onDuplicateAsset, onAssetAdded, onResolveRef, onReplaceAsset, }: AssetManagerModalProps) => import("react").JSX.Element | null;
61
59
  export default AssetManagerModal;
@@ -36,6 +36,7 @@ interface CodeEditorProps {
36
36
  * since the tag/title/xml:id aren't editable in-place.
37
37
  */
38
38
  onRequestWrapperEdit?: () => void;
39
+ hideAssets?: boolean;
39
40
  }
40
41
  /** Imperative handle exposed via `forwardRef` for programmatic control. */
41
42
  export interface CodeEditorHandle {
@@ -34,6 +34,7 @@ interface CodeEditorMenuProps {
34
34
  onOpenAssets?: () => void;
35
35
  /** Called when the user clicks "Display Full Source" to open the assembled-source modal. */
36
36
  onShowFullSource: () => void;
37
+ hideAssets?: boolean;
37
38
  }
38
39
  declare const CodeEditorMenu: React.FC<CodeEditorMenuProps>;
39
40
  export default CodeEditorMenu;
@@ -100,13 +100,12 @@ export interface editorProps {
100
100
  * `xmlId` the editor picked — and should be persisted as-is.
101
101
  *
102
102
  * The division is added to the local pool synchronously and immediately,
103
- * before this is called, so the host's `id` provisioning never blocks the
104
- * UI. If a host needs to mint its own stable `id` (e.g. a Rails record
105
- * id) for the division, it can return that id here; once the returned
106
- * promise resolves, the editor patches it into the division's `id` field
107
- * in place. `xmlId` is unaffected and is never remapped.
103
+ * before this is called, so persistence never blocks the UI. The division
104
+ * arrives with **no** `id`: it is new until the host saves it through the
105
+ * project's nested `divisions_attributes` (no id = insert) and the server
106
+ * mints one, which flows back via the `divisions` prop (matched by `xmlId`).
108
107
  */
109
- onDivisionAdd?: (division: Division) => Promise<string> | void;
108
+ onDivisionAdd?: (division: Division) => void;
110
109
  /**
111
110
  * Called when the user deletes a division via the TOC UI.
112
111
  */
@@ -127,27 +126,27 @@ export interface editorProps {
127
126
  * button and modal are hidden entirely.
128
127
  */
129
128
  projectAssets?: Asset[];
130
- /**
131
- * All assets available in the user's library (across all projects).
132
- */
133
- libraryAssets?: Asset[];
134
129
  /**
135
130
  * @deprecated Assets are no longer inserted at the cursor — adding an asset
136
131
  * now copies its embed code to the clipboard. Retained for backward
137
132
  * compatibility; it is no longer called. Use the creation hooks
138
- * (`onAssetUpload`/`onAssetAddFromLibrary`/`onCreateDoenet`) to learn when an
139
- * asset enters the project.
133
+ * (`onAssetUpload`/`onCreateDoenet`) to learn when an asset enters the
134
+ * project.
140
135
  */
141
136
  onAssetInsert?: (asset: Asset) => void;
142
- /** Called when the user picks a library asset not yet in this project. */
143
- onAssetAddFromLibrary?: (asset: Asset) => Promise<void> | void;
144
- /** Called when the user uploads an image file. */
145
- onAssetUpload?: (file: File) => Promise<Asset>;
137
+ /**
138
+ * Called when the user uploads an image file, or after `onAssetFetchUrl`
139
+ * fetches an external URL. `title` is the human-readable title the user
140
+ * entered in the modal (may differ from `file.name`) persist it as the
141
+ * asset's title rather than deriving one from the filename.
142
+ */
143
+ onAssetUpload?: (file: File, title?: string) => Promise<Asset>;
146
144
  /**
147
145
  * Called when the user adds an image by URL. Should fetch the URL
148
146
  * server-side (to avoid CORS) and return the raw file bytes — it must
149
147
  * NOT create a persisted asset. The returned file is then committed via
150
- * `onAssetUpload`, the same as a local file pick.
148
+ * `onAssetUpload`, the same as a local file pick, with the user's entered
149
+ * title passed as `onAssetUpload`'s second argument.
151
150
  */
152
151
  onAssetFetchUrl?: (url: string) => Promise<File>;
153
152
  /** Called when the user creates a new Doenet activity. */
@@ -156,10 +155,8 @@ export interface editorProps {
156
155
  onAssetRemove?: (asset: Asset) => void;
157
156
  /** Called when the user saves edits to an asset's content (e.g. its `source`). */
158
157
  onAssetUpdate?: (asset: Asset) => Promise<void> | void;
159
- /** Called when the asset modal opens to fetch the latest project assets. */
160
- onLoadAssets?: () => Promise<Asset[]>;
161
- /** Called when the asset modal opens to fetch the full library asset list. */
162
- onLoadLibraryAssets?: () => Promise<Asset[]>;
158
+ /** If true, the TOC and asset manager hide all assets. */
159
+ hideAssets?: boolean;
163
160
  }
164
161
  /**
165
162
  * Top-level editor component. Creates the per-instance Zustand store and
@@ -4,7 +4,9 @@ export interface TableOfContentsProps {
4
4
  onToggleCollapse: () => void;
5
5
  /** When provided, shows "Open asset picker" affordance in the TOC. */
6
6
  onOpenAssetPicker?: () => void;
7
+ /** If true, hides all assets in the TOC and asset manager. */
8
+ hideAssets?: boolean;
7
9
  }
8
10
  /** TOC sidebar. ArticleToc reads divisions data from the editor store. */
9
- declare const TableOfContents: ({ isCollapsed, onToggleCollapse, onOpenAssetPicker, }: TableOfContentsProps) => import("react").JSX.Element;
11
+ declare const TableOfContents: ({ isCollapsed, onToggleCollapse, onOpenAssetPicker, hideAssets, }: TableOfContentsProps) => import("react").JSX.Element;
10
12
  export default TableOfContents;
@@ -1,5 +1,6 @@
1
1
  export interface ArticleTocProps {
2
2
  onOpenAssetPicker?: () => void;
3
+ hideAssets?: boolean;
3
4
  }
4
- declare const ArticleToc: ({ onOpenAssetPicker }: ArticleTocProps) => import("react").JSX.Element;
5
+ declare const ArticleToc: ({ onOpenAssetPicker, hideAssets }: ArticleTocProps) => import("react").JSX.Element;
5
6
  export default ArticleToc;