@folijs/react 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/LICENSE +21 -0
- package/README.md +48 -2
- package/dist/FoliCanvas.d.ts +23 -0
- package/dist/FoliCanvas.d.ts.map +1 -0
- package/dist/FoliCanvas.js +32 -0
- package/dist/FoliCanvas.js.map +1 -0
- package/dist/FoliEditor.d.ts +44 -0
- package/dist/FoliEditor.d.ts.map +1 -0
- package/dist/FoliEditor.js +38 -0
- package/dist/FoliEditor.js.map +1 -0
- package/dist/FoliToolbar.d.ts +26 -0
- package/dist/FoliToolbar.d.ts.map +1 -0
- package/dist/FoliToolbar.js +136 -0
- package/dist/FoliToolbar.js.map +1 -0
- package/dist/editor.d.ts +40 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +63 -0
- package/dist/editor.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -3
- package/src/FoliCanvas.tsx +68 -0
- package/src/FoliEditor.tsx +103 -0
- package/src/FoliToolbar.tsx +231 -0
- package/src/editor.tsx +105 -0
- package/src/index.ts +16 -0
- package/styles.css +142 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @folijs/react
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- First release: a document editor for the web with its own editing engine, on real pages.
|
|
8
|
+
- **Documents** (`@folijs/core`): a versioned JSON format (`schemaVersion: 1`) with page size and margins in millimetres; `parseDocument` validates untrusted input and never drops document content silently. Schema v1: paragraphs, headings 1–6, line breaks, page breaks; bold, italic, underline, strikethrough.
|
|
9
|
+
- **Engine** (`@folijs/core`): immutable state, steps and transactions, undo/redo history, commands, key bindings, a headless `createEditor`. No DOM.
|
|
10
|
+
- **View** (`@folijs/view`): `EditorView` renders the document on A4 or Letter pages in one `contenteditable` host. Paragraphs split across pages at a line, with widow/orphan and keep-with-next rules, explicit page breaks, incremental reflow, and print with one sheet per page (PDF output checked in Chromium). Typing, IME composition, copy, cut and paste (Foli JSON, HTML mapped to the schema, plain text), read-only mode, placeholder.
|
|
11
|
+
- **React** (`@folijs/react`, React 18.2+ and 19): `FoliEditor` with a formatting toolbar and `onChange`; `useFoliEditor`, `FoliEditorProvider`, `FoliCanvas`, `FoliToolbar`, `useCurrentEditor`, `useEditorState`. Server rendering gives the editor's shell; the document appears on hydration. Default theme in `@folijs/react/styles.css` (CSS variables).
|
|
12
|
+
|
|
13
|
+
Known risks: real IME and dead keys (Windows, macOS, Android, iOS input methods), NVDA and VoiceOver, macOS key bindings, spellcheck at a page break, and pastes from real Word, Google Docs and LibreOffice have not been checked by hand. Automated tests run in Chromium, Firefox and WebKit on Windows (IME only through Chromium's emulation, paste not in WebKit, no screen-reader tests); Safari on macOS and iOS is not tested. See [Known limitations](https://github.com/josep-audenis/foli/blob/main/docs/limitations.md).
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @folijs/core@0.1.0
|
|
19
|
+
- @folijs/view@0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Josep Audenis
|
|
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,49 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @folijs/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React components for [Foli](https://github.com/josep-audenis/foli), a document editor for the
|
|
4
|
+
web: documents on real pages (A4, Letter), edited in the browser, stored as JSON. Its own
|
|
5
|
+
editing engine, no ProseMirror or similar underneath.
|
|
6
|
+
|
|
7
|
+
> Early release: the API may change in any 0.x minor version (changes in `CHANGELOG.md`).
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @folijs/react @folijs/core react react-dom
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Keep all `@folijs/*` packages on the same version.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { createDocument, parseDocument } from "@folijs/core";
|
|
17
|
+
import { type FoliChange, FoliEditor } from "@folijs/react";
|
|
18
|
+
import "@folijs/react/styles.css";
|
|
19
|
+
|
|
20
|
+
// Load: parseDocument validates the saved JSON (throws FoliDocumentError when invalid).
|
|
21
|
+
const saved = localStorage.getItem("doc");
|
|
22
|
+
const initial = saved ? parseDocument(JSON.parse(saved)) : createDocument();
|
|
23
|
+
|
|
24
|
+
// Save once typing pauses: reading `change.document` serializes the whole document.
|
|
25
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
26
|
+
function onChange(change: FoliChange) {
|
|
27
|
+
clearTimeout(timer);
|
|
28
|
+
timer = setTimeout(() => localStorage.setItem("doc", JSON.stringify(change.document)), 300);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function App() {
|
|
32
|
+
return <FoliEditor initialContent={initial} onChange={onChange} />;
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Browser-only as written; for server rendering (Next.js) and saving on page close, see
|
|
37
|
+
[Getting started](https://github.com/josep-audenis/foli/blob/main/docs/getting-started.md).
|
|
38
|
+
|
|
39
|
+
`FoliEditor` shows the pages with a formatting toolbar. For your own layout: `useFoliEditor`,
|
|
40
|
+
`FoliEditorProvider`, `FoliCanvas`, `FoliToolbar`, `useCurrentEditor` and
|
|
41
|
+
`useEditorState(selector)`. React 18.2+ and 19; server rendering gives the editor's shell, the
|
|
42
|
+
document appears on hydration.
|
|
43
|
+
|
|
44
|
+
- [Getting started](https://github.com/josep-audenis/foli/blob/main/docs/getting-started.md): loading and saving, read-only, Next.js, your own toolbar
|
|
45
|
+
- [API reference](https://github.com/josep-audenis/foli/blob/main/docs/api.md#folireact)
|
|
46
|
+
- [Styling](https://github.com/josep-audenis/foli/blob/main/docs/styling.md): CSS variables, dark theme, print
|
|
47
|
+
- [Known limitations](https://github.com/josep-audenis/foli/blob/main/docs/limitations.md)
|
|
48
|
+
|
|
49
|
+
MIT
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Editor } from "@folijs/core";
|
|
2
|
+
export interface FoliCanvasProps {
|
|
3
|
+
/** Default: the editor of the nearest `FoliEditorProvider`. */
|
|
4
|
+
editor?: Editor | undefined;
|
|
5
|
+
/** The user can read, select and copy, but not change the document. */
|
|
6
|
+
readOnly?: boolean | undefined;
|
|
7
|
+
/** Shown while the document is empty. */
|
|
8
|
+
placeholder?: string | undefined;
|
|
9
|
+
/** Accessible name of the editable area (default "Document"). */
|
|
10
|
+
label?: string | undefined;
|
|
11
|
+
className?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
/** What a `ref` on `FoliCanvas` gives. */
|
|
14
|
+
export interface FoliCanvasHandle {
|
|
15
|
+
/** Focuses the document and shows the editor's selection in it. */
|
|
16
|
+
focus(): void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The editable document on real pages (size and margins from the document settings). The view
|
|
20
|
+
* owns the DOM inside it; React never renders children there.
|
|
21
|
+
*/
|
|
22
|
+
export declare const FoliCanvas: import("react").ForwardRefExoticComponent<FoliCanvasProps & import("react").RefAttributes<FoliCanvasHandle>>;
|
|
23
|
+
//# sourceMappingURL=FoliCanvas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FoliCanvas.d.ts","sourceRoot":"","sources":["../src/FoliCanvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAK3C,MAAM,WAAW,eAAe;IAC9B,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,uEAAuE;IACvE,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED,0CAA0C;AAC1C,MAAM,WAAW,gBAAgB;IAC/B,mEAAmE;IACnE,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,8GAwCrB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { EditorView } from "@folijs/view";
|
|
3
|
+
import { forwardRef, useImperativeHandle, useRef } from "react";
|
|
4
|
+
import { useEditorOrContext, useIsomorphicLayoutEffect } from "./editor.js";
|
|
5
|
+
/**
|
|
6
|
+
* The editable document on real pages (size and margins from the document settings). The view
|
|
7
|
+
* owns the DOM inside it; React never renders children there.
|
|
8
|
+
*/
|
|
9
|
+
export const FoliCanvas = forwardRef(function FoliCanvas({ editor: given, readOnly = false, placeholder = "", label = "Document", className }, ref) {
|
|
10
|
+
const editor = useEditorOrContext(given, "FoliCanvas");
|
|
11
|
+
const contentRef = useRef(null);
|
|
12
|
+
const viewRef = useRef(null);
|
|
13
|
+
useImperativeHandle(ref, () => ({ focus: () => viewRef.current?.focus() }), []);
|
|
14
|
+
useIsomorphicLayoutEffect(() => {
|
|
15
|
+
const host = contentRef.current;
|
|
16
|
+
if (!host)
|
|
17
|
+
return;
|
|
18
|
+
const view = new EditorView(host, editor);
|
|
19
|
+
viewRef.current = view;
|
|
20
|
+
return () => {
|
|
21
|
+
view.destroy();
|
|
22
|
+
viewRef.current = null;
|
|
23
|
+
};
|
|
24
|
+
}, [editor]);
|
|
25
|
+
// Runs after the view is created (effects run in order): for a new view, and when the props change.
|
|
26
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: a new editor means a new view, which needs the options too.
|
|
27
|
+
useIsomorphicLayoutEffect(() => {
|
|
28
|
+
viewRef.current?.setOptions({ editable: !readOnly, placeholder });
|
|
29
|
+
}, [editor, readOnly, placeholder]);
|
|
30
|
+
return (_jsx("div", { className: className ? `foli-canvas ${className}` : "foli-canvas", children: _jsx("div", { ref: contentRef, className: "foli-content", role: "textbox", "aria-multiline": "true", "aria-label": label, tabIndex: 0 }) }));
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=FoliCanvas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FoliCanvas.js","sourceRoot":"","sources":["../src/FoliCanvas.tsx"],"names":[],"mappings":";AACA,OA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AU,CAAC,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC;IACpE,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;IAEpC,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,eAAe,SAAS,EAAE,CAAC,CAAC,CAAC,aAAa,YAEpE,cACE,GAAG,EAAE,UAAU,EACf,SAAS,EAAC,cAAc,EACxB,IAAI,EAAC,SAAS,oBACC,MAAM,gBACT,KAAK,EACjB,QAAQ,EAAE,CAAC,GACX,GACE,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type Editor, type FoliDocument, type Plugin, type Transaction } from "@folijs/core";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
import { type FoliCanvasHandle, type FoliCanvasProps } from "./FoliCanvas.js";
|
|
4
|
+
/**
|
|
5
|
+
* A change to the document's content, as `FoliEditor` reports it. `document` is a getter:
|
|
6
|
+
* spreading the object or `JSON.stringify(change)` serializes the document (and walks `editor`).
|
|
7
|
+
*/
|
|
8
|
+
export interface FoliChange {
|
|
9
|
+
readonly editor: Editor;
|
|
10
|
+
/** The transactions of this change (several when plugins append their own). */
|
|
11
|
+
readonly transactions: readonly Transaction[];
|
|
12
|
+
/**
|
|
13
|
+
* The whole document right after this change, serialized on first read (keep reads out of
|
|
14
|
+
* the hot path of typing: a debounced save reads only the last change's).
|
|
15
|
+
*/
|
|
16
|
+
readonly document: FoliDocument;
|
|
17
|
+
}
|
|
18
|
+
export interface FoliEditorProps extends Omit<FoliCanvasProps, "editor"> {
|
|
19
|
+
/** Read once on mount. To load another document later: `editor.setDocument()` or a new `key`. */
|
|
20
|
+
initialContent?: FoliDocument | undefined;
|
|
21
|
+
/** Read once on mount. */
|
|
22
|
+
plugins?: readonly Plugin[] | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Called after every change to the document's content made through transactions (typing,
|
|
25
|
+
* commands, undo). Not for selection changes, and not for `editor.setDocument()`, whose
|
|
26
|
+
* caller already has the document.
|
|
27
|
+
*/
|
|
28
|
+
onChange?: ((change: FoliChange) => void) | undefined;
|
|
29
|
+
/** Show the default `FoliToolbar` above the pages (default true). */
|
|
30
|
+
toolbar?: boolean | undefined;
|
|
31
|
+
/** Rendered between the toolbar and the pages, inside the editor's context. */
|
|
32
|
+
children?: ReactNode | undefined;
|
|
33
|
+
}
|
|
34
|
+
/** What a `ref` on `FoliEditor` gives: its editor (commands, `setDocument`…) and focus. */
|
|
35
|
+
export interface FoliEditorHandle extends FoliCanvasHandle {
|
|
36
|
+
readonly editor: Editor;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* An editable document on real pages with a toolbar: creates its editor, provides it to
|
|
40
|
+
* `children` and shows it. Uncontrolled: the editor owns the document; React observes it
|
|
41
|
+
* through `onChange`, a parent reaches it through a `ref`.
|
|
42
|
+
*/
|
|
43
|
+
export declare const FoliEditor: import("react").ForwardRefExoticComponent<FoliEditorProps & import("react").RefAttributes<FoliEditorHandle>>;
|
|
44
|
+
//# sourceMappingURL=FoliEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FoliEditor.d.ts","sourceRoot":"","sources":["../src/FoliEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAc,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAEhF,OAAO,EAAc,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAG1F;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,EAAE,SAAS,WAAW,EAAE,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;CACjC;AAED,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC;IACtE,iGAAiG;IACjG,cAAc,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IAC1C,0BAA0B;IAC1B,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACxC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACtD,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAClC;AAED,2FAA2F;AAC3F,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,8GA+CrB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createDocument, } from "@folijs/core";
|
|
3
|
+
import { forwardRef, useImperativeHandle, useRef } from "react";
|
|
4
|
+
import { FoliEditorProvider, useFoliEditor, useIsomorphicLayoutEffect } from "./editor.js";
|
|
5
|
+
import { FoliCanvas } from "./FoliCanvas.js";
|
|
6
|
+
import { FoliToolbar } from "./FoliToolbar.js";
|
|
7
|
+
/**
|
|
8
|
+
* An editable document on real pages with a toolbar: creates its editor, provides it to
|
|
9
|
+
* `children` and shows it. Uncontrolled: the editor owns the document; React observes it
|
|
10
|
+
* through `onChange`, a parent reaches it through a `ref`.
|
|
11
|
+
*/
|
|
12
|
+
export const FoliEditor = forwardRef(function FoliEditor({ initialContent, plugins, onChange, toolbar = true, children, ...canvas }, ref) {
|
|
13
|
+
const editor = useFoliEditor({ initialContent, plugins });
|
|
14
|
+
const onChangeRef = useRef(onChange);
|
|
15
|
+
const canvasRef = useRef(null);
|
|
16
|
+
useImperativeHandle(ref, () => ({ editor, focus: () => canvasRef.current?.focus() }), [editor]);
|
|
17
|
+
useIsomorphicLayoutEffect(() => {
|
|
18
|
+
onChangeRef.current = onChange;
|
|
19
|
+
});
|
|
20
|
+
useIsomorphicLayoutEffect(() => editor.subscribe((state, transactions) => {
|
|
21
|
+
const listener = onChangeRef.current;
|
|
22
|
+
if (!listener || !transactions.some((tr) => tr.docChanged))
|
|
23
|
+
return;
|
|
24
|
+
// The state is immutable: keeping it makes a later read give this change's document.
|
|
25
|
+
const { settings } = editor;
|
|
26
|
+
let document;
|
|
27
|
+
listener({
|
|
28
|
+
editor,
|
|
29
|
+
transactions,
|
|
30
|
+
get document() {
|
|
31
|
+
document ??= createDocument(state.doc.toJSON(), settings);
|
|
32
|
+
return document;
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}), [editor]);
|
|
36
|
+
return (_jsxs(FoliEditorProvider, { editor: editor, children: [toolbar && (_jsx(FoliToolbar, { editor: editor, disabled: canvas.readOnly, onClickCommand: () => canvasRef.current?.focus() })), children, _jsx(FoliCanvas, { ref: canvasRef, editor: editor, ...canvas })] }));
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=FoliEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FoliEditor.js","sourceRoot":"","sources":["../src/FoliEditor.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,cAAc,GAMf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAkB,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC3F,OAAO,EAAE,UAAU,EAA+C,MAAM,iBAAiB,CA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QAAQ,CAAC,CAAC;gBACrE,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC,EACJ,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO,CACL,MAAC,kBAAkB,IAAC,MAAM,EAAE,MAAM,aAC/B,OAAO,IAAI,CACV,KAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,cAAc,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,GAChD,CACH,EACA,QAAQ,EACT,KAAC,UAAU,IAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,KAAM,MAAM,GAAI,IACvC,CACtB,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Editor } from "@folijs/core";
|
|
2
|
+
export interface FoliToolbarProps {
|
|
3
|
+
/** Default: the editor of the nearest `FoliEditorProvider`. */
|
|
4
|
+
editor?: Editor | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Every button is disabled. Pass it whenever the canvas is `readOnly`: commands run through
|
|
7
|
+
* the editor, which code may always change (`FoliEditor` does this for you).
|
|
8
|
+
*/
|
|
9
|
+
disabled?: boolean | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Called after a click ran a command, to show its result in the document (`FoliEditor`
|
|
12
|
+
* focuses its canvas). Keyboard activation keeps the focus in the toolbar.
|
|
13
|
+
*/
|
|
14
|
+
onClickCommand?: (() => void) | undefined;
|
|
15
|
+
/** Accessible name of the toolbar (default "Formatting"). */
|
|
16
|
+
label?: string | undefined;
|
|
17
|
+
className?: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Formatting buttons for an editor: marks, paragraph and heading levels, undo, redo, page
|
|
21
|
+
* break. One tab stop (arrow keys, Home and End move between buttons); toggles carry
|
|
22
|
+
* `aria-pressed`; a button whose command cannot run now is `aria-disabled` (still focusable).
|
|
23
|
+
* Clicks leave the focus and selection in the document.
|
|
24
|
+
*/
|
|
25
|
+
export declare function FoliToolbar({ editor: given, disabled, onClickCommand, label, className, }: FoliToolbarProps): import("react").JSX.Element;
|
|
26
|
+
//# sourceMappingURL=FoliToolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FoliToolbar.d.ts","sourceRoot":"","sources":["../src/FoliToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EASZ,MAAM,cAAc,CAAC;AAItB,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IAC1C,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAkHD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EAAE,KAAK,EACb,QAAgB,EAChB,cAAc,EACd,KAAoB,EACpB,SAAS,GACV,EAAE,gBAAgB,+BAyElB"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { insertPageBreak, redo, redoDepth, setBlockType, toggleMark, undo, undoDepth, } from "@folijs/core";
|
|
3
|
+
import { Fragment, useRef, useState } from "react";
|
|
4
|
+
import { useEditorOrContext, useEditorState } from "./editor.js";
|
|
5
|
+
/** Whether the selection holds textblocks and all of them are `type` with `level` (if given). */
|
|
6
|
+
function blockIs(state, type, level) {
|
|
7
|
+
const { from, to } = state.selection;
|
|
8
|
+
let all = true;
|
|
9
|
+
let any = false;
|
|
10
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
11
|
+
if (!all)
|
|
12
|
+
return false;
|
|
13
|
+
if (node.isTextblock) {
|
|
14
|
+
any = true;
|
|
15
|
+
if (node.type.name !== type || (level && node.attrs.level !== level))
|
|
16
|
+
all = false;
|
|
17
|
+
}
|
|
18
|
+
return !node.isTextblock;
|
|
19
|
+
});
|
|
20
|
+
return any && all;
|
|
21
|
+
}
|
|
22
|
+
const mark = (key, label, text) => ({
|
|
23
|
+
key,
|
|
24
|
+
label,
|
|
25
|
+
text,
|
|
26
|
+
symbol: true,
|
|
27
|
+
pressed: (_state, editor) => editor.isMarkActive(key),
|
|
28
|
+
command: () => toggleMark(key),
|
|
29
|
+
});
|
|
30
|
+
const heading = (level) => ({
|
|
31
|
+
key: `h${level}`,
|
|
32
|
+
label: `Heading ${level}`,
|
|
33
|
+
text: `H${level}`,
|
|
34
|
+
pressed: (state) => blockIs(state, "heading", level),
|
|
35
|
+
// Pressing an active heading turns it back into a paragraph.
|
|
36
|
+
command: (state) => blockIs(state, "heading", level)
|
|
37
|
+
? setBlockType("paragraph")
|
|
38
|
+
: setBlockType("heading", { level }),
|
|
39
|
+
});
|
|
40
|
+
const GROUPS = [
|
|
41
|
+
[
|
|
42
|
+
mark("bold", "Bold", "B"),
|
|
43
|
+
mark("italic", "Italic", "I"),
|
|
44
|
+
mark("underline", "Underline", "U"),
|
|
45
|
+
mark("strike", "Strikethrough", "S"),
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
{
|
|
49
|
+
key: "paragraph",
|
|
50
|
+
label: "Paragraph",
|
|
51
|
+
text: "¶",
|
|
52
|
+
symbol: true,
|
|
53
|
+
pressed: (state) => blockIs(state, "paragraph"),
|
|
54
|
+
command: () => setBlockType("paragraph"),
|
|
55
|
+
},
|
|
56
|
+
heading(1),
|
|
57
|
+
heading(2),
|
|
58
|
+
heading(3),
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
{
|
|
62
|
+
key: "undo",
|
|
63
|
+
label: "Undo",
|
|
64
|
+
text: "Undo",
|
|
65
|
+
enabled: (state) => undoDepth(state) > 0,
|
|
66
|
+
command: () => undo,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
key: "redo",
|
|
70
|
+
label: "Redo",
|
|
71
|
+
text: "Redo",
|
|
72
|
+
enabled: (state) => redoDepth(state) > 0,
|
|
73
|
+
command: () => redo,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
[{ key: "pageBreak", label: "Page break", text: "Page break", command: () => insertPageBreak }],
|
|
77
|
+
];
|
|
78
|
+
const ITEMS = GROUPS.flat();
|
|
79
|
+
const sameStates = (a, b) => a.length === b.length &&
|
|
80
|
+
a.every((item, i) => item.pressed === b[i]?.pressed && item.enabled === b[i]?.enabled);
|
|
81
|
+
/** Runs after every transaction: O(selection), no transactions built. */
|
|
82
|
+
const selectStates = (state, editor) => ITEMS.map((item) => ({
|
|
83
|
+
pressed: item.pressed?.(state, editor),
|
|
84
|
+
enabled: item.enabled?.(state) ?? true,
|
|
85
|
+
}));
|
|
86
|
+
/**
|
|
87
|
+
* Formatting buttons for an editor: marks, paragraph and heading levels, undo, redo, page
|
|
88
|
+
* break. One tab stop (arrow keys, Home and End move between buttons); toggles carry
|
|
89
|
+
* `aria-pressed`; a button whose command cannot run now is `aria-disabled` (still focusable).
|
|
90
|
+
* Clicks leave the focus and selection in the document.
|
|
91
|
+
*/
|
|
92
|
+
export function FoliToolbar({ editor: given, disabled = false, onClickCommand, label = "Formatting", className, }) {
|
|
93
|
+
const editor = useEditorOrContext(given, "FoliToolbar");
|
|
94
|
+
const states = useEditorState(selectStates, { editor, isEqual: sameStates });
|
|
95
|
+
const [active, setActive] = useState(0);
|
|
96
|
+
const buttons = useRef([]);
|
|
97
|
+
const run = (index, event) => {
|
|
98
|
+
const item = ITEMS[index];
|
|
99
|
+
if (!item || disabled || !states[index]?.enabled)
|
|
100
|
+
return;
|
|
101
|
+
editor.run(item.command(editor.state));
|
|
102
|
+
// `detail` counts pointer clicks; Enter and Space on a button give 0.
|
|
103
|
+
if (event.detail > 0)
|
|
104
|
+
onClickCommand?.();
|
|
105
|
+
};
|
|
106
|
+
const onKeyDown = (event) => {
|
|
107
|
+
// Alt+Left (back) and other shortcuts are the browser's.
|
|
108
|
+
if (event.altKey || event.ctrlKey || event.metaKey)
|
|
109
|
+
return;
|
|
110
|
+
const count = ITEMS.length;
|
|
111
|
+
const moves = {
|
|
112
|
+
ArrowRight: (active + 1) % count,
|
|
113
|
+
ArrowLeft: (active - 1 + count) % count,
|
|
114
|
+
Home: 0,
|
|
115
|
+
End: count - 1,
|
|
116
|
+
};
|
|
117
|
+
const next = moves[event.key];
|
|
118
|
+
if (next === undefined)
|
|
119
|
+
return;
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
setActive(next);
|
|
122
|
+
buttons.current[next]?.focus();
|
|
123
|
+
};
|
|
124
|
+
let index = 0;
|
|
125
|
+
return (_jsx("div", { role: "toolbar", "aria-label": label, className: className ? `foli-toolbar ${className}` : "foli-toolbar", onKeyDown: onKeyDown, children: GROUPS.map((group, g) => (_jsxs(Fragment, { children: [g > 0 && _jsx("hr", { className: "foli-toolbar-separator", "aria-orientation": "vertical" }), group.map((item) => {
|
|
126
|
+
const i = index++;
|
|
127
|
+
const state = states[i];
|
|
128
|
+
const off = disabled || !state?.enabled;
|
|
129
|
+
return (_jsx("button", { ref: (element) => {
|
|
130
|
+
buttons.current[i] = element;
|
|
131
|
+
}, type: "button", className: `foli-toolbar-button foli-toolbar-${item.key}`, "aria-label": item.symbol ? item.label : undefined, title: item.label, "aria-pressed": item.pressed ? Boolean(state?.pressed) : undefined, "aria-disabled": off || undefined, tabIndex: i === active ? 0 : -1,
|
|
132
|
+
// Keep the focus (and the selection) in the document on click.
|
|
133
|
+
onMouseDown: (event) => event.preventDefault(), onFocus: () => setActive(i), onClick: (event) => run(i, event), children: item.text }, item.key));
|
|
134
|
+
})] }, group[0]?.key)))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,GAAG,EAAE,gBAE7C,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAChD,KAAK,EAAE,IAAI,CAAC,KAAK,kBACH,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,mBACjD,GAAG,IAAI,SAAS,EAC/B,QAAQ,EAAE,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;wBAC/B,+DAA+D;wBAC/D,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE,EAC9C,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,EAC3B,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,YAEhC,IAAI,CAAC,IAAI,IAjBL,IAAI,CAAC,GAAG,CAkBN,CACV,CAAC;gBACJ,CAAC,CAAC,KA5BW,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CA6BjB,CACZ,CAAC,GACE,CACP,CAAC;AACJ,CAAC"}
|
package/dist/editor.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Editor, type EditorState, type FoliDocument, type Plugin } from "@folijs/core";
|
|
2
|
+
import { type ReactNode, useLayoutEffect } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* `useLayoutEffect` in the browser, `useEffect` on the server, where neither runs: React 18
|
|
5
|
+
* warns about a layout effect in server rendering.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
|
8
|
+
export interface UseFoliEditorOptions {
|
|
9
|
+
/** Read once, when the editor is created. To load another document, `editor.setDocument()`. */
|
|
10
|
+
initialContent?: FoliDocument | undefined;
|
|
11
|
+
/** Read once, when the editor is created. */
|
|
12
|
+
plugins?: readonly Plugin[] | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A headless `Editor` (state, commands, history) owned by the calling component: created on the
|
|
16
|
+
* first render and kept for its lifetime. Later changes to `options` are ignored.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useFoliEditor(options?: UseFoliEditorOptions): Editor;
|
|
19
|
+
/** Makes `editor` the one `useCurrentEditor`, `useEditorState` and `FoliCanvas` use below it. */
|
|
20
|
+
export declare function FoliEditorProvider({ editor, children, }: {
|
|
21
|
+
editor: Editor;
|
|
22
|
+
children?: ReactNode | undefined;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
/** The editor of the nearest `FoliEditorProvider` (or `FoliEditor`). Throws outside one. */
|
|
25
|
+
export declare function useCurrentEditor(): Editor;
|
|
26
|
+
/** `editor` if given, else the context's. */
|
|
27
|
+
export declare function useEditorOrContext(editor: Editor | undefined, caller: string): Editor;
|
|
28
|
+
export interface UseEditorStateOptions<T> {
|
|
29
|
+
/** Default: the context's editor. */
|
|
30
|
+
editor?: Editor | undefined;
|
|
31
|
+
/** When the selected value equals the previous one, the component does not re-render (default `Object.is`). */
|
|
32
|
+
isEqual?: ((a: T, b: T) => boolean) | undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A slice of the editor state that re-renders the component only when it changes, e.g.
|
|
36
|
+
* `useEditorState((state, editor) => editor.isMarkActive("bold"))`. The selector runs after
|
|
37
|
+
* every transaction: keep it cheap.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useEditorState<T>(selector: (state: EditorState, editor: Editor) => T, { editor: given, isEqual }?: UseEditorStateOptions<T>): T;
|
|
40
|
+
//# sourceMappingURL=editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,K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|
package/dist/editor.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createEditor, } from "@folijs/core";
|
|
3
|
+
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, } from "react";
|
|
4
|
+
/**
|
|
5
|
+
* `useLayoutEffect` in the browser, `useEffect` on the server, where neither runs: React 18
|
|
6
|
+
* warns about a layout effect in server rendering.
|
|
7
|
+
*/
|
|
8
|
+
export const useIsomorphicLayoutEffect = typeof document === "undefined" ? useEffect : useLayoutEffect;
|
|
9
|
+
/**
|
|
10
|
+
* A headless `Editor` (state, commands, history) owned by the calling component: created on the
|
|
11
|
+
* first render and kept for its lifetime. Later changes to `options` are ignored.
|
|
12
|
+
*/
|
|
13
|
+
export function useFoliEditor(options = {}) {
|
|
14
|
+
const [editor] = useState(() => {
|
|
15
|
+
const { initialContent: document, plugins } = options;
|
|
16
|
+
return createEditor({ ...(document && { document }), ...(plugins && { plugins }) });
|
|
17
|
+
});
|
|
18
|
+
return editor;
|
|
19
|
+
}
|
|
20
|
+
const EditorContext = createContext(null);
|
|
21
|
+
/** Makes `editor` the one `useCurrentEditor`, `useEditorState` and `FoliCanvas` use below it. */
|
|
22
|
+
export function FoliEditorProvider({ editor, children, }) {
|
|
23
|
+
return _jsx(EditorContext.Provider, { value: editor, children: children });
|
|
24
|
+
}
|
|
25
|
+
/** The editor of the nearest `FoliEditorProvider` (or `FoliEditor`). Throws outside one. */
|
|
26
|
+
export function useCurrentEditor() {
|
|
27
|
+
const editor = useContext(EditorContext);
|
|
28
|
+
if (!editor)
|
|
29
|
+
throw new Error("useCurrentEditor: no FoliEditorProvider or FoliEditor above");
|
|
30
|
+
return editor;
|
|
31
|
+
}
|
|
32
|
+
/** `editor` if given, else the context's. */
|
|
33
|
+
export function useEditorOrContext(editor, caller) {
|
|
34
|
+
const context = useContext(EditorContext);
|
|
35
|
+
const found = editor ?? context;
|
|
36
|
+
if (!found)
|
|
37
|
+
throw new Error(`${caller}: pass an editor or render inside a FoliEditorProvider`);
|
|
38
|
+
return found;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A slice of the editor state that re-renders the component only when it changes, e.g.
|
|
42
|
+
* `useEditorState((state, editor) => editor.isMarkActive("bold"))`. The selector runs after
|
|
43
|
+
* every transaction: keep it cheap.
|
|
44
|
+
*/
|
|
45
|
+
export function useEditorState(selector, { editor: given, isEqual = Object.is } = {}) {
|
|
46
|
+
const editor = useEditorOrContext(given, "useEditorState");
|
|
47
|
+
// The last selected value, kept across renders so an equal one keeps its identity (an inline
|
|
48
|
+
// selector is a new function every render: it runs again, the result stays the same object).
|
|
49
|
+
const last = useRef(null);
|
|
50
|
+
const subscribe = useCallback((notify) => editor.subscribe(notify), [editor]);
|
|
51
|
+
const getSnapshot = () => {
|
|
52
|
+
const state = editor.state;
|
|
53
|
+
const previous = last.current;
|
|
54
|
+
if (previous?.state === state && previous.selector === selector)
|
|
55
|
+
return previous.value;
|
|
56
|
+
const value = selector(state, editor);
|
|
57
|
+
const kept = previous && isEqual(previous.value, value) ? previous.value : value;
|
|
58
|
+
last.current = { state, selector, value: kept };
|
|
59
|
+
return kept;
|
|
60
|
+
};
|
|
61
|
+
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.js","sourceRoot":"","sources":["../src/editor.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,YAAY,GAKb,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,aAAa,EAEb,WAAW,EACX,UAAU,EACV,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,EACR,oBAAoB,GACrB,MAAM,OAAO,CAAC;AAEf;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACpC,OAAO,QAAQ,KAAK,WAAW,CAAC,CA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|
2
|
+
export { FoliCanvas, type FoliCanvasHandle, type FoliCanvasProps } from "./FoliCanvas.js";
|
|
3
|
+
export { type FoliChange, FoliEditor, type FoliEditorHandle, type FoliEditorProps, } from "./FoliEditor.js";
|
|
4
|
+
export { FoliToolbar, type FoliToolbarProps } from "./FoliToolbar.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,cAAc,EACd,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EACL,KAAK,UAAU,EACf,UAAU,EACV,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { FoliEditorProvider, useCurrentEditor, useEditorState, useFoliEditor, } from "./editor.js";
|
|
2
|
+
export { FoliCanvas } from "./FoliCanvas.js";
|
|
3
|
+
export { FoliEditor, } from "./FoliEditor.js";
|
|
4
|
+
export { FoliToolbar } from "./FoliToolbar.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAGlB,gBAAgB,EAChB,cAAc,EACd,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAA+C,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EAEL,UAAU,GAGX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAyB,MAAM,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@folijs/react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React components for the Foli document editor.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/josep-audenis/foli.git",
|
|
9
|
+
"directory": "packages/react"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/josep-audenis/foli#readme",
|
|
12
|
+
"bugs": "https://github.com/josep-audenis/foli/issues",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"sideEffects": [
|
|
15
|
+
"*.css"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./styles.css": "./styles.css"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"CHANGELOG.md",
|
|
27
|
+
"src",
|
|
28
|
+
"styles.css",
|
|
29
|
+
"!src/**/*.test.*"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@folijs/core": "^0.1.0",
|
|
33
|
+
"@folijs/view": "^0.1.0"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"react": "^18.2.0 || ^19.0.0",
|
|
37
|
+
"react-dom": "^18.2.0 || ^19.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"react": "^19.3.1",
|
|
41
|
+
"react-dom": "^19.3.1"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
|
|
45
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
46
|
+
}
|
|
6
47
|
}
|