@fileverse-dev/ddoc 6.0.0-drop-in.3 → 6.0.1-dist-slim.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 +18 -89
- package/dist/data-BCRDUrcS.mjs +59842 -0
- package/dist/ddoc-persistence-DLdSviUr.mjs +371 -0
- package/dist/headless-editor-utils.es.js +1 -1
- package/dist/index--ObnXdbg.mjs +14053 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +10734 -21551
- package/dist/markdown-source-pane-BJbpMXo2.mjs +143 -0
- package/dist/package/components/editor-toolbar.d.ts +1 -2
- package/dist/package/components/fullscreen-toolbar.d.ts +2 -2
- package/dist/package/components/mobile-toolbar.d.ts +1 -2
- package/dist/package/components/tabs/document-mobile-tab-panel.d.ts +1 -3
- package/dist/package/components/tabs/document-tabs-sidebar.d.ts +1 -2
- package/dist/package/components/toc/document-outline.d.ts +1 -1
- package/dist/package/components/toc/toc.d.ts +1 -1
- package/dist/package/components/toc/types.d.ts +0 -7
- package/dist/package/extensions/emoji/components/emoji-utils.d.ts +2 -2
- package/dist/package/hooks/use-export-headless-editor-content.d.ts +6 -2
- package/dist/package/hooks/use-focus-mode.d.ts +3 -1
- package/dist/package/hooks/use-headless-editor.d.ts +12 -4
- package/dist/package/hooks/use-tab-editor.d.ts +1 -4
- package/dist/package/hooks/use-tab-manager.d.ts +3 -1
- package/dist/package/hooks/use-yjs-setup.d.ts +7 -1
- package/dist/package/persistence/compaction.d.ts +27 -0
- package/dist/package/persistence/content-fingerprint.d.ts +27 -0
- package/dist/package/persistence/ddoc-persistence.d.ts +96 -0
- package/dist/package/persistence/index.d.ts +2 -0
- package/dist/package/persistence/provider-lifecycle.d.ts +37 -0
- package/dist/package/sync-local/SyncManager.d.ts +8 -1
- package/dist/package/sync-local/types/index.d.ts +2 -0
- package/dist/package/types.d.ts +25 -43
- package/dist/package/use-ddoc-editor.d.ts +1 -3
- package/dist/package/utils/responsive.d.ts +1 -3
- package/dist/persistence.d.ts +1 -0
- package/dist/persistence.es.js +10 -0
- package/dist/{split-view-toolbar-NTimkQK1.mjs → split-view-toolbar-6aBSjsO2.mjs} +47 -46
- package/dist/style.css +1 -1
- package/dist/tab-utils-BNFvrUAj.mjs +284 -0
- package/dist/use-headless-editor-fZCM6BjV.mjs +43828 -0
- package/package.json +11 -4
- package/tailwind.preset.cjs +0 -42
- package/dist/index-eP_xxZsk.mjs +0 -13126
- package/dist/markdown-source-pane-D-8OmL1r.mjs +0 -6069
- package/dist/package/components/editor-navbar.d.ts +0 -12
- package/dist/package/hooks/use-canvas-metrics.d.ts +0 -16
- package/dist/package/hooks/use-controllable-state.d.ts +0 -3
- package/dist/package/hooks/use-editor-media-query.d.ts +0 -4
- package/dist/package/utils/container-query-support.d.ts +0 -1
- package/dist/package/utils/editor-width-store.d.ts +0 -6
- package/dist/package/utils/stats-publisher.d.ts +0 -8
- package/dist/use-headless-editor-KdKS6vWp.mjs +0 -162186
package/README.md
CHANGED
|
@@ -46,32 +46,6 @@ import 'katex/dist/katex.min.css'; // math; fonts are served as files
|
|
|
46
46
|
import '@fileverse-dev/ddoc/styles'; // editor CSS
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
### Sizing
|
|
50
|
-
|
|
51
|
-
`DdocEditor` fills its parent: `width: 100%; height: 100%`. The parent must have a definite height. The editor never reads the viewport, so a navbar above it or a footer below it is ordinary layout:
|
|
52
|
-
|
|
53
|
-
```tsx
|
|
54
|
-
<div style={{ height: '100dvh', display: 'flex', flexDirection: 'column' }}>
|
|
55
|
-
<div style={{ flex: 1, minHeight: 0 }}>
|
|
56
|
-
<DdocEditor renderNavbar={renderNavbar} />
|
|
57
|
-
</div>
|
|
58
|
-
<footer>…</footer>
|
|
59
|
-
</div>
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
If the editor renders with no height, its parent has none.
|
|
63
|
-
|
|
64
|
-
`renderNavbar` output is the editor's first row by default, rendered as is: the editor adds no styling, so return one element with your own background, padding and border. In flow it sits in an unstyled row that only animates the collapse. Without `renderNavbar` nothing is rendered. To place the navbar elsewhere, pass the element to render into. Hold it in state, not in a ref, so the editor re-renders when it attaches:
|
|
65
|
-
|
|
66
|
-
```tsx
|
|
67
|
-
const [navbarEl, setNavbarEl] = useState<HTMLElement | null>(null);
|
|
68
|
-
|
|
69
|
-
<header ref={setNavbarEl} />
|
|
70
|
-
<DdocEditor navbarContainer={navbarEl} renderNavbar={renderNavbar} />
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
The layout follows the editor's width, not the window's: in a narrow panel it uses its narrow layout. Known limits: one `DdocEditor` per page; in a narrow editor on a wide screen the comment sheet still covers the whole viewport.
|
|
74
|
-
|
|
75
49
|
### Peer Dependencies
|
|
76
50
|
|
|
77
51
|
This package requires the following peer dependencies to be installed in your project:
|
|
@@ -146,28 +120,6 @@ The preset composes `@fileverse/ui/tailwind` (class-based dark mode, animate plu
|
|
|
146
120
|
|
|
147
121
|
You should now be set to use dDocs!
|
|
148
122
|
|
|
149
|
-
### Migrating from 5.x
|
|
150
|
-
|
|
151
|
-
6.0 changes how the editor is sized. No prop was removed.
|
|
152
|
-
|
|
153
|
-
- Give the editor a parent with a definite height (see Sizing). It no longer sizes itself from `100dvh`.
|
|
154
|
-
- Put your footer after the editor in normal flow. `footerHeight` has no effect and can be removed.
|
|
155
|
-
- The navbar and toolbars are no longer inside `#editor-canvas`. CSS that used `#editor-canvas` as their ancestor should use `.ddoc-editor-root`.
|
|
156
|
-
- The editor no longer wraps your navbar in `<nav id="Navbar">`. It renders what `renderNavbar` returns, so move the wrapper's styling (`color-bg-default p-2 flex gap-10 items-center justify-between w-full border-b color-border-default`) and the `id`, if you select on it, onto your own element. The Escape-returns-focus-to-editor handler went with it, and hiding now collapses an unstyled row (`.ddoc-navbar-row`) around your element. Without `renderNavbar` nothing is rendered. The navbar's height comes from its content; it was a fixed 64px, 46px below `lg`.
|
|
157
|
-
- `editorCanvasClassNames` should not set a height.
|
|
158
|
-
- `zoomLevel`, `isNavbarVisible` and `isPreviewMode` are optional. Every UI state can be left out, or controlled with a value and an `onXChange` callback. The `setX` props still work and are deprecated.
|
|
159
|
-
- Your Tailwind build needs no config change. The new `ddoc-*` variants (container-query breakpoints that follow the editor's width) come from the `@fileverse-dev/ddoc/tailwind` preset you already use.
|
|
160
|
-
|
|
161
|
-
Behaviour that changes without a code change on your side:
|
|
162
|
-
|
|
163
|
-
- UI features that did nothing without their `setX` prop now work on internal state. The Split View toggle shows whenever live collaboration is off (it needed `setIsSplitView` before), and the comment drawer, the outline and presentation mode open without a setter. To keep one fixed, pass its value with no callback, for example `isPresentationMode={false}`. For Split View, `isSplitView={false}` keeps the editor out of Split View, but the toolbar toggle is still shown and does nothing.
|
|
164
|
-
- `onFocusModeChange` and the deprecated `onFocusMode` also fire when `isFocusMode` is not passed.
|
|
165
|
-
- `#editor-canvas` is now the document scroller (it carries `data-editor-scroll-container`), and the root (`.ddoc-editor-root`) is `overflow: hidden`.
|
|
166
|
-
- A navbar portalled with `navbarContainer` is positioned and layered by you; the editor only renders into the element. Focus mode and the toolbar's collapse toggle do not hide it: hide your own element from `onFocusModeChange` and `onNavbarVisibleChange` if you want that, or pass `showNavbarToggle={false}` to remove the collapse toggle.
|
|
167
|
-
- The toolbars no longer slide or fade when hidden; their rows are removed and the canvas takes the space. An in-flow navbar still slides up and fades over 300ms. For a portalled navbar the animation is yours: put `ddoc-navbar-row` on your element and add `ddoc-navbar-row--hidden` to collapse it.
|
|
168
|
-
- The mobile tab panel sits at the editor's bottom edge. It no longer adds `24px + env(safe-area-inset-bottom)`, so your footer must carry the safe-area inset.
|
|
169
|
-
- The editor's responsive classes use `:where()` in their window fallback, so they need Chrome 88+, Safari 14+ or Firefox 78+.
|
|
170
|
-
|
|
171
123
|
# dDocProps Interface
|
|
172
124
|
|
|
173
125
|
The `DdocProps` interface is a TypeScript interface that defines the properties for a page-related component. It includes properties for handling preview mode, managing publishing data, and optionally storing metadata and content associated with the page.
|
|
@@ -179,7 +131,7 @@ The `DdocProps` interface is a TypeScript interface that defines the properties
|
|
|
179
131
|
| `initialContent` | `JSONContent` | Initial content of the editor |
|
|
180
132
|
| `onChange` | `(changes: JSONContent, chunk?: any) => void` | Callback triggered on editor content changes |
|
|
181
133
|
| `ref` | `React.RefObject` | Reference to access editor instance |
|
|
182
|
-
| `isPreviewMode` | `boolean` | Controls if editor is in preview/read-only mode
|
|
134
|
+
| `isPreviewMode` | `boolean` | Controls if editor is in preview/read-only mode |
|
|
183
135
|
| `editorCanvasClassNames` | `string` | Additional CSS classes for editor canvas |
|
|
184
136
|
| `ignoreCorruptedData` | `boolean` | Whether to ignore corrupted data during loading |
|
|
185
137
|
| `onInvalidContentError` | `(error: any) => void` | Callback for handling invalid content errors |
|
|
@@ -199,41 +151,19 @@ The `DdocProps` interface is a TypeScript interface that defines the properties
|
|
|
199
151
|
|
|
200
152
|
## UI/UX Props
|
|
201
153
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
|
205
|
-
|
|
|
206
|
-
| `
|
|
207
|
-
| `
|
|
208
|
-
| `
|
|
209
|
-
| `
|
|
210
|
-
| `
|
|
211
|
-
| `
|
|
212
|
-
| `
|
|
213
|
-
| `
|
|
214
|
-
| `
|
|
215
|
-
| `renderThemeToggle` | `() => JSX.Element` | Custom theme toggle renderer |
|
|
216
|
-
| `showTOC` | `boolean` | Controls the outline |
|
|
217
|
-
| `onShowTOCChange` | `(show: boolean) => void` | Outline shown or hidden |
|
|
218
|
-
| `setShowTOC` | `React.Dispatch<SetStateAction<boolean>>` | Deprecated, use `onShowTOCChange` |
|
|
219
|
-
| `commentDrawerOpen` | `boolean` | Controls the comment drawer |
|
|
220
|
-
| `onCommentDrawerOpenChange` | `(open: boolean) => void` | Comment drawer opened or closed |
|
|
221
|
-
| `setCommentDrawerOpen` | `React.Dispatch<SetStateAction<boolean>>` | Deprecated, use `onCommentDrawerOpenChange` |
|
|
222
|
-
| `isPresentationMode` | `boolean` | Controls presentation mode |
|
|
223
|
-
| `onPresentationModeChange` | `(active: boolean) => void` | Presentation mode entered or left |
|
|
224
|
-
| `setIsPresentationMode` | `React.Dispatch<SetStateAction<boolean>>` | Deprecated, use `onPresentationModeChange` |
|
|
225
|
-
| `isSplitView` | `boolean` | Controls Split View |
|
|
226
|
-
| `onSplitViewChange` | `(active: boolean) => void` | Split View entered or left |
|
|
227
|
-
| `setIsSplitView` | `React.Dispatch<SetStateAction<boolean>>` | Deprecated, use `onSplitViewChange` |
|
|
228
|
-
| `isFocusMode` | `boolean` | Controls focus mode |
|
|
229
|
-
| `onFocusModeChange` | `(isFocusMode: boolean) => void` | Focus mode changed |
|
|
230
|
-
| `onFocusMode` | `(isFocusMode: boolean) => void` | Deprecated, use `onFocusModeChange` |
|
|
231
|
-
| `onStatsChange` | `(stats: { words; characters; selectedWords; pages: number \| null }) => void` | Active-tab stats; fires when any field changes. `pages` is `null` until measured |
|
|
232
|
-
| `setWordCount`, `setCharacterCount`, `setSelectedWordCount`, `setPageCount` | `React.Dispatch<SetStateAction<number>>` | Deprecated, use `onStatsChange` |
|
|
233
|
-
| `footerHeight` | `string` | Deprecated, no effect. Put the footer after the editor in normal flow |
|
|
234
|
-
| `sharedSlidesLink` | `string` | Link for shared presentation slides |
|
|
235
|
-
| `documentStyling` | `DocumentStyling` | Custom styling for document appearance |
|
|
236
|
-
| `fonts` | `FontDescriptor[]` | Consumer-provided font catalog (see Custom Fonts) |
|
|
154
|
+
| Property | Type | Description |
|
|
155
|
+
| ----------------------- | ----------------------------------------- | -------------------------------------- |
|
|
156
|
+
| `zoomLevel` | `string` | Current zoom level of the editor |
|
|
157
|
+
| `setZoomLevel` | `React.Dispatch<SetStateAction<string>>` | Function to update zoom level |
|
|
158
|
+
| `isNavbarVisible` | `boolean` | Controls navbar visibility |
|
|
159
|
+
| `setIsNavbarVisible` | `React.Dispatch<SetStateAction<boolean>>` | Function to toggle navbar visibility |
|
|
160
|
+
| `renderNavbar` | `() => JSX.Element` | Custom navbar renderer |
|
|
161
|
+
| `renderThemeToggle` | `() => JSX.Element` | Custom theme toggle renderer |
|
|
162
|
+
| `isPresentationMode` | `boolean` | Controls presentation mode |
|
|
163
|
+
| `setIsPresentationMode` | `React.Dispatch<SetStateAction<boolean>>` | Function to toggle presentation mode |
|
|
164
|
+
| `sharedSlidesLink` | `string` | Link for shared presentation slides |
|
|
165
|
+
| `documentStyling` | `DocumentStyling` | Custom styling for document appearance |
|
|
166
|
+
| `fonts` | `FontDescriptor[]` | Consumer-provided font catalog (see Custom Fonts) |
|
|
237
167
|
|
|
238
168
|
## Document Styling
|
|
239
169
|
|
|
@@ -353,8 +283,7 @@ const fonts: FontDescriptor[] = [
|
|
|
353
283
|
| `onCommentReply` | `(id: string, reply: IComment) => void` | Callback for comment replies |
|
|
354
284
|
| `onNewComment` | `(comment: IComment) => void` | Callback for new comments |
|
|
355
285
|
| `commentDrawerOpen` | `boolean` | Controls comment drawer visibility |
|
|
356
|
-
| `
|
|
357
|
-
| `setCommentDrawerOpen` | `(isOpen: boolean) => void` | Deprecated, use `onCommentDrawerOpenChange` |
|
|
286
|
+
| `setCommentDrawerOpen` | `(isOpen: boolean) => void` | Function to toggle comment drawer |
|
|
358
287
|
| `onResolveComment` | `(commentId: string) => void` | Callback when resolving comments |
|
|
359
288
|
| `onUnresolveComment` | `(commentId: string) => void` | Callback when unresolving comments |
|
|
360
289
|
| `onDeleteComment` | `(commentId: string) => void` | Callback when deleting comments |
|
|
@@ -374,9 +303,9 @@ const fonts: FontDescriptor[] = [
|
|
|
374
303
|
|
|
375
304
|
| Property | Type | Description |
|
|
376
305
|
| ------------------- | ------------------------------------------------------------------------ | ----------------------------------------- |
|
|
377
|
-
| `setCharacterCount` | `React.Dispatch<SetStateAction<number>>` |
|
|
378
|
-
| `setWordCount` | `React.Dispatch<SetStateAction<number>>` |
|
|
379
|
-
| `setPageCount` | `React.Dispatch<SetStateAction<number>>` |
|
|
306
|
+
| `setCharacterCount` | `React.Dispatch<SetStateAction<number>>` | Updates character count |
|
|
307
|
+
| `setWordCount` | `React.Dispatch<SetStateAction<number>>` | Updates word count |
|
|
308
|
+
| `setPageCount` | `React.Dispatch<SetStateAction<number>>` | Updates approx. export page count |
|
|
380
309
|
| `ensResolutionUrl` | `string` | URL for ENS name resolution |
|
|
381
310
|
| `ipfsImageUploadFn` | ` (file: File) => Promise<IpfsImageUploadResponse>` | function for secure image uploads |
|
|
382
311
|
| `ipfsImageFetchFn` | ` (_data: IpfsImageFetchPayload) => Promise<{ url: string;file: File;}>` | function for fetch secure image from IPFS |
|