@domternal/pm 1.1.1 → 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.
Files changed (2) hide show
  1. package/README.md +39 -58
  2. package/package.json +4 -7
package/README.md CHANGED
@@ -3,83 +3,53 @@
3
3
  [![Version](https://img.shields.io/npm/v/@domternal/pm.svg)](https://www.npmjs.com/package/@domternal/pm)
4
4
  [![MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/domternal/domternal/blob/main/LICENSE)
5
5
 
6
- The ProseMirror dependency layer for the [Domternal](https://domternal.dev) editor. It
7
- re-exports the underlying `prosemirror-*` libraries under stable `@domternal/pm/*`
8
- subpaths so every Domternal package imports ProseMirror from one place. Because the
9
- `prosemirror-*` packages are declared here once, as ordinary dependencies of this package,
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> &nbsp;&nbsp;&nbsp;•&nbsp;&nbsp;&nbsp; <u>[Documentation](https://domternal.dev/v1/packages)</u> &nbsp;&nbsp;&nbsp;•&nbsp;&nbsp;&nbsp; <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
- Install it explicitly when you import ProseMirror primitives in your own code, or when a
20
- strict peer resolver asks for it: every `@domternal/extension-*` package declares
21
- `@domternal/pm` as a peer dependency with the same minor floor and next-major ceiling as
22
- `@domternal/core`. For the 1.1.1 release, both ranges remain `>=1.1.0 <2.0.0`;
23
- upgrade core, pm, and the extensions together to 1.1.1.
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
- `@domternal/pm` itself has no peer dependencies: the `prosemirror-*` libraries are its own
30
- dependencies.
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
- Import from a subpath matching the ProseMirror package you need. Each subpath
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 myPlugin = new Plugin({
72
- key: new PluginKey('my-plugin'),
73
- view: (view: EditorView) => ({ destroy: () => {} }),
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
- ## Subpaths
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
- | Subpath | Re-exports |
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domternal/pm",
3
- "version": "1.1.1",
3
+ "version": "1.3.0",
4
4
  "description": "ProseMirror package re-exports for Domternal",
5
5
  "author": "https://github.com/ThomasNowHere",
6
6
  "license": "MIT",
@@ -174,10 +174,6 @@
174
174
  "files": [
175
175
  "src"
176
176
  ],
177
- "scripts": {
178
- "prepublishOnly": "node ../../scripts/prepare-publish-manifest.mjs",
179
- "postpublish": "git checkout package.json"
180
- },
181
177
  "dependencies": {
182
178
  "prosemirror-commands": "^1.7.1",
183
179
  "prosemirror-dropcursor": "^1.8.2",
@@ -204,5 +200,6 @@
204
200
  "bugs": {
205
201
  "url": "https://github.com/domternal/domternal/issues"
206
202
  },
207
- "homepage": "https://domternal.dev"
208
- }
203
+ "homepage": "https://domternal.dev",
204
+ "scripts": {}
205
+ }