stilo-editor 0.2.0 → 0.3.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 +111 -173
- package/dist/action-lB2jnYNO.js +66 -0
- package/dist/content.css +9 -0
- package/dist/core/editor.d.ts +12 -2
- package/dist/index.js +1 -1
- package/dist/react/index.d.ts +5 -0
- package/dist/react/stilo-editor.d.ts +37 -0
- package/dist/react/use-stilo-editor.d.ts +15 -0
- package/dist/react.js +75 -0
- package/dist/{src-CV6pgfTS.js → src-DxTXpULc.js} +402 -392
- package/dist/style.css +9 -0
- package/dist/svelte/action.d.ts +5 -0
- package/dist/svelte/action.js +1 -0
- package/dist/svelte/editor-action.d.ts +15 -0
- package/dist/svelte/editor-with-ui-action.d.ts +35 -0
- package/dist/svelte/index.d.ts +5 -0
- package/dist/svelte/index.js +3 -0
- package/dist/svelte/stilo-editor.svelte +47 -0
- package/dist/svelte/stilo-editor.svelte.d.ts +22 -0
- package/dist/ui/components/link-popover.d.ts +4 -1
- package/dist/ui-WFNvrkbM.js +2351 -0
- package/dist/ui.js +1 -2350
- package/dist/vue/index.d.ts +5 -0
- package/dist/vue/stilo-editor.d.ts +52 -0
- package/dist/vue/use-stilo-editor.d.ts +19 -0
- package/dist/vue.js +101 -0
- package/package.json +43 -4
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Public API of the Stilo Vue wrapper. */
|
|
2
|
+
/** The editor with the default UI. */
|
|
3
|
+
export { StiloEditor, type StiloEditorEmits, type StiloEditorProps } from './stilo-editor';
|
|
4
|
+
/** The editor alone, for a custom UI. */
|
|
5
|
+
export { type UseStiloEditorOptions, type UseStiloEditorResult, useStiloEditor, } from './use-stilo-editor';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type Editor, type EditorEvents, type EditorOptions, type EventHandler } from '../index';
|
|
2
|
+
import { type Messages, type ToolbarOptions } from '../ui/index';
|
|
3
|
+
/**
|
|
4
|
+
* Events of {@link StiloEditor}: `ready` with the editor once it is created, and the editor
|
|
5
|
+
* events with the same payload, `selectionchange` under the name `selectionChange`.
|
|
6
|
+
*/
|
|
7
|
+
export type StiloEditorEmits = {
|
|
8
|
+
ready: (editor: Editor) => void;
|
|
9
|
+
input: EventHandler<EditorEvents['input']>;
|
|
10
|
+
selectionChange: EventHandler<EditorEvents['selectionchange']>;
|
|
11
|
+
transaction: EventHandler<EditorEvents['transaction']>;
|
|
12
|
+
focus: EventHandler<EditorEvents['focus']>;
|
|
13
|
+
blur: EventHandler<EditorEvents['blur']>;
|
|
14
|
+
};
|
|
15
|
+
/** Props of {@link StiloEditor}. */
|
|
16
|
+
export interface StiloEditorProps extends Omit<EditorOptions, 'element' | 'extensions'> {
|
|
17
|
+
/** Extensions to load. Default: `[defaultExtensions()]`. */
|
|
18
|
+
extensions?: EditorOptions['extensions'];
|
|
19
|
+
/** The default toolbar: `true` (default), `false`, or its options without `container`. */
|
|
20
|
+
toolbar?: boolean | Omit<ToolbarOptions, 'container' | 'messages'>;
|
|
21
|
+
/** The status bar with the word and character count, under the editor. Default: `false`. */
|
|
22
|
+
statusBar?: boolean;
|
|
23
|
+
/** Strings of the toolbar and the status bar. Default: `en`. */
|
|
24
|
+
messages?: Messages;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The editor with the default UI. The props are read once, when the editor is created, except
|
|
28
|
+
* `editable`, which follows its changes.
|
|
29
|
+
*/
|
|
30
|
+
export declare const StiloEditor: import("vue").DefineSetupFnComponent<StiloEditorProps, StiloEditorEmits, {}, StiloEditorProps & {
|
|
31
|
+
onBlur?: ((payload: {
|
|
32
|
+
editor: Editor;
|
|
33
|
+
event: FocusEvent;
|
|
34
|
+
}) => any) | undefined;
|
|
35
|
+
onFocus?: ((payload: {
|
|
36
|
+
editor: Editor;
|
|
37
|
+
event: FocusEvent;
|
|
38
|
+
}) => any) | undefined;
|
|
39
|
+
onInput?: ((payload: {
|
|
40
|
+
editor: Editor;
|
|
41
|
+
transaction: import("prosemirror-state").Transaction | null;
|
|
42
|
+
}) => any) | undefined;
|
|
43
|
+
onReady?: ((editor: Editor) => any) | undefined;
|
|
44
|
+
onSelectionChange?: ((payload: {
|
|
45
|
+
editor: Editor;
|
|
46
|
+
transaction: import("prosemirror-state").Transaction;
|
|
47
|
+
}) => any) | undefined;
|
|
48
|
+
onTransaction?: ((payload: {
|
|
49
|
+
editor: Editor;
|
|
50
|
+
transaction: import("prosemirror-state").Transaction;
|
|
51
|
+
}) => any) | undefined;
|
|
52
|
+
}, import("vue").PublicProps>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter, type ShallowRef } from 'vue';
|
|
2
|
+
import { Editor, type EditorOptions } from '../index';
|
|
3
|
+
/** Options of {@link useStiloEditor}: the editor options without `element`. */
|
|
4
|
+
export interface UseStiloEditorOptions extends Omit<EditorOptions, 'element' | 'editable'> {
|
|
5
|
+
/** Whether the content is editable; a ref or a getter is followed. Default: `true`. */
|
|
6
|
+
editable?: MaybeRefOrGetter<boolean | undefined>;
|
|
7
|
+
}
|
|
8
|
+
/** What {@link useStiloEditor} returns. */
|
|
9
|
+
export interface UseStiloEditorResult {
|
|
10
|
+
/** Template ref of the element that holds the editor: `<div ref="element">`. */
|
|
11
|
+
element: ShallowRef<HTMLElement | null>;
|
|
12
|
+
/** The editor; `null` before the element is mounted, on the server and after unmount. */
|
|
13
|
+
editor: ShallowRef<Editor | null>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates an editor inside the element bound to `element` and destroys it when the element goes.
|
|
17
|
+
* The options are read once, when the editor is created; only `editable` follows its changes.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useStiloEditor(options: UseStiloEditorOptions): UseStiloEditorResult;
|
package/dist/vue.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Q as e, t } from "./src-DxTXpULc.js";
|
|
2
|
+
import { h as n, t as r } from "./ui-WFNvrkbM.js";
|
|
3
|
+
import { defineComponent as i, h as a, shallowRef as o, toValue as s, watch as c } from "vue";
|
|
4
|
+
//#region src/vue/use-stilo-editor.ts
|
|
5
|
+
function l(t) {
|
|
6
|
+
let n = o(null), r = o(null), i = () => s(t.editable) ?? !0;
|
|
7
|
+
return c(n, (n, a, o) => {
|
|
8
|
+
if (!n) return;
|
|
9
|
+
let s = new e({
|
|
10
|
+
...t,
|
|
11
|
+
editable: i(),
|
|
12
|
+
element: n
|
|
13
|
+
});
|
|
14
|
+
r.value = s, o(() => {
|
|
15
|
+
s.destroy(), r.value = null;
|
|
16
|
+
});
|
|
17
|
+
}, { flush: "post" }), c(i, (e) => {
|
|
18
|
+
r.value && r.value.isEditable !== e && r.value.setEditable(e);
|
|
19
|
+
}), {
|
|
20
|
+
element: n,
|
|
21
|
+
editor: r
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
var u = /* @__PURE__ */ i((e, { emit: i }) => {
|
|
25
|
+
let { extensions: s = [t()], toolbar: u, statusBar: f, messages: p, ...m } = e, { element: h, editor: g } = l({
|
|
26
|
+
...m,
|
|
27
|
+
extensions: s,
|
|
28
|
+
editable: () => e.editable
|
|
29
|
+
}), _ = o(null), v = o(null), y = {
|
|
30
|
+
input: (e) => i("input", e),
|
|
31
|
+
selectionchange: (e) => i("selectionChange", e),
|
|
32
|
+
transaction: (e) => i("transaction", e),
|
|
33
|
+
focus: (e) => i("focus", e),
|
|
34
|
+
blur: (e) => i("blur", e)
|
|
35
|
+
};
|
|
36
|
+
return c(g, (e, t, a) => {
|
|
37
|
+
if (!e) return;
|
|
38
|
+
let o, s;
|
|
39
|
+
u && _.value && (o = r(e, {
|
|
40
|
+
...u === !0 ? {} : u,
|
|
41
|
+
container: _.value,
|
|
42
|
+
messages: p
|
|
43
|
+
})), f && v.value && (s = n(e, {
|
|
44
|
+
container: v.value,
|
|
45
|
+
messages: p
|
|
46
|
+
}));
|
|
47
|
+
let c = Object.keys(y).map((t) => d(e, t, y));
|
|
48
|
+
i("ready", e), a(() => {
|
|
49
|
+
if (!e.isDestroyed) {
|
|
50
|
+
o?.destroy(), s?.destroy();
|
|
51
|
+
for (let e of c) e();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}), () => a("div", null, [
|
|
55
|
+
u ? a("div", { ref: _ }) : null,
|
|
56
|
+
a("div", { ref: h }),
|
|
57
|
+
f ? a("div", { ref: v }) : null
|
|
58
|
+
]);
|
|
59
|
+
}, {
|
|
60
|
+
name: "StiloEditor",
|
|
61
|
+
props: {
|
|
62
|
+
extensions: null,
|
|
63
|
+
content: null,
|
|
64
|
+
editable: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: void 0
|
|
67
|
+
},
|
|
68
|
+
autofocus: {
|
|
69
|
+
type: [Boolean, String],
|
|
70
|
+
default: void 0
|
|
71
|
+
},
|
|
72
|
+
ariaLabel: null,
|
|
73
|
+
compactParagraphs: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: void 0
|
|
76
|
+
},
|
|
77
|
+
toolbar: {
|
|
78
|
+
type: [Boolean, Object],
|
|
79
|
+
default: !0
|
|
80
|
+
},
|
|
81
|
+
statusBar: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: !1
|
|
84
|
+
},
|
|
85
|
+
messages: null
|
|
86
|
+
},
|
|
87
|
+
emits: [
|
|
88
|
+
"ready",
|
|
89
|
+
"input",
|
|
90
|
+
"selectionChange",
|
|
91
|
+
"transaction",
|
|
92
|
+
"focus",
|
|
93
|
+
"blur"
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
function d(e, t, n) {
|
|
97
|
+
let r = n[t];
|
|
98
|
+
return e.on(t, r), () => e.off(t, r);
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { u as StiloEditor, l as useStiloEditor };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stilo-editor",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Open-source
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "A complete rich text editor. Everything included, ready in minutes. Open-source WYSIWYG HTML editor built on ProseMirror: clean HTML in and out, headless core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wysiwyg",
|
|
7
7
|
"wysiwyg-editor",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"author": "Alessio Coggiola <alessio.coggiola@gmail.com>",
|
|
23
23
|
"license": "MIT",
|
|
24
|
-
"homepage": "https://github.
|
|
24
|
+
"homepage": "https://kojak8791.github.io/stilo-editor/",
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|
|
27
27
|
"url": "git+https://github.com/kojak8791/stilo-editor.git"
|
|
@@ -45,6 +45,22 @@
|
|
|
45
45
|
"types": "./dist/ui/index.d.ts",
|
|
46
46
|
"import": "./dist/ui.js"
|
|
47
47
|
},
|
|
48
|
+
"./react": {
|
|
49
|
+
"types": "./dist/react/index.d.ts",
|
|
50
|
+
"import": "./dist/react.js"
|
|
51
|
+
},
|
|
52
|
+
"./vue": {
|
|
53
|
+
"types": "./dist/vue/index.d.ts",
|
|
54
|
+
"import": "./dist/vue.js"
|
|
55
|
+
},
|
|
56
|
+
"./svelte": {
|
|
57
|
+
"types": "./dist/svelte/index.d.ts",
|
|
58
|
+
"svelte": "./dist/svelte/index.js"
|
|
59
|
+
},
|
|
60
|
+
"./svelte/action": {
|
|
61
|
+
"types": "./dist/svelte/action.d.ts",
|
|
62
|
+
"import": "./dist/svelte/action.js"
|
|
63
|
+
},
|
|
48
64
|
"./content.css": "./dist/content.css",
|
|
49
65
|
"./ui.css": "./dist/ui.css",
|
|
50
66
|
"./style.css": "./dist/style.css"
|
|
@@ -86,13 +102,36 @@
|
|
|
86
102
|
"prosemirror-transform": "^1.12.2",
|
|
87
103
|
"prosemirror-view": "^1.42.6"
|
|
88
104
|
},
|
|
105
|
+
"peerDependencies": {
|
|
106
|
+
"react": "^18 || ^19",
|
|
107
|
+
"svelte": "^4 || ^5",
|
|
108
|
+
"vue": "^3.4"
|
|
109
|
+
},
|
|
110
|
+
"peerDependenciesMeta": {
|
|
111
|
+
"react": {
|
|
112
|
+
"optional": true
|
|
113
|
+
},
|
|
114
|
+
"svelte": {
|
|
115
|
+
"optional": true
|
|
116
|
+
},
|
|
117
|
+
"vue": {
|
|
118
|
+
"optional": true
|
|
119
|
+
}
|
|
120
|
+
},
|
|
89
121
|
"devDependencies": {
|
|
90
122
|
"@biomejs/biome": "^2.5.15",
|
|
91
123
|
"@playwright/test": "^1.64.0",
|
|
124
|
+
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
92
125
|
"@types/node": "^26.6.5",
|
|
126
|
+
"@types/react": "^19.3.0",
|
|
127
|
+
"@types/react-dom": "^19.3.0",
|
|
93
128
|
"jsdom": "^30.1.2",
|
|
129
|
+
"react": "^19.3.1",
|
|
130
|
+
"react-dom": "^19.3.1",
|
|
131
|
+
"svelte": "^5.57.2",
|
|
94
132
|
"typescript": "^7.0.2",
|
|
95
133
|
"vite": "^8.3.4",
|
|
96
|
-
"vitest": "^5.0.3"
|
|
134
|
+
"vitest": "^5.0.3",
|
|
135
|
+
"vue": "^3.5.44"
|
|
97
136
|
}
|
|
98
137
|
}
|