scriviamo-angular 0.0.0-stage → 1.0.1-beta.16
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/LICENSE.md +21 -0
- package/README.md +79 -2
- package/fesm2022/scriviamo-angular-inspector.mjs +77 -0
- package/fesm2022/scriviamo-angular-inspector.mjs.map +1 -0
- package/fesm2022/scriviamo-angular.mjs +390 -0
- package/fesm2022/scriviamo-angular.mjs.map +1 -0
- package/index.d.ts +108 -0
- package/index.d.ts.map +1 -0
- package/inspector/index.d.ts +29 -0
- package/inspector/index.d.ts.map +1 -0
- package/package.json +36 -3
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GraffitiSuite Solutions
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,80 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Scriviamo for Angular
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Standalone Angular components for the Scriviamo editor: `<scriviamo-editor>` and
|
|
4
|
+
`<scriviamo-inspector>`.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import {Component} from "@angular/core"
|
|
8
|
+
import {ScriviamoEditorComponent} from "scriviamo-angular"
|
|
9
|
+
import {ScriviamoInspectorComponent} from "scriviamo-angular/inspector"
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: "notes-page",
|
|
13
|
+
standalone: true,
|
|
14
|
+
imports: [ScriviamoEditorComponent, ScriviamoInspectorComponent],
|
|
15
|
+
template: `
|
|
16
|
+
<div style="display: flex; gap: 8px">
|
|
17
|
+
<scriviamo-editor #notes [(value)]="doc" format="markdown" style="flex: 1; height: 500px"></scriviamo-editor>
|
|
18
|
+
<scriviamo-inspector [editor]="notes.editor" style="width: 320px"></scriviamo-inspector>
|
|
19
|
+
</div>
|
|
20
|
+
`
|
|
21
|
+
})
|
|
22
|
+
export class NotesPage {
|
|
23
|
+
doc = "# Notes\n\nStart writing."
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Add Bootstrap 5's CSS and Bootstrap Icons, which Scriviamo's interface uses, then Scriviamo's
|
|
28
|
+
stylesheet and those of the add-ons you use, to the `styles` in your `angular.json`. Bootstrap's
|
|
29
|
+
JavaScript isn't needed.
|
|
30
|
+
|
|
31
|
+
## scriviamo-editor
|
|
32
|
+
|
|
33
|
+
Takes every setting in the [wrappers README](../README.md#settings) as an input. `value` and
|
|
34
|
+
`valueChange` make `[(value)]` work.
|
|
35
|
+
|
|
36
|
+
| Output | Gives | When |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| `valueChange` | the value | The document changed, in `format` |
|
|
39
|
+
| `selectionChange` | the node, or null | The primary selected node changed |
|
|
40
|
+
| `ready` | the editor | The editor was created |
|
|
41
|
+
|
|
42
|
+
The component's `editor` property is the editor, so a template variable reaches it:
|
|
43
|
+
`#notes` then `notes.editor`. It exists from the component's first check, so a binding such as
|
|
44
|
+
`[editor]="notes.editor"` sees it straight away.
|
|
45
|
+
|
|
46
|
+
The editor is created when the component starts and destroyed with it. Inputs are applied as
|
|
47
|
+
they change; only `value` changing from outside reloads the document. The editor's own
|
|
48
|
+
listeners run outside Angular's zone, and only the outputs come back into it.
|
|
49
|
+
|
|
50
|
+
### Angular forms
|
|
51
|
+
|
|
52
|
+
The component is a form control, so `ngModel`, `formControl` and `formControlName` work:
|
|
53
|
+
|
|
54
|
+
```html
|
|
55
|
+
<scriviamo-editor [formControl]="body" format="html"></scriviamo-editor>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Disabling the control makes the editor read-only, and leaving the editor marks the control
|
|
59
|
+
touched.
|
|
60
|
+
|
|
61
|
+
## scriviamo-inspector
|
|
62
|
+
|
|
63
|
+
`ScriviamoInspectorComponent`, imported from `scriviamo-angular/inspector`. The inspector component needs Scriviamo's `inspector` add-on, which is premium, so it has its own entry point. Import the add-on before showing the inspector: `scriviamo/addons/inspector` from this repository, or `@scriviamo-pro/pro/addons/inspector` (or `pro-collab`) from npm, with its stylesheet. The component finds it whichever package it came from (see [The inspector](../../docs/inspector.md)); the editor component works without it.
|
|
64
|
+
|
|
65
|
+
| Input | Meaning |
|
|
66
|
+
|---|---|
|
|
67
|
+
| `editor` | The editor to follow |
|
|
68
|
+
| `collapsedSections` | Identifiers of sections that start collapsed |
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## Building
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm install
|
|
75
|
+
npm run build
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The build uses `ng-packagr`, which needs Node.js 20.19 or later, and writes an Angular Package
|
|
79
|
+
Format library to `dist/`, with the components compiled in partial mode so apps compile them
|
|
80
|
+
ahead of time. Angular and Scriviamo stay external, as peer dependencies.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { ViewChild, Input, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { Editor } from 'scriviamo';
|
|
4
|
+
|
|
5
|
+
// Copied from wrappers/shared/inspectorbinding.ts by sync-shared.mjs. Edit that file, not this one.
|
|
6
|
+
// The inspector is a premium add-on, so its binding lives apart from the editor's: a wrapper's
|
|
7
|
+
// main entry point never uses it, and the editor components work without it. The binding doesn't
|
|
8
|
+
// import the add-on either: the add-on registers itself with the editor when an app imports it,
|
|
9
|
+
// from scriviamo/addons/inspector in a repository or @scriviamo-pro/pro/addons/inspector (or
|
|
10
|
+
// pro-collab) from npm, and the binding finds it there.
|
|
11
|
+
/** Keeps an inspector following an editor. */
|
|
12
|
+
class InspectorBinding {
|
|
13
|
+
constructor(element, editor, collapsedSections = []) {
|
|
14
|
+
let Inspector = Editor.addon("inspector")?.Inspector;
|
|
15
|
+
if (!Inspector)
|
|
16
|
+
throw new Error("The inspector needs Scriviamo's inspector add-on: import it before showing the inspector, such as import \"@scriviamo-pro/pro/addons/inspector\".");
|
|
17
|
+
this.inspector = new Inspector(element, { editor, collapsedSections });
|
|
18
|
+
}
|
|
19
|
+
update(editor) {
|
|
20
|
+
if (this.inspector.inspectedEditor !== editor)
|
|
21
|
+
this.inspector.inspectedEditor = editor;
|
|
22
|
+
}
|
|
23
|
+
destroy() {
|
|
24
|
+
this.inspector.destroy();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The property panel for an editor's selected nodes, or its document.
|
|
30
|
+
*
|
|
31
|
+
* <scriviamo-editor #doc /> <scriviamo-inspector [editor]="doc.editor" />
|
|
32
|
+
*
|
|
33
|
+
* It needs Scriviamo's inspector add-on, a premium add-on, so it has its own entry point:
|
|
34
|
+
* import it from "scriviamo-angular/inspector".
|
|
35
|
+
*/
|
|
36
|
+
class ScriviamoInspectorComponent {
|
|
37
|
+
#binding;
|
|
38
|
+
constructor(zone) {
|
|
39
|
+
this.zone = zone;
|
|
40
|
+
this.editor = null;
|
|
41
|
+
/** Identifiers of sections that start collapsed. */
|
|
42
|
+
this.collapsedSections = [];
|
|
43
|
+
this.#binding = null;
|
|
44
|
+
}
|
|
45
|
+
ngOnInit() {
|
|
46
|
+
this.zone.runOutsideAngular(() => {
|
|
47
|
+
this.#binding = new InspectorBinding(this.host.nativeElement, this.editor, this.collapsedSections);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
ngOnChanges() {
|
|
51
|
+
this.#binding?.update(this.editor);
|
|
52
|
+
}
|
|
53
|
+
ngOnDestroy() {
|
|
54
|
+
this.#binding?.destroy();
|
|
55
|
+
this.#binding = null;
|
|
56
|
+
}
|
|
57
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: ScriviamoInspectorComponent, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
58
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.35", type: ScriviamoInspectorComponent, isStandalone: true, selector: "scriviamo-inspector", inputs: { editor: "editor", collapsedSections: "collapsedSections" }, viewQueries: [{ propertyName: "host", first: true, predicate: ["host"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<div #host></div>", isInline: true, styles: [":host{display:block}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
59
|
+
}
|
|
60
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: ScriviamoInspectorComponent, decorators: [{
|
|
61
|
+
type: Component,
|
|
62
|
+
args: [{ selector: "scriviamo-inspector", standalone: true, template: "<div #host></div>", changeDetection: ChangeDetectionStrategy.OnPush, styles: [":host{display:block}\n"] }]
|
|
63
|
+
}], ctorParameters: () => [{ type: i0.NgZone }], propDecorators: { editor: [{
|
|
64
|
+
type: Input
|
|
65
|
+
}], collapsedSections: [{
|
|
66
|
+
type: Input
|
|
67
|
+
}], host: [{
|
|
68
|
+
type: ViewChild,
|
|
69
|
+
args: ["host", { static: true }]
|
|
70
|
+
}] } });
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Generated bundle index. Do not edit.
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
export { ScriviamoInspectorComponent };
|
|
77
|
+
//# sourceMappingURL=scriviamo-angular-inspector.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scriviamo-angular-inspector.mjs","sources":["../../inspector/src/inspectorbinding.ts","../../inspector/src/scriviamo-inspector.component.ts","../../inspector/src/scriviamo-angular-inspector.ts"],"sourcesContent":["// Copied from wrappers/shared/inspectorbinding.ts by sync-shared.mjs. Edit that file, not this one.\n\n// The inspector is a premium add-on, so its binding lives apart from the editor's: a wrapper's\n// main entry point never uses it, and the editor components work without it. The binding doesn't\n// import the add-on either: the add-on registers itself with the editor when an app imports it,\n// from scriviamo/addons/inspector in a repository or @scriviamo-pro/pro/addons/inspector (or\n// pro-collab) from npm, and the binding finds it there.\nimport {Editor} from \"scriviamo\"\n\n/** What the binding uses of the inspector add-on's Inspector. */\nexport interface InspectorLike {\n inspectedEditor: Editor | null\n destroy(): void\n}\n\n/** Keeps an inspector following an editor. */\nexport class InspectorBinding {\n readonly inspector: InspectorLike\n\n constructor(element: HTMLElement, editor: Editor | null, collapsedSections: Array<string> = []) {\n let Inspector = Editor.addon(\"inspector\")?.Inspector\n if (!Inspector) throw new Error(\"The inspector needs Scriviamo's inspector add-on: import it before showing the inspector, such as import \\\"@scriviamo-pro/pro/addons/inspector\\\".\")\n this.inspector = new Inspector(element, {editor, collapsedSections})\n }\n\n update(editor: Editor | null) {\n if (this.inspector.inspectedEditor !== editor) this.inspector.inspectedEditor = editor\n }\n\n destroy() {\n this.inspector.destroy()\n }\n}\n","import {ChangeDetectionStrategy, Component, ElementRef, Input, NgZone, OnChanges, OnDestroy, OnInit, ViewChild} from \"@angular/core\"\nimport type {Editor} from \"scriviamo\"\nimport {InspectorBinding} from \"./inspectorbinding\"\n\n/**\n * The property panel for an editor's selected nodes, or its document.\n *\n * <scriviamo-editor #doc /> <scriviamo-inspector [editor]=\"doc.editor\" />\n *\n * It needs Scriviamo's inspector add-on, a premium add-on, so it has its own entry point:\n * import it from \"scriviamo-angular/inspector\".\n */\n@Component({\n selector: \"scriviamo-inspector\",\n standalone: true,\n template: \"<div #host></div>\",\n styles: [\":host { display: block; }\"],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class ScriviamoInspectorComponent implements OnInit, OnChanges, OnDestroy {\n @Input() editor: Editor | null = null\n /** Identifiers of sections that start collapsed. */\n @Input() collapsedSections: Array<string> = []\n\n @ViewChild(\"host\", {static: true}) host!: ElementRef<HTMLElement>\n\n #binding: InspectorBinding | null = null\n\n constructor(private zone: NgZone) {}\n\n ngOnInit() {\n this.zone.runOutsideAngular(() => {\n this.#binding = new InspectorBinding(this.host.nativeElement, this.editor, this.collapsedSections)\n })\n }\n\n ngOnChanges() {\n this.#binding?.update(this.editor)\n }\n\n ngOnDestroy() {\n this.#binding?.destroy()\n this.#binding = null\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AASA;MACa,gBAAgB,CAAA;AAG3B,IAAA,WAAA,CAAY,OAAoB,EAAE,MAAqB,EAAE,oBAAmC,EAAE,EAAA;QAC5F,IAAI,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,SAAS;AACpD,QAAA,IAAI,CAAC,SAAS;AAAE,YAAA,MAAM,IAAI,KAAK,CAAC,mJAAmJ,CAAC;AAC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AAA,CAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,2BAA2B,sRAJ5B,mBAAmB,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,wBAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;4FAIlB,2BAA2B,EAAA,UAAA,EAAA,CAAA;kBAPvC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,qBAAqB,cACnB,IAAI,EAAA,QAAA,EACN,mBAAmB,EAAA,eAAA,EAEZ,uBAAuB,CAAC,MAAM,EAAA,MAAA,EAAA,CAAA,wBAAA,CAAA,EAAA;;sBAG9C;;sBAEA;;sBAEA,SAAS;AAAC,gBAAA,IAAA,EAAA,CAAA,MAAM,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC;;;ACxBnC;;AAEG;;"}
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { EventEmitter, forwardRef, ViewChild, Output, Input, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
|
+
import { Editor } from 'scriviamo';
|
|
5
|
+
|
|
6
|
+
// Copied from wrappers/shared/editorbinding.ts by sync-shared.mjs. Edit that file, not this one.
|
|
7
|
+
/**
|
|
8
|
+
* Keeps an editor in step with a framework component's settings: it creates the editor, applies
|
|
9
|
+
* changed settings to it, reports changes, and tears it down. Each framework wrapper is a thin
|
|
10
|
+
* layer over this.
|
|
11
|
+
*/
|
|
12
|
+
class EditorBinding {
|
|
13
|
+
#settings;
|
|
14
|
+
#callbacks;
|
|
15
|
+
/** The value last reported, and the value last loaded from outside, so a wrapper passing either back doesn't reload the document. */
|
|
16
|
+
#value;
|
|
17
|
+
#loadedValue;
|
|
18
|
+
/** True while a value from outside is loading, whose changes aren't the user's. */
|
|
19
|
+
#loading = false;
|
|
20
|
+
#timer = null;
|
|
21
|
+
#listeners = [];
|
|
22
|
+
#onContent;
|
|
23
|
+
#onSelection;
|
|
24
|
+
constructor(element, settings, callbacks = {}) {
|
|
25
|
+
this.#settings = { ...settings };
|
|
26
|
+
this.#callbacks = callbacks;
|
|
27
|
+
this.editor = new Editor(element, EditorBinding.#options(settings));
|
|
28
|
+
if (settings.value !== undefined)
|
|
29
|
+
this.#load(settings.value, this.#format(settings));
|
|
30
|
+
this.#onContent = () => {
|
|
31
|
+
if (!this.#loading)
|
|
32
|
+
this.#scheduleChange();
|
|
33
|
+
};
|
|
34
|
+
this.#onSelection = event => this.#callbacks.selectionChange?.(event.detail?.node ?? null, this.editor);
|
|
35
|
+
this.editor.addEventListener("contentChanged", this.#onContent);
|
|
36
|
+
this.editor.addEventListener("selectionChanged", this.#onSelection);
|
|
37
|
+
this.#listen(settings.events);
|
|
38
|
+
callbacks.ready?.(this.editor);
|
|
39
|
+
}
|
|
40
|
+
/** The options a new editor starts with. Content is loaded separately, in the chosen format. */
|
|
41
|
+
static #options(settings) {
|
|
42
|
+
let options = {};
|
|
43
|
+
if (settings.readOnly !== undefined)
|
|
44
|
+
options.readOnly = settings.readOnly;
|
|
45
|
+
if (settings.toolbarVisible !== undefined)
|
|
46
|
+
options.toolbarVisible = settings.toolbarVisible;
|
|
47
|
+
if (settings.toolbarDisplayMode !== undefined)
|
|
48
|
+
options.toolbarDisplayMode = settings.toolbarDisplayMode;
|
|
49
|
+
if (settings.showContextualToolbars !== undefined)
|
|
50
|
+
options.showContextualToolbars = settings.showContextualToolbars;
|
|
51
|
+
if (settings.hoverInsertion !== undefined)
|
|
52
|
+
options.isHoverInsertionEnabled = settings.hoverInsertion;
|
|
53
|
+
if (settings.markdownShortcuts !== undefined)
|
|
54
|
+
options.markdownShortcuts = settings.markdownShortcuts;
|
|
55
|
+
if (settings.allowAnnotations !== undefined)
|
|
56
|
+
options.allowAnnotations = settings.allowAnnotations;
|
|
57
|
+
if (settings.adaptiveHeight !== undefined)
|
|
58
|
+
options.adaptiveHeight = settings.adaptiveHeight;
|
|
59
|
+
if (settings.fontName)
|
|
60
|
+
options.fontName = settings.fontName;
|
|
61
|
+
if (settings.fontSize)
|
|
62
|
+
options.fontSize = settings.fontSize;
|
|
63
|
+
if (settings.locale)
|
|
64
|
+
options.strings = settings.locale;
|
|
65
|
+
if (settings.editorClass)
|
|
66
|
+
options.class = settings.editorClass;
|
|
67
|
+
if (settings.statusBar !== undefined)
|
|
68
|
+
options.statusBar = settings.statusBar;
|
|
69
|
+
if (settings.autosave)
|
|
70
|
+
options.autosave = settings.autosave;
|
|
71
|
+
if (settings.fileUploader)
|
|
72
|
+
options.fileUploader = settings.fileUploader;
|
|
73
|
+
return options;
|
|
74
|
+
}
|
|
75
|
+
#format(settings) {
|
|
76
|
+
return settings.format == "html" || settings.format == "markdown" ? settings.format : "json";
|
|
77
|
+
}
|
|
78
|
+
/** Applies the settings that changed since previous. A new editor gets them as options instead. */
|
|
79
|
+
#apply(settings, previous) {
|
|
80
|
+
let editor = this.editor;
|
|
81
|
+
let changed = (name) => settings[name] !== undefined && settings[name] !== previous[name];
|
|
82
|
+
if (changed("readOnly"))
|
|
83
|
+
editor.readOnly = !!settings.readOnly;
|
|
84
|
+
if (changed("toolbarVisible"))
|
|
85
|
+
editor.toolbarVisible = !!settings.toolbarVisible;
|
|
86
|
+
if (changed("toolbarDisplayMode"))
|
|
87
|
+
editor.toolbarDisplayMode = settings.toolbarDisplayMode;
|
|
88
|
+
if (changed("showContextualToolbars"))
|
|
89
|
+
editor.showContextualToolbars = !!settings.showContextualToolbars;
|
|
90
|
+
if (changed("hoverInsertion"))
|
|
91
|
+
editor.isHoverInsertionEnabled = !!settings.hoverInsertion;
|
|
92
|
+
if (changed("markdownShortcuts"))
|
|
93
|
+
editor.markdownShortcuts = !!settings.markdownShortcuts;
|
|
94
|
+
if (changed("allowAnnotations"))
|
|
95
|
+
editor.allowAnnotations = !!settings.allowAnnotations;
|
|
96
|
+
if (changed("adaptiveHeight"))
|
|
97
|
+
editor.adaptiveHeight = !!settings.adaptiveHeight;
|
|
98
|
+
if (changed("fontName"))
|
|
99
|
+
editor.fontName = settings.fontName;
|
|
100
|
+
if (changed("fontSize"))
|
|
101
|
+
editor.fontSize = settings.fontSize;
|
|
102
|
+
if (changed("editorClass"))
|
|
103
|
+
editor.class = settings.editorClass;
|
|
104
|
+
if (changed("locale"))
|
|
105
|
+
editor.localize(settings.locale);
|
|
106
|
+
if (changed("statusBar"))
|
|
107
|
+
editor.statusBarVisible = !!settings.statusBar;
|
|
108
|
+
if (settings.autosave !== previous.autosave)
|
|
109
|
+
editor.updateAutosave(settings.autosave ?? null);
|
|
110
|
+
if (settings.fileUploader !== previous.fileUploader)
|
|
111
|
+
editor.fileUploader = settings.fileUploader ?? null;
|
|
112
|
+
}
|
|
113
|
+
/** Applies new settings from the framework component. */
|
|
114
|
+
update(settings) {
|
|
115
|
+
let previous = this.#settings;
|
|
116
|
+
this.#settings = { ...settings };
|
|
117
|
+
this.#apply(settings, previous);
|
|
118
|
+
if (settings.events !== previous.events) {
|
|
119
|
+
this.#unlisten();
|
|
120
|
+
this.#listen(settings.events);
|
|
121
|
+
}
|
|
122
|
+
let format = this.#format(settings);
|
|
123
|
+
let formatChanged = format != this.#format(previous);
|
|
124
|
+
let known = settings.value === this.#value || settings.value === this.#loadedValue;
|
|
125
|
+
if (settings.value !== undefined && !known) {
|
|
126
|
+
this.#flush();
|
|
127
|
+
this.#load(settings.value, format);
|
|
128
|
+
}
|
|
129
|
+
else if (formatChanged) {
|
|
130
|
+
this.#value = this.value;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** The document in the binding's format. */
|
|
134
|
+
get value() {
|
|
135
|
+
switch (this.#format(this.#settings)) {
|
|
136
|
+
case "html": return this.editor.toHTML();
|
|
137
|
+
case "markdown": return this.editor.toMarkdown();
|
|
138
|
+
}
|
|
139
|
+
return this.editor.toJSON();
|
|
140
|
+
}
|
|
141
|
+
#load(value, format) {
|
|
142
|
+
let editor = this.editor;
|
|
143
|
+
this.#loading = true;
|
|
144
|
+
try {
|
|
145
|
+
this.#loadInto(editor, value, format);
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
this.#loading = false;
|
|
149
|
+
}
|
|
150
|
+
editor.history.reset();
|
|
151
|
+
editor.isChanged = false;
|
|
152
|
+
this.#loadedValue = value;
|
|
153
|
+
// The editor's export of what was loaded, which may differ from it in small ways.
|
|
154
|
+
this.#value = this.value;
|
|
155
|
+
}
|
|
156
|
+
#loadInto(editor, value, format) {
|
|
157
|
+
if (format == "json") {
|
|
158
|
+
if (value.trim().length == 0)
|
|
159
|
+
editor.removeAllNodes();
|
|
160
|
+
else
|
|
161
|
+
editor.fromJSON(value);
|
|
162
|
+
}
|
|
163
|
+
else if (format == "html") {
|
|
164
|
+
if (value.trim().length == 0)
|
|
165
|
+
editor.removeAllNodes();
|
|
166
|
+
else
|
|
167
|
+
editor.fromHTML(value);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
if (value.trim().length == 0)
|
|
171
|
+
editor.removeAllNodes();
|
|
172
|
+
else
|
|
173
|
+
editor.fromMarkdown(value);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
#scheduleChange() {
|
|
177
|
+
let delay = Math.max(0, this.#settings.changeDelay ?? 0);
|
|
178
|
+
if (this.#timer)
|
|
179
|
+
clearTimeout(this.#timer);
|
|
180
|
+
this.#timer = null;
|
|
181
|
+
if (delay == 0) {
|
|
182
|
+
this.#report();
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
this.#timer = setTimeout(() => {
|
|
186
|
+
this.#timer = null;
|
|
187
|
+
this.#report();
|
|
188
|
+
}, delay);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
#report() {
|
|
192
|
+
let value = this.value;
|
|
193
|
+
if (value === this.#value)
|
|
194
|
+
return;
|
|
195
|
+
this.#value = value;
|
|
196
|
+
// The document no longer matches what was loaded, so loading that value again must reload it.
|
|
197
|
+
this.#loadedValue = undefined;
|
|
198
|
+
this.#callbacks.change?.(value, this.editor);
|
|
199
|
+
}
|
|
200
|
+
/** Reports a change that is waiting for changeDelay. */
|
|
201
|
+
#flush() {
|
|
202
|
+
if (!this.#timer)
|
|
203
|
+
return;
|
|
204
|
+
clearTimeout(this.#timer);
|
|
205
|
+
this.#timer = null;
|
|
206
|
+
this.#report();
|
|
207
|
+
}
|
|
208
|
+
#listen(events) {
|
|
209
|
+
for (let name of Object.keys(events || {})) {
|
|
210
|
+
let handler = events[name];
|
|
211
|
+
if (typeof handler != "function")
|
|
212
|
+
continue;
|
|
213
|
+
let listener = event => handler(event);
|
|
214
|
+
this.editor.addEventListener(name, listener);
|
|
215
|
+
this.#listeners.push([name, listener]);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
#unlisten() {
|
|
219
|
+
for (let [name, listener] of this.#listeners)
|
|
220
|
+
this.editor.removeEventListener(name, listener);
|
|
221
|
+
this.#listeners = [];
|
|
222
|
+
}
|
|
223
|
+
/** Reports any waiting change, then removes the editor. */
|
|
224
|
+
destroy() {
|
|
225
|
+
this.#flush();
|
|
226
|
+
this.#unlisten();
|
|
227
|
+
this.editor.removeEventListener("contentChanged", this.#onContent);
|
|
228
|
+
this.editor.removeEventListener("selectionChanged", this.#onSelection);
|
|
229
|
+
this.editor.destroy();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* A Scriviamo editor. Import the add-ons you use before it is created.
|
|
235
|
+
*
|
|
236
|
+
* <scriviamo-editor [(value)]="doc" format="markdown" style="display: block; height: 500px" />
|
|
237
|
+
*
|
|
238
|
+
* It also works with Angular forms, through ngModel or a form control. value is read when it
|
|
239
|
+
* changes from outside: the editor's own changes come back through valueChange, and passing
|
|
240
|
+
* them back in doesn't reload the document.
|
|
241
|
+
*/
|
|
242
|
+
class ScriviamoEditorComponent {
|
|
243
|
+
#binding;
|
|
244
|
+
#formsDisabled;
|
|
245
|
+
#onFormChange;
|
|
246
|
+
#onFormTouched;
|
|
247
|
+
constructor(zone) {
|
|
248
|
+
this.zone = zone;
|
|
249
|
+
this.format = "json";
|
|
250
|
+
/** The document changed in the editor, for [(value)]. */
|
|
251
|
+
this.valueChange = new EventEmitter();
|
|
252
|
+
this.selectionChange = new EventEmitter();
|
|
253
|
+
/** The editor was created. */
|
|
254
|
+
this.ready = new EventEmitter();
|
|
255
|
+
this.#binding = null;
|
|
256
|
+
this.#formsDisabled = false;
|
|
257
|
+
this.#onFormChange = () => { };
|
|
258
|
+
this.#onFormTouched = () => { };
|
|
259
|
+
}
|
|
260
|
+
/** The editor, once the view exists. */
|
|
261
|
+
get editor() {
|
|
262
|
+
return this.#binding ? this.#binding.editor : null;
|
|
263
|
+
}
|
|
264
|
+
#settings() {
|
|
265
|
+
return {
|
|
266
|
+
value: this.value,
|
|
267
|
+
format: this.format,
|
|
268
|
+
readOnly: this.#formsDisabled ? true : this.readOnly,
|
|
269
|
+
toolbarVisible: this.toolbarVisible,
|
|
270
|
+
toolbarDisplayMode: this.toolbarDisplayMode,
|
|
271
|
+
showContextualToolbars: this.showContextualToolbars,
|
|
272
|
+
hoverInsertion: this.hoverInsertion,
|
|
273
|
+
markdownShortcuts: this.markdownShortcuts,
|
|
274
|
+
allowAnnotations: this.allowAnnotations,
|
|
275
|
+
adaptiveHeight: this.adaptiveHeight,
|
|
276
|
+
fontName: this.fontName,
|
|
277
|
+
fontSize: this.fontSize,
|
|
278
|
+
locale: this.locale,
|
|
279
|
+
editorClass: this.editorClass,
|
|
280
|
+
statusBar: this.statusBar,
|
|
281
|
+
autosave: this.autosave,
|
|
282
|
+
fileUploader: this.fileUploader,
|
|
283
|
+
changeDelay: this.changeDelay,
|
|
284
|
+
events: this.events
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
// The editor is created as early as possible, so a template binding such as
|
|
288
|
+
// [editor]="doc.editor" already sees it in the first check. The host is a static query.
|
|
289
|
+
ngOnInit() {
|
|
290
|
+
// The editor's own listeners run outside Angular; only the outputs re-enter it.
|
|
291
|
+
this.zone.runOutsideAngular(() => {
|
|
292
|
+
this.#binding = new EditorBinding(this.host.nativeElement, this.#settings(), {
|
|
293
|
+
change: value => this.zone.run(() => {
|
|
294
|
+
this.value = value;
|
|
295
|
+
this.valueChange.emit(value);
|
|
296
|
+
this.#onFormChange(value);
|
|
297
|
+
}),
|
|
298
|
+
selectionChange: node => this.zone.run(() => this.selectionChange.emit(node))
|
|
299
|
+
});
|
|
300
|
+
this.host.nativeElement.addEventListener("focusout", event => {
|
|
301
|
+
// Touched once focus leaves the editor altogether, not when it moves inside it.
|
|
302
|
+
if (!this.host.nativeElement.contains(event.relatedTarget))
|
|
303
|
+
this.zone.run(() => this.#onFormTouched());
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
this.ready.emit(this.#binding.editor);
|
|
307
|
+
}
|
|
308
|
+
ngOnChanges() {
|
|
309
|
+
this.#binding?.update(this.#settings());
|
|
310
|
+
}
|
|
311
|
+
ngOnDestroy() {
|
|
312
|
+
this.#binding?.destroy();
|
|
313
|
+
this.#binding = null;
|
|
314
|
+
}
|
|
315
|
+
// Angular forms
|
|
316
|
+
writeValue(value) {
|
|
317
|
+
this.value = value ?? "";
|
|
318
|
+
this.#binding?.update(this.#settings());
|
|
319
|
+
}
|
|
320
|
+
registerOnChange(callback) {
|
|
321
|
+
this.#onFormChange = callback;
|
|
322
|
+
}
|
|
323
|
+
registerOnTouched(callback) {
|
|
324
|
+
this.#onFormTouched = callback;
|
|
325
|
+
}
|
|
326
|
+
setDisabledState(disabled) {
|
|
327
|
+
this.#formsDisabled = disabled;
|
|
328
|
+
this.#binding?.update(this.#settings());
|
|
329
|
+
}
|
|
330
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: ScriviamoEditorComponent, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
331
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.35", type: ScriviamoEditorComponent, isStandalone: true, selector: "scriviamo-editor", inputs: { value: "value", format: "format", readOnly: "readOnly", toolbarVisible: "toolbarVisible", toolbarDisplayMode: "toolbarDisplayMode", showContextualToolbars: "showContextualToolbars", hoverInsertion: "hoverInsertion", markdownShortcuts: "markdownShortcuts", allowAnnotations: "allowAnnotations", adaptiveHeight: "adaptiveHeight", fontName: "fontName", fontSize: "fontSize", locale: "locale", editorClass: "editorClass", statusBar: "statusBar", autosave: "autosave", fileUploader: "fileUploader", changeDelay: "changeDelay", events: "events" }, outputs: { valueChange: "valueChange", selectionChange: "selectionChange", ready: "ready" }, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => ScriviamoEditorComponent), multi: true }], viewQueries: [{ propertyName: "host", first: true, predicate: ["host"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<div #host class=\"scriviamo-editor-host\"></div>", isInline: true, styles: [":host{display:block}.scriviamo-editor-host{height:100%}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
332
|
+
}
|
|
333
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: ScriviamoEditorComponent, decorators: [{
|
|
334
|
+
type: Component,
|
|
335
|
+
args: [{ selector: "scriviamo-editor", standalone: true, template: "<div #host class=\"scriviamo-editor-host\"></div>", changeDetection: ChangeDetectionStrategy.OnPush, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => ScriviamoEditorComponent), multi: true }], styles: [":host{display:block}.scriviamo-editor-host{height:100%}\n"] }]
|
|
336
|
+
}], ctorParameters: () => [{ type: i0.NgZone }], propDecorators: { value: [{
|
|
337
|
+
type: Input
|
|
338
|
+
}], format: [{
|
|
339
|
+
type: Input
|
|
340
|
+
}], readOnly: [{
|
|
341
|
+
type: Input
|
|
342
|
+
}], toolbarVisible: [{
|
|
343
|
+
type: Input
|
|
344
|
+
}], toolbarDisplayMode: [{
|
|
345
|
+
type: Input
|
|
346
|
+
}], showContextualToolbars: [{
|
|
347
|
+
type: Input
|
|
348
|
+
}], hoverInsertion: [{
|
|
349
|
+
type: Input
|
|
350
|
+
}], markdownShortcuts: [{
|
|
351
|
+
type: Input
|
|
352
|
+
}], allowAnnotations: [{
|
|
353
|
+
type: Input
|
|
354
|
+
}], adaptiveHeight: [{
|
|
355
|
+
type: Input
|
|
356
|
+
}], fontName: [{
|
|
357
|
+
type: Input
|
|
358
|
+
}], fontSize: [{
|
|
359
|
+
type: Input
|
|
360
|
+
}], locale: [{
|
|
361
|
+
type: Input
|
|
362
|
+
}], editorClass: [{
|
|
363
|
+
type: Input
|
|
364
|
+
}], statusBar: [{
|
|
365
|
+
type: Input
|
|
366
|
+
}], autosave: [{
|
|
367
|
+
type: Input
|
|
368
|
+
}], fileUploader: [{
|
|
369
|
+
type: Input
|
|
370
|
+
}], changeDelay: [{
|
|
371
|
+
type: Input
|
|
372
|
+
}], events: [{
|
|
373
|
+
type: Input
|
|
374
|
+
}], valueChange: [{
|
|
375
|
+
type: Output
|
|
376
|
+
}], selectionChange: [{
|
|
377
|
+
type: Output
|
|
378
|
+
}], ready: [{
|
|
379
|
+
type: Output
|
|
380
|
+
}], host: [{
|
|
381
|
+
type: ViewChild,
|
|
382
|
+
args: ["host", { static: true }]
|
|
383
|
+
}] } });
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Generated bundle index. Do not edit.
|
|
387
|
+
*/
|
|
388
|
+
|
|
389
|
+
export { ScriviamoEditorComponent };
|
|
390
|
+
//# sourceMappingURL=scriviamo-angular.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scriviamo-angular.mjs","sources":["../../src/editorbinding.ts","../../src/scriviamo-editor.component.ts","../../src/scriviamo-angular.ts"],"sourcesContent":["// Copied from wrappers/shared/editorbinding.ts by sync-shared.mjs. Edit that file, not this one.\n\nimport {AutosaveFunction, Editor, FileUploader, Node, ToolbarDisplayModes} from \"scriviamo\"\n\n/** The document format a wrapper's value is read and written in. */\nexport type ScriviamoFormat = \"json\" | \"html\" | \"markdown\"\n\n/** Settings every framework wrapper accepts. Missing settings keep the editor's defaults. */\nexport interface ScriviamoSettings {\n /** The document, in format. Changing it from outside replaces the document. */\n value?: string\n /** The format of value. \"json\" keeps everything; HTML and Markdown keep what they can express. */\n format?: ScriviamoFormat\n readOnly?: boolean\n toolbarVisible?: boolean\n toolbarDisplayMode?: ToolbarDisplayModes\n showContextualToolbars?: boolean\n hoverInsertion?: boolean\n markdownShortcuts?: boolean\n allowAnnotations?: boolean\n adaptiveHeight?: boolean\n fontName?: string\n fontSize?: number\n /** A locale pack, or an object of localized strings. */\n locale?: string | object\n /** Extra classes for the editor element. */\n editorClass?: string\n /** Shows the status bar: word and character counts, reading time and the autosave state. */\n statusBar?: boolean\n /** Saves the document after changes: a save function, or one with its settings. */\n autosave?: AutosaveFunction | {save: AutosaveFunction, delay?: number, maximumWait?: number, retryDelay?: number, warnBeforeLeaving?: boolean} | null\n /** Uploads the files people add, such as pictures, and returns their addresses. */\n fileUploader?: FileUploader | null\n /** Milliseconds to wait after typing stops before reporting a change; 0 reports each change. */\n changeDelay?: number\n /** Editor events to listen to, by name, such as {linkPressed: event => ...}. */\n events?: {[name: string]: (event: CustomEvent) => void}\n}\n\n/** What a binding reports to its framework wrapper. */\nexport interface ScriviamoCallbacks {\n /** The document changed in the editor. value is in the binding's format. */\n change?(value: string, editor: Editor): void\n /** The primary selected node changed. */\n selectionChange?(node: Node | null, editor: Editor): void\n /** The editor was created. */\n ready?(editor: Editor): void\n}\n\n/**\n * Keeps an editor in step with a framework component's settings: it creates the editor, applies\n * changed settings to it, reports changes, and tears it down. Each framework wrapper is a thin\n * layer over this.\n */\nexport class EditorBinding {\n readonly editor: Editor\n #settings: ScriviamoSettings\n #callbacks: ScriviamoCallbacks\n /** The value last reported, and the value last loaded from outside, so a wrapper passing either back doesn't reload the document. */\n #value: string | undefined\n #loadedValue: string | undefined\n /** True while a value from outside is loading, whose changes aren't the user's. */\n #loading: boolean = false\n #timer: ReturnType<typeof setTimeout> | null = null\n #listeners: Array<[string, EventListener]> = []\n #onContent: EventListener\n #onSelection: EventListener\n\n constructor(element: HTMLElement, settings: ScriviamoSettings, callbacks: ScriviamoCallbacks = {}) {\n this.#settings = {...settings}\n this.#callbacks = callbacks\n this.editor = new Editor(element, EditorBinding.#options(settings))\n if (settings.value !== undefined) this.#load(settings.value, this.#format(settings))\n this.#onContent = () => {\n if (!this.#loading) this.#scheduleChange()\n }\n this.#onSelection = event => this.#callbacks.selectionChange?.((event as CustomEvent).detail?.node ?? null, this.editor)\n this.editor.addEventListener(\"contentChanged\", this.#onContent)\n this.editor.addEventListener(\"selectionChanged\", this.#onSelection)\n this.#listen(settings.events)\n callbacks.ready?.(this.editor)\n }\n\n /** The options a new editor starts with. Content is loaded separately, in the chosen format. */\n static #options(settings: ScriviamoSettings) {\n let options: any = {}\n if (settings.readOnly !== undefined) options.readOnly = settings.readOnly\n if (settings.toolbarVisible !== undefined) options.toolbarVisible = settings.toolbarVisible\n if (settings.toolbarDisplayMode !== undefined) options.toolbarDisplayMode = settings.toolbarDisplayMode\n if (settings.showContextualToolbars !== undefined) options.showContextualToolbars = settings.showContextualToolbars\n if (settings.hoverInsertion !== undefined) options.isHoverInsertionEnabled = settings.hoverInsertion\n if (settings.markdownShortcuts !== undefined) options.markdownShortcuts = settings.markdownShortcuts\n if (settings.allowAnnotations !== undefined) options.allowAnnotations = settings.allowAnnotations\n if (settings.adaptiveHeight !== undefined) options.adaptiveHeight = settings.adaptiveHeight\n if (settings.fontName) options.fontName = settings.fontName\n if (settings.fontSize) options.fontSize = settings.fontSize\n if (settings.locale) options.strings = settings.locale\n if (settings.editorClass) options.class = settings.editorClass\n if (settings.statusBar !== undefined) options.statusBar = settings.statusBar\n if (settings.autosave) options.autosave = settings.autosave\n if (settings.fileUploader) options.fileUploader = settings.fileUploader\n return options\n }\n\n #format(settings: ScriviamoSettings): ScriviamoFormat {\n return settings.format == \"html\" || settings.format == \"markdown\" ? settings.format : \"json\"\n }\n\n /** Applies the settings that changed since previous. A new editor gets them as options instead. */\n #apply(settings: ScriviamoSettings, previous: ScriviamoSettings) {\n let editor = this.editor\n let changed = (name: keyof ScriviamoSettings) => settings[name] !== undefined && settings[name] !== previous[name]\n if (changed(\"readOnly\")) editor.readOnly = !!settings.readOnly\n if (changed(\"toolbarVisible\")) editor.toolbarVisible = !!settings.toolbarVisible\n if (changed(\"toolbarDisplayMode\")) editor.toolbarDisplayMode = settings.toolbarDisplayMode\n if (changed(\"showContextualToolbars\")) editor.showContextualToolbars = !!settings.showContextualToolbars\n if (changed(\"hoverInsertion\")) editor.isHoverInsertionEnabled = !!settings.hoverInsertion\n if (changed(\"markdownShortcuts\")) editor.markdownShortcuts = !!settings.markdownShortcuts\n if (changed(\"allowAnnotations\")) editor.allowAnnotations = !!settings.allowAnnotations\n if (changed(\"adaptiveHeight\")) editor.adaptiveHeight = !!settings.adaptiveHeight\n if (changed(\"fontName\")) editor.fontName = settings.fontName\n if (changed(\"fontSize\")) editor.fontSize = settings.fontSize\n if (changed(\"editorClass\")) editor.class = settings.editorClass\n if (changed(\"locale\")) editor.localize(settings.locale)\n if (changed(\"statusBar\")) editor.statusBarVisible = !!settings.statusBar\n if (settings.autosave !== previous.autosave) editor.updateAutosave(settings.autosave ?? null)\n if (settings.fileUploader !== previous.fileUploader) editor.fileUploader = settings.fileUploader ?? null\n }\n\n /** Applies new settings from the framework component. */\n update(settings: ScriviamoSettings) {\n let previous = this.#settings\n this.#settings = {...settings}\n this.#apply(settings, previous)\n if (settings.events !== previous.events) {\n this.#unlisten()\n this.#listen(settings.events)\n }\n let format = this.#format(settings)\n let formatChanged = format != this.#format(previous)\n let known = settings.value === this.#value || settings.value === this.#loadedValue\n if (settings.value !== undefined && !known) {\n this.#flush()\n this.#load(settings.value, format)\n } else if (formatChanged) {\n this.#value = this.value\n }\n }\n\n /** The document in the binding's format. */\n get value(): string {\n switch (this.#format(this.#settings)) {\n case \"html\": return this.editor.toHTML()\n case \"markdown\": return this.editor.toMarkdown()\n }\n return this.editor.toJSON()\n }\n\n #load(value: string, format: ScriviamoFormat) {\n let editor = this.editor\n this.#loading = true\n try {\n this.#loadInto(editor, value, format)\n } finally {\n this.#loading = false\n }\n editor.history.reset()\n editor.isChanged = false\n this.#loadedValue = value\n // The editor's export of what was loaded, which may differ from it in small ways.\n this.#value = this.value\n }\n\n #loadInto(editor: Editor, value: string, format: ScriviamoFormat) {\n if (format == \"json\") {\n if (value.trim().length == 0) editor.removeAllNodes()\n else editor.fromJSON(value)\n } else if (format == \"html\") {\n if (value.trim().length == 0) editor.removeAllNodes()\n else editor.fromHTML(value)\n } else {\n if (value.trim().length == 0) editor.removeAllNodes()\n else editor.fromMarkdown(value)\n }\n }\n\n #scheduleChange() {\n let delay = Math.max(0, this.#settings.changeDelay ?? 0)\n if (this.#timer) clearTimeout(this.#timer)\n this.#timer = null\n if (delay == 0) {\n this.#report()\n } else {\n this.#timer = setTimeout(() => {\n this.#timer = null\n this.#report()\n }, delay)\n }\n }\n\n #report() {\n let value = this.value\n if (value === this.#value) return\n this.#value = value\n // The document no longer matches what was loaded, so loading that value again must reload it.\n this.#loadedValue = undefined\n this.#callbacks.change?.(value, this.editor)\n }\n\n /** Reports a change that is waiting for changeDelay. */\n #flush() {\n if (!this.#timer) return\n clearTimeout(this.#timer)\n this.#timer = null\n this.#report()\n }\n\n #listen(events: ScriviamoSettings[\"events\"]) {\n for (let name of Object.keys(events || {})) {\n let handler = events[name]\n if (typeof handler != \"function\") continue\n let listener: EventListener = event => handler(event as CustomEvent)\n this.editor.addEventListener(name, listener)\n this.#listeners.push([name, listener])\n }\n }\n\n #unlisten() {\n for (let [name, listener] of this.#listeners) this.editor.removeEventListener(name, listener)\n this.#listeners = []\n }\n\n /** Reports any waiting change, then removes the editor. */\n destroy() {\n this.#flush()\n this.#unlisten()\n this.editor.removeEventListener(\"contentChanged\", this.#onContent)\n this.editor.removeEventListener(\"selectionChanged\", this.#onSelection)\n this.editor.destroy()\n }\n}\n","import {ChangeDetectionStrategy, Component, ElementRef, EventEmitter, forwardRef, Input, NgZone, OnChanges, OnDestroy, OnInit, Output, ViewChild} from \"@angular/core\"\nimport {ControlValueAccessor, NG_VALUE_ACCESSOR} from \"@angular/forms\"\nimport type {Editor, Node, ToolbarDisplayModes} from \"scriviamo\"\nimport {EditorBinding, ScriviamoFormat, ScriviamoSettings} from \"./editorbinding\"\n\n/**\n * A Scriviamo editor. Import the add-ons you use before it is created.\n *\n * <scriviamo-editor [(value)]=\"doc\" format=\"markdown\" style=\"display: block; height: 500px\" />\n *\n * It also works with Angular forms, through ngModel or a form control. value is read when it\n * changes from outside: the editor's own changes come back through valueChange, and passing\n * them back in doesn't reload the document.\n */\n@Component({\n selector: \"scriviamo-editor\",\n standalone: true,\n template: \"<div #host class=\\\"scriviamo-editor-host\\\"></div>\",\n styles: [\":host { display: block; } .scriviamo-editor-host { height: 100%; }\"],\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [{provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => ScriviamoEditorComponent), multi: true}]\n})\nexport class ScriviamoEditorComponent implements OnInit, OnChanges, OnDestroy, ControlValueAccessor {\n /** The document, in format. */\n @Input() value: string | undefined\n @Input() format: ScriviamoFormat = \"json\"\n @Input() readOnly: boolean | undefined\n @Input() toolbarVisible: boolean | undefined\n @Input() toolbarDisplayMode: ToolbarDisplayModes | undefined\n @Input() showContextualToolbars: boolean | undefined\n @Input() hoverInsertion: boolean | undefined\n @Input() markdownShortcuts: boolean | undefined\n @Input() allowAnnotations: boolean | undefined\n @Input() adaptiveHeight: boolean | undefined\n @Input() fontName: string | undefined\n @Input() fontSize: number | undefined\n /** A locale pack, or an object of localized strings. */\n @Input() locale: string | object | undefined\n @Input() editorClass: string | undefined\n /** Shows the status bar: counts, reading time and the autosave state. */\n @Input() statusBar: boolean | undefined\n /** Saves the document after changes: a save function, or one with its settings. */\n @Input() autosave: ScriviamoSettings[\"autosave\"]\n /** Uploads the files people add, such as pictures, and returns their addresses. */\n @Input() fileUploader: ScriviamoSettings[\"fileUploader\"]\n /** Milliseconds to wait after typing stops before reporting a change. */\n @Input() changeDelay: number | undefined\n /** Editor events to listen to, by name. */\n @Input() events: ScriviamoSettings[\"events\"]\n\n /** The document changed in the editor, for [(value)]. */\n @Output() valueChange = new EventEmitter<string>()\n @Output() selectionChange = new EventEmitter<Node | null>()\n /** The editor was created. */\n @Output() ready = new EventEmitter<Editor>()\n\n @ViewChild(\"host\", {static: true}) host!: ElementRef<HTMLElement>\n\n #binding: EditorBinding | null = null\n #formsDisabled = false\n #onFormChange: (value: string) => void = () => {}\n #onFormTouched: () => void = () => {}\n\n constructor(private zone: NgZone) {}\n\n /** The editor, once the view exists. */\n get editor(): Editor | null {\n return this.#binding ? this.#binding.editor : null\n }\n\n #settings(): ScriviamoSettings {\n return {\n value: this.value,\n format: this.format,\n readOnly: this.#formsDisabled ? true : this.readOnly,\n toolbarVisible: this.toolbarVisible,\n toolbarDisplayMode: this.toolbarDisplayMode,\n showContextualToolbars: this.showContextualToolbars,\n hoverInsertion: this.hoverInsertion,\n markdownShortcuts: this.markdownShortcuts,\n allowAnnotations: this.allowAnnotations,\n adaptiveHeight: this.adaptiveHeight,\n fontName: this.fontName,\n fontSize: this.fontSize,\n locale: this.locale,\n editorClass: this.editorClass,\n statusBar: this.statusBar,\n autosave: this.autosave,\n fileUploader: this.fileUploader,\n changeDelay: this.changeDelay,\n events: this.events\n }\n }\n\n // The editor is created as early as possible, so a template binding such as\n // [editor]=\"doc.editor\" already sees it in the first check. The host is a static query.\n ngOnInit() {\n // The editor's own listeners run outside Angular; only the outputs re-enter it.\n this.zone.runOutsideAngular(() => {\n this.#binding = new EditorBinding(this.host.nativeElement, this.#settings(), {\n change: value => this.zone.run(() => {\n this.value = value\n this.valueChange.emit(value)\n this.#onFormChange(value)\n }),\n selectionChange: node => this.zone.run(() => this.selectionChange.emit(node))\n })\n this.host.nativeElement.addEventListener(\"focusout\", event => {\n // Touched once focus leaves the editor altogether, not when it moves inside it.\n if (!this.host.nativeElement.contains(event.relatedTarget as globalThis.Node | null)) this.zone.run(() => this.#onFormTouched())\n })\n })\n this.ready.emit(this.#binding!.editor)\n }\n\n ngOnChanges() {\n this.#binding?.update(this.#settings())\n }\n\n ngOnDestroy() {\n this.#binding?.destroy()\n this.#binding = null\n }\n\n // Angular forms\n\n writeValue(value: string | null) {\n this.value = value ?? \"\"\n this.#binding?.update(this.#settings())\n }\n\n registerOnChange(callback: (value: string) => void) {\n this.#onFormChange = callback\n }\n\n registerOnTouched(callback: () => void) {\n this.#onFormTouched = callback\n }\n\n setDisabledState(disabled: boolean) {\n this.#formsDisabled = disabled\n this.#binding?.update(this.#settings())\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAAA;AAiDA;;;;AAIG;MACU,aAAa,CAAA;AAExB,IAAA,SAAS;AACT,IAAA,UAAU;;AAEV,IAAA,MAAM;AACN,IAAA,YAAY;;IAEZ,QAAQ,GAAY,KAAK;IACzB,MAAM,GAAyC,IAAI;IACnD,UAAU,GAAmC,EAAE;AAC/C,IAAA,UAAU;AACV,IAAA,YAAY;AAEZ,IAAA,WAAA,CAAY,OAAoB,EAAE,QAA2B,EAAE,YAAgC,EAAE,EAAA;AAC/F,QAAA,IAAI,CAAC,SAAS,GAAG,EAAC,GAAG,QAAQ,EAAC;AAC9B,QAAA,IAAI,CAAC,UAAU,GAAG,SAAS;AAC3B,QAAA,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACnE,QAAA,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;sBACA;;sBAEA;;sBACA;;sBAEA;;sBAEA;;sBAEA;;sBAEA;;sBAEA;;sBAGA;;sBACA;;sBAEA;;sBAEA,SAAS;AAAC,gBAAA,IAAA,EAAA,CAAA,MAAM,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC;;;ACxDnC;;AAEG;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { OnInit, OnChanges, OnDestroy, EventEmitter, ElementRef, NgZone } from '@angular/core';
|
|
3
|
+
import { ControlValueAccessor } from '@angular/forms';
|
|
4
|
+
import { ToolbarDisplayModes, AutosaveFunction, FileUploader, Node, Editor } from 'scriviamo';
|
|
5
|
+
|
|
6
|
+
/** The document format a wrapper's value is read and written in. */
|
|
7
|
+
type ScriviamoFormat = "json" | "html" | "markdown";
|
|
8
|
+
/** Settings every framework wrapper accepts. Missing settings keep the editor's defaults. */
|
|
9
|
+
interface ScriviamoSettings {
|
|
10
|
+
/** The document, in format. Changing it from outside replaces the document. */
|
|
11
|
+
value?: string;
|
|
12
|
+
/** The format of value. "json" keeps everything; HTML and Markdown keep what they can express. */
|
|
13
|
+
format?: ScriviamoFormat;
|
|
14
|
+
readOnly?: boolean;
|
|
15
|
+
toolbarVisible?: boolean;
|
|
16
|
+
toolbarDisplayMode?: ToolbarDisplayModes;
|
|
17
|
+
showContextualToolbars?: boolean;
|
|
18
|
+
hoverInsertion?: boolean;
|
|
19
|
+
markdownShortcuts?: boolean;
|
|
20
|
+
allowAnnotations?: boolean;
|
|
21
|
+
adaptiveHeight?: boolean;
|
|
22
|
+
fontName?: string;
|
|
23
|
+
fontSize?: number;
|
|
24
|
+
/** A locale pack, or an object of localized strings. */
|
|
25
|
+
locale?: string | object;
|
|
26
|
+
/** Extra classes for the editor element. */
|
|
27
|
+
editorClass?: string;
|
|
28
|
+
/** Shows the status bar: word and character counts, reading time and the autosave state. */
|
|
29
|
+
statusBar?: boolean;
|
|
30
|
+
/** Saves the document after changes: a save function, or one with its settings. */
|
|
31
|
+
autosave?: AutosaveFunction | {
|
|
32
|
+
save: AutosaveFunction;
|
|
33
|
+
delay?: number;
|
|
34
|
+
maximumWait?: number;
|
|
35
|
+
retryDelay?: number;
|
|
36
|
+
warnBeforeLeaving?: boolean;
|
|
37
|
+
} | null;
|
|
38
|
+
/** Uploads the files people add, such as pictures, and returns their addresses. */
|
|
39
|
+
fileUploader?: FileUploader | null;
|
|
40
|
+
/** Milliseconds to wait after typing stops before reporting a change; 0 reports each change. */
|
|
41
|
+
changeDelay?: number;
|
|
42
|
+
/** Editor events to listen to, by name, such as {linkPressed: event => ...}. */
|
|
43
|
+
events?: {
|
|
44
|
+
[name: string]: (event: CustomEvent) => void;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A Scriviamo editor. Import the add-ons you use before it is created.
|
|
50
|
+
*
|
|
51
|
+
* <scriviamo-editor [(value)]="doc" format="markdown" style="display: block; height: 500px" />
|
|
52
|
+
*
|
|
53
|
+
* It also works with Angular forms, through ngModel or a form control. value is read when it
|
|
54
|
+
* changes from outside: the editor's own changes come back through valueChange, and passing
|
|
55
|
+
* them back in doesn't reload the document.
|
|
56
|
+
*/
|
|
57
|
+
declare class ScriviamoEditorComponent implements OnInit, OnChanges, OnDestroy, ControlValueAccessor {
|
|
58
|
+
#private;
|
|
59
|
+
private zone;
|
|
60
|
+
/** The document, in format. */
|
|
61
|
+
value: string | undefined;
|
|
62
|
+
format: ScriviamoFormat;
|
|
63
|
+
readOnly: boolean | undefined;
|
|
64
|
+
toolbarVisible: boolean | undefined;
|
|
65
|
+
toolbarDisplayMode: ToolbarDisplayModes | undefined;
|
|
66
|
+
showContextualToolbars: boolean | undefined;
|
|
67
|
+
hoverInsertion: boolean | undefined;
|
|
68
|
+
markdownShortcuts: boolean | undefined;
|
|
69
|
+
allowAnnotations: boolean | undefined;
|
|
70
|
+
adaptiveHeight: boolean | undefined;
|
|
71
|
+
fontName: string | undefined;
|
|
72
|
+
fontSize: number | undefined;
|
|
73
|
+
/** A locale pack, or an object of localized strings. */
|
|
74
|
+
locale: string | object | undefined;
|
|
75
|
+
editorClass: string | undefined;
|
|
76
|
+
/** Shows the status bar: counts, reading time and the autosave state. */
|
|
77
|
+
statusBar: boolean | undefined;
|
|
78
|
+
/** Saves the document after changes: a save function, or one with its settings. */
|
|
79
|
+
autosave: ScriviamoSettings["autosave"];
|
|
80
|
+
/** Uploads the files people add, such as pictures, and returns their addresses. */
|
|
81
|
+
fileUploader: ScriviamoSettings["fileUploader"];
|
|
82
|
+
/** Milliseconds to wait after typing stops before reporting a change. */
|
|
83
|
+
changeDelay: number | undefined;
|
|
84
|
+
/** Editor events to listen to, by name. */
|
|
85
|
+
events: ScriviamoSettings["events"];
|
|
86
|
+
/** The document changed in the editor, for [(value)]. */
|
|
87
|
+
valueChange: EventEmitter<string>;
|
|
88
|
+
selectionChange: EventEmitter<Node>;
|
|
89
|
+
/** The editor was created. */
|
|
90
|
+
ready: EventEmitter<Editor>;
|
|
91
|
+
host: ElementRef<HTMLElement>;
|
|
92
|
+
constructor(zone: NgZone);
|
|
93
|
+
/** The editor, once the view exists. */
|
|
94
|
+
get editor(): Editor | null;
|
|
95
|
+
ngOnInit(): void;
|
|
96
|
+
ngOnChanges(): void;
|
|
97
|
+
ngOnDestroy(): void;
|
|
98
|
+
writeValue(value: string | null): void;
|
|
99
|
+
registerOnChange(callback: (value: string) => void): void;
|
|
100
|
+
registerOnTouched(callback: () => void): void;
|
|
101
|
+
setDisabledState(disabled: boolean): void;
|
|
102
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScriviamoEditorComponent, never>;
|
|
103
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ScriviamoEditorComponent, "scriviamo-editor", never, { "value": { "alias": "value"; "required": false; }; "format": { "alias": "format"; "required": false; }; "readOnly": { "alias": "readOnly"; "required": false; }; "toolbarVisible": { "alias": "toolbarVisible"; "required": false; }; "toolbarDisplayMode": { "alias": "toolbarDisplayMode"; "required": false; }; "showContextualToolbars": { "alias": "showContextualToolbars"; "required": false; }; "hoverInsertion": { "alias": "hoverInsertion"; "required": false; }; "markdownShortcuts": { "alias": "markdownShortcuts"; "required": false; }; "allowAnnotations": { "alias": "allowAnnotations"; "required": false; }; "adaptiveHeight": { "alias": "adaptiveHeight"; "required": false; }; "fontName": { "alias": "fontName"; "required": false; }; "fontSize": { "alias": "fontSize"; "required": false; }; "locale": { "alias": "locale"; "required": false; }; "editorClass": { "alias": "editorClass"; "required": false; }; "statusBar": { "alias": "statusBar"; "required": false; }; "autosave": { "alias": "autosave"; "required": false; }; "fileUploader": { "alias": "fileUploader"; "required": false; }; "changeDelay": { "alias": "changeDelay"; "required": false; }; "events": { "alias": "events"; "required": false; }; }, { "valueChange": "valueChange"; "selectionChange": "selectionChange"; "ready": "ready"; }, never, never, true, never>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { ScriviamoEditorComponent };
|
|
107
|
+
export type { ScriviamoFormat, ScriviamoSettings };
|
|
108
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../src/editorbinding.ts","../src/scriviamo-editor.component.ts"],"mappings":";;;;;AAIA;AACA,KAAA;AAEA;AACA,2BAAiB;;;;aAIN,eAAe;;;yBAGH,mBAAmB;;;;;;;;;AASxC;;;;;;eAMW,gBAAgB;cAAU,gBAAgB;;;;;AAAyF;;AAE9I,mBAAe,YAAY;;;;AAI3B;gCAAkC,WAAW;;AAC9C;;AChCD;;;;;;;;AAQG;AACH,cAAA,wBAQa,oBAAoC,oBAAmB,EAAA,oBAAW;;AAyCjE;;AAvCH;YACQ,eAAe;AACvB;AACA;AACA,wBAAoB,mBAAmB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA,cAAU,iBAAiB;;AAE3B,kBAAc,iBAAiB;;AAE/B;;AAEA,YAAQ,iBAAiB;;AAGxB,iBAAW,YAAA;AACX,qBAAe,YAAA,CAAA,IAAA;;AAEf,WAAK,YAAA,CAAA,MAAA;AAEoB,UAAO,UAAU,CAAC,WAAW;AAO5C,sBAAM,MAAM;;AAGhC,kBAAc,MAAM;;;;AA4DpB;;AASA;;yCAjHW,wBAAwB;2CAAxB,wBAAwB;AAyHpC;;","names":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { OnInit, OnChanges, OnDestroy, ElementRef, NgZone } from '@angular/core';
|
|
3
|
+
import { Editor } from 'scriviamo';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The property panel for an editor's selected nodes, or its document.
|
|
7
|
+
*
|
|
8
|
+
* <scriviamo-editor #doc /> <scriviamo-inspector [editor]="doc.editor" />
|
|
9
|
+
*
|
|
10
|
+
* It needs Scriviamo's inspector add-on, a premium add-on, so it has its own entry point:
|
|
11
|
+
* import it from "scriviamo-angular/inspector".
|
|
12
|
+
*/
|
|
13
|
+
declare class ScriviamoInspectorComponent implements OnInit, OnChanges, OnDestroy {
|
|
14
|
+
#private;
|
|
15
|
+
private zone;
|
|
16
|
+
editor: Editor | null;
|
|
17
|
+
/** Identifiers of sections that start collapsed. */
|
|
18
|
+
collapsedSections: Array<string>;
|
|
19
|
+
host: ElementRef<HTMLElement>;
|
|
20
|
+
constructor(zone: NgZone);
|
|
21
|
+
ngOnInit(): void;
|
|
22
|
+
ngOnChanges(): void;
|
|
23
|
+
ngOnDestroy(): void;
|
|
24
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScriviamoInspectorComponent, never>;
|
|
25
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ScriviamoInspectorComponent, "scriviamo-inspector", never, { "editor": { "alias": "editor"; "required": false; }; "collapsedSections": { "alias": "collapsedSections"; "required": false; }; }, {}, never, never, true, never>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { ScriviamoInspectorComponent };
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../../inspector/src/scriviamo-inspector.component.ts"],"mappings":";;;;AAIA;;;;;;;AAOG;AACH,cAAA,uCAOyC,MAAA,EAAW,SAAQ,EAAA,SAAW;;AASzD;AARH,YAAQ,MAAM;;AAEd,uBAAmB,KAAK;AAEE,UAAO,UAAU,CAAC,WAAW;AAI5C,sBAAM,MAAM;;;;yCATrB,2BAA2B;2CAA3B,2BAA2B;AAyBvC;;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scriviamo-angular",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.1-beta.16",
|
|
4
|
+
"description": "Angular components for the Scriviamo editor",
|
|
5
|
+
"peerDependencies": {
|
|
6
|
+
"@angular/core": ">=17",
|
|
7
|
+
"@angular/forms": ">=17",
|
|
8
|
+
"scriviamo": "^1.0.1-beta.16"
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=20.19"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"homepage": "https://scriviamo.dev",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/Scriviamo-Pro/scriviamo.git",
|
|
18
|
+
"directory": "wrappers/angular"
|
|
19
|
+
},
|
|
20
|
+
"module": "fesm2022/scriviamo-angular.mjs",
|
|
21
|
+
"typings": "index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
"./package.json": {
|
|
24
|
+
"default": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./index.d.ts",
|
|
28
|
+
"default": "./fesm2022/scriviamo-angular.mjs"
|
|
29
|
+
},
|
|
30
|
+
"./inspector": {
|
|
31
|
+
"types": "./inspector/index.d.ts",
|
|
32
|
+
"default": "./fesm2022/scriviamo-angular-inspector.mjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"tslib": "^2.3.0"
|
|
38
|
+
}
|
|
6
39
|
}
|