smoodly 0.0.53 → 0.0.55
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/admin/editor/CanvasOverlay.d.ts +3 -1
- package/dist/admin/editor/CanvasOverlay.js +2 -2
- package/dist/admin/editor/EditorView.js +243 -63
- package/dist/admin/editor/InsertPicker.d.ts +8 -1
- package/dist/admin/editor/InsertPicker.js +2 -2
- package/dist/admin/editor/InspectorFields.js +1 -1
- package/dist/admin/editor/Outline.d.ts +11 -3
- package/dist/admin/editor/Outline.js +12 -3
- package/dist/admin/editor/PageInspector.js +1 -1
- package/dist/admin/editor/StructureView.d.ts +23 -0
- package/dist/admin/editor/StructureView.js +58 -0
- package/dist/admin/editor/card-preview.d.ts +10 -0
- package/dist/admin/editor/card-preview.js +50 -0
- package/dist/admin/editor/global-edit.js +29 -22
- package/dist/admin/editor/history.d.ts +39 -0
- package/dist/admin/editor/history.js +64 -0
- package/dist/admin/editor/section-clipboard.d.ts +40 -0
- package/dist/admin/editor/section-clipboard.js +106 -0
- package/dist/admin/editor/undo-keys.d.ts +19 -0
- package/dist/admin/editor/undo-keys.js +27 -0
- package/dist/admin/editor/useInlineSession.d.ts +4 -1
- package/dist/admin/editor/useInlineSession.js +11 -2
- package/dist/admin/editor/view-memory.d.ts +9 -0
- package/dist/admin/editor/view-memory.js +17 -0
- package/dist/admin/files.generated.js +1 -1
- package/dist/admin/ui/ActionMenu.d.ts +2 -0
- package/dist/admin/ui/ActionMenu.js +1 -1
- package/dist/admin/ui/primitives.d.ts +1 -0
- package/dist/admin/ui/primitives.js +1 -1
- package/dist/admin/ui/theme.js +69 -0
- package/dist/admin/ui/useSortable.js +3 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ import { INITIAL_INLINE, reduceInline } from "./inline-session.js";
|
|
|
17
17
|
const CLOSE_FALLBACK_MS = 4000;
|
|
18
18
|
/** On a hidden child: its inline display before the session, restored after. */
|
|
19
19
|
const HIDDEN_ATTR = "data-smd-hidden";
|
|
20
|
-
export function useInlineSession({ iframeRef, postToCanvas, patch }) {
|
|
20
|
+
export function useInlineSession({ iframeRef, postToCanvas, patch, onSession }) {
|
|
21
21
|
const [state, setState] = useState(INITIAL_INLINE);
|
|
22
22
|
const stateRef = useRef(state);
|
|
23
23
|
const [richtext, setRichtext] = useState(null);
|
|
@@ -27,6 +27,11 @@ export function useInlineSession({ iframeRef, postToCanvas, patch }) {
|
|
|
27
27
|
const closeTimer = useRef(null);
|
|
28
28
|
const patchRef = useRef(patch);
|
|
29
29
|
patchRef.current = patch;
|
|
30
|
+
const onSessionRef = useRef(onSession);
|
|
31
|
+
onSessionRef.current = onSession;
|
|
32
|
+
/** The open session's release from `onSession`. */
|
|
33
|
+
const releaseSessionRef = useRef(null);
|
|
34
|
+
const releaseSession = () => { const r = releaseSessionRef.current; releaseSessionRef.current = null; r?.(); };
|
|
30
35
|
const dispatch = useCallback((event) => {
|
|
31
36
|
const { state: next, refresh } = reduceInline(stateRef.current, event);
|
|
32
37
|
stateRef.current = next;
|
|
@@ -137,6 +142,7 @@ export function useInlineSession({ iframeRef, postToCanvas, patch }) {
|
|
|
137
142
|
const changed = changedRef.current;
|
|
138
143
|
// The reducer first: the blur that removing contenteditable fires re-enters here and must see no session.
|
|
139
144
|
dispatch({ type: "end" });
|
|
145
|
+
releaseSession();
|
|
140
146
|
if (text) {
|
|
141
147
|
textRef.current = null;
|
|
142
148
|
text.teardown();
|
|
@@ -169,8 +175,10 @@ export function useInlineSession({ iframeRef, postToCanvas, patch }) {
|
|
|
169
175
|
}
|
|
170
176
|
end();
|
|
171
177
|
const ok = session.kind === "text" ? mountText(d, session, at) : mountRichtext(d, session, at);
|
|
172
|
-
if (ok)
|
|
178
|
+
if (ok) {
|
|
173
179
|
dispatch({ type: "start", session });
|
|
180
|
+
releaseSessionRef.current = onSessionRef.current?.(session) ?? null;
|
|
181
|
+
}
|
|
174
182
|
return ok;
|
|
175
183
|
}, [iframeRef, dispatch, end, release, mountText, mountRichtext]);
|
|
176
184
|
// ── the instant write (spec §7) ─────────────────────────────────────────
|
|
@@ -210,6 +218,7 @@ export function useInlineSession({ iframeRef, postToCanvas, patch }) {
|
|
|
210
218
|
const mount = richtextRef.current;
|
|
211
219
|
if (mount)
|
|
212
220
|
release(mount);
|
|
221
|
+
releaseSession();
|
|
213
222
|
dispatch({ type: "canvas" });
|
|
214
223
|
}, [dispatch, release]);
|
|
215
224
|
useEffect(() => () => { if (closeTimer.current)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type EditorViewMode = "canvas" | "structure";
|
|
2
|
+
export declare const VIEW_KEY = "smoodly-editor-view";
|
|
3
|
+
type Storage = {
|
|
4
|
+
getItem(key: string): string | null;
|
|
5
|
+
setItem(key: string, value: string): void;
|
|
6
|
+
};
|
|
7
|
+
export declare function rememberedView(storage?: Storage): EditorViewMode;
|
|
8
|
+
export declare function rememberView(view: EditorViewMode, storage?: Storage): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const VIEW_KEY = "smoodly-editor-view";
|
|
2
|
+
export function rememberedView(storage) {
|
|
3
|
+
try {
|
|
4
|
+
return (storage ?? window.localStorage).getItem(VIEW_KEY) === "structure" ? "structure" : "canvas";
|
|
5
|
+
}
|
|
6
|
+
catch {
|
|
7
|
+
return "canvas";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function rememberView(view, storage) {
|
|
11
|
+
try {
|
|
12
|
+
(storage ?? window.localStorage).setItem(VIEW_KEY, view);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// not remembered — the view still switches
|
|
16
|
+
}
|
|
17
|
+
}
|