@bendyline/squisq-editor-react 1.6.0 → 1.6.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.
Files changed (37) hide show
  1. package/README.md +57 -10
  2. package/dist/index.d.ts +401 -76
  3. package/dist/index.js +1334 -930
  4. package/dist/index.js.map +1 -1
  5. package/dist/styles/fa-brands-400-AHOAZHCU.woff2 +0 -0
  6. package/dist/styles/fa-regular-400-VRZYIBIZ.woff2 +0 -0
  7. package/dist/styles/fa-solid-900-MDEYK55F.woff2 +0 -0
  8. package/dist/styles/fa-v4compatibility-ETEVP6IB.woff2 +0 -0
  9. package/dist/styles/index.css +13867 -0
  10. package/package.json +15 -7
  11. package/src/EditorContext.tsx +22 -16
  12. package/src/EditorShell.tsx +68 -27
  13. package/src/OutlinePanel.tsx +26 -4
  14. package/src/PreviewControls.tsx +338 -141
  15. package/src/PreviewPanel.tsx +15 -9
  16. package/src/RawEditor.tsx +10 -4
  17. package/src/Toolbar.tsx +21 -11
  18. package/src/VersionHistoryPanel.tsx +2 -2
  19. package/src/__tests__/codeContextSectionView.test.tsx +95 -0
  20. package/src/__tests__/codeContextZoneManager.test.ts +127 -0
  21. package/src/__tests__/diffContextSections.test.ts +39 -0
  22. package/src/__tests__/editorShellCodeContext.test.tsx +86 -0
  23. package/src/__tests__/editorShellProps.test.tsx +96 -0
  24. package/src/__tests__/previewControls.test.tsx +70 -0
  25. package/src/__tests__/useJsonEditorTokens.test.ts +59 -0
  26. package/src/__tests__/useMediaRecorder.test.ts +17 -0
  27. package/src/codeContext/CodeContextSectionView.tsx +124 -0
  28. package/src/codeContext/CodeContextZoneManager.ts +149 -0
  29. package/src/codeContext/CodeContextZones.tsx +121 -0
  30. package/src/codeContext/diffContextSections.ts +38 -0
  31. package/src/codeContext/types.ts +75 -0
  32. package/src/index.ts +32 -1
  33. package/src/jsonEditor/useJsonEditorTokens.ts +13 -43
  34. package/src/recorder/hooks/useMediaRecorder.ts +9 -10
  35. package/src/styles/code-context.css +155 -0
  36. package/src/styles/editor.css +149 -3
  37. package/src/styles/index.css +1 -0
package/README.md CHANGED
@@ -11,9 +11,14 @@ Part of the [Squisq](https://github.com/bendyline/squisq) monorepo.
11
11
 
12
12
  ```bash
13
13
  npm install @bendyline/squisq-editor-react @bendyline/squisq @bendyline/squisq-react
14
+ # optional: add monaco-editor only if you use the Raw (Monaco) view
15
+ npm install monaco-editor
14
16
  ```
15
17
 
16
- **Peer dependencies:** `react` and `react-dom` (v18 or v19).
18
+ **Peer dependencies:** `react` and `react-dom` (v18 or v19). `monaco-editor`
19
+ (^0.50.0) is an **optional** peer dependency (v1.5) — install it only if you use
20
+ the Raw view; the WYSIWYG and Preview views work without it. Tiptap is bundled as
21
+ a regular dependency — you don't need to install it yourself.
17
22
 
18
23
  ## Quick Start
19
24
 
@@ -36,22 +41,58 @@ function App() {
36
41
 
37
42
  ## Components
38
43
 
39
- | Component | Description |
40
- | ---------------- | ---------------------------------------------------------------- |
41
- | `EditorShell` | Top-level editor — combines all three views with a view switcher |
42
- | `EditorProvider` | Context provider for editor state management |
44
+ | Component | Description |
45
+ | ---------------------------------------------------- | ---------------------------------------------------------------- |
46
+ | `EditorShell` | Top-level editor — combines all three views with a view switcher |
47
+ | `EditorProvider` | Context provider for editor state management |
48
+ | `RawEditor` / `WysiwygEditor` / `PreviewPanel` | The individual views, exported for custom layouts |
49
+ | `JsonEditor` | Editable form for JSON values bound to a Squisq-annotated schema |
50
+ | `ImageEditor` / `ImageViewer` | Layered raster authoring surface + read-only viewer |
51
+ | `RecorderPanel` / `RecorderButton` / `RecorderModal` | Browser audio/camera/screen recording (MediaRecorder) |
52
+ | `FolderView` | Standalone folder browser surface |
53
+
54
+ Beyond components, the package also exports Tiptap extensions (diagram editor,
55
+ heading template annotations), the markdown ↔ Tiptap bridge
56
+ (`markdownToTiptap` / `tiptapToMarkdown`), drag-and-drop helpers
57
+ (`useFileDrop`, `processMediaFiles`), file-kind detection (`resolveFileKind`),
58
+ and block-at-a-time / timeline editing primitives (`useBlockNavigator`,
59
+ `BlockCardView`, `TimelineTrack`).
60
+
61
+ ## Notable `EditorShell` features
62
+
63
+ - **Versioning** — pass `allowVersioning` + `workspaceContainer` to auto-save
64
+ snapshots on idle (`versioningAutoSaveIdleMs`, default 5000ms) with pruning
65
+ (`versioningPrunePolicy`, default keep-last-50); a Version History panel
66
+ appears in the toolbar.
67
+ - **Recording** — with a `mediaProvider` wired, a record button appears in the
68
+ toolbar (`allowRecording`, default `true`).
69
+ - **Panels** — `outline` (heading outline pane) and `inlinePreview` (per-block
70
+ SVG preview gutter, `inlinePreviewWidth` default 320).
71
+ - **Code & image modes** — pass `fileName` / `language` to get a Monaco-only
72
+ code editor, or `imageSrc` (+ `imageMode: 'edit'`) for the image surface.
73
+ - **Embedding** — `readOnly`, `placeholder`, `submitOnEnter`, `fullWidth`,
74
+ `thinMargins`, `minHeight`/`maxHeight` auto-grow for chat-composer use.
75
+ - **Color scheme** — pass `colorScheme="light" | "dark"` for the editor chrome
76
+ (**v1.5:** renamed from the old `theme` prop; `RawEditor`'s own `theme` prop is
77
+ now `monacoTheme`).
78
+
79
+ Also exported (v1.5): `useMonacoLoader` (share the load-once Monaco bootstrap),
80
+ and the custom theme / template provider stacks — `CustomThemeProvider` /
81
+ `useCustomThemes` / `useDocCustomThemes` and `CustomTemplateProvider` /
82
+ `useCustomTemplates` / `useDocCustomTemplates`.
43
83
 
44
84
  ## Context API
45
85
 
46
- Use `useEditorContext()` to access editor state and actions from child components:
86
+ Use `useEditorContext()` to access editor state and actions from child
87
+ components. The context value is flat — state fields and action methods live
88
+ side by side:
47
89
 
48
90
  ```tsx
49
- import { EditorProvider, useEditorContext } from '@bendyline/squisq-editor-react';
91
+ import { useEditorContext } from '@bendyline/squisq-editor-react';
50
92
 
51
93
  function MyComponent() {
52
- const { state, actions } = useEditorContext();
53
- // state.markdown, state.view, state.doc
54
- // actions.setMarkdown(), actions.setView()
94
+ const { markdownSource, doc, activeView, setMarkdownSource, setActiveView } = useEditorContext();
95
+ // markdownSource: string, doc: Doc | null, activeView: 'raw' | 'wysiwyg' | 'preview'
55
96
  }
56
97
  ```
57
98
 
@@ -63,6 +104,12 @@ Import the editor CSS:
63
104
  import '@bendyline/squisq-editor-react/styles';
64
105
  ```
65
106
 
107
+ ## Full API Reference
108
+
109
+ See [docs/API.md](https://github.com/bendyline/squisq/blob/main/docs/API.md)
110
+ for the complete `EditorShellProps` reference, context API, and every exported
111
+ component, hook, and helper.
112
+
66
113
  ## Related Packages
67
114
 
68
115
  | Package | Description |