@themarioga/grid-editor 8.5.0 → 8.6.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/CHANGELOG.md +33 -0
- package/README.md +78 -4
- package/dist/grideditor.bundle.min.js +3 -3
- package/dist/grideditor.css +15 -4
- package/dist/grideditor.d.ts +59 -3
- package/dist/grideditor.esm.js +200 -36
- package/dist/grideditor.js +200 -36
- package/dist/grideditor.min.css +1 -1
- package/dist/grideditor.min.css.map +1 -1
- package/dist/grideditor.min.js +2 -2
- package/dist/grideditor.min.js.map +3 -3
- package/dist/locales/grideditor.es.esm.js +4 -0
- package/dist/locales/grideditor.es.js +4 -0
- package/dist/locales/grideditor.es.min.js +1 -1
- package/dist/locales/grideditor.es.min.js.map +2 -2
- package/dist/plugins/grideditor.accordion.esm.js +7 -0
- package/dist/plugins/grideditor.accordion.js +7 -0
- package/dist/plugins/grideditor.accordion.min.js +1 -1
- package/dist/plugins/grideditor.accordion.min.js.map +3 -3
- package/dist/plugins/grideditor.autosave.esm.js +309 -0
- package/dist/plugins/grideditor.autosave.js +316 -0
- package/dist/plugins/grideditor.autosave.min.js +1 -0
- package/dist/plugins/grideditor.autosave.min.js.map +7 -0
- package/dist/plugins/grideditor.card.esm.js +10 -0
- package/dist/plugins/grideditor.card.js +10 -0
- package/dist/plugins/grideditor.card.min.js +1 -1
- package/dist/plugins/grideditor.card.min.js.map +3 -3
- package/dist/plugins/grideditor.ckeditor.esm.js +29 -0
- package/dist/plugins/grideditor.ckeditor.js +29 -0
- package/dist/plugins/grideditor.ckeditor.min.js +1 -1
- package/dist/plugins/grideditor.ckeditor.min.js.map +3 -3
- package/dist/plugins/grideditor.clipboard.esm.js +3 -0
- package/dist/plugins/grideditor.clipboard.js +3 -0
- package/dist/plugins/grideditor.clipboard.min.js +1 -1
- package/dist/plugins/grideditor.clipboard.min.js.map +2 -2
- package/dist/plugins/grideditor.codemirror-inline.esm.js +11 -0
- package/dist/plugins/grideditor.codemirror-inline.js +11 -0
- package/dist/plugins/grideditor.codemirror-inline.min.js +1 -1
- package/dist/plugins/grideditor.codemirror-inline.min.js.map +3 -3
- package/dist/plugins/grideditor.elements.esm.js +6 -3
- package/dist/plugins/grideditor.elements.js +6 -3
- package/dist/plugins/grideditor.elements.min.js +1 -1
- package/dist/plugins/grideditor.elements.min.js.map +3 -3
- package/dist/plugins/grideditor.gutters.esm.js +5 -0
- package/dist/plugins/grideditor.gutters.js +5 -0
- package/dist/plugins/grideditor.gutters.min.js +1 -1
- package/dist/plugins/grideditor.gutters.min.js.map +3 -3
- package/dist/plugins/grideditor.inline-style.esm.js +18 -10
- package/dist/plugins/grideditor.inline-style.js +18 -10
- package/dist/plugins/grideditor.inline-style.min.js +3 -3
- package/dist/plugins/grideditor.inline-style.min.js.map +3 -3
- package/dist/plugins/grideditor.order.esm.js +5 -0
- package/dist/plugins/grideditor.order.js +5 -0
- package/dist/plugins/grideditor.order.min.js +1 -1
- package/dist/plugins/grideditor.order.min.js.map +3 -3
- package/dist/plugins/grideditor.popup.esm.js +17 -6
- package/dist/plugins/grideditor.popup.js +17 -6
- package/dist/plugins/grideditor.popup.min.js +1 -1
- package/dist/plugins/grideditor.popup.min.js.map +3 -3
- package/dist/plugins/grideditor.sections.esm.js +6 -3
- package/dist/plugins/grideditor.sections.js +6 -3
- package/dist/plugins/grideditor.sections.min.js +1 -1
- package/dist/plugins/grideditor.sections.min.js.map +3 -3
- package/dist/plugins/grideditor.summernote.esm.js +39 -0
- package/dist/plugins/grideditor.summernote.js +39 -0
- package/dist/plugins/grideditor.summernote.min.js +1 -1
- package/dist/plugins/grideditor.summernote.min.js.map +3 -3
- package/dist/plugins/grideditor.tabs.esm.js +7 -0
- package/dist/plugins/grideditor.tabs.js +7 -0
- package/dist/plugins/grideditor.tabs.min.js +1 -1
- package/dist/plugins/grideditor.tabs.min.js.map +3 -3
- package/dist/plugins/grideditor.tinymce.esm.js +31 -0
- package/dist/plugins/grideditor.tinymce.js +31 -0
- package/dist/plugins/grideditor.tinymce.min.js +1 -1
- package/dist/plugins/grideditor.tinymce.min.js.map +3 -3
- package/docs/events.md +8 -0
- package/docs/locale-keys.md +14 -0
- package/docs/plugins.md +54 -2
- package/example/autosave.html +39 -22
- package/example/index.html +1 -1
- package/example/plugins.html +10 -0
- package/package.json +1 -2
- package/src/js/grideditor.js +242 -28
- package/src/js/inline-style/display.js +4 -3
- package/src/js/inline-style/drawerflow.js +10 -5
- package/src/js/locales/grideditor.es.js +4 -0
- package/src/js/plugins/grideditor.accordion.js +6 -0
- package/src/js/plugins/grideditor.autosave.js +349 -0
- package/src/js/plugins/grideditor.card.js +6 -0
- package/src/js/plugins/grideditor.ckeditor.js +6 -0
- package/src/js/plugins/grideditor.clipboard.js +3 -0
- package/src/js/plugins/grideditor.codemirror-inline.js +7 -0
- package/src/js/plugins/grideditor.elements.js +4 -3
- package/src/js/plugins/grideditor.gutters.js +4 -0
- package/src/js/plugins/grideditor.inline-style.js +2 -0
- package/src/js/plugins/grideditor.order.js +4 -0
- package/src/js/plugins/grideditor.popup.js +15 -6
- package/src/js/plugins/grideditor.sections.js +4 -3
- package/src/js/plugins/grideditor.summernote.js +14 -0
- package/src/js/plugins/grideditor.tabs.js +6 -0
- package/src/js/plugins/grideditor.tinymce.js +8 -0
- package/src/js/text/grideditor.text.js +26 -0
- package/src/less/grideditor.less +16 -8
- package/types/grideditor.d.ts +59 -3
- package/AUTO_SAVE.md +0 -30
package/types/grideditor.d.ts
CHANGED
|
@@ -126,6 +126,8 @@ export interface GridEditorOptions {
|
|
|
126
126
|
/** The tabs plugin: the variant of the tabs containers made new. */
|
|
127
127
|
tabs?: TabsOptions;
|
|
128
128
|
elements?: { enabled?: boolean | 'auto'; selector?: string; auto?: boolean; types?: ElementType[] };
|
|
129
|
+
/** The autosave plugin: what is edited, kept in the browser's storage as it changes. */
|
|
130
|
+
autosave?: AutosaveOptions;
|
|
129
131
|
custom_filter?: CustomFilter | CustomFilter[] | '';
|
|
130
132
|
valid_col_sizes?: ColumnSize[];
|
|
131
133
|
valid_col_offsets?: number[];
|
|
@@ -151,6 +153,50 @@ export interface GridEditorOptions {
|
|
|
151
153
|
[plugin: string]: unknown;
|
|
152
154
|
}
|
|
153
155
|
|
|
156
|
+
/** The autosave plugin's options. */
|
|
157
|
+
export interface AutosaveOptions {
|
|
158
|
+
/** Saving from the start; the methods turn it on and off. Default true. */
|
|
159
|
+
enabled?: boolean;
|
|
160
|
+
/** localStorage or sessionStorage. Default 'local'. */
|
|
161
|
+
storage?: 'local' | 'session';
|
|
162
|
+
/** Where the draft is kept. Default 'grideditor.autosave:' + the page's path + '#' + the canvas's id. One per document on a page that loads several. */
|
|
163
|
+
key?: string | null;
|
|
164
|
+
/** Milliseconds after the last change. Default 1000. */
|
|
165
|
+
delay?: number;
|
|
166
|
+
/** Milliseconds a draft is offered for; null, the default, for ever. */
|
|
167
|
+
maxAge?: number | null;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** A draft the autosave plugin kept. */
|
|
171
|
+
export interface AutosaveDraft {
|
|
172
|
+
html: string;
|
|
173
|
+
/** When, as an ISO 8601 date. */
|
|
174
|
+
savedAt: string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface GetHtmlOptions {
|
|
178
|
+
/** Read the canvas without it leaving editing: open texts and settings panels stay open. */
|
|
179
|
+
keepEditing?: boolean;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface AutosavePayload {
|
|
183
|
+
canvas: HTMLElement;
|
|
184
|
+
html: string;
|
|
185
|
+
savedAt: string;
|
|
186
|
+
source: 'change' | 'pagehide' | 'api' | 'destroy';
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface RestoreDraftPayload {
|
|
190
|
+
canvas: HTMLElement;
|
|
191
|
+
html: string;
|
|
192
|
+
savedAt: string;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface AutosaveErrorPayload {
|
|
196
|
+
canvas: HTMLElement;
|
|
197
|
+
error: unknown;
|
|
198
|
+
}
|
|
199
|
+
|
|
154
200
|
/** Where a node was, or went: its parent and its index among the blocks there. */
|
|
155
201
|
export interface Position {
|
|
156
202
|
parent: HTMLElement;
|
|
@@ -271,6 +317,9 @@ export interface GridEditorEventMap {
|
|
|
271
317
|
'grideditor:popup-orphan': PopupOrphanPayload;
|
|
272
318
|
'grideditor:view-change': ViewChangePayload;
|
|
273
319
|
'grideditor:target-change': TargetChangePayload;
|
|
320
|
+
'grideditor:after-autosave': AutosavePayload;
|
|
321
|
+
'grideditor:after-restore-draft': RestoreDraftPayload;
|
|
322
|
+
'grideditor:autosave-error': AutosaveErrorPayload;
|
|
274
323
|
}
|
|
275
324
|
|
|
276
325
|
/** An event the editor dispatches on its canvas: a CustomEvent whose detail is the payload. */
|
|
@@ -362,10 +411,10 @@ export declare class GridEditor {
|
|
|
362
411
|
/** A read-only copy of the settings the editor runs with. */
|
|
363
412
|
readonly settings: Readonly<GridEditorOptions>;
|
|
364
413
|
|
|
365
|
-
/** The html to save: no drawers, no editor classes, no inline styles. */
|
|
366
|
-
getHtml(): string;
|
|
414
|
+
/** The html to save: no drawers, no editor classes, no inline styles. keepEditing reads it without the canvas leaving editing. */
|
|
415
|
+
getHtml(options?: GetHtmlOptions): string;
|
|
367
416
|
/** getHtml without grid-editor's marking, for publishing. It cannot be edited again as it was. */
|
|
368
|
-
getPlainHtml(): string;
|
|
417
|
+
getPlainHtml(options?: GetHtmlOptions): string;
|
|
369
418
|
/** Run the editing pass over the canvas again, after markup was put in. */
|
|
370
419
|
init(): this;
|
|
371
420
|
/** Take the editing furniture off, leaving the markup. */
|
|
@@ -395,6 +444,13 @@ export declare class GridEditor {
|
|
|
395
444
|
getUtility(node: Target, family: string, view?: View): string | null;
|
|
396
445
|
/** Write one through the events; null is inherit. False when canceled or nothing changed. */
|
|
397
446
|
setUtility(node: Target, family: string, value: string | number | null, view?: View): boolean;
|
|
447
|
+
/** The autosave plugin's, when it is loaded: false when the browser gives it no storage. */
|
|
448
|
+
enableAutosave?(): boolean;
|
|
449
|
+
disableAutosave?(): boolean;
|
|
450
|
+
/** Save now, if it changed: true when it was written. */
|
|
451
|
+
saveDraft?(): boolean;
|
|
452
|
+
getDraft?(): AutosaveDraft | null;
|
|
453
|
+
clearDraft?(): boolean;
|
|
398
454
|
}
|
|
399
455
|
|
|
400
456
|
export default GridEditor;
|
package/AUTO_SAVE.md
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
## Auto save and layout import/export
|
|
2
|
-
|
|
3
|
-
The `example/autosave.html` demo shows how to add **auto save** and
|
|
4
|
-
**import/export** on top of Grid Editor, using only the editor's public API
|
|
5
|
-
(`getHtml()` and `destroy()` on the `GridEditor` instance).
|
|
6
|
-
|
|
7
|
-
### Features
|
|
8
|
-
|
|
9
|
-
- **Auto save**
|
|
10
|
-
Saves the layout to `localStorage` every 5 seconds, so work is not lost on
|
|
11
|
-
an accidental refresh. The saved draft is restored on page load.
|
|
12
|
-
|
|
13
|
-
- **Import a saved layout**
|
|
14
|
-
Load a previously exported `.html` file back into the editor.
|
|
15
|
-
|
|
16
|
-
- **Export HTML**
|
|
17
|
-
Download the edited layout as an HTML file for saving or sharing.
|
|
18
|
-
|
|
19
|
-
- **Clear draft**
|
|
20
|
-
Remove the stored layout from `localStorage` and start over.
|
|
21
|
-
|
|
22
|
-
### Demo
|
|
23
|
-
|
|
24
|
-
Build the `dist/` files first, then open the example:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npm install
|
|
28
|
-
npm run build
|
|
29
|
-
open example/autosave.html
|
|
30
|
-
```
|