Skip to content

Commit 680213c

Browse files
committed
feat(json-crdt-peritext-ui): 🎸 move state one folder up
1 parent 98f69e7 commit 680213c

File tree

17 files changed

+26
-43
lines changed

17 files changed

+26
-43
lines changed

src/json-crdt-peritext-ui/plugins/cursor/RenderPeritext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import {context, type CursorPluginContextValue} from './context';
33
import {ValueSyncStore} from '../../../util/events/sync-store';
44
import type {ChangeDetail} from '../../events/types';
5-
import type {PeritextSurfaceState} from '../../web/react';
5+
import type {PeritextSurfaceState} from '../../web';
66
import type {CursorPlugin} from './CursorPlugin';
77

88
export interface RenderPeritextProps {

src/json-crdt-peritext-ui/plugins/cursor/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import type {PeritextSurfaceState} from '../../web/react';
2+
import type {PeritextSurfaceState} from '../../web';
33
import type {ValueSyncStore} from '../../../util/events/sync-store';
44
import type {CursorPlugin} from './CursorPlugin';
55

src/json-crdt-peritext-ui/plugins/debug/RenderPeritext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {Console} from './Console';
66
import {ValueSyncStore} from '../../../util/events/sync-store';
77
import {useSyncStore} from '../../web/react/hooks';
88
import {DebugState} from './state';
9-
import type {PeritextSurfaceState} from '../../web/react';
9+
import type {PeritextSurfaceState} from '../../web';
1010

1111
const blockClass = rule({
1212
pos: 'relative',

src/json-crdt-peritext-ui/plugins/debug/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import type {ValueSyncStore} from '../../../util/events/sync-store';
3-
import type {PeritextSurfaceState} from '../../web/react/state';
3+
import type {PeritextSurfaceState} from '../../web';
44
import type {DebugState} from './state';
55

66
export interface DebugRenderersContextValue {

src/json-crdt-peritext-ui/plugins/minimal/RenderPeritext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {Chrome} from './Chrome';
33
import {context, type MinimalPluginContextValue} from './context';
44
import {ValueSyncStore} from '../../../util/events/sync-store';
55
import type {ChangeDetail} from '../../events/types';
6-
import type {PeritextSurfaceState} from '../../web/react';
6+
import type {PeritextSurfaceState} from '../../web';
77

88
export interface RenderPeritextProps {
99
ctx: PeritextSurfaceState;

src/json-crdt-peritext-ui/plugins/minimal/TopToolbar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {CommonSliceType} from '../../../../json-crdt-extensions';
55
import {ButtonGroup} from '../../../components/ButtonGroup';
66
import {useSyncStore} from '../../../web/react/hooks';
77
import {ButtonSeparator} from '../../../components/ButtonSeparator';
8-
import type {PeritextSurfaceState} from '../../../web/react';
8+
import type {PeritextSurfaceState} from '../../../web';
99

1010
export interface TopToolbarProps {
1111
ctx: PeritextSurfaceState;

src/json-crdt-peritext-ui/plugins/minimal/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import type {PeritextSurfaceState} from '../../web/react';
2+
import type {PeritextSurfaceState} from '../../web';
33
import type {ValueSyncStore} from '../../../util/events/sync-store';
44

55
export interface MinimalPluginContextValue {

src/json-crdt-peritext-ui/plugins/toolbar/RenderPeritext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import {Chrome} from './Chrome';
33
import {context, type ToolbarPluginContextValue} from './context';
44
import {ToolbarState} from './state';
5-
import type {PeritextSurfaceState, } from '../../web/react';
5+
import type {PeritextSurfaceState, } from '../../web';
66
import type {ToolbarPluginOpts} from './ToolbarPlugin';
77

88
export interface RenderPeritextProps {

src/json-crdt-peritext-ui/plugins/toolbar/TopToolbar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {ButtonGroup} from '../../../components/ButtonGroup';
66
import {useSyncStore, useSyncStoreOpt} from '../../../web/react/hooks';
77
import {ButtonSeparator} from '../../../components/ButtonSeparator';
88
import {useToolbarPlugin} from '../context';
9-
import type {PeritextSurfaceState} from '../../../web/react';
9+
import type {PeritextSurfaceState} from '../../../web';
1010

1111
export interface TopToolbarProps {
1212
ctx: PeritextSurfaceState;

src/json-crdt-peritext-ui/plugins/toolbar/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import type {ToolbarState} from './state';
3-
import type {PeritextSurfaceState} from '../../web/react';
3+
import type {PeritextSurfaceState} from '../../web';
44

55
export interface ToolbarPluginContextValue {
66
surface: PeritextSurfaceState;

src/json-crdt-peritext-ui/plugins/toolbar/state/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {FontStyleButton} from 'nice-ui/lib/2-inline-block/FontStyleButton';
88
import {CommonSliceType} from '../../../../json-crdt-extensions';
99
import type {UiLifeCyclesRender} from '../../../web/types';
1010
import type {BufferDetail, PeritextEventDetailMap} from '../../../events/types';
11-
import type {PeritextSurfaceState} from '../../../web/react';
11+
import type {PeritextSurfaceState} from '../../../web';
1212
import type {MenuItem} from '../types';
1313
import type {ToolbarPluginOpts} from '../ToolbarPlugin';
1414

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,2 @@
1-
import {Peritext} from "../../json-crdt-extensions";
2-
import {PeritextSurfaceState} from "./react";
3-
import {createEvents as createEvents} from "../events";
4-
5-
export const create = (events: PeritextEventDefaults) => {
6-
const state = new PeritextSurfaceState(events.txt, events, rerender, plugins);
7-
// onState?.(state);
8-
// if (dom && dom.opts.source === el) return;
9-
const newDom = new DomController({source: el, events: state.events, log: state.log});
10-
const txt = state.peritext;
11-
const uiHandle = new UiHandle(txt, newDom);
12-
state.events.ui = uiHandle;
13-
state.events.undo = newDom.annals;
14-
newDom.start();
15-
state.dom = newDom;
16-
setDom(newDom);
17-
newDom.et.addEventListener('change', rerender);
18-
};
1+
export * from './react';
2+
export {PeritextSurfaceState} from './state';

src/json-crdt-peritext-ui/web/react/PeritextView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {put} from 'nano-theme';
44
import {CssClass} from '../constants';
55
import {CursorPlugin} from '../../plugins/cursor';
66
import {defaultPlugin} from '../../plugins/minimal';
7-
import {PeritextSurfaceState} from './state';
7+
import {PeritextSurfaceState} from '../state';
88
import {createEvents} from '../../events';
99
import {context} from './context';
1010
import {BlockView} from './BlockView';
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import type {PeritextSurfaceState} from './state';
2+
import type {PeritextSurfaceState} from '../state';
33

4-
export const context = React.createContext<PeritextSurfaceState | null>(null);
4+
export const context = React.createContext<PeritextSurfaceState>(null!);
55
export const usePeritext = () => React.useContext(context)!;
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
export type {PeritextSurfaceState} from './state';
2-
export * from './context';
3-
export * from './PeritextView';
1+
export {usePeritext} from './context';
2+
export {PeritextView, PeritextViewProps} from './PeritextView';

src/json-crdt-peritext-ui/web/react/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {CaretViewProps} from './cursor/CaretView';
44
import type {AnchorViewProps} from './cursor/AnchorView';
55
import type {InlineViewProps} from './InlineView';
66
import type {BlockViewProps} from './BlockView';
7-
import type {PeritextSurfaceState} from './state';
7+
import type {PeritextSurfaceState} from '../state';
88
import type {Inline} from '../../../json-crdt-extensions/peritext/block/Inline';
99

1010
export interface PeritextPlugin {

src/json-crdt-peritext-ui/web/react/state.ts renamed to src/json-crdt-peritext-ui/web/state.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {Log} from '../../../json-crdt/log/Log';
2-
import {DomController} from '../dom/DomController';
3-
import {ValueSyncStore} from '../../../util/events/sync-store';
4-
import type {PeritextPlugin} from './types';
5-
import type {Peritext} from '../../../json-crdt-extensions/peritext/Peritext';
6-
import type {PeritextEventDefaults} from '../../events/defaults/PeritextEventDefaults';
7-
import type {UiLifeCyclesRender} from '../types';
1+
import {Log} from '../../json-crdt/log/Log';
2+
import {DomController} from './dom/DomController';
3+
import {ValueSyncStore} from '../../util/events/sync-store';
4+
import type {PeritextPlugin} from './react/types';
5+
import type {Peritext} from '../../json-crdt-extensions/peritext/Peritext';
6+
import type {PeritextEventDefaults} from '../events/defaults/PeritextEventDefaults';
7+
import type {UiLifeCyclesRender} from './types';
88

99
export class PeritextSurfaceState implements UiLifeCyclesRender {
1010
public readonly peritext: Peritext;

0 commit comments

Comments
 (0)