@input/pen-core 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/LICENSE.md +21 -0
- package/README.md +89 -0
- package/dist/index.cjs +15173 -0
- package/dist/index.d.cts +998 -0
- package/dist/index.d.ts +998 -0
- package/dist/index.mjs +14998 -0
- package/package.json +63 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026-present Input B.V.
|
|
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
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# @input/pen-core
|
|
2
|
+
|
|
3
|
+
Headless editor runtime for Pen.
|
|
4
|
+
|
|
5
|
+
`createEditor` and `createHeadlessEditor` own document state, selection, normalization, and `editor.apply`. This package does not render a surface or ship CSS.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @input/pen-core @input/pen
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Most hosts start with `@input/pen` instead: its `createEditor()` defaults an omitted `preset` to `defaultPreset()`. This package's `createEditor()` is the bare constructor — it installs no extensions, and the fallback list is empty. Four that used to come from core are gone: `tools`, `undo`, `rich-text-shortcuts`, and `delta-stream`. Dependents of the first three fail loudly. Undo fails silently: `canUndo()` is false, Mod-Z is dead, and nothing throws.
|
|
14
|
+
|
|
15
|
+
## What It Provides
|
|
16
|
+
|
|
17
|
+
- `createEditor(...)` to create editor instances
|
|
18
|
+
- `createHeadlessEditor(...)` for server-side, worker, and test workflows that need editor semantics without a renderer
|
|
19
|
+
- document state, selection, normalization, and mutation orchestration
|
|
20
|
+
- the canonical `editor.apply(...)` document mutation boundary
|
|
21
|
+
- `aiEgressFacet` / `aiEgressExtension` / `streamThroughEgress` — the single `pen.aiEgress` filter shared by generation, suggestions, and autocomplete
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { createEditor } from "@input/pen-core";
|
|
27
|
+
import { defaultPreset } from "@input/pen";
|
|
28
|
+
|
|
29
|
+
const editor = createEditor({
|
|
30
|
+
preset: defaultPreset(),
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Headless Usage
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import * as Y from "yjs";
|
|
38
|
+
import { createHeadlessEditor } from "@input/pen-core";
|
|
39
|
+
import { yjsAdapter, wrapYjsDocument } from "@input/pen-yjs";
|
|
40
|
+
|
|
41
|
+
const ydoc = new Y.Doc();
|
|
42
|
+
const adapter = yjsAdapter();
|
|
43
|
+
const editor = createHeadlessEditor({
|
|
44
|
+
crdt: adapter,
|
|
45
|
+
document: wrapYjsDocument(adapter, ydoc),
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This snippet also needs `yjs` and `@input/pen-yjs`. Use this shape for migrations, AI workers, export workers, and tests that should run through Pen's mutation pipeline without mounting a UI.
|
|
50
|
+
|
|
51
|
+
`editor.destroy()` deactivates extensions and observation. It does not tear down an attached field editor — hosts own that call (React `EditorRoot` and Vue `PenEditor` already do). The method returns the queued teardown promise; callers that ignore it stay correct.
|
|
52
|
+
|
|
53
|
+
## Typical Pairing
|
|
54
|
+
|
|
55
|
+
Most apps use `@input/pen-core` with:
|
|
56
|
+
|
|
57
|
+
- `@input/pen`
|
|
58
|
+
- `@input/pen-react` or `@input/pen-vue`
|
|
59
|
+
|
|
60
|
+
See the repository root README for the broader package map.
|
|
61
|
+
|
|
62
|
+
## Options
|
|
63
|
+
|
|
64
|
+
Every `CreateEditorOptions` field is optional.
|
|
65
|
+
|
|
66
|
+
| Option | Default | Effect |
|
|
67
|
+
| ----------------- | ------- | --------------------------------------------------------------------- |
|
|
68
|
+
| `schema` | unset | Active schema. Omitted with no preset does not install default blocks |
|
|
69
|
+
| `preset` | unset | Assembler such as `defaultPreset()` |
|
|
70
|
+
| `extensions` | unset | Extra extensions merged with the preset |
|
|
71
|
+
| `locale` | unset | Editor locale |
|
|
72
|
+
| `messages` | unset | Partial message-catalog override |
|
|
73
|
+
| `a11yLabel` | unset | Accessible name for the editor surface |
|
|
74
|
+
| `editorViewMode` | unset | View mode |
|
|
75
|
+
| `documentProfile` | unset | Authoring profile |
|
|
76
|
+
|
|
77
|
+
`createHeadlessEditor` adds `useDefaultExtensions`, default `false`. When that flag is false and no `preset` is passed, the editor uses an empty preset. `useDefaultExtensions: true` installs nothing — the fallback list is empty. It does not install `tools`, `undo`, `rich-text-shortcuts`, or `delta-stream`. Pass `preset: defaultPreset()` for those, or use `@input/pen`'s constructors, which default an omitted `preset` to `defaultPreset()`.
|
|
78
|
+
|
|
79
|
+
`ariaReadOnlyFacet` (`pen.ariaReadOnly`) only sets `aria-readonly` on a mounted surface. It does not decline typing or stop `editor.apply`. The renderer `readonly` prop is what declines typing.
|
|
80
|
+
|
|
81
|
+
## Documentation
|
|
82
|
+
|
|
83
|
+
The docs site (the `@input/pen-docs` package) covers this area on the Core concepts page (`#/core-concepts`).
|
|
84
|
+
|
|
85
|
+
The public signatures of record are in `api-report.md` next to this package's source in the Pen repository. The docs site does not host a generated browsable reference.
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
MIT © Input B.V. See [`LICENSE.md`](./LICENSE.md).
|