stilo-editor 0.2.1 → 0.3.1
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 +46 -1
- 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 +46 -3
package/dist/style.css
CHANGED
|
@@ -152,6 +152,15 @@ li.ProseMirror-selectednode:after {
|
|
|
152
152
|
|
|
153
153
|
/* Stilo content defaults */
|
|
154
154
|
|
|
155
|
+
/*
|
|
156
|
+
* The editable area gets some room around the text and a visible height when empty.
|
|
157
|
+
* `:where()` has no specificity, so any rule of the page replaces these values.
|
|
158
|
+
*/
|
|
159
|
+
:where(.stilo-content.ProseMirror) {
|
|
160
|
+
min-height: 6em;
|
|
161
|
+
padding: 12px 16px;
|
|
162
|
+
}
|
|
163
|
+
|
|
155
164
|
/* Lists: list items hold paragraphs, which must not add their own margins. */
|
|
156
165
|
.stilo-content ul,
|
|
157
166
|
.stilo-content ol {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Public API of `stilo-editor/svelte/action`: the Svelte actions, for Svelte 4 and 5. */
|
|
2
|
+
/** The editor alone, for a custom UI. */
|
|
3
|
+
export { type StiloEditorOptions, stiloEditor } from './editor-action';
|
|
4
|
+
/** The editor with the default UI. */
|
|
5
|
+
export { type StiloEditorCallbacks, type StiloEditorWithUIOptions, stiloEditorWithUI, } from './editor-with-ui-action';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { n as stiloEditor, t as stiloEditorWithUI } from "../action-lB2jnYNO.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ActionReturn } from 'svelte/action';
|
|
2
|
+
import { Editor, type EditorOptions } from '../index';
|
|
3
|
+
/** Options of {@link stiloEditor}: the editor options without `element`. */
|
|
4
|
+
export interface StiloEditorOptions extends Omit<EditorOptions, 'element'> {
|
|
5
|
+
/** Called with the editor once it is created. */
|
|
6
|
+
onready?: (editor: Editor) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Svelte action that creates an editor inside its element and destroys it when the element
|
|
10
|
+
* goes: `<div use:stiloEditor={options}>`. The options are read once, when the editor is
|
|
11
|
+
* created; only `editable` follows their changes.
|
|
12
|
+
*/
|
|
13
|
+
export declare function stiloEditor(node: HTMLElement, options: StiloEditorOptions): ActionReturn<StiloEditorOptions>;
|
|
14
|
+
/** Applies a new value of the `editable` option. */
|
|
15
|
+
export declare function followEditable(editor: Editor, editable: boolean | undefined): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ActionReturn } from 'svelte/action';
|
|
2
|
+
import { type EditorEvents, type EditorOptions, type EventHandler } from '../index';
|
|
3
|
+
import { type Messages, type ToolbarOptions } from '../ui/index';
|
|
4
|
+
import { type StiloEditorOptions } from './editor-action';
|
|
5
|
+
/** Editor events forwarded to the callbacks of {@link stiloEditorWithUI}. */
|
|
6
|
+
declare const CALLBACKS: {
|
|
7
|
+
readonly input: 'oninput';
|
|
8
|
+
readonly selectionchange: 'onselectionchange';
|
|
9
|
+
readonly transaction: 'ontransaction';
|
|
10
|
+
readonly focus: 'onfocus';
|
|
11
|
+
readonly blur: 'onblur';
|
|
12
|
+
};
|
|
13
|
+
type ForwardedEvent = keyof typeof CALLBACKS;
|
|
14
|
+
/** Callbacks of {@link stiloEditorWithUI}: `oninput` for `input`, and so on. */
|
|
15
|
+
export type StiloEditorCallbacks = {
|
|
16
|
+
[E in ForwardedEvent as (typeof CALLBACKS)[E]]?: EventHandler<EditorEvents[E]>;
|
|
17
|
+
};
|
|
18
|
+
/** Options of {@link stiloEditorWithUI}, and props of the `StiloEditor` component. */
|
|
19
|
+
export interface StiloEditorWithUIOptions extends Omit<StiloEditorOptions, 'extensions'>, StiloEditorCallbacks {
|
|
20
|
+
/** Extensions to load. Default: `[defaultExtensions()]`. */
|
|
21
|
+
extensions?: EditorOptions['extensions'];
|
|
22
|
+
/** The default toolbar: `true` (default), `false`, or its options without `container`. */
|
|
23
|
+
toolbar?: boolean | Omit<ToolbarOptions, 'container' | 'messages'>;
|
|
24
|
+
/** The status bar with the word and character count, under the editor. Default: `false`. */
|
|
25
|
+
statusBar?: boolean;
|
|
26
|
+
/** Strings of the toolbar and the status bar. Default: `en`. */
|
|
27
|
+
messages?: Messages;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Svelte action that creates the editor with the default UI inside its element:
|
|
31
|
+
* `<div use:stiloEditorWithUI={options}>`. The options are read once, when the editor is
|
|
32
|
+
* created, except `editable` and the callbacks, which follow their changes.
|
|
33
|
+
*/
|
|
34
|
+
export declare function stiloEditorWithUI(node: HTMLElement, options?: StiloEditorWithUIOptions): ActionReturn<StiloEditorWithUIOptions>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { stiloEditorWithUI } from './action.js';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
editor = $bindable(null),
|
|
6
|
+
extensions,
|
|
7
|
+
content,
|
|
8
|
+
editable,
|
|
9
|
+
autofocus,
|
|
10
|
+
ariaLabel,
|
|
11
|
+
compactParagraphs,
|
|
12
|
+
toolbar,
|
|
13
|
+
statusBar,
|
|
14
|
+
messages,
|
|
15
|
+
onready,
|
|
16
|
+
oninput,
|
|
17
|
+
onselectionchange,
|
|
18
|
+
ontransaction,
|
|
19
|
+
onfocus,
|
|
20
|
+
onblur,
|
|
21
|
+
...attributes
|
|
22
|
+
} = $props();
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<div
|
|
26
|
+
{...attributes}
|
|
27
|
+
use:stiloEditorWithUI={{
|
|
28
|
+
extensions,
|
|
29
|
+
content,
|
|
30
|
+
editable,
|
|
31
|
+
autofocus,
|
|
32
|
+
ariaLabel,
|
|
33
|
+
compactParagraphs,
|
|
34
|
+
toolbar,
|
|
35
|
+
statusBar,
|
|
36
|
+
messages,
|
|
37
|
+
oninput,
|
|
38
|
+
onselectionchange,
|
|
39
|
+
ontransaction,
|
|
40
|
+
onfocus,
|
|
41
|
+
onblur,
|
|
42
|
+
onready: (created) => {
|
|
43
|
+
editor = created;
|
|
44
|
+
onready?.(created);
|
|
45
|
+
},
|
|
46
|
+
}}
|
|
47
|
+
></div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Component } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { Editor } from '../index';
|
|
4
|
+
import type { StiloEditorWithUIOptions } from './editor-with-ui-action';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Props of `StiloEditor`: the options of `stiloEditorWithUI`, `editor` to bind, and the
|
|
8
|
+
* attributes of its element.
|
|
9
|
+
*/
|
|
10
|
+
export interface StiloEditorProps
|
|
11
|
+
extends StiloEditorWithUIOptions,
|
|
12
|
+
Omit<HTMLAttributes<HTMLDivElement>, keyof StiloEditorWithUIOptions> {
|
|
13
|
+
/** The editor, for `bind:editor`; `null` until it is created. */
|
|
14
|
+
editor?: Editor | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The editor with the default UI. The props are read once, when the editor is created, except
|
|
19
|
+
* `editable` and the callbacks, which follow their changes.
|
|
20
|
+
*/
|
|
21
|
+
declare const StiloEditor: Component<StiloEditorProps, object, 'editor'>;
|
|
22
|
+
export default StiloEditor;
|
|
@@ -14,7 +14,10 @@ export interface LinkPopover {
|
|
|
14
14
|
close(): void;
|
|
15
15
|
destroy(): void;
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Whether the editor is editable and the selection is in a link or can be linked (a cursor
|
|
19
|
+
* outside a link cannot).
|
|
20
|
+
*/
|
|
18
21
|
export declare function canEditLink(editor: Editor): boolean;
|
|
19
22
|
/** Creates the link popover (closed), anchored to the selection of `editor`. */
|
|
20
23
|
export declare function createLinkPopover(editor: Editor, options: LinkPopoverOptions): LinkPopover;
|