@mp-lb/mdkit 0.2.2 → 0.2.3-main.21.1
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/dist/collaboration/useMdKitCollaboration.d.ts +1 -1
- package/dist/core/checkpointPolicy.d.ts +25 -0
- package/dist/core/checkpointPolicy.js +45 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +1 -0
- package/dist/document/MdKitConflictPanel.d.ts +1 -1
- package/dist/document/MdKitConflictPanel.js +1 -1
- package/dist/document/MdKitDocumentToolbar.d.ts +3 -3
- package/dist/document/MdKitDocumentToolbar.js +1 -1
- package/dist/document/useMdKitDocument.d.ts +1 -1
- package/dist/fastify.d.ts +3 -3
- package/dist/fastify.js +1 -1
- package/dist/index.d.ts +29 -25
- package/dist/index.js +14 -12
- package/dist/markdown/MarkdownBubbleMenu.js +1 -1
- package/dist/markdown/MdKitEditor.d.ts +2 -2
- package/dist/markdown/MdKitEditor.js +2 -2
- package/dist/markdown/MdKitView.js +1 -1
- package/dist/markdown/TiptapMarkdownSurface.d.ts +2 -2
- package/dist/markdown/TiptapMarkdownSurface.js +33 -25
- package/dist/markdown/createMdKitTiptapExtensions.d.ts +8 -0
- package/dist/markdown/createMdKitTiptapExtensions.js +27 -0
- package/dist/markdown/prepareMarkdownForEditorHydration.js +1 -1
- package/dist/markdown/preserveMarkdownWhitespace.js +1 -1
- package/dist/server.d.ts +2 -0
- package/dist/server.js +1 -0
- package/dist/theme/MdKitThemeEditor.d.ts +1 -1
- package/dist/transport/backend.d.ts +29 -0
- package/dist/transport/backend.js +93 -0
- package/dist/transport/fastify.d.ts +1 -1
- package/dist/transport/fastify.js +1 -1
- package/dist/transport/http.d.ts +1 -1
- package/dist/transport/index.d.ts +5 -5
- package/dist/transport/index.js +2 -2
- package/dist/transport/rest.d.ts +1 -1
- package/dist/transport/store.d.ts +1 -1
- package/dist/transport/trpcClient.d.ts +29 -8
- package/dist/transport/trpcServer.d.ts +1 -1
- package/dist/trpc/client.d.ts +3 -3
- package/dist/trpc/client.js +1 -1
- package/dist/trpc/server.d.ts +5 -3
- package/dist/trpc/server.js +2 -1
- package/dist/trpc.d.ts +3 -3
- package/dist/trpc.js +1 -1
- package/dist/versioning/VersionHistoryPanel.d.ts +2 -2
- package/dist/versioning/VersionHistoryPanel.js +1 -1
- package/dist/versioning/useMdKitDocumentVersions.d.ts +1 -1
- package/dist/yjs/MdKitMarkdownYjs.d.ts +12 -0
- package/dist/yjs/MdKitMarkdownYjs.js +40 -0
- package/dist/yjs/index.d.ts +2 -0
- package/dist/yjs/index.js +1 -0
- package/docs/.vitepress/cache/deps/@theme_index.js +275 -0
- package/docs/.vitepress/cache/deps/@theme_index.js.map +7 -0
- package/docs/.vitepress/cache/deps/_metadata.json +40 -0
- package/docs/.vitepress/cache/deps/chunk-PM3I3KHC.js +9719 -0
- package/docs/.vitepress/cache/deps/chunk-PM3I3KHC.js.map +7 -0
- package/docs/.vitepress/cache/deps/chunk-VSHFF4ZG.js +13018 -0
- package/docs/.vitepress/cache/deps/chunk-VSHFF4ZG.js.map +7 -0
- package/docs/.vitepress/cache/deps/package.json +3 -0
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +4505 -0
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +583 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
- package/docs/.vitepress/cache/deps/vue.js +347 -0
- package/docs/.vitepress/cache/deps/vue.js.map +7 -0
- package/docs/.vitepress/config.ts +11 -0
- package/docs/api.md +153 -18
- package/docs/architecture.md +24 -9
- package/docs/collaboration-persistence.md +147 -0
- package/docs/index.md +139 -65
- package/docs/permissions.md +139 -0
- package/docs/rest.md +98 -0
- package/docs/shadcn.md +6 -3
- package/docs/styling.md +11 -10
- package/docs/use-cases.md +148 -0
- package/package.json +15 -2
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseTransition,
|
|
3
|
+
BaseTransitionPropsValidators,
|
|
4
|
+
Comment,
|
|
5
|
+
DeprecationTypes,
|
|
6
|
+
EffectScope,
|
|
7
|
+
ErrorCodes,
|
|
8
|
+
ErrorTypeStrings,
|
|
9
|
+
Fragment,
|
|
10
|
+
KeepAlive,
|
|
11
|
+
ReactiveEffect,
|
|
12
|
+
Static,
|
|
13
|
+
Suspense,
|
|
14
|
+
Teleport,
|
|
15
|
+
Text,
|
|
16
|
+
TrackOpTypes,
|
|
17
|
+
Transition,
|
|
18
|
+
TransitionGroup,
|
|
19
|
+
TriggerOpTypes,
|
|
20
|
+
VueElement,
|
|
21
|
+
assertNumber,
|
|
22
|
+
callWithAsyncErrorHandling,
|
|
23
|
+
callWithErrorHandling,
|
|
24
|
+
camelize,
|
|
25
|
+
capitalize,
|
|
26
|
+
cloneVNode,
|
|
27
|
+
compatUtils,
|
|
28
|
+
compile,
|
|
29
|
+
computed,
|
|
30
|
+
createApp,
|
|
31
|
+
createBaseVNode,
|
|
32
|
+
createBlock,
|
|
33
|
+
createCommentVNode,
|
|
34
|
+
createElementBlock,
|
|
35
|
+
createHydrationRenderer,
|
|
36
|
+
createPropsRestProxy,
|
|
37
|
+
createRenderer,
|
|
38
|
+
createSSRApp,
|
|
39
|
+
createSlots,
|
|
40
|
+
createStaticVNode,
|
|
41
|
+
createTextVNode,
|
|
42
|
+
createVNode,
|
|
43
|
+
customRef,
|
|
44
|
+
defineAsyncComponent,
|
|
45
|
+
defineComponent,
|
|
46
|
+
defineCustomElement,
|
|
47
|
+
defineEmits,
|
|
48
|
+
defineExpose,
|
|
49
|
+
defineModel,
|
|
50
|
+
defineOptions,
|
|
51
|
+
defineProps,
|
|
52
|
+
defineSSRCustomElement,
|
|
53
|
+
defineSlots,
|
|
54
|
+
devtools,
|
|
55
|
+
effect,
|
|
56
|
+
effectScope,
|
|
57
|
+
getCurrentInstance,
|
|
58
|
+
getCurrentScope,
|
|
59
|
+
getCurrentWatcher,
|
|
60
|
+
getTransitionRawChildren,
|
|
61
|
+
guardReactiveProps,
|
|
62
|
+
h,
|
|
63
|
+
handleError,
|
|
64
|
+
hasInjectionContext,
|
|
65
|
+
hydrate,
|
|
66
|
+
hydrateOnIdle,
|
|
67
|
+
hydrateOnInteraction,
|
|
68
|
+
hydrateOnMediaQuery,
|
|
69
|
+
hydrateOnVisible,
|
|
70
|
+
initCustomFormatter,
|
|
71
|
+
initDirectivesForSSR,
|
|
72
|
+
inject,
|
|
73
|
+
isMemoSame,
|
|
74
|
+
isProxy,
|
|
75
|
+
isReactive,
|
|
76
|
+
isReadonly,
|
|
77
|
+
isRef,
|
|
78
|
+
isRuntimeOnly,
|
|
79
|
+
isShallow,
|
|
80
|
+
isVNode,
|
|
81
|
+
markRaw,
|
|
82
|
+
mergeDefaults,
|
|
83
|
+
mergeModels,
|
|
84
|
+
mergeProps,
|
|
85
|
+
nextTick,
|
|
86
|
+
nodeOps,
|
|
87
|
+
normalizeClass,
|
|
88
|
+
normalizeProps,
|
|
89
|
+
normalizeStyle,
|
|
90
|
+
onActivated,
|
|
91
|
+
onBeforeMount,
|
|
92
|
+
onBeforeUnmount,
|
|
93
|
+
onBeforeUpdate,
|
|
94
|
+
onDeactivated,
|
|
95
|
+
onErrorCaptured,
|
|
96
|
+
onMounted,
|
|
97
|
+
onRenderTracked,
|
|
98
|
+
onRenderTriggered,
|
|
99
|
+
onScopeDispose,
|
|
100
|
+
onServerPrefetch,
|
|
101
|
+
onUnmounted,
|
|
102
|
+
onUpdated,
|
|
103
|
+
onWatcherCleanup,
|
|
104
|
+
openBlock,
|
|
105
|
+
patchProp,
|
|
106
|
+
popScopeId,
|
|
107
|
+
provide,
|
|
108
|
+
proxyRefs,
|
|
109
|
+
pushScopeId,
|
|
110
|
+
queuePostFlushCb,
|
|
111
|
+
reactive,
|
|
112
|
+
readonly,
|
|
113
|
+
ref,
|
|
114
|
+
registerRuntimeCompiler,
|
|
115
|
+
render,
|
|
116
|
+
renderList,
|
|
117
|
+
renderSlot,
|
|
118
|
+
resolveComponent,
|
|
119
|
+
resolveDirective,
|
|
120
|
+
resolveDynamicComponent,
|
|
121
|
+
resolveFilter,
|
|
122
|
+
resolveTransitionHooks,
|
|
123
|
+
setBlockTracking,
|
|
124
|
+
setDevtoolsHook,
|
|
125
|
+
setTransitionHooks,
|
|
126
|
+
shallowReactive,
|
|
127
|
+
shallowReadonly,
|
|
128
|
+
shallowRef,
|
|
129
|
+
ssrContextKey,
|
|
130
|
+
ssrUtils,
|
|
131
|
+
stop,
|
|
132
|
+
toDisplayString,
|
|
133
|
+
toHandlerKey,
|
|
134
|
+
toHandlers,
|
|
135
|
+
toRaw,
|
|
136
|
+
toRef,
|
|
137
|
+
toRefs,
|
|
138
|
+
toValue,
|
|
139
|
+
transformVNodeArgs,
|
|
140
|
+
triggerRef,
|
|
141
|
+
unref,
|
|
142
|
+
useAttrs,
|
|
143
|
+
useCssModule,
|
|
144
|
+
useCssVars,
|
|
145
|
+
useHost,
|
|
146
|
+
useId,
|
|
147
|
+
useModel,
|
|
148
|
+
useSSRContext,
|
|
149
|
+
useShadowRoot,
|
|
150
|
+
useSlots,
|
|
151
|
+
useTemplateRef,
|
|
152
|
+
useTransitionState,
|
|
153
|
+
vModelCheckbox,
|
|
154
|
+
vModelDynamic,
|
|
155
|
+
vModelRadio,
|
|
156
|
+
vModelSelect,
|
|
157
|
+
vModelText,
|
|
158
|
+
vShow,
|
|
159
|
+
version,
|
|
160
|
+
warn,
|
|
161
|
+
watch,
|
|
162
|
+
watchEffect,
|
|
163
|
+
watchPostEffect,
|
|
164
|
+
watchSyncEffect,
|
|
165
|
+
withAsyncContext,
|
|
166
|
+
withCtx,
|
|
167
|
+
withDefaults,
|
|
168
|
+
withDirectives,
|
|
169
|
+
withKeys,
|
|
170
|
+
withMemo,
|
|
171
|
+
withModifiers,
|
|
172
|
+
withScopeId
|
|
173
|
+
} from "./chunk-VSHFF4ZG.js";
|
|
174
|
+
export {
|
|
175
|
+
BaseTransition,
|
|
176
|
+
BaseTransitionPropsValidators,
|
|
177
|
+
Comment,
|
|
178
|
+
DeprecationTypes,
|
|
179
|
+
EffectScope,
|
|
180
|
+
ErrorCodes,
|
|
181
|
+
ErrorTypeStrings,
|
|
182
|
+
Fragment,
|
|
183
|
+
KeepAlive,
|
|
184
|
+
ReactiveEffect,
|
|
185
|
+
Static,
|
|
186
|
+
Suspense,
|
|
187
|
+
Teleport,
|
|
188
|
+
Text,
|
|
189
|
+
TrackOpTypes,
|
|
190
|
+
Transition,
|
|
191
|
+
TransitionGroup,
|
|
192
|
+
TriggerOpTypes,
|
|
193
|
+
VueElement,
|
|
194
|
+
assertNumber,
|
|
195
|
+
callWithAsyncErrorHandling,
|
|
196
|
+
callWithErrorHandling,
|
|
197
|
+
camelize,
|
|
198
|
+
capitalize,
|
|
199
|
+
cloneVNode,
|
|
200
|
+
compatUtils,
|
|
201
|
+
compile,
|
|
202
|
+
computed,
|
|
203
|
+
createApp,
|
|
204
|
+
createBlock,
|
|
205
|
+
createCommentVNode,
|
|
206
|
+
createElementBlock,
|
|
207
|
+
createBaseVNode as createElementVNode,
|
|
208
|
+
createHydrationRenderer,
|
|
209
|
+
createPropsRestProxy,
|
|
210
|
+
createRenderer,
|
|
211
|
+
createSSRApp,
|
|
212
|
+
createSlots,
|
|
213
|
+
createStaticVNode,
|
|
214
|
+
createTextVNode,
|
|
215
|
+
createVNode,
|
|
216
|
+
customRef,
|
|
217
|
+
defineAsyncComponent,
|
|
218
|
+
defineComponent,
|
|
219
|
+
defineCustomElement,
|
|
220
|
+
defineEmits,
|
|
221
|
+
defineExpose,
|
|
222
|
+
defineModel,
|
|
223
|
+
defineOptions,
|
|
224
|
+
defineProps,
|
|
225
|
+
defineSSRCustomElement,
|
|
226
|
+
defineSlots,
|
|
227
|
+
devtools,
|
|
228
|
+
effect,
|
|
229
|
+
effectScope,
|
|
230
|
+
getCurrentInstance,
|
|
231
|
+
getCurrentScope,
|
|
232
|
+
getCurrentWatcher,
|
|
233
|
+
getTransitionRawChildren,
|
|
234
|
+
guardReactiveProps,
|
|
235
|
+
h,
|
|
236
|
+
handleError,
|
|
237
|
+
hasInjectionContext,
|
|
238
|
+
hydrate,
|
|
239
|
+
hydrateOnIdle,
|
|
240
|
+
hydrateOnInteraction,
|
|
241
|
+
hydrateOnMediaQuery,
|
|
242
|
+
hydrateOnVisible,
|
|
243
|
+
initCustomFormatter,
|
|
244
|
+
initDirectivesForSSR,
|
|
245
|
+
inject,
|
|
246
|
+
isMemoSame,
|
|
247
|
+
isProxy,
|
|
248
|
+
isReactive,
|
|
249
|
+
isReadonly,
|
|
250
|
+
isRef,
|
|
251
|
+
isRuntimeOnly,
|
|
252
|
+
isShallow,
|
|
253
|
+
isVNode,
|
|
254
|
+
markRaw,
|
|
255
|
+
mergeDefaults,
|
|
256
|
+
mergeModels,
|
|
257
|
+
mergeProps,
|
|
258
|
+
nextTick,
|
|
259
|
+
nodeOps,
|
|
260
|
+
normalizeClass,
|
|
261
|
+
normalizeProps,
|
|
262
|
+
normalizeStyle,
|
|
263
|
+
onActivated,
|
|
264
|
+
onBeforeMount,
|
|
265
|
+
onBeforeUnmount,
|
|
266
|
+
onBeforeUpdate,
|
|
267
|
+
onDeactivated,
|
|
268
|
+
onErrorCaptured,
|
|
269
|
+
onMounted,
|
|
270
|
+
onRenderTracked,
|
|
271
|
+
onRenderTriggered,
|
|
272
|
+
onScopeDispose,
|
|
273
|
+
onServerPrefetch,
|
|
274
|
+
onUnmounted,
|
|
275
|
+
onUpdated,
|
|
276
|
+
onWatcherCleanup,
|
|
277
|
+
openBlock,
|
|
278
|
+
patchProp,
|
|
279
|
+
popScopeId,
|
|
280
|
+
provide,
|
|
281
|
+
proxyRefs,
|
|
282
|
+
pushScopeId,
|
|
283
|
+
queuePostFlushCb,
|
|
284
|
+
reactive,
|
|
285
|
+
readonly,
|
|
286
|
+
ref,
|
|
287
|
+
registerRuntimeCompiler,
|
|
288
|
+
render,
|
|
289
|
+
renderList,
|
|
290
|
+
renderSlot,
|
|
291
|
+
resolveComponent,
|
|
292
|
+
resolveDirective,
|
|
293
|
+
resolveDynamicComponent,
|
|
294
|
+
resolveFilter,
|
|
295
|
+
resolveTransitionHooks,
|
|
296
|
+
setBlockTracking,
|
|
297
|
+
setDevtoolsHook,
|
|
298
|
+
setTransitionHooks,
|
|
299
|
+
shallowReactive,
|
|
300
|
+
shallowReadonly,
|
|
301
|
+
shallowRef,
|
|
302
|
+
ssrContextKey,
|
|
303
|
+
ssrUtils,
|
|
304
|
+
stop,
|
|
305
|
+
toDisplayString,
|
|
306
|
+
toHandlerKey,
|
|
307
|
+
toHandlers,
|
|
308
|
+
toRaw,
|
|
309
|
+
toRef,
|
|
310
|
+
toRefs,
|
|
311
|
+
toValue,
|
|
312
|
+
transformVNodeArgs,
|
|
313
|
+
triggerRef,
|
|
314
|
+
unref,
|
|
315
|
+
useAttrs,
|
|
316
|
+
useCssModule,
|
|
317
|
+
useCssVars,
|
|
318
|
+
useHost,
|
|
319
|
+
useId,
|
|
320
|
+
useModel,
|
|
321
|
+
useSSRContext,
|
|
322
|
+
useShadowRoot,
|
|
323
|
+
useSlots,
|
|
324
|
+
useTemplateRef,
|
|
325
|
+
useTransitionState,
|
|
326
|
+
vModelCheckbox,
|
|
327
|
+
vModelDynamic,
|
|
328
|
+
vModelRadio,
|
|
329
|
+
vModelSelect,
|
|
330
|
+
vModelText,
|
|
331
|
+
vShow,
|
|
332
|
+
version,
|
|
333
|
+
warn,
|
|
334
|
+
watch,
|
|
335
|
+
watchEffect,
|
|
336
|
+
watchPostEffect,
|
|
337
|
+
watchSyncEffect,
|
|
338
|
+
withAsyncContext,
|
|
339
|
+
withCtx,
|
|
340
|
+
withDefaults,
|
|
341
|
+
withDirectives,
|
|
342
|
+
withKeys,
|
|
343
|
+
withMemo,
|
|
344
|
+
withModifiers,
|
|
345
|
+
withScopeId
|
|
346
|
+
};
|
|
347
|
+
//# sourceMappingURL=vue.js.map
|
|
@@ -9,6 +9,10 @@ export default defineConfig({
|
|
|
9
9
|
{ text: "Quick Start", link: "/" },
|
|
10
10
|
{ text: "Styling", link: "/styling" },
|
|
11
11
|
{ text: "Shadcn", link: "/shadcn" },
|
|
12
|
+
{ text: "REST", link: "/rest" },
|
|
13
|
+
{ text: "Use Cases", link: "/use-cases" },
|
|
14
|
+
{ text: "Permissions", link: "/permissions" },
|
|
15
|
+
{ text: "Collaboration Persistence", link: "/collaboration-persistence" },
|
|
12
16
|
{ text: "API", link: "/api" },
|
|
13
17
|
{ text: "Architecture", link: "/architecture" },
|
|
14
18
|
],
|
|
@@ -19,6 +23,13 @@ export default defineConfig({
|
|
|
19
23
|
{ text: "Quick Start", link: "/" },
|
|
20
24
|
{ text: "Styling", link: "/styling" },
|
|
21
25
|
{ text: "Shadcn Plugin", link: "/shadcn" },
|
|
26
|
+
{ text: "REST Backend", link: "/rest" },
|
|
27
|
+
{ text: "Use Cases", link: "/use-cases" },
|
|
28
|
+
{ text: "Permissions", link: "/permissions" },
|
|
29
|
+
{
|
|
30
|
+
text: "Collaboration Persistence",
|
|
31
|
+
link: "/collaboration-persistence",
|
|
32
|
+
},
|
|
22
33
|
{ text: "API Reference", link: "/api" },
|
|
23
34
|
{ text: "Architecture", link: "/architecture" },
|
|
24
35
|
],
|
package/docs/api.md
CHANGED
|
@@ -103,8 +103,8 @@ without adopting a design system.
|
|
|
103
103
|
/>
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
It renders save status, collaboration status, an optional
|
|
107
|
-
point labelled with the current
|
|
106
|
+
It renders save status, collaboration status, an optional checkpoint-history
|
|
107
|
+
entry point labelled with the current revision token, and a conflict entry via
|
|
108
108
|
`onOpenConflict`.
|
|
109
109
|
|
|
110
110
|
Related type:
|
|
@@ -158,10 +158,15 @@ Required storage methods:
|
|
|
158
158
|
- `resyncDocument` is optional and can force a fresh read from the canonical
|
|
159
159
|
source.
|
|
160
160
|
|
|
161
|
-
Optional
|
|
161
|
+
Optional checkpoint-history methods:
|
|
162
162
|
|
|
163
|
-
- `listDocumentVersions` returns available
|
|
164
|
-
- `readDocumentVersion` returns a saved markdown snapshot for one
|
|
163
|
+
- `listDocumentVersions` returns available checkpoints for the document.
|
|
164
|
+
- `readDocumentVersion` returns a saved markdown snapshot for one checkpoint.
|
|
165
|
+
|
|
166
|
+
The current public names still use `Version` because that is the existing API.
|
|
167
|
+
Conceptually these records are checkpoints. `MdKitDocumentSnapshot.version` is
|
|
168
|
+
an opaque current-document revision token, not necessarily a user-facing
|
|
169
|
+
checkpoint id.
|
|
165
170
|
|
|
166
171
|
Related storage types:
|
|
167
172
|
|
|
@@ -220,16 +225,16 @@ Related exports:
|
|
|
220
225
|
`MdKitThemeEditor` also relies on the optional package stylesheet for its own
|
|
221
226
|
layout. Without that stylesheet, it still renders normal form controls.
|
|
222
227
|
|
|
223
|
-
##
|
|
228
|
+
## Checkpoint History
|
|
224
229
|
|
|
225
230
|
### `useMdKitDocumentVersions`
|
|
226
231
|
|
|
227
|
-
Hook for listing
|
|
228
|
-
history loading state.
|
|
232
|
+
Hook for listing checkpoints, reading a checkpoint detail, and tracking
|
|
233
|
+
checkpoint-history loading state.
|
|
229
234
|
|
|
230
235
|
### `VersionHistoryPanel`
|
|
231
236
|
|
|
232
|
-
UI component for rendering
|
|
237
|
+
UI component for rendering checkpoint history from `useMdKitDocumentVersions`.
|
|
233
238
|
|
|
234
239
|
Related types:
|
|
235
240
|
|
|
@@ -256,6 +261,119 @@ type MdKitDocumentVersionDetail = MdKitDocumentVersionSummary & {
|
|
|
256
261
|
};
|
|
257
262
|
```
|
|
258
263
|
|
|
264
|
+
The `Version` type names are retained for compatibility with the current public
|
|
265
|
+
API. The data model should be understood as checkpoint history.
|
|
266
|
+
|
|
267
|
+
### `CheckpointPolicy`
|
|
268
|
+
|
|
269
|
+
Backend helper for deciding when saved content should become checkpoint
|
|
270
|
+
history. Pass the policy to mdkit's backend helper, not to your application
|
|
271
|
+
store. Your store exposes database operations; mdkit evaluates the policy after
|
|
272
|
+
writes and calls your checkpoint storage when the policy triggers.
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
import { CheckpointPolicy } from "@mp-lb/mdkit/core";
|
|
276
|
+
|
|
277
|
+
const never = CheckpointPolicy.never();
|
|
278
|
+
const always = CheckpointPolicy.always();
|
|
279
|
+
const smart = CheckpointPolicy.smart();
|
|
280
|
+
const tunedSmart = CheckpointPolicy.smart({
|
|
281
|
+
minEditDistance: 250,
|
|
282
|
+
minIntervalMs: 5 * 60_000,
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
const custom = CheckpointPolicy.function(
|
|
286
|
+
({
|
|
287
|
+
currentContent,
|
|
288
|
+
editDistance,
|
|
289
|
+
previousCheckpointContent,
|
|
290
|
+
timeSinceLastCheckpointMs,
|
|
291
|
+
}) =>
|
|
292
|
+
editDistance > 500 ||
|
|
293
|
+
timeSinceLastCheckpointMs > 10 * 60_000 ||
|
|
294
|
+
currentContent.startsWith("# Published") !==
|
|
295
|
+
previousCheckpointContent?.startsWith("# Published"),
|
|
296
|
+
);
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
`smart()` without options uses mdkit's default autosave-friendly policy.
|
|
300
|
+
`function()` receives both mdkit's computed edit distance and the raw document
|
|
301
|
+
content, so products can use the built-in comparison or replace it with their
|
|
302
|
+
own.
|
|
303
|
+
|
|
304
|
+
### `createMdKitBackend`
|
|
305
|
+
|
|
306
|
+
Creates the mdkit backend surface from your application store and checkpoint
|
|
307
|
+
policy. This is the layer that owns checkpoint orchestration.
|
|
308
|
+
|
|
309
|
+
```ts
|
|
310
|
+
import { CheckpointPolicy } from "@mp-lb/mdkit/core";
|
|
311
|
+
import {
|
|
312
|
+
createMdKitBackend,
|
|
313
|
+
type MdKitBackendStore,
|
|
314
|
+
} from "@mp-lb/mdkit/server";
|
|
315
|
+
import { createMdKitTrpcRouter } from "@mp-lb/mdkit/trpc/server";
|
|
316
|
+
|
|
317
|
+
const store: MdKitBackendStore = createYourDocumentStore();
|
|
318
|
+
|
|
319
|
+
const mdkit = createMdKitBackend({
|
|
320
|
+
store,
|
|
321
|
+
checkpointPolicy: CheckpointPolicy.smart(),
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
const router = createMdKitTrpcRouter(mdkit);
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
On a document write, the helper should:
|
|
328
|
+
|
|
329
|
+
- write the canonical current document
|
|
330
|
+
- compare the current content with the latest checkpoint
|
|
331
|
+
- evaluate the configured `CheckpointPolicy`
|
|
332
|
+
- call the store's checkpoint creation method when the policy triggers
|
|
333
|
+
- return the write result to the transport layer
|
|
334
|
+
|
|
335
|
+
Exported from `@mp-lb/mdkit/server`.
|
|
336
|
+
|
|
337
|
+
### `MdKitBackendStore`
|
|
338
|
+
|
|
339
|
+
Application-owned persistence contract consumed by `createMdKitBackend`.
|
|
340
|
+
Implement this with your database. The checkpoint policy is not interpreted by
|
|
341
|
+
this store; mdkit calls `createCheckpoint` when the configured policy triggers.
|
|
342
|
+
|
|
343
|
+
```ts
|
|
344
|
+
type MdKitBackendStore = {
|
|
345
|
+
readDocument(documentId: string): Promise<MdKitDocumentSnapshot>;
|
|
346
|
+
writeDocument(
|
|
347
|
+
input: MdKitDocumentWriteInput,
|
|
348
|
+
): Promise<MdKitDocumentWriteResult>;
|
|
349
|
+
getLatestCheckpoint?(
|
|
350
|
+
documentId: string,
|
|
351
|
+
): Promise<MdKitDocumentVersionDetail | null>;
|
|
352
|
+
createCheckpoint?(input: {
|
|
353
|
+
documentId: string;
|
|
354
|
+
content: string;
|
|
355
|
+
sourceRevision: MdKitDocumentVersionToken;
|
|
356
|
+
metadata?: unknown;
|
|
357
|
+
}): Promise<MdKitDocumentVersionSummary>;
|
|
358
|
+
listDocumentVersions?(
|
|
359
|
+
documentId: string,
|
|
360
|
+
): Promise<MdKitDocumentVersionSummary[]>;
|
|
361
|
+
readDocumentVersion?(input: {
|
|
362
|
+
documentId: string;
|
|
363
|
+
versionId: string;
|
|
364
|
+
}): Promise<MdKitDocumentVersionDetail | null>;
|
|
365
|
+
restoreDocumentVersion?(input: {
|
|
366
|
+
documentId: string;
|
|
367
|
+
versionId: string;
|
|
368
|
+
}): Promise<MdKitDocumentWriteResult>;
|
|
369
|
+
readCollaborationState?(documentName: string): Promise<Uint8Array | null>;
|
|
370
|
+
writeCollaborationState?(
|
|
371
|
+
documentName: string,
|
|
372
|
+
state: Uint8Array,
|
|
373
|
+
): Promise<void>;
|
|
374
|
+
};
|
|
375
|
+
```
|
|
376
|
+
|
|
259
377
|
## Collaboration
|
|
260
378
|
|
|
261
379
|
### `useMdKitCollaboration`
|
|
@@ -283,6 +401,9 @@ type MdKitCollaborationSession = {
|
|
|
283
401
|
### `createMdKitRestAdapter`
|
|
284
402
|
|
|
285
403
|
Creates an `MdKitDocumentAdapter` that talks to the mdkit REST endpoint shape.
|
|
404
|
+
Restore is not part of `MdKitDocumentAdapter` yet, so REST restore needs a
|
|
405
|
+
separate `POST /versions/:versionId/restore` call from application code. See
|
|
406
|
+
[REST Backend](./rest.md).
|
|
286
407
|
|
|
287
408
|
```ts
|
|
288
409
|
const adapter = createMdKitRestAdapter({
|
|
@@ -299,7 +420,7 @@ Registers the matching REST endpoints on a Fastify app.
|
|
|
299
420
|
```ts
|
|
300
421
|
await registerMdKitFastify(app, {
|
|
301
422
|
prefix: "/mdkit",
|
|
302
|
-
store,
|
|
423
|
+
store: mdkit,
|
|
303
424
|
});
|
|
304
425
|
```
|
|
305
426
|
|
|
@@ -307,15 +428,19 @@ Exported from `@mp-lb/mdkit/fastify`.
|
|
|
307
428
|
|
|
308
429
|
### `createMdKitTrpcRouter`
|
|
309
430
|
|
|
310
|
-
Creates a tRPC router for document reads, writes, resync,
|
|
311
|
-
|
|
431
|
+
Creates a tRPC router for document reads, writes, resync, checkpoint list/read,
|
|
432
|
+
and restore. The current API names still use `Version`, but these methods model
|
|
433
|
+
checkpoint history.
|
|
312
434
|
|
|
313
435
|
```ts
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
436
|
+
const appRouter = t.router({
|
|
437
|
+
mdkit: createMdKitTrpcRouter(mdkit),
|
|
438
|
+
// otherRouters: ...
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
const server = createHTTPServer({
|
|
442
|
+
basePath: "/trpc",
|
|
443
|
+
router: appRouter,
|
|
319
444
|
});
|
|
320
445
|
```
|
|
321
446
|
|
|
@@ -330,11 +455,21 @@ const client = createMdKitTrpcClient({ url: `${apiUrl}/trpc` });
|
|
|
330
455
|
const adapter = createMdKitTrpcAdapter({ client });
|
|
331
456
|
```
|
|
332
457
|
|
|
458
|
+
If the mdkit router is nested inside your app router, create your normal app
|
|
459
|
+
client and pass the mdkit sub-client:
|
|
460
|
+
|
|
461
|
+
```ts
|
|
462
|
+
const adapter = createMdKitTrpcAdapter({ client: trpc.mdkit });
|
|
463
|
+
```
|
|
464
|
+
|
|
333
465
|
Exported from `@mp-lb/mdkit/trpc/client`.
|
|
334
466
|
|
|
335
467
|
### `MdKitTransportStore`
|
|
336
468
|
|
|
337
|
-
|
|
469
|
+
Transport-ready backend surface used by the Fastify and tRPC helpers. You can
|
|
470
|
+
implement this directly for full control, but the opinionated path is to create
|
|
471
|
+
it with `createMdKitBackend({ store, checkpointPolicy })` so mdkit owns
|
|
472
|
+
checkpoint policy orchestration.
|
|
338
473
|
|
|
339
474
|
```ts
|
|
340
475
|
type MdKitTransportStore = {
|
package/docs/architecture.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Architecture
|
|
2
2
|
|
|
3
|
-
The editor package should keep UI concerns separate from persistence,
|
|
3
|
+
The editor package should keep UI concerns separate from persistence,
|
|
4
|
+
checkpoint history, permissions, and collaboration infrastructure.
|
|
4
5
|
|
|
5
6
|
## Layers
|
|
6
7
|
|
|
@@ -15,7 +16,9 @@ For local editing, it accepts:
|
|
|
15
16
|
- `onFocusChange?: (focused: boolean) => void`
|
|
16
17
|
- `instanceKey?: string | number`
|
|
17
18
|
|
|
18
|
-
It should behave like a fancy textarea from the consumer's point of view. It
|
|
19
|
+
It should behave like a fancy textarea from the consumer's point of view. It
|
|
20
|
+
must not know about storage, checkpoints, auth, servers, Hocuspocus, MongoDB,
|
|
21
|
+
or the host application.
|
|
19
22
|
|
|
20
23
|
For collaborative editing, the same component accepts:
|
|
21
24
|
|
|
@@ -29,12 +32,12 @@ component.
|
|
|
29
32
|
`MdKitView` is the read-only companion surface. It accepts a markdown `value`
|
|
30
33
|
and uses the same package styling and full-height layout contract as
|
|
31
34
|
`MdKitEditor`, but it renders markdown without Tiptap or ProseMirror. Use it
|
|
32
|
-
when consumers need previews,
|
|
33
|
-
visually match the editor without paying the editor runtime cost.
|
|
35
|
+
when consumers need previews, checkpoint snapshots, or readonly document views
|
|
36
|
+
that visually match the editor without paying the editor runtime cost.
|
|
34
37
|
|
|
35
38
|
### Headless Hooks
|
|
36
39
|
|
|
37
|
-
Storage,
|
|
40
|
+
Storage, checkpoint history, and collaboration controls should come from hooks and
|
|
38
41
|
consumer-owned UI. A product can render those controls in a header, toolbar,
|
|
39
42
|
side panel, command menu, or nowhere at all.
|
|
40
43
|
|
|
@@ -42,25 +45,37 @@ Hooks should expose enough state for consumers to decide which UI features are
|
|
|
42
45
|
visible based on available adapters:
|
|
43
46
|
|
|
44
47
|
- storage adapter present: load/save UI and autosave can exist
|
|
45
|
-
-
|
|
48
|
+
- checkpoint adapter present: checkpoint history UI can exist
|
|
46
49
|
- collaboration adapter present: collaborative state and presence can exist
|
|
47
50
|
|
|
48
51
|
Missing adapters should remove functionality, not break the editor.
|
|
49
52
|
|
|
50
53
|
### Reference Integrations
|
|
51
54
|
|
|
52
|
-
Reference integrations should provide plug-and-play adapters for supported
|
|
55
|
+
Reference integrations should provide plug-and-play adapters for supported
|
|
56
|
+
backends. The editor UI should depend on adapter interfaces, not implementation
|
|
57
|
+
details.
|
|
53
58
|
|
|
54
59
|
Examples:
|
|
55
60
|
|
|
56
61
|
- JSON document storage
|
|
57
62
|
- MongoDB-backed document storage
|
|
58
|
-
- JSON or MongoDB
|
|
63
|
+
- JSON or MongoDB checkpoint history
|
|
59
64
|
- Hocuspocus/Yjs collaboration
|
|
60
65
|
|
|
66
|
+
### Backend Helpers
|
|
67
|
+
|
|
68
|
+
The opinionated backend helper should provide structure, not own application
|
|
69
|
+
data. Applications still own storage, metadata, auth, permissions, tenancy, and
|
|
70
|
+
infrastructure. MDKit should own the workflow shape: current-document writes,
|
|
71
|
+
checkpoint policy, restore ordering, collaboration authorization hooks, and
|
|
72
|
+
markdown/Yjs bridging.
|
|
73
|
+
|
|
61
74
|
## Ownership Rule
|
|
62
75
|
|
|
63
|
-
The frontend editor owns rendering and local editing state. Adapters own
|
|
76
|
+
The frontend editor owns rendering and local editing state. Adapters own
|
|
77
|
+
durable state and transport. The editor should never import database clients,
|
|
78
|
+
server framework code, or backend-specific SDKs.
|
|
64
79
|
|
|
65
80
|
## Package Boundaries
|
|
66
81
|
|