@domternal/pm 1.2.0 → 1.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 +39 -58
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,83 +3,53 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@domternal/pm)
|
|
4
4
|
[](https://github.com/domternal/domternal/blob/main/LICENSE)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
re-exports the
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
your package manager dedupes them to a single copy across `@domternal/core` and every
|
|
11
|
-
extension. You rarely install it yourself: it ships transitively with `@domternal/core`.
|
|
12
|
-
|
|
13
|
-
## Links
|
|
14
|
-
|
|
15
|
-
<u>[Website](https://domternal.dev)</u> • <u>[Documentation](https://domternal.dev/v1/packages)</u> • <u>[Live examples](https://domternal.dev/examples)</u>
|
|
6
|
+
Shared ProseMirror dependencies for [Domternal](https://domternal.dev). Each
|
|
7
|
+
`@domternal/pm/*` subpath re-exports the corresponding `prosemirror-*` package,
|
|
8
|
+
including its TypeScript types. Domternal packages use these entry points to share
|
|
9
|
+
the same ProseMirror classes and plugins.
|
|
16
10
|
|
|
17
11
|
## Install
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`@domternal/core`. For the 1.2.0 release, both ranges remain `>=1.2.0 <2.0.0`;
|
|
23
|
-
upgrade core, pm, and the extensions together to 1.2.0.
|
|
13
|
+
`@domternal/core` already depends on this package. Add it directly when your own
|
|
14
|
+
code imports from `@domternal/pm/*`, or when an extension's peer dependencies
|
|
15
|
+
require it:
|
|
24
16
|
|
|
25
17
|
```bash
|
|
26
18
|
pnpm add @domternal/pm
|
|
27
19
|
```
|
|
28
20
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
## One copy, always
|
|
33
|
-
|
|
34
|
-
ProseMirror compares by identity, not by shape. Two copies of `prosemirror-model` make
|
|
35
|
-
`Fragment.from` reject a fragment the editor itself produced ("Can not convert <> to a
|
|
36
|
-
Fragment"), two copies of `prosemirror-state` collide on a keyed plugin. That is a crash,
|
|
37
|
-
not a few extra kilobytes, and nothing warns at install time.
|
|
38
|
-
|
|
39
|
-
Declaring the libraries here once is what normally prevents it. It stops being enough when
|
|
40
|
-
another library in your app declares the same packages as **peer dependencies** and takes
|
|
41
|
-
whatever your application root offers: `y-prosemirror` is the common case, and the one
|
|
42
|
-
that reaches Domternal Pro's collaboration. The two resolutions can then differ with
|
|
43
|
-
nothing warning at install or build time.
|
|
44
|
-
|
|
45
|
-
Domternal detects it at runtime and names both packages and the fix. The dedupe recipe per
|
|
46
|
-
package manager and bundler:
|
|
47
|
-
https://domternal.dev/v1/guides/single-prosemirror-copy/
|
|
48
|
-
|
|
49
|
-
### Why these are dependencies and not peers
|
|
50
|
-
|
|
51
|
-
Declaring them as peer dependencies would make a second copy impossible, since there would be
|
|
52
|
-
nothing here to bring. It is not worth what it costs: peers are installed automatically by npm 7
|
|
53
|
-
and later, by pnpm and by Bun, but by neither version of Yarn, so every Yarn user would have to
|
|
54
|
-
install twelve ProseMirror packages by hand. An install that fails outright is a worse first day
|
|
55
|
-
than a duplicate that is rare, loud when it happens, and fixed by one block of JSON.
|
|
56
|
-
|
|
57
|
-
What is done instead: the ranges declared here are checked in CI against those of every library
|
|
58
|
-
that shares ProseMirror with this one, so a release cannot make the two impossible to reconcile,
|
|
59
|
-
and a duplicate that does form is reported by name at runtime.
|
|
21
|
+
The package declares Node.js 22 or later for tooling and has no peer dependencies. Keep installed Domternal packages on the
|
|
22
|
+
same release; the Free 1.3.0 extensions require `@domternal/core` and
|
|
23
|
+
`@domternal/pm` in the range `>=1.3.0 <2.0.0`.
|
|
60
24
|
|
|
61
25
|
## Usage
|
|
62
26
|
|
|
63
|
-
|
|
64
|
-
re-exports the full API of its `prosemirror-*` counterpart. There is no root export, so
|
|
65
|
-
`import { Plugin } from '@domternal/pm'` does not resolve.
|
|
27
|
+
Always import a subpath. There is no `@domternal/pm` root export.
|
|
66
28
|
|
|
67
29
|
```ts
|
|
68
30
|
import { Plugin, PluginKey } from '@domternal/pm/state';
|
|
69
|
-
import type { EditorView } from '@domternal/pm/view';
|
|
70
31
|
|
|
71
|
-
const
|
|
72
|
-
key: new PluginKey('
|
|
73
|
-
view: (
|
|
32
|
+
export const documentChangeLogger = new Plugin({
|
|
33
|
+
key: new PluginKey('documentChangeLogger'),
|
|
34
|
+
view: () => ({
|
|
35
|
+
update(view, previousState) {
|
|
36
|
+
if (!view.state.doc.eq(previousState.doc)) {
|
|
37
|
+
console.log(view.state.doc.toJSON());
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
74
41
|
});
|
|
75
|
-
|
|
76
|
-
// Every `@domternal/pm/*` subpath re-exports its `prosemirror-*`
|
|
77
|
-
// counterpart unchanged.
|
|
78
42
|
```
|
|
79
43
|
|
|
80
|
-
|
|
44
|
+
Register a plugin through an extension's `addProseMirrorPlugins()` hook or
|
|
45
|
+
`editor.registerPlugin()`. See [custom extensions](https://domternal.dev/v1/guides/configuration/#add-prosemirror-plugins)
|
|
46
|
+
and [dynamic plugins](https://domternal.dev/v1/guides/editor-api/#dynamic-plugin-management).
|
|
47
|
+
|
|
48
|
+
## Entry points
|
|
49
|
+
|
|
50
|
+
Every subpath supports ESM, CommonJS, and TypeScript:
|
|
81
51
|
|
|
82
|
-
|
|
|
52
|
+
| Import | Re-exports |
|
|
83
53
|
| --- | --- |
|
|
84
54
|
| `@domternal/pm/commands` | `prosemirror-commands` |
|
|
85
55
|
| `@domternal/pm/dropcursor` | `prosemirror-dropcursor` |
|
|
@@ -93,3 +63,14 @@ const myPlugin = new Plugin({
|
|
|
93
63
|
| `@domternal/pm/tables` | `prosemirror-tables` |
|
|
94
64
|
| `@domternal/pm/transform` | `prosemirror-transform` |
|
|
95
65
|
| `@domternal/pm/view` | `prosemirror-view` |
|
|
66
|
+
|
|
67
|
+
## Avoid duplicate ProseMirror copies
|
|
68
|
+
|
|
69
|
+
ProseMirror compares objects by identity. Loading two copies can cause fragment
|
|
70
|
+
conversion errors, keyed-plugin collisions, and broken selections. Prefer these
|
|
71
|
+
subpaths over direct `prosemirror-*` imports in code that interacts with Domternal.
|
|
72
|
+
|
|
73
|
+
Other dependencies and linked workspaces can still introduce duplicates.
|
|
74
|
+
The [single-copy guide](https://domternal.dev/v1/guides/single-prosemirror-copy/)
|
|
75
|
+
explains runtime diagnostics and the package-manager and bundler fixes, including
|
|
76
|
+
collaboration integrations.
|