@barocss/editor-view-react 0.1.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/LICENSE +23 -0
- package/README.md +89 -0
- package/dist/editor-view-react/src/EditorView.d.ts +14 -0
- package/dist/editor-view-react/src/EditorView.d.ts.map +1 -0
- package/dist/editor-view-react/src/EditorViewContentLayer.d.ts +9 -0
- package/dist/editor-view-react/src/EditorViewContentLayer.d.ts.map +1 -0
- package/dist/editor-view-react/src/EditorViewContext.d.ts +43 -0
- package/dist/editor-view-react/src/EditorViewContext.d.ts.map +1 -0
- package/dist/editor-view-react/src/EditorViewLayer.d.ts +8 -0
- package/dist/editor-view-react/src/EditorViewLayer.d.ts.map +1 -0
- package/dist/editor-view-react/src/EditorViewOverlayLayerContent.d.ts +14 -0
- package/dist/editor-view-react/src/EditorViewOverlayLayerContent.d.ts.map +1 -0
- package/dist/editor-view-react/src/dom-sync/classify-c1.d.ts +45 -0
- package/dist/editor-view-react/src/dom-sync/classify-c1.d.ts.map +1 -0
- package/dist/editor-view-react/src/dom-sync/edit-position.d.ts +6 -0
- package/dist/editor-view-react/src/dom-sync/edit-position.d.ts.map +1 -0
- package/dist/editor-view-react/src/index.d.ts +12 -0
- package/dist/editor-view-react/src/index.d.ts.map +1 -0
- package/dist/editor-view-react/src/input-handler.d.ts +51 -0
- package/dist/editor-view-react/src/input-handler.d.ts.map +1 -0
- package/dist/editor-view-react/src/mutation-observer-manager.d.ts +13 -0
- package/dist/editor-view-react/src/mutation-observer-manager.d.ts.map +1 -0
- package/dist/editor-view-react/src/selection-handler.d.ts +56 -0
- package/dist/editor-view-react/src/selection-handler.d.ts.map +1 -0
- package/dist/editor-view-react/src/types.d.ts +103 -0
- package/dist/editor-view-react/src/types.d.ts.map +1 -0
- package/dist/index.cjs +4 -0
- package/dist/index.js +11882 -0
- package/docs/SPEC_VERIFICATION.md +109 -0
- package/docs/editor-view-react-spec.md +359 -0
- package/docs/improvement-opportunities.md +66 -0
- package/docs/layers-spec.md +97 -0
- package/package.json +53 -0
- package/src/EditorView.tsx +312 -0
- package/src/EditorViewContentLayer.tsx +90 -0
- package/src/EditorViewContext.tsx +228 -0
- package/src/EditorViewLayer.tsx +35 -0
- package/src/EditorViewOverlayLayerContent.tsx +42 -0
- package/src/dom-sync/classify-c1.ts +91 -0
- package/src/dom-sync/edit-position.ts +27 -0
- package/src/index.ts +33 -0
- package/src/input-handler.ts +716 -0
- package/src/mutation-observer-manager.ts +65 -0
- package/src/selection-handler.ts +450 -0
- package/src/types.ts +123 -0
- package/test/EditorView-decorator.test.tsx +198 -0
- package/test/EditorView-layers.test.tsx +352 -0
- package/test/EditorView.test.tsx +218 -0
- package/test/dom-sync.test.ts +49 -0
- package/test/mutation-observer-manager.test.ts +48 -0
- package/test/selection-handler.test.ts +86 -0
- package/tsconfig.json +12 -0
- package/vite.config.ts +26 -0
- package/vitest.config.ts +10 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 BaroCSS contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# @barocss/editor-view-react
|
|
2
|
+
|
|
3
|
+
React view layer for Barocss Editor. Renders the editor document with **renderer-react** and re-renders on `editor:content.change`. editor-view-dom의 React 대응 패키지.
|
|
4
|
+
|
|
5
|
+
## EditorView (composite)
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Editor } from '@barocss/editor-core';
|
|
9
|
+
import { EditorView } from '@barocss/editor-view-react';
|
|
10
|
+
|
|
11
|
+
<EditorView
|
|
12
|
+
editor={editor}
|
|
13
|
+
options={{
|
|
14
|
+
className: 'editor-view-root',
|
|
15
|
+
layers: {
|
|
16
|
+
content: { className: 'document editor-content', editable: true },
|
|
17
|
+
decorator: { className: 'barocss-editor-decorators' },
|
|
18
|
+
selection: { className: 'barocss-editor-selection' },
|
|
19
|
+
context: { className: 'barocss-editor-context' },
|
|
20
|
+
custom: { className: 'barocss-editor-custom' },
|
|
21
|
+
},
|
|
22
|
+
}}
|
|
23
|
+
>
|
|
24
|
+
{/* optional: custom layer content */}
|
|
25
|
+
</EditorView>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Layer components (composable)
|
|
29
|
+
|
|
30
|
+
Layers can be used separately for custom composition (must be inside `EditorView` or `EditorViewContextProvider` so editor comes from context):
|
|
31
|
+
|
|
32
|
+
- **EditorView.ContentLayer** — Renders document with ReactRenderer in a contenteditable div. Subscribes to `editor:content.change`. Editor from context only.
|
|
33
|
+
- **EditorView.Layer** — Overlay layer wrapper (decorator, selection, context, custom). Positioned absolute, `pointer-events: none` by default.
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { EditorView } from '@barocss/editor-view-react';
|
|
37
|
+
|
|
38
|
+
<div style={{ position: 'relative' }}>
|
|
39
|
+
<EditorView.ContentLayer options={{ className: 'content', editable: true }} />
|
|
40
|
+
<EditorView.Layer layer="decorator" className="my-decorators" />
|
|
41
|
+
<EditorView.Layer layer="selection" />
|
|
42
|
+
<EditorView.Layer layer="custom">
|
|
43
|
+
<MyCustomOverlay />
|
|
44
|
+
</EditorView.Layer>
|
|
45
|
+
</div>
|
|
46
|
+
```
|
|
47
|
+
(When using layers outside `<EditorView>`, wrap with `<EditorViewContextProvider editor={editor}>`.)
|
|
48
|
+
|
|
49
|
+
## API
|
|
50
|
+
|
|
51
|
+
- **EditorView** — Composite view. Props: `editor`, `options?` (registry, className, layers), `children?` (custom layer content). Supports `ref` for imperative handle (EditorViewHandle).
|
|
52
|
+
- **EditorView.ContentLayer** — Props: `options?` (registry, className, editable). Editor is from EditorViewContext (use inside EditorView).
|
|
53
|
+
- **EditorView.Layer** — Props: `layer` ('decorator' | 'selection' | 'context' | 'custom'), `className?`, `style?`, `children?`.
|
|
54
|
+
|
|
55
|
+
**Ref API (EditorViewHandle)** — When using `ref` on EditorView: `addDecorator(Decorator | DecoratorGenerator)`, `removeDecorator`, `updateDecorator`, `getDecorators(options?)`, `getDecorator`, `exportDecorators`, `loadDecorators`, `contentEditableElement`, `convertModelSelectionToDOM`, `convertDOMSelectionToModel`, `convertStaticRangeToModel`, `defineDecoratorType`, and refs to `decoratorManager`, `remoteDecoratorManager`, `patternDecoratorConfigManager`, `decoratorGeneratorManager`. See editor-view-react-spec.md § 3.3.
|
|
56
|
+
|
|
57
|
+
## Docs
|
|
58
|
+
|
|
59
|
+
- **editor-view-react-spec.md** — API, context, layers, selection/input flow, tests.
|
|
60
|
+
- **layers-spec.md** — Layer roles (content, decorator, selection, context, custom) and `layerTarget` routing; how to use selection/context/custom layers.
|
|
61
|
+
|
|
62
|
+
## Requirements
|
|
63
|
+
|
|
64
|
+
- **Editor** from `@barocss/editor-core` (with `getDocumentProxy()`, `on`/`off` for `editor:content.change`).
|
|
65
|
+
- **define()** templates (document, paragraph, inline-text, etc.) in the same registry used by the content layer.
|
|
66
|
+
|
|
67
|
+
## Testing
|
|
68
|
+
|
|
69
|
+
Unit tests (Vitest, jsdom, @testing-library/react):
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pnpm --filter @barocss/editor-view-react test:run
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Tests cover: EditorView and EditorViewLayer (root, content layer, overlay layers, children), EditorViewContext (Provider value, useEditorViewContext throw, useOptionalEditorViewContext), ReactSelectionHandler (isSelectionInsideEditableText, setProgrammaticChange), ReactMutationObserverManager (setup/disconnect, batch), dom-sync (findClosestInlineTextNode, reconstructModelTextFromDOM). See `packages/editor-view-react/docs/editor-view-react-spec.md` and `docs/SPEC_VERIFICATION.md`.
|
|
76
|
+
|
|
77
|
+
To run the React app that uses EditorView:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pnpm --filter @barocss/editor-react dev
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## See also
|
|
84
|
+
|
|
85
|
+
- **packages/editor-view-react/docs/editor-view-react-spec.md** — Full spec: goals, architecture, API, context, layers, selection/input, DOM sync, MutationObserver, test strategy.
|
|
86
|
+
- **packages/editor-view-react/docs/SPEC_VERIFICATION.md** — Spec vs implementation verification and checklist.
|
|
87
|
+
- **packages/renderer-react** — DSL → ReactNode.
|
|
88
|
+
- **packages/editor-view-dom** — DOM view layer (EditorViewDOM).
|
|
89
|
+
- **docs/renderer-react-and-editor-react.md** — Design.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EditorViewProps, EditorViewOverlayLayerProps } from './types';
|
|
2
|
+
import { EditorViewContentLayer } from './EditorViewContentLayer';
|
|
3
|
+
import { EditorViewLayer } from './EditorViewLayer';
|
|
4
|
+
|
|
5
|
+
/** EditorView with ref (addDecorator, removeDecorator, getDecorators) and static layer components. */
|
|
6
|
+
export declare const EditorView: import('react').ForwardRefExoticComponent<EditorViewProps & import('react').RefAttributes<import('./types').EditorViewHandle>> & {
|
|
7
|
+
ContentLayer: typeof EditorViewContentLayer;
|
|
8
|
+
DecoratorLayer: ({ className, style, children }: EditorViewOverlayLayerProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
SelectionLayer: ({ className, style, children }: EditorViewOverlayLayerProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
ContextLayer: ({ className, style, children }: EditorViewOverlayLayerProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
CustomLayer: ({ className, style, children }: EditorViewOverlayLayerProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
Layer: typeof EditorViewLayer;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=EditorView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorView.d.ts","sourceRoot":"","sources":["../../../src/EditorView.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,2BAA2B,EAK5B,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAmSpD,sGAAsG;AACtG,eAAO,MAAM,UAAU;;qDAVwC,2BAA2B;qDAA3B,2BAA2B;mDAA3B,2BAA2B;kDAA3B,2BAA2B;;CAiBxF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EditorViewContentLayerProps } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* EditorViewContentLayer: renders the editor document with ReactRenderer in a contenteditable div.
|
|
5
|
+
* Subscribes to editor:content.change and editor:selection.model.
|
|
6
|
+
* Must be used inside EditorView (EditorViewContextProvider); editor is taken from context only.
|
|
7
|
+
*/
|
|
8
|
+
export declare function EditorViewContentLayer({ options }: EditorViewContentLayerProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=EditorViewContentLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorViewContentLayer.d.ts","sourceRoot":"","sources":["../../../src/EditorViewContentLayer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE3D;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,OAAY,EAAE,EAAE,2BAA2B,2CA8EnF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Editor } from '../../editor-core/src';
|
|
3
|
+
import { Decorator, DecoratorManager, RemoteDecoratorManager, PatternDecoratorConfigManager, DecoratorGeneratorManager, DecoratorSchemaRegistry } from '@barocss/shared';
|
|
4
|
+
import { ReactSelectionHandler } from './selection-handler';
|
|
5
|
+
import { ReactInputHandler } from './input-handler';
|
|
6
|
+
import { ReactMutationObserverManager } from './mutation-observer-manager';
|
|
7
|
+
|
|
8
|
+
export interface EditorViewViewState {
|
|
9
|
+
isModelDrivenChange: boolean;
|
|
10
|
+
isRendering: boolean;
|
|
11
|
+
isComposing: boolean;
|
|
12
|
+
/** When true, next editor:content.change (from model commit during MO C1) must not trigger refresh (data-only update). */
|
|
13
|
+
skipNextRenderFromMO: boolean;
|
|
14
|
+
/** When true, editor:selection.model must not call convertModelSelectionToDOM (selection came from DOM input; leave DOM selection as-is). */
|
|
15
|
+
skipApplyModelSelectionToDOM: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface EditorViewContextValue {
|
|
18
|
+
editor: Editor;
|
|
19
|
+
viewStateRef: React.MutableRefObject<EditorViewViewState>;
|
|
20
|
+
selectionHandler: ReactSelectionHandler;
|
|
21
|
+
inputHandler: ReactInputHandler;
|
|
22
|
+
mutationObserverManager: ReactMutationObserverManager;
|
|
23
|
+
setContentEditableElement: (el: HTMLElement | null) => void;
|
|
24
|
+
/** Ref to content-editable root (set by ContentLayer on mount). */
|
|
25
|
+
contentEditableRef: React.RefObject<HTMLElement | null>;
|
|
26
|
+
decoratorManagerRef: React.RefObject<DecoratorManager | null>;
|
|
27
|
+
decoratorSchemaRegistryRef: React.RefObject<DecoratorSchemaRegistry | null>;
|
|
28
|
+
remoteDecoratorManagerRef: React.RefObject<RemoteDecoratorManager | null>;
|
|
29
|
+
patternDecoratorConfigManagerRef: React.RefObject<PatternDecoratorConfigManager | null>;
|
|
30
|
+
decoratorGeneratorManagerRef: React.RefObject<DecoratorGeneratorManager | null>;
|
|
31
|
+
getMergedDecorators: (model: unknown) => Decorator[];
|
|
32
|
+
bumpDecoratorVersion: () => void;
|
|
33
|
+
decoratorVersion: number;
|
|
34
|
+
}
|
|
35
|
+
declare const EditorViewContext: import('react').Context<EditorViewContextValue | null>;
|
|
36
|
+
export declare function useEditorViewContext(): EditorViewContextValue;
|
|
37
|
+
export declare function useOptionalEditorViewContext(): EditorViewContextValue | null;
|
|
38
|
+
export declare function EditorViewContextProvider({ editor, children }: {
|
|
39
|
+
editor: Editor;
|
|
40
|
+
children: ReactNode;
|
|
41
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export { EditorViewContext };
|
|
43
|
+
//# sourceMappingURL=EditorViewContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorViewContext.d.ts","sourceRoot":"","sources":["../../../src/EditorViewContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgF,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACrH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,6BAA6B,E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;IAChF,mBAAmB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;IACrD,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,QAAA,MAAM,iBAAiB,wDAAqD,CAAC;AAE7E,wBAAgB,oBAAoB,IAAI,sBAAsB,CAM7D;AAED,wBAAgB,4BAA4B,IAAI,sBAAsB,GAAG,IAAI,CAE5E;AAED,wBAAgB,yBAAyB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAoKtG;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EditorViewLayerProps } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Overlay layer wrapper (decorator, selection, context, custom).
|
|
5
|
+
* Positioned absolute, pointer-events: none by default so content layer receives input.
|
|
6
|
+
*/
|
|
7
|
+
export declare function EditorViewLayer({ layer, className, style, children }: EditorViewLayerProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=EditorViewLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorViewLayer.d.ts","sourceRoot":"","sources":["../../../src/EditorViewLayer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AASpD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,oBAAoB,2CAqB1F"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EditorViewLayerType } from './types';
|
|
2
|
+
|
|
3
|
+
export interface EditorViewOverlayLayerContentProps {
|
|
4
|
+
/** Layer to render (decorator, selection, context, custom). Only decorators with layerTarget === layer are rendered. */
|
|
5
|
+
layer: Exclude<EditorViewLayerType, 'content'>;
|
|
6
|
+
/** Registry for resolving decorator templates. If omitted, uses getGlobalRegistry(). */
|
|
7
|
+
registry?: import('../../dsl/src').RendererRegistry;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Renders overlay layer content by filtering merged decorators by layerTarget and building them with ReactRenderer.buildOverlayDecorators.
|
|
11
|
+
* Uses getMergedDecorators(document) so remote, pattern, and generator decorators are included.
|
|
12
|
+
*/
|
|
13
|
+
export declare function EditorViewOverlayLayerContent({ layer, registry: registryProp }: EditorViewOverlayLayerContentProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=EditorViewOverlayLayerContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorViewOverlayLayerContent.d.ts","sourceRoot":"","sources":["../../../src/EditorViewOverlayLayerContent.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,WAAW,kCAAkC;IACjD,wHAAwH;IACxH,KAAK,EAAE,OAAO,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;IAC/C,wFAAwF;IACxF,QAAQ,CAAC,EAAE,OAAO,cAAc,EAAE,gBAAgB,CAAC;CACpD;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,kCAAkC,2CAwBlH"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Editor } from '../../../editor-core/src';
|
|
2
|
+
|
|
3
|
+
export interface ClassifiedChangeC1 {
|
|
4
|
+
case: 'C1';
|
|
5
|
+
nodeId: string;
|
|
6
|
+
prevText: string;
|
|
7
|
+
newText: string;
|
|
8
|
+
contentRange?: {
|
|
9
|
+
startNodeId: string;
|
|
10
|
+
startOffset: number;
|
|
11
|
+
endNodeId: string;
|
|
12
|
+
endOffset: number;
|
|
13
|
+
};
|
|
14
|
+
mutations: MutationRecord[];
|
|
15
|
+
metadata?: {
|
|
16
|
+
usedInputHint?: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface InputHint {
|
|
20
|
+
contentRange: {
|
|
21
|
+
startNodeId: string;
|
|
22
|
+
startOffset: number;
|
|
23
|
+
endNodeId: string;
|
|
24
|
+
endOffset: number;
|
|
25
|
+
};
|
|
26
|
+
timestamp: number;
|
|
27
|
+
}
|
|
28
|
+
export interface ClassifyOptions {
|
|
29
|
+
editor: Editor;
|
|
30
|
+
selection?: Selection;
|
|
31
|
+
modelSelection?: {
|
|
32
|
+
startNodeId: string;
|
|
33
|
+
startOffset: number;
|
|
34
|
+
endNodeId: string;
|
|
35
|
+
endOffset: number;
|
|
36
|
+
};
|
|
37
|
+
inputHint?: InputHint;
|
|
38
|
+
isComposing?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export type ClassifiedChange = ClassifiedChangeC1 | {
|
|
41
|
+
case: 'UNKNOWN';
|
|
42
|
+
mutations: MutationRecord[];
|
|
43
|
+
};
|
|
44
|
+
export declare function classifyDomChangeC1(mutations: MutationRecord[], options: ClassifyOptions): ClassifiedChangeC1 | null;
|
|
45
|
+
//# sourceMappingURL=classify-c1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classify-c1.d.ts","sourceRoot":"","sources":["../../../../src/dom-sync/classify-c1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAClG,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACxC;AAED,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACjG,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,cAAc,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACpG,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,cAAc,EAAE,CAAA;CAAE,CAAC;AAErG,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,cAAc,EAAE,EAC3B,OAAO,EAAE,eAAe,GACvB,kBAAkB,GAAG,IAAI,CAuD3B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function findClosestInlineTextNode(node: Node): Element | null;
|
|
2
|
+
/**
|
|
3
|
+
* Reconstruct full text of an inline-text container from DOM (all text nodes in order).
|
|
4
|
+
*/
|
|
5
|
+
export declare function reconstructModelTextFromDOM(inlineTextNode: Element): string;
|
|
6
|
+
//# sourceMappingURL=edit-position.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-position.d.ts","sourceRoot":"","sources":["../../../../src/dom-sync/edit-position.ts"],"names":[],"mappings":"AAMA,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,GAAG,IAAI,CAUpE;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM,CAK3E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @barocss/editor-view-react
|
|
3
|
+
* React view layer for Barocss Editor (Editor + ReactRenderer).
|
|
4
|
+
*/
|
|
5
|
+
export { EditorView } from './EditorView';
|
|
6
|
+
export { EditorViewContentLayer } from './EditorViewContentLayer';
|
|
7
|
+
export { EditorViewLayer } from './EditorViewLayer';
|
|
8
|
+
export { EditorViewContextProvider, useEditorViewContext, useOptionalEditorViewContext, type EditorViewViewState, type EditorViewContextValue, } from './EditorViewContext';
|
|
9
|
+
export { createMutationObserverManager } from './mutation-observer-manager';
|
|
10
|
+
export type { ReactMutationObserverManager } from './mutation-observer-manager';
|
|
11
|
+
export type { EditorViewOptions, EditorViewProps, EditorViewRef, EditorViewHandle, DecoratorExportData, LoadDecoratorsPatternFunctions, DecoratorQueryOptions, DecoratorTypeSchema, ModelSelection, EditorViewContentLayerOptions, EditorViewContentLayerProps, EditorViewLayerOptions, EditorViewLayerProps, EditorViewLayersConfig, EditorViewLayerType, } from './types';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,4BAA4B,EAC5B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,YAAY,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAChF,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,8BAA8B,EAC9B,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,6BAA6B,EAC7B,2BAA2B,EAC3B,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
import { Editor } from '../../editor-core/src';
|
|
3
|
+
import { ReactSelectionHandler } from './selection-handler';
|
|
4
|
+
import { EditorViewViewState } from './EditorViewContext';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Input handler for React editor view: beforeinput/keydown handling and model updates.
|
|
8
|
+
* Uses ReactSelectionHandler for DOM↔model selection. Does not depend on editor-view-dom.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ReactInputHandler {
|
|
11
|
+
private editor;
|
|
12
|
+
private selectionHandler;
|
|
13
|
+
private viewStateRef;
|
|
14
|
+
private _isComposing;
|
|
15
|
+
private _pendingInsertHint;
|
|
16
|
+
constructor(editor: Editor, selectionHandler: ReactSelectionHandler, viewStateRef: MutableRefObject<EditorViewViewState>);
|
|
17
|
+
/** Set IME composition state. Called from compositionstart/compositionend so keydown/beforeinput see it early. */
|
|
18
|
+
setComposing(isComposing: boolean): void;
|
|
19
|
+
/**
|
|
20
|
+
* Sync model to DOM for the focused inline-text node. Call once after compositionend so the final composed text is applied (no intermediate C1).
|
|
21
|
+
*/
|
|
22
|
+
syncFocusedTextNodeAfterComposition(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Called from MutationObserver (same role as editor-view-dom InputHandler.handleDomMutations).
|
|
25
|
+
* Classifies DOM changes (C1 for single-node text) and updates model; emit editor:content.change with skipRender.
|
|
26
|
+
* During IME composition we skip C1 and sync once on compositionend via syncFocusedTextNodeAfterComposition.
|
|
27
|
+
* Set skipNextRenderFromMO so the model's content.change (no skipRender) does not trigger React refresh (data-only update).
|
|
28
|
+
*/
|
|
29
|
+
handleDomMutations(mutations: MutationRecord[]): Promise<void>;
|
|
30
|
+
private handleDomMutationsInner;
|
|
31
|
+
private getValidInsertHint;
|
|
32
|
+
private handleC1;
|
|
33
|
+
handleBeforeInput(event: InputEvent): void;
|
|
34
|
+
private updateInsertHintFromBeforeInput;
|
|
35
|
+
/**
|
|
36
|
+
* Keydown: keybindings only (Enter, Backspace, Delete, etc.). Do not insert characters here so IME works.
|
|
37
|
+
* Character input is handled in beforeinput via tryHandleInsertViaGetTargetRanges (non-IME) or MutationObserver (IME).
|
|
38
|
+
*/
|
|
39
|
+
handleKeydown(event: KeyboardEvent): void;
|
|
40
|
+
private insertTextAtSelection;
|
|
41
|
+
private tryHandleInsertViaGetTargetRanges;
|
|
42
|
+
private applyModelSelectionAfterRender;
|
|
43
|
+
private handleDelete;
|
|
44
|
+
private calculateDeleteRange;
|
|
45
|
+
private calculateCrossNodeDeleteRange;
|
|
46
|
+
private executeStructuralCommand;
|
|
47
|
+
private insertParagraph;
|
|
48
|
+
private insertText;
|
|
49
|
+
private executeFormatCommand;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=input-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-handler.d.ts","sourceRoot":"","sources":["../../../src/input-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAGjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAkC/D;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAwB;IAChD,OAAO,CAAC,YAAY,CAAwC;IAC5D,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,kBAAkB,CAA0B;gBAGlD,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,qBAAqB,EACvC,YAAY,EAAE,gBAAgB,CAAC,mBAAmB,CAAC;IAOrD,kHAAkH;IAClH,YAAY,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI;IAKxC;;OAEG;IACG,mCAAmC,IAAI,OAAO,CAAC,IAAI,CAAC;IAwE1D;;;;;OAKG;IACG,kBAAkB,CAAC,SAAS,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;YAatD,uBAAuB;IAkCrC,OAAO,CAAC,kBAAkB;YAQZ,QAAQ;IAwEtB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAqC1C,OAAO,CAAC,+BAA+B;IA0BvC;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAkCzC,OAAO,CAAC,qBAAqB;IA6B7B,OAAO,CAAC,iCAAiC;IA+DzC,OAAO,CAAC,8BAA8B;YAQxB,YAAY;IAyD1B,OAAO,CAAC,oBAAoB;IAyD5B,OAAO,CAAC,6BAA6B;IA2DrC,OAAO,CAAC,wBAAwB;IAiBhC,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,oBAAoB;CAa7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MutationObserver manager for editor-view-react.
|
|
3
|
+
* Observes contentEditableElement and calls onMutations (e.g. inputHandler.handleDomMutations).
|
|
4
|
+
* Same role as editor-view-dom's MutationObserverManagerImpl; does not depend on editor-view-dom.
|
|
5
|
+
*/
|
|
6
|
+
export interface ReactMutationObserverManager {
|
|
7
|
+
setup(contentEditableElement: HTMLElement): void;
|
|
8
|
+
disconnect(): void;
|
|
9
|
+
}
|
|
10
|
+
type OnMutations = (mutations: MutationRecord[]) => void;
|
|
11
|
+
export declare function createMutationObserverManager(onMutations: OnMutations): ReactMutationObserverManager;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=mutation-observer-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation-observer-manager.d.ts","sourceRoot":"","sources":["../../../src/mutation-observer-manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,KAAK,CAAC,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IACjD,UAAU,IAAI,IAAI,CAAC;CACpB;AAED,KAAK,WAAW,GAAG,CAAC,SAAS,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;AAEzD,wBAAgB,6BAA6B,CAAC,WAAW,EAAE,WAAW,GAAG,4BAA4B,CAoDpG"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Editor } from '../../editor-core/src';
|
|
2
|
+
|
|
3
|
+
export type ModelSelection = {
|
|
4
|
+
type: 'none';
|
|
5
|
+
} | {
|
|
6
|
+
type: 'range';
|
|
7
|
+
startNodeId: string;
|
|
8
|
+
startOffset: number;
|
|
9
|
+
endNodeId: string;
|
|
10
|
+
endOffset: number;
|
|
11
|
+
direction?: 'forward' | 'backward' | 'none';
|
|
12
|
+
} | {
|
|
13
|
+
type: 'node';
|
|
14
|
+
nodeId: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Selection handler for React editor view: converts DOM Selection to/from model selection
|
|
18
|
+
* using renderer-dom text run index. Does not depend on editor-view-dom.
|
|
19
|
+
*/
|
|
20
|
+
export declare class ReactSelectionHandler {
|
|
21
|
+
private editor;
|
|
22
|
+
private getContentEditableElement;
|
|
23
|
+
private _isProgrammaticChange;
|
|
24
|
+
constructor(editor: Editor, getContentEditableElement: () => HTMLElement | null);
|
|
25
|
+
setProgrammaticChange(value: boolean): void;
|
|
26
|
+
/**
|
|
27
|
+
* Returns true if the given (or current) selection is entirely inside inline-text nodes.
|
|
28
|
+
* Used to restrict character input to editable text only (same as editor-view-dom).
|
|
29
|
+
*/
|
|
30
|
+
isSelectionInsideEditableText(domSelection?: Selection | null): boolean;
|
|
31
|
+
handleSelectionChange(): void;
|
|
32
|
+
convertDOMSelectionToModel(selection: Selection): ModelSelection;
|
|
33
|
+
convertStaticRangeToModel(staticRange: StaticRange): {
|
|
34
|
+
type: 'range';
|
|
35
|
+
startNodeId: string;
|
|
36
|
+
startOffset: number;
|
|
37
|
+
endNodeId: string;
|
|
38
|
+
endOffset: number;
|
|
39
|
+
direction?: 'forward';
|
|
40
|
+
} | null;
|
|
41
|
+
private convertRangeBoundariesToModel;
|
|
42
|
+
private isTextContainer;
|
|
43
|
+
private nodeExistsInModel;
|
|
44
|
+
private findClosestDataNode;
|
|
45
|
+
private findBestContainer;
|
|
46
|
+
private ensureRuns;
|
|
47
|
+
private convertOffsetWithRuns;
|
|
48
|
+
private findTextAtElementBoundary;
|
|
49
|
+
private determineSelectionDirection;
|
|
50
|
+
convertModelSelectionToDOM(modelSelection: ModelSelection | null | undefined): void;
|
|
51
|
+
private convertRangeSelectionToDOM;
|
|
52
|
+
private convertNodeSelectionToDOM;
|
|
53
|
+
private getTextRunsForContainer;
|
|
54
|
+
private findDOMRangeFromModelOffset;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=selection-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection-handler.d.ts","sourceRoot":"","sources":["../../../src/selection-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAQnD,MAAM,MAAM,cA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AyB;IA2BjC,OAAO,CAAC,2BAA2B;IA+BnC,0BAA0B,CAAC,cAAc,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI;IAmBnF,OAAO,CAAC,0BAA0B;IA2ClC,OAAO,CAAC,yBAAyB;IAajC,OAAO,CAAC,uBAAuB;IAgB/B,OAAO,CAAC,2BAA2B;CAwBpC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Editor } from '../../editor-core/src';
|
|
2
|
+
import { RendererRegistry } from '../../dsl/src';
|
|
3
|
+
import { Decorator, DecoratorGenerator, DecoratorManager, RemoteDecoratorManager, PatternDecoratorConfigManager, DecoratorGeneratorManager, DecoratorExportData, LoadDecoratorsPatternFunctions, DecoratorQueryOptions, DecoratorTypeSchema } from '@barocss/shared';
|
|
4
|
+
|
|
5
|
+
export type { DecoratorExportData, LoadDecoratorsPatternFunctions, DecoratorQueryOptions, DecoratorTypeSchema };
|
|
6
|
+
/** Model selection type for convert* APIs. */
|
|
7
|
+
export type ModelSelection = {
|
|
8
|
+
type: 'none';
|
|
9
|
+
} | {
|
|
10
|
+
type: 'range';
|
|
11
|
+
startNodeId: string;
|
|
12
|
+
startOffset: number;
|
|
13
|
+
endNodeId: string;
|
|
14
|
+
endOffset: number;
|
|
15
|
+
direction?: 'forward' | 'backward' | 'none';
|
|
16
|
+
} | {
|
|
17
|
+
type: 'node';
|
|
18
|
+
nodeId: string;
|
|
19
|
+
};
|
|
20
|
+
/** Imperative handle for EditorView: decorator management and selection/convenience APIs. */
|
|
21
|
+
export interface EditorViewHandle {
|
|
22
|
+
addDecorator(decorator: Decorator | DecoratorGenerator): void;
|
|
23
|
+
removeDecorator(id: string): void;
|
|
24
|
+
updateDecorator(id: string, updates: Partial<Decorator>): void;
|
|
25
|
+
getDecorators(options?: DecoratorQueryOptions): Decorator[];
|
|
26
|
+
getDecorator(id: string): Decorator | undefined;
|
|
27
|
+
exportDecorators(): DecoratorExportData;
|
|
28
|
+
loadDecorators(data: DecoratorExportData, patternFunctions?: LoadDecoratorsPatternFunctions): void;
|
|
29
|
+
/** Content-editable root element (null until mounted). */
|
|
30
|
+
contentEditableElement: HTMLElement | null;
|
|
31
|
+
convertModelSelectionToDOM(sel: ModelSelection | null | undefined): void;
|
|
32
|
+
convertDOMSelectionToModel(selection: Selection): ModelSelection;
|
|
33
|
+
/** Converts a StaticRange (e.g. from getRangeAt) to model selection, or null if not resolvable. */
|
|
34
|
+
convertStaticRangeToModel(staticRange: StaticRange): ModelSelection | null;
|
|
35
|
+
defineDecoratorType(type: string, category: 'layer' | 'inline' | 'block', schema: DecoratorTypeSchema): void;
|
|
36
|
+
decoratorManager: DecoratorManager | null;
|
|
37
|
+
remoteDecoratorManager: RemoteDecoratorManager | null;
|
|
38
|
+
patternDecoratorConfigManager: PatternDecoratorConfigManager | null;
|
|
39
|
+
decoratorGeneratorManager: DecoratorGeneratorManager | null;
|
|
40
|
+
}
|
|
41
|
+
export type EditorViewLayerType = 'decorator' | 'selection' | 'context' | 'custom';
|
|
42
|
+
/** Options for the content layer (document rendering). Decorators are managed internally; use ref.addDecorator / ref.getDecorators. */
|
|
43
|
+
export interface EditorViewContentLayerOptions {
|
|
44
|
+
/** Renderer registry. If omitted, uses getGlobalRegistry(). */
|
|
45
|
+
registry?: RendererRegistry;
|
|
46
|
+
/** Class name for the contenteditable wrapper. */
|
|
47
|
+
className?: string;
|
|
48
|
+
/** Whether the content is editable. Default true. */
|
|
49
|
+
editable?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** Options for overlay layers (decorator, selection, context, custom). */
|
|
52
|
+
export interface EditorViewLayerOptions {
|
|
53
|
+
/** Class name for the layer wrapper. */
|
|
54
|
+
className?: string;
|
|
55
|
+
/** Inline styles. */
|
|
56
|
+
style?: React.CSSProperties;
|
|
57
|
+
}
|
|
58
|
+
/** Layer configuration for EditorView (optional per-layer classNames/styles). */
|
|
59
|
+
export interface EditorViewLayersConfig {
|
|
60
|
+
content?: EditorViewContentLayerOptions;
|
|
61
|
+
decorator?: EditorViewLayerOptions;
|
|
62
|
+
selection?: EditorViewLayerOptions;
|
|
63
|
+
context?: EditorViewLayerOptions;
|
|
64
|
+
custom?: EditorViewLayerOptions;
|
|
65
|
+
}
|
|
66
|
+
export interface EditorViewOptions {
|
|
67
|
+
/** Renderer registry (used by content layer if layers.content not set). */
|
|
68
|
+
registry?: RendererRegistry;
|
|
69
|
+
/** Class name for the root container. */
|
|
70
|
+
className?: string;
|
|
71
|
+
/** Per-layer configuration. */
|
|
72
|
+
layers?: EditorViewLayersConfig;
|
|
73
|
+
}
|
|
74
|
+
export interface EditorViewProps {
|
|
75
|
+
/** Editor instance. */
|
|
76
|
+
editor: Editor;
|
|
77
|
+
/** Optional options (registry, className, layers). */
|
|
78
|
+
options?: EditorViewOptions;
|
|
79
|
+
/** Optional children (e.g. custom layer content). Rendered inside the custom layer slot when present. */
|
|
80
|
+
children?: React.ReactNode;
|
|
81
|
+
}
|
|
82
|
+
/** EditorView ref type (when using forwardRef). Exposes decorator API like editor-view-dom. */
|
|
83
|
+
export type EditorViewRef = EditorViewHandle;
|
|
84
|
+
export interface EditorViewContentLayerProps {
|
|
85
|
+
/** Options (registry, className, editable). Editor is taken from EditorViewContext only. */
|
|
86
|
+
options?: EditorViewContentLayerOptions;
|
|
87
|
+
}
|
|
88
|
+
export interface EditorViewLayerProps {
|
|
89
|
+
/** Layer type (data-bc-layer value). */
|
|
90
|
+
layer: EditorViewLayerType;
|
|
91
|
+
/** Optional className. */
|
|
92
|
+
className?: string;
|
|
93
|
+
/** Optional style. */
|
|
94
|
+
style?: React.CSSProperties;
|
|
95
|
+
children?: React.ReactNode;
|
|
96
|
+
}
|
|
97
|
+
/** Props for named overlay layers (DecoratorLayer, SelectionLayer, ContextLayer, CustomLayer). */
|
|
98
|
+
export interface EditorViewOverlayLayerProps {
|
|
99
|
+
className?: string;
|
|
100
|
+
style?: React.CSSProperties;
|
|
101
|
+
children?: React.ReactNode;
|
|
102
|
+
}
|
|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