fable-editor 1.0.1 → 1.1.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 +43 -4
- package/dist/angular/LICENSE +1 -1
- package/dist/angular/README.md +44 -5
- package/dist/angular/core/config.d.ts +10 -0
- package/dist/angular/core/editor.d.ts +96 -0
- package/dist/angular/core/i18n.d.ts +45 -0
- package/dist/angular/core/types.d.ts +10 -0
- package/dist/angular/esm2022/core/config.mjs +143 -2
- package/dist/angular/esm2022/core/editor.mjs +1102 -27
- package/dist/angular/esm2022/core/i18n.mjs +93 -3
- package/dist/angular/esm2022/core/icons.mjs +11 -2
- package/dist/angular/esm2022/core/types.mjs +1 -1
- package/dist/angular/fesm2022/fable-editor.mjs +1344 -29
- package/dist/angular/fesm2022/fable-editor.mjs.map +1 -1
- package/dist/core/config.d.ts +10 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/editor.css +328 -3
- package/dist/core/editor.d.ts +96 -0
- package/dist/core/editor.d.ts.map +1 -1
- package/dist/core/i18n.d.ts +45 -0
- package/dist/core/i18n.d.ts.map +1 -1
- package/dist/core/icons.d.ts.map +1 -1
- package/dist/core/index.cjs +262 -6
- package/dist/core/index.mjs +14547 -1451
- package/dist/core/types.d.ts +10 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/react/FableEditor.d.ts.map +1 -1
- package/dist/react/index.cjs +271 -15
- package/dist/react/index.mjs +15064 -2004
- package/package.json +5 -1
- package/style.css +328 -3
package/README.md
CHANGED
|
@@ -13,8 +13,10 @@ A rich text editor packaged as an npm library with first-class React and Angular
|
|
|
13
13
|
| Fonts & formatting | Configurable font list (`fontFamilyFormats`), sizes, line-height, word-spacing, text/background color, change case |
|
|
14
14
|
| Custom content styling | `contentStyle` injects scoped CSS into the editable area (e.g. default font/size) |
|
|
15
15
|
| Images | Placeholder upload UI, drag-and-drop, configurable accepted file types (`imageFileTypes`), pluggable async upload handler |
|
|
16
|
+
| Video | Insert/edit dialog with **General** (source URL / upload / width / height), **Embed** (paste embed code) and **Advanced** (alternative source, poster image) tabs. YouTube / Vimeo / Dailymotion page URLs become embedded players — including when pasted directly into the editor. Template media slots can host a video instead of an image. |
|
|
17
|
+
| Math formulas | Insert inline or multi-line LaTeX derivations, rendered with [KaTeX](https://katex.org) — click an inserted formula to edit or delete it. Pasting LaTeX from the clipboard (`$…$`, `$$…$$`, `\(…\)`, `\[…\]`, `\begin{…}…\end{…}`) auto-renders it, and typing `$x^2$` inline converts as soon as the closing `$` is typed |
|
|
16
18
|
| Documents | Import `.docx` files, source-code view, print preview |
|
|
17
|
-
| Productivity | Undo/redo, revision history, autosave draft restore, word count, special characters, page breaks |
|
|
19
|
+
| Productivity | Undo/redo, revision history, autosave draft restore, word count, special characters & emoji pickers (category tabs + glyph grid), page breaks |
|
|
18
20
|
| Fullscreen | Toggle fullscreen editing |
|
|
19
21
|
| Help | Built-in shortcuts/help dialog |
|
|
20
22
|
|
|
@@ -68,9 +70,38 @@ editor.destroy();
|
|
|
68
70
|
| `imageFileTypes` | `string[]` | common image MIME types | `accept` list for the native image file picker. |
|
|
69
71
|
| `imageUploadHandler` | `(file: File) => Promise<string>` | — | Resolve with a URL after uploading; omit to inline images as base64. |
|
|
70
72
|
| `onImageUploadError` | `(error, file) => void` | — | Called when `imageUploadHandler` rejects. |
|
|
73
|
+
| `videoFileTypes` | `string[]` | `['video/mp4','video/webm','video/ogg']` | `accept` list for the native video file picker. |
|
|
74
|
+
| `videoUploadHandler` | `(file: File) => Promise<string>` | — | Resolve with a URL after uploading; omit to inline videos as base64. |
|
|
75
|
+
| `onVideoUploadError` | `(error, file) => void` | — | Called when `videoUploadHandler` rejects. |
|
|
71
76
|
| `draftKey` | `string` | current page path | Storage key suffix for autosaved drafts. |
|
|
72
77
|
| `onChange` / `onReady` | functions | — | Content-change and ready callbacks (usually set by the React/Angular wrapper instead). |
|
|
73
78
|
|
|
79
|
+
> **Math formulas:** the "Insert math formula" toolbar/menu item renders LaTeX with [KaTeX](https://katex.org), which FableEditor uses as a rendering dependency but does not bundle the stylesheet for (to avoid shipping KaTeX's webfonts in every install). If you use this feature, also import KaTeX's CSS once in your app: `import 'katex/dist/katex.min.css'`.
|
|
80
|
+
|
|
81
|
+
### Math from the clipboard / keyboard
|
|
82
|
+
|
|
83
|
+
Besides the dialog, formulas can enter the document two more ways — the regular paste pipeline is untouched, these only kick in when the clipboard is *entirely* one formula:
|
|
84
|
+
|
|
85
|
+
- **Paste** `$$…$$`, `\[…\]` or a `\begin{…}…\end{…}` environment → a **block** formula on its own line. A derivation pasted as separate lines gets each step on its own row automatically.
|
|
86
|
+
- **Paste** `\(…\)` or a LaTeX-looking `$…$` → an **inline** formula at the caret (same line). Plain text like `$5 and $10` is left alone.
|
|
87
|
+
- **Type** `$x^2$` — the moment the closing `$` is typed, the run converts to an inline formula (only when it parses as valid LaTeX; a literal `$5` stays text).
|
|
88
|
+
|
|
89
|
+
### Toolbar & menubar configuration
|
|
90
|
+
|
|
91
|
+
The `toolbar`/`menubar` options accept the same style of layout string as TinyMCE — `|` separates visual groups, spaces separate items:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
new FableEditor({
|
|
95
|
+
target: document.querySelector('#default-editor')!,
|
|
96
|
+
toolbar:
|
|
97
|
+
'undo redo | styles | bold italic underline strikethrough | ' +
|
|
98
|
+
'alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
|
99
|
+
menubar: 'file edit insert format'
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Available toolbar items: `undo redo preview print importword revhistory fontfamily fontsize fontsizeincrease fontsizedecrease bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify bullist numlist outdent indent link blockquote changecase lineheight wordspacing removeformat blocks ltr rtl quickimage quickvideo quicktable mathformula template charmap emoji fullscreen sourcecode`. The TinyMCE names `styles` (→ `blocks`), `image` (→ `quickimage`), `media` (→ `quickvideo`) and `table` (→ `quicktable`) are accepted as aliases, so a typical TinyMCE toolbar string works unchanged. Unknown tokens are skipped with a console warning. Menubar keys: `file edit view insert format tools table help`.
|
|
104
|
+
|
|
74
105
|
## React
|
|
75
106
|
|
|
76
107
|
```tsx
|
|
@@ -86,12 +117,15 @@ function App() {
|
|
|
86
117
|
onChange={setValue}
|
|
87
118
|
language="en"
|
|
88
119
|
height={400}
|
|
120
|
+
toolbar="undo redo | styles | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
|
|
89
121
|
/>
|
|
90
122
|
);
|
|
91
123
|
}
|
|
92
124
|
```
|
|
93
125
|
|
|
94
|
-
|
|
126
|
+
`toolbar`/`menubar` accept the same layout strings as the core option (see [Toolbar & menubar configuration](#toolbar--menubar-configuration)), so each app can show exactly the controls it needs.
|
|
127
|
+
|
|
128
|
+
Props: `value`, `defaultValue`, `onChange`, `language`, `height`, `menubar`, `toolbar`, `statusbar`, `readonly`, `fontFamilyFormats`, `contentStyle`, `imageFileTypes`, `imageUploadHandler`, `onImageUploadError`, `videoFileTypes`, `videoUploadHandler`, `onVideoUploadError`, `init`, `className`, `style` (see the [`init` options](#init-options) table above — every option is also a top-level prop). A ref exposes `getContent`, `setContent`, `insertContent`, `setLanguage`, `focus`, `destroy`.
|
|
95
129
|
|
|
96
130
|
## Angular
|
|
97
131
|
|
|
@@ -118,10 +152,15 @@ export class AppModule {}
|
|
|
118
152
|
Use in a template:
|
|
119
153
|
|
|
120
154
|
```html
|
|
121
|
-
<fable-editor
|
|
155
|
+
<fable-editor
|
|
156
|
+
[(ngModel)]="content"
|
|
157
|
+
language="en"
|
|
158
|
+
[height]="400"
|
|
159
|
+
toolbar="undo redo | styles | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image">
|
|
160
|
+
</fable-editor>
|
|
122
161
|
```
|
|
123
162
|
|
|
124
|
-
Inputs: `language`, `height`, `menubar`, `toolbar`, `statusbar`, `readonly`, `init`. `menubar`/`toolbar` accept a string directly (e.g. `[toolbar]="'undo redo | bold italic'"`); `fontFamilyFormats`, `contentStyle`, `imageFileTypes`, `imageUploadHandler`, and `
|
|
163
|
+
Inputs: `language`, `height`, `menubar`, `toolbar`, `statusbar`, `readonly`, `init`. `menubar`/`toolbar` accept a string directly (e.g. `[toolbar]="'undo redo | bold italic'"`); `fontFamilyFormats`, `contentStyle`, `imageFileTypes`, `imageUploadHandler`, `onImageUploadError`, `videoFileTypes`, `videoUploadHandler`, and `onVideoUploadError` aren't top-level inputs — pass them via `[init]="{ contentStyle: '...' }"` (see the [`init` options](#init-options) table above). Outputs: `editorChange`, `editorReady`. Works with `ngModel` and `formControlName`.
|
|
125
164
|
|
|
126
165
|
## Development & testing
|
|
127
166
|
|
package/dist/angular/LICENSE
CHANGED
package/dist/angular/README.md
CHANGED
|
@@ -13,8 +13,10 @@ A rich text editor packaged as an npm library with first-class React and Angular
|
|
|
13
13
|
| Fonts & formatting | Configurable font list (`fontFamilyFormats`), sizes, line-height, word-spacing, text/background color, change case |
|
|
14
14
|
| Custom content styling | `contentStyle` injects scoped CSS into the editable area (e.g. default font/size) |
|
|
15
15
|
| Images | Placeholder upload UI, drag-and-drop, configurable accepted file types (`imageFileTypes`), pluggable async upload handler |
|
|
16
|
+
| Video | Insert/edit dialog with **General** (source URL / upload / width / height), **Embed** (paste embed code) and **Advanced** (alternative source, poster image) tabs. YouTube / Vimeo / Dailymotion page URLs become embedded players — including when pasted directly into the editor. Template media slots can host a video instead of an image. |
|
|
17
|
+
| Math formulas | Insert inline or multi-line LaTeX derivations, rendered with [KaTeX](https://katex.org) — click an inserted formula to edit or delete it. Pasting LaTeX from the clipboard (`$…$`, `$$…$$`, `\(…\)`, `\[…\]`, `\begin{…}…\end{…}`) auto-renders it, and typing `$x^2$` inline converts as soon as the closing `$` is typed |
|
|
16
18
|
| Documents | Import `.docx` files, source-code view, print preview |
|
|
17
|
-
| Productivity | Undo/redo, revision history, autosave draft restore, word count, special characters, page breaks |
|
|
19
|
+
| Productivity | Undo/redo, revision history, autosave draft restore, word count, special characters & emoji pickers (category tabs + glyph grid), page breaks |
|
|
18
20
|
| Fullscreen | Toggle fullscreen editing |
|
|
19
21
|
| Help | Built-in shortcuts/help dialog |
|
|
20
22
|
|
|
@@ -68,9 +70,38 @@ editor.destroy();
|
|
|
68
70
|
| `imageFileTypes` | `string[]` | common image MIME types | `accept` list for the native image file picker. |
|
|
69
71
|
| `imageUploadHandler` | `(file: File) => Promise<string>` | — | Resolve with a URL after uploading; omit to inline images as base64. |
|
|
70
72
|
| `onImageUploadError` | `(error, file) => void` | — | Called when `imageUploadHandler` rejects. |
|
|
73
|
+
| `videoFileTypes` | `string[]` | `['video/mp4','video/webm','video/ogg']` | `accept` list for the native video file picker. |
|
|
74
|
+
| `videoUploadHandler` | `(file: File) => Promise<string>` | — | Resolve with a URL after uploading; omit to inline videos as base64. |
|
|
75
|
+
| `onVideoUploadError` | `(error, file) => void` | — | Called when `videoUploadHandler` rejects. |
|
|
71
76
|
| `draftKey` | `string` | current page path | Storage key suffix for autosaved drafts. |
|
|
72
77
|
| `onChange` / `onReady` | functions | — | Content-change and ready callbacks (usually set by the React/Angular wrapper instead). |
|
|
73
78
|
|
|
79
|
+
> **Math formulas:** the "Insert math formula" toolbar/menu item renders LaTeX with [KaTeX](https://katex.org), which FableEditor uses as a rendering dependency but does not bundle the stylesheet for (to avoid shipping KaTeX's webfonts in every install). If you use this feature, also import KaTeX's CSS once in your app: `import 'katex/dist/katex.min.css'`.
|
|
80
|
+
|
|
81
|
+
### Math from the clipboard / keyboard
|
|
82
|
+
|
|
83
|
+
Besides the dialog, formulas can enter the document two more ways — the regular paste pipeline is untouched, these only kick in when the clipboard is *entirely* one formula:
|
|
84
|
+
|
|
85
|
+
- **Paste** `$$…$$`, `\[…\]` or a `\begin{…}…\end{…}` environment → a **block** formula on its own line. A derivation pasted as separate lines gets each step on its own row automatically.
|
|
86
|
+
- **Paste** `\(…\)` or a LaTeX-looking `$…$` → an **inline** formula at the caret (same line). Plain text like `$5 and $10` is left alone.
|
|
87
|
+
- **Type** `$x^2$` — the moment the closing `$` is typed, the run converts to an inline formula (only when it parses as valid LaTeX; a literal `$5` stays text).
|
|
88
|
+
|
|
89
|
+
### Toolbar & menubar configuration
|
|
90
|
+
|
|
91
|
+
The `toolbar`/`menubar` options accept the same style of layout string as TinyMCE — `|` separates visual groups, spaces separate items:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
new FableEditor({
|
|
95
|
+
target: document.querySelector('#default-editor')!,
|
|
96
|
+
toolbar:
|
|
97
|
+
'undo redo | styles | bold italic underline strikethrough | ' +
|
|
98
|
+
'alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
|
99
|
+
menubar: 'file edit insert format'
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Available toolbar items: `undo redo preview print importword revhistory fontfamily fontsize fontsizeincrease fontsizedecrease bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify bullist numlist outdent indent link blockquote changecase lineheight wordspacing removeformat blocks ltr rtl quickimage quickvideo quicktable mathformula template charmap emoji fullscreen sourcecode`. The TinyMCE names `styles` (→ `blocks`), `image` (→ `quickimage`), `media` (→ `quickvideo`) and `table` (→ `quicktable`) are accepted as aliases, so a typical TinyMCE toolbar string works unchanged. Unknown tokens are skipped with a console warning. Menubar keys: `file edit view insert format tools table help`.
|
|
104
|
+
|
|
74
105
|
## React
|
|
75
106
|
|
|
76
107
|
```tsx
|
|
@@ -86,12 +117,15 @@ function App() {
|
|
|
86
117
|
onChange={setValue}
|
|
87
118
|
language="en"
|
|
88
119
|
height={400}
|
|
120
|
+
toolbar="undo redo | styles | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
|
|
89
121
|
/>
|
|
90
122
|
);
|
|
91
123
|
}
|
|
92
124
|
```
|
|
93
125
|
|
|
94
|
-
|
|
126
|
+
`toolbar`/`menubar` accept the same layout strings as the core option (see [Toolbar & menubar configuration](#toolbar--menubar-configuration)), so each app can show exactly the controls it needs.
|
|
127
|
+
|
|
128
|
+
Props: `value`, `defaultValue`, `onChange`, `language`, `height`, `menubar`, `toolbar`, `statusbar`, `readonly`, `fontFamilyFormats`, `contentStyle`, `imageFileTypes`, `imageUploadHandler`, `onImageUploadError`, `videoFileTypes`, `videoUploadHandler`, `onVideoUploadError`, `init`, `className`, `style` (see the [`init` options](#init-options) table above — every option is also a top-level prop). A ref exposes `getContent`, `setContent`, `insertContent`, `setLanguage`, `focus`, `destroy`.
|
|
95
129
|
|
|
96
130
|
## Angular
|
|
97
131
|
|
|
@@ -118,10 +152,15 @@ export class AppModule {}
|
|
|
118
152
|
Use in a template:
|
|
119
153
|
|
|
120
154
|
```html
|
|
121
|
-
<fable-editor
|
|
155
|
+
<fable-editor
|
|
156
|
+
[(ngModel)]="content"
|
|
157
|
+
language="en"
|
|
158
|
+
[height]="400"
|
|
159
|
+
toolbar="undo redo | styles | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image">
|
|
160
|
+
</fable-editor>
|
|
122
161
|
```
|
|
123
162
|
|
|
124
|
-
Inputs: `language`, `height`, `menubar`, `toolbar`, `statusbar`, `readonly`, `init`. `menubar`/`toolbar` accept a string directly (e.g. `[toolbar]="'undo redo | bold italic'"`); `fontFamilyFormats`, `contentStyle`, `imageFileTypes`, `imageUploadHandler`, and `
|
|
163
|
+
Inputs: `language`, `height`, `menubar`, `toolbar`, `statusbar`, `readonly`, `init`. `menubar`/`toolbar` accept a string directly (e.g. `[toolbar]="'undo redo | bold italic'"`); `fontFamilyFormats`, `contentStyle`, `imageFileTypes`, `imageUploadHandler`, `onImageUploadError`, `videoFileTypes`, `videoUploadHandler`, and `onVideoUploadError` aren't top-level inputs — pass them via `[init]="{ contentStyle: '...' }"` (see the [`init` options](#init-options) table above). Outputs: `editorChange`, `editorReady`. Works with `ngModel` and `formControlName`.
|
|
125
164
|
|
|
126
165
|
## Development & testing
|
|
127
166
|
|
|
@@ -168,7 +207,7 @@ test/
|
|
|
168
207
|
|
|
169
208
|
## Author
|
|
170
209
|
|
|
171
|
-
|
|
210
|
+
Sajin Satheesan <an.sajinsatheesan@gmail.com>
|
|
172
211
|
|
|
173
212
|
## License
|
|
174
213
|
|
|
@@ -14,4 +14,14 @@ export declare const BLOCKS: [string, string][];
|
|
|
14
14
|
/** Quick-access text color chips shown directly in the toolbar. */
|
|
15
15
|
export declare const QUICK_COLORS: string[];
|
|
16
16
|
export declare const COLORS: string[];
|
|
17
|
+
/** Category key = i18n string key for the tab label in the picker dialogs. */
|
|
18
|
+
export interface GlyphCategory {
|
|
19
|
+
key: string;
|
|
20
|
+
chars: string[];
|
|
21
|
+
}
|
|
22
|
+
/** Special-character map, grouped for the two-pane picker (tabs left, glyphs right).
|
|
23
|
+
* `CHARS` below is the legacy flat list and is kept exported for back-compat. */
|
|
24
|
+
export declare const CHAR_CATEGORIES: GlyphCategory[];
|
|
25
|
+
/** Emoji map for the emoji picker — same two-pane dialog as the character map. */
|
|
26
|
+
export declare const EMOJI_CATEGORIES: GlyphCategory[];
|
|
17
27
|
export declare const CHARS: string[];
|
|
@@ -37,7 +37,20 @@ export declare class FableEditor implements FableEditorApi {
|
|
|
37
37
|
private imageUploadHandler?;
|
|
38
38
|
private onImageUploadError?;
|
|
39
39
|
private contentStyle?;
|
|
40
|
+
private vidInput;
|
|
41
|
+
private vidActive;
|
|
42
|
+
private vidCtx;
|
|
43
|
+
private vidHideTimer;
|
|
44
|
+
private vphActive;
|
|
45
|
+
private vphCtx;
|
|
46
|
+
private vphUploadTarget;
|
|
47
|
+
private videoUploadHandler?;
|
|
48
|
+
private onVideoUploadError?;
|
|
49
|
+
private mathActive;
|
|
50
|
+
private mathCtx;
|
|
40
51
|
private selCtx;
|
|
52
|
+
private tplActive;
|
|
53
|
+
private tplCtx;
|
|
41
54
|
private docInput;
|
|
42
55
|
private revisions;
|
|
43
56
|
private revTimer;
|
|
@@ -154,13 +167,22 @@ export declare class FableEditor implements FableEditorApi {
|
|
|
154
167
|
private helpDlg;
|
|
155
168
|
private wordCountDlg;
|
|
156
169
|
private previewDlg;
|
|
170
|
+
/** Two-pane picker shared by the special-character map and the emoji map:
|
|
171
|
+
* fixed category tabs on the left, the active category's glyphs on the right. */
|
|
172
|
+
private glyphPickerDlg;
|
|
157
173
|
private charMap;
|
|
174
|
+
private emojiMap;
|
|
158
175
|
private printDoc;
|
|
159
176
|
private pickImage;
|
|
177
|
+
private imgPhHTML;
|
|
160
178
|
private insertImagePlaceholder;
|
|
161
179
|
private clearImgPlaceholderSel;
|
|
180
|
+
private removeImgPlaceholder;
|
|
162
181
|
private selectImgPlaceholder;
|
|
163
182
|
private renderPhCtxButtons;
|
|
183
|
+
/** Swaps a template slot's placeholder between image and video kinds, so the
|
|
184
|
+
* same media slot can be filled with either. */
|
|
185
|
+
private swapPlaceholderKind;
|
|
164
186
|
private renderPhCtxUrlInput;
|
|
165
187
|
private readImageFileInto;
|
|
166
188
|
/** Runs the host-supplied imageUploadHandler instead of inlining base64,
|
|
@@ -168,6 +190,80 @@ export declare class FableEditor implements FableEditorApi {
|
|
|
168
190
|
private uploadImageFile;
|
|
169
191
|
private replacePlaceholderWithImage;
|
|
170
192
|
private positionImgPhCtx;
|
|
193
|
+
private pickVideo;
|
|
194
|
+
private vidPhHTML;
|
|
195
|
+
private insertVideoPlaceholder;
|
|
196
|
+
private clearVphPlaceholderSel;
|
|
197
|
+
private removeVphPlaceholder;
|
|
198
|
+
private selectVphPlaceholder;
|
|
199
|
+
private renderVphCtxButtons;
|
|
200
|
+
private renderVphCtxUrlInput;
|
|
201
|
+
private readVideoFileInto;
|
|
202
|
+
/** Runs the host-supplied videoUploadHandler instead of inlining base64,
|
|
203
|
+
* so apps can route the file to S3 / Azure Blob / their own server. */
|
|
204
|
+
private uploadVideoFile;
|
|
205
|
+
private replacePlaceholderWithVideo;
|
|
206
|
+
/** Swaps a video placeholder for a hosted player iframe (YouTube & co.). */
|
|
207
|
+
private replacePlaceholderWithEmbed;
|
|
208
|
+
private positionVphCtx;
|
|
209
|
+
private cancelVidHide;
|
|
210
|
+
private clearVidHandles;
|
|
211
|
+
private selectVideo;
|
|
212
|
+
private buildVideoCtxToolbar;
|
|
213
|
+
private setVideoAlign;
|
|
214
|
+
private positionVidCtx;
|
|
215
|
+
/** Maps a page URL from a known video host to its iframe player URL. Returns
|
|
216
|
+
* null for anything else (e.g. direct .mp4 file URLs). */
|
|
217
|
+
private videoEmbedUrl;
|
|
218
|
+
private videoEmbedHTML;
|
|
219
|
+
/** Insert/edit-video dialog with General (source/width/height), Embed (embed
|
|
220
|
+
* code) and Advanced (alternative source, poster image) tabs. Hosted page
|
|
221
|
+
* URLs (YouTube & co.) become iframe players; anything else becomes a
|
|
222
|
+
* <video> tag. The General tab also offers the same upload path as before
|
|
223
|
+
* (videoUploadHandler when configured, else inline base64). */
|
|
224
|
+
private videoDlg;
|
|
225
|
+
private renderMathHTML;
|
|
226
|
+
/** Shared by the math dialog, math paste, and math typing: renders `src` with
|
|
227
|
+
* KaTeX and inserts it at the caret as the standard math element (inline span /
|
|
228
|
+
* block div carrying its LaTeX source in data-latex). Block formulas get the
|
|
229
|
+
* same \begin{aligned} wrapping the dialog applies, so pasted derivations align
|
|
230
|
+
* their steps and re-open correctly in the edit dialog. */
|
|
231
|
+
private insertMathElement;
|
|
232
|
+
/** Recognizes a plain-text clipboard payload that is entirely one math formula:
|
|
233
|
+
* $$…$$ / \[…\] (block), \(…\) (inline), a \begin{…}…\end{…} environment (block),
|
|
234
|
+
* or $…$ (inline — only when the inside looks like LaTeX, so "$50" stays text).
|
|
235
|
+
* Multi-line block content (a derivation pasted as separate lines) gets its lines
|
|
236
|
+
* joined with \\ so each step lands on its own line. Returns null for anything
|
|
237
|
+
* else, letting the normal paste pipeline run unchanged. */
|
|
238
|
+
private mathFromClipboard;
|
|
239
|
+
/** A derivation pasted as separate lines has no explicit \\ row breaks — add them.
|
|
240
|
+
* Content that already breaks rows itself (\\ present, or a \begin environment
|
|
241
|
+
* managing its own layout) only has its newlines collapsed to spaces. */
|
|
242
|
+
private joinDerivationLines;
|
|
243
|
+
/** Typing "$…$" converts to an inline formula the moment the closing "$" is typed,
|
|
244
|
+
* so math can be written in place without opening the dialog. Only kicks in when
|
|
245
|
+
* the run since the opening "$" parses as valid LaTeX and contains LaTeX-ish
|
|
246
|
+
* syntax (\ ^ _ { } =) — a literal "$5 and 3$" stays plain text. */
|
|
247
|
+
private tryMathTyping;
|
|
248
|
+
private mathDlg;
|
|
249
|
+
private escapeAttr;
|
|
250
|
+
private unescapeAttr;
|
|
251
|
+
private clearMathSel;
|
|
252
|
+
private selectMathEl;
|
|
253
|
+
private buildMathCtxToolbar;
|
|
254
|
+
private positionMathCtx;
|
|
255
|
+
private templateMenu;
|
|
256
|
+
/** Miniature div-based mockup of a layout, mirroring what the block looks
|
|
257
|
+
like in the editor: grey box = image slot, bars = heading/paragraph. */
|
|
258
|
+
private tplPreviewHTML;
|
|
259
|
+
private buildTemplatePickInto;
|
|
260
|
+
private insertTemplate;
|
|
261
|
+
private clearTplSel;
|
|
262
|
+
private selectTemplate;
|
|
263
|
+
private renderTplCtxButtons;
|
|
264
|
+
private setTplLayout;
|
|
265
|
+
private removeTemplate;
|
|
266
|
+
private positionTplCtx;
|
|
171
267
|
private pickWordDoc;
|
|
172
268
|
private toggleFullscreen;
|
|
173
269
|
private clearTableHandles;
|
|
@@ -134,6 +134,51 @@ export interface I18nStrings {
|
|
|
134
134
|
dropimage: string;
|
|
135
135
|
uploading: string;
|
|
136
136
|
uploadfailed: string;
|
|
137
|
+
template: string;
|
|
138
|
+
tplimgleft: string;
|
|
139
|
+
tplimgright: string;
|
|
140
|
+
tplimgtop: string;
|
|
141
|
+
tplimgcenter: string;
|
|
142
|
+
deltemplate: string;
|
|
143
|
+
video: string;
|
|
144
|
+
quickvideo: string;
|
|
145
|
+
deletevideo: string;
|
|
146
|
+
uploadvideo: string;
|
|
147
|
+
videolink: string;
|
|
148
|
+
videourlph: string;
|
|
149
|
+
insertvideo: string;
|
|
150
|
+
dropvideo: string;
|
|
151
|
+
mathformula: string;
|
|
152
|
+
mathdlgttl: string;
|
|
153
|
+
mathderivation: string;
|
|
154
|
+
mathlatex: string;
|
|
155
|
+
editmath: string;
|
|
156
|
+
deletemath: string;
|
|
157
|
+
videodlgttl: string;
|
|
158
|
+
vidgeneral: string;
|
|
159
|
+
vidembed: string;
|
|
160
|
+
vidadvanced: string;
|
|
161
|
+
vidsource: string;
|
|
162
|
+
vidembedhint: string;
|
|
163
|
+
vidaltsource: string;
|
|
164
|
+
vidposter: string;
|
|
165
|
+
emoji: string;
|
|
166
|
+
chcat_currency: string;
|
|
167
|
+
chcat_text: string;
|
|
168
|
+
chcat_math: string;
|
|
169
|
+
chcat_arrows: string;
|
|
170
|
+
chcat_symbols: string;
|
|
171
|
+
chcat_latin: string;
|
|
172
|
+
chcat_arabic: string;
|
|
173
|
+
emcat_smileys: string;
|
|
174
|
+
emcat_people: string;
|
|
175
|
+
emcat_animals: string;
|
|
176
|
+
emcat_food: string;
|
|
177
|
+
emcat_travel: string;
|
|
178
|
+
emcat_activities: string;
|
|
179
|
+
emcat_objects: string;
|
|
180
|
+
emcat_symbols: string;
|
|
181
|
+
emcat_flags: string;
|
|
137
182
|
}
|
|
138
183
|
export declare const I18N: Record<EditorLanguage, I18nStrings>;
|
|
139
184
|
export declare function getStrings(lang: EditorLanguage): I18nStrings;
|
|
@@ -50,6 +50,16 @@ export interface EditorInitOptions {
|
|
|
50
50
|
imageUploadHandler?: (file: File) => Promise<string>;
|
|
51
51
|
/** Called when imageUploadHandler rejects, so the host app can surface it. */
|
|
52
52
|
onImageUploadError?: (error: unknown, file: File) => void;
|
|
53
|
+
/** MIME types accepted by the native video file picker (the `accept` attribute).
|
|
54
|
+
* Defaults to `['video/mp4','video/webm','video/ogg']`. */
|
|
55
|
+
videoFileTypes?: string[];
|
|
56
|
+
/** Called when a user picks or drops a video. Resolve with the URL to
|
|
57
|
+
* insert (e.g. after uploading to S3/Azure Blob/your own server). If
|
|
58
|
+
* omitted, videos are inlined as base64 data URIs instead. Mirrors
|
|
59
|
+
* `imageUploadHandler` — the engine owns all placeholder/progress/insert UI. */
|
|
60
|
+
videoUploadHandler?: (file: File) => Promise<string>;
|
|
61
|
+
/** Called when videoUploadHandler rejects, so the host app can surface it. */
|
|
62
|
+
onVideoUploadError?: (error: unknown, file: File) => void;
|
|
53
63
|
}
|
|
54
64
|
export interface FableEditorApi {
|
|
55
65
|
getContent(): string;
|