plitejs 0.0.1 → 54.0.0-beta.3

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 (61) hide show
  1. package/LICENSE +4 -1
  2. package/README.md +83 -0
  3. package/dist/annotation-store-metrics-Ccjkef45.js +12 -0
  4. package/dist/annotations/index.d.ts +2 -0
  5. package/dist/annotations/index.js +2 -0
  6. package/dist/authored/index.d.ts +596 -0
  7. package/dist/authored/index.js +18558 -0
  8. package/dist/authored-veto-DSnQcHGR.js +6 -0
  9. package/dist/browser-protocol-pvt4HFF7.js +5 -0
  10. package/dist/comparison-plan-CEQL0ooW.js +1338 -0
  11. package/dist/comparison-types-Dt-unJZY.d.ts +179 -0
  12. package/dist/create-editor-CkHtPWXV.js +1107 -0
  13. package/dist/diff/index.d.ts +32 -0
  14. package/dist/diff/index.js +1748 -0
  15. package/dist/dom/index.d.ts +2 -0
  16. package/dist/dom/index.js +2 -0
  17. package/dist/dom-Cgfscvnm.js +9220 -0
  18. package/dist/editor-owner-IUmkTeXz.js +171 -0
  19. package/dist/editor-view-lifetime-GJKa_QGh.js +23 -0
  20. package/dist/history/index.d.ts +170 -0
  21. package/dist/history/index.js +6718 -0
  22. package/dist/hyperscript/index.d.ts +2 -0
  23. package/dist/hyperscript/index.js +2 -0
  24. package/dist/hyperscript-FPuoArEi.js +299 -0
  25. package/dist/index-BpQx2UG4.d.ts +1093 -0
  26. package/dist/index-Cw-oC2ps.d.ts +190 -0
  27. package/dist/index-DPWyk3lG.d.ts +65 -0
  28. package/dist/index-DpltOCot.d.ts +9753 -0
  29. package/dist/index-HPYawTae.d.ts +119 -0
  30. package/dist/index-K0Za9YXc.d.ts +1246 -0
  31. package/dist/index.d.ts +2 -0
  32. package/dist/index.js +5 -0
  33. package/dist/internal/index.d.ts +2 -0
  34. package/dist/internal/index.js +156 -0
  35. package/dist/mapped-view-store-ld-6uxEU.js +120 -0
  36. package/dist/native-grouping-input-DMNcsIaW.js +8 -0
  37. package/dist/pagination/index.d.ts +169 -0
  38. package/dist/pagination/index.js +2 -0
  39. package/dist/pagination/react.d.ts +33 -0
  40. package/dist/pagination/react.js +1509 -0
  41. package/dist/pagination-D_A8iPJP.js +1021 -0
  42. package/dist/plugin-DWzkJbnJ.js +50999 -0
  43. package/dist/range-geometry-BLAHRE11.d.ts +38 -0
  44. package/dist/range-geometry-BjeLHOnl.js +486 -0
  45. package/dist/react/index.d.ts +5 -0
  46. package/dist/react/index.js +7 -0
  47. package/dist/react/virtualized.d.ts +13 -0
  48. package/dist/react/virtualized.js +209 -0
  49. package/dist/react-DZ15gmz2.js +1018 -0
  50. package/dist/retraction-BMem8Rfk.js +109 -0
  51. package/dist/src-cT1OTKP_.js +1386 -0
  52. package/dist/store-Cz2mXyDe.js +704 -0
  53. package/dist/testing/index.d.ts +183 -0
  54. package/dist/testing/index.js +96 -0
  55. package/dist/use-editor-dom-scope-BbMDSCpW.js +28354 -0
  56. package/dist/yjs/index.d.ts +2 -0
  57. package/dist/yjs/index.js +2 -0
  58. package/dist/yjs/react/index.d.ts +26 -0
  59. package/dist/yjs/react/index.js +85 -0
  60. package/dist/yjs-DOK-m7kl.js +13413 -0
  61. package/package.json +191 -43
package/LICENSE CHANGED
@@ -1,6 +1,9 @@
1
1
  The MIT License (MIT)
2
2
 
3
- zbeyens
3
+ Copyright (c) Ziad Beyens, Dylan Schiemann, Joe Anderson, Felix Feng
4
+
5
+ Unless otherwise specified in a LICENSE file within an individual package directory,
6
+ this license applies to all files in this repository outside of those package directories.
4
7
 
5
8
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
9
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -0,0 +1,83 @@
1
+ # plitejs
2
+
3
+ Core Plite editor runtime.
4
+
5
+ Plite owns the document model, canonical changes, paths, points, ranges, transactions, state fields, schema plugins, and pure node/location helper namespaces.
6
+
7
+ ```ts
8
+ import { createEditor } from 'plitejs';
9
+
10
+ const editor = createEditor({
11
+ initialValue: [{ type: 'paragraph', children: [{ text: '' }] }],
12
+ });
13
+ ```
14
+
15
+ Use `isEditor` when library code needs to validate an unknown value before treating it as an editor.
16
+
17
+ Use `createEditorView(editor, options)` when framework packages need a root-scoped view over a committed editor. React components use `useEditor` from `plitejs/react`.
18
+
19
+ Read committed state with `editor.read(...)`. Use direct read methods for one-shot reads and the callback form when several reads must share one state view.
20
+
21
+ ```ts
22
+ const value = editor.read.value();
23
+ const selection = editor.read.selection();
24
+ const atBlockStart = editor.read.selection.isAtBlockStart();
25
+
26
+ const info = editor.read((state) => ({
27
+ text: state.text.string([]),
28
+ value: state.value(),
29
+ }));
30
+ ```
31
+
32
+ Write document, selection, mark, root, and state-field changes inside `editor.update(...)`. Use direct update methods for one-shot writes and the callback form when a command groups related writes into one commit.
33
+
34
+ ```ts
35
+ editor.update.text.insert('Hello');
36
+
37
+ editor.update((tx) => {
38
+ tx.text.insert(' ');
39
+ tx.text.insert('world');
40
+ });
41
+ ```
42
+
43
+ Use `defineEditorSchema`, `element`, `schema`, and `property` for declarative document grammar and property laws. Use `definePlugin` and `defineStateField` for state groups, transaction groups, corrections, commit listeners, and mounted runtime APIs.
44
+
45
+ Declared schemas reject unknown vocabulary by default. Set `unknown: 'preserve'` only when the application intentionally carries undeclared elements and properties; an unknown element must also be admitted by its parent's compiled content grammar.
46
+
47
+ Closed application content uses `fragment.replace`. Parsed and clipboard content uses `ContentSlice` so structural openness survives fitting.
48
+
49
+ ```ts
50
+ editor.update.fragment.replace([
51
+ { type: 'paragraph', children: [{ text: 'Hello' }] },
52
+ ]);
53
+ ```
54
+
55
+ Persist state fields and shared effects through `EditorValuePersistence`. Its `decode` and `encode` functions map live and JSON values; `version` and `legacyDecoders` own stored envelope history. Primitive mappings use `valueCodecs`. Install each standalone effect descriptor once through a plugin's `effectTypes` resource.
56
+
57
+ ```ts
58
+ import { defineStateField, valueCodecs } from 'plitejs';
59
+
60
+ const documentTitle = defineStateField({
61
+ key: 'document.title',
62
+ initial: () => 'Untitled',
63
+ persist: { ...valueCodecs.string, version: 1 },
64
+ });
65
+ ```
66
+
67
+ ```ts
68
+ import { definePlugin, defineEffect } from 'plitejs';
69
+
70
+ const refreshIndex = defineEffect({ key: 'search.refresh-index' });
71
+
72
+ const searchEffects = definePlugin('search-effects', {
73
+ effectTypes: [refreshIndex],
74
+ });
75
+ ```
76
+
77
+ Advanced library code can install descriptor-based read middleware and grouped transaction, commit, node, or text listeners through `on`. Diagnostic tooling can configure the debug value scrubber.
78
+
79
+ Pure data helpers live on namespaces such as `ElementApi`, `NodeApi`, `PathApi`, `PointApi`, `RangeApi`, `SpanApi`, and `TextApi`. Inside a live editor, prefer `editor.read.<group>.<method>()` for one-shot reads, grouped `state.*` reads for custom read logic, `editor.update.<group>.<method>()` for one-shot writes, and grouped `tx.*` writes for composed commands. Plugin `read` factories return callable method trees built once per configuration; methods read live state when invoked.
80
+
81
+ DOM, React, annotations, history, hyperscript, layout, diff, and testing APIs live on explicit `plitejs/*` subpaths. There is no public `/internal` entrypoint.
82
+
83
+ React components create annotation stores with `useAnnotationStore` from `plitejs/react`. Framework adapters with an independent lifetime use `createAnnotationStore` from `plitejs/annotations`; the React root does not export the imperative constructor.
@@ -0,0 +1,12 @@
1
+ //#region src/internal/view/annotation-store-metrics.ts
2
+ const metricsByStore = /* @__PURE__ */ new WeakMap();
3
+ const registerAnnotationStoreMetrics = (store, readMetrics) => {
4
+ metricsByStore.set(store, readMetrics);
5
+ };
6
+ const getAnnotationStoreMetrics = (store) => {
7
+ const readMetrics = metricsByStore.get(store);
8
+ if (!readMetrics) throw new Error("Annotation store metrics are unavailable.");
9
+ return readMetrics();
10
+ };
11
+ //#endregion
12
+ export { registerAnnotationStoreMetrics as n, getAnnotationStoreMetrics as t };
@@ -0,0 +1,2 @@
1
+ import { a as AnnotationSnapshot, c as OwnedAnnotationStore, i as AnnotationRefreshOptions, l as ResolvedAnnotation, n as AnnotationAnchor, o as AnnotationStore, r as AnnotationChange, s as AnnotationStoreOptions, t as Annotation, u as createAnnotationStore } from "../index-DPWyk3lG.js";
2
+ export { type Annotation, type AnnotationAnchor, type AnnotationChange, type AnnotationRefreshOptions, type AnnotationSnapshot, type AnnotationStore, type AnnotationStoreOptions, type OwnedAnnotationStore, type ResolvedAnnotation, createAnnotationStore };
@@ -0,0 +1,2 @@
1
+ import { t as createAnnotationStore } from "../store-Cz2mXyDe.js";
2
+ export { createAnnotationStore };