@inshapardaz/likhari-react 0.1.11-dev.105 → 0.1.11
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/EditorRoot.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { type Locale } from './i18n/index.js';
|
|
|
8
8
|
/** What happens when the user is about to leave with unsaved changes. */
|
|
9
9
|
export type NavigationGuardMode = 'confirm' | 'save-draft' | 'off';
|
|
10
10
|
export interface EditorInitialContent {
|
|
11
|
-
format: FormatId
|
|
11
|
+
format: Extract<FormatId, 'lexical-json' | 'plain-text'>;
|
|
12
12
|
value: string;
|
|
13
13
|
}
|
|
14
14
|
export interface EditorRootProps {
|
package/dist/EditorRoot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorRoot.d.ts","sourceRoot":"","sources":["../src/EditorRoot.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAY1D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"EditorRoot.d.ts","sourceRoot":"","sources":["../src/EditorRoot.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAY1D,OAAO,KAAK,EAAe,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAyB,KAAK,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EAAwB,KAAK,mBAAmB,EAAE,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAKzH,OAAO,EAAyB,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAGjE,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAYhF,OAAO,EAAgC,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMnE,yEAAyE;AACzE,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,YAA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;;;;;OAeG;IACH,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC,uGAAuG;IACvG,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC3E,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAC;IACrC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IAClD,iBAAiB,IAAI,OAAO,CAAC;IAC7B,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,KAAK,IAAI,IAAI,CAAC;CACf;AAQD,eAAO,MAAM,UAAU,uGA+WrB,CAAC"}
|
package/dist/EditorRoot.js
CHANGED
|
@@ -11,7 +11,6 @@ import { TablePlugin } from '@lexical/react/LexicalTablePlugin';
|
|
|
11
11
|
import { HorizontalRulePlugin } from '@lexical/react/LexicalHorizontalRulePlugin';
|
|
12
12
|
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
|
|
13
13
|
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
14
|
-
import { EditorInstancePlugin } from './plugins/EditorInstancePlugin.js';
|
|
15
14
|
import { defaultFormatRegistry } from '@inshapardaz/likhari-converters';
|
|
16
15
|
import { resolveFeatureConfig } from '@inshapardaz/likhari-core';
|
|
17
16
|
import { EDITOR_NODES } from './nodes.js';
|
|
@@ -201,20 +200,13 @@ export const EditorRoot = forwardRef(function EditorRoot({ documentId, initialCo
|
|
|
201
200
|
return defaultFormatRegistry.serialize(format, json);
|
|
202
201
|
},
|
|
203
202
|
setContent(value, format) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (autosaveTimerRef.current) {
|
|
212
|
-
clearTimeout(autosaveTimerRef.current);
|
|
213
|
-
autosaveTimerRef.current = null;
|
|
214
|
-
}
|
|
215
|
-
pendingDraftRef.current = null;
|
|
216
|
-
editor.setEditorState(parsed);
|
|
217
|
-
setIsDirty(false);
|
|
203
|
+
// Applied on next render via editorState prop is not supported for
|
|
204
|
+
// an already-mounted LexicalComposer; hosts needing this before
|
|
205
|
+
// Phase 2's controlled-mode support should remount with a new
|
|
206
|
+
// `initialContent`/`documentId` in the meantime.
|
|
207
|
+
void value;
|
|
208
|
+
void format;
|
|
209
|
+
throw new Error('@inshapardaz/likhari-react: EditorRef.setContent is not implemented yet — controlled mode is Phase 2 work (docs/editor-architecture-design.md §5).');
|
|
218
210
|
},
|
|
219
211
|
hasUnsavedChanges() {
|
|
220
212
|
return isDirty;
|
|
@@ -227,7 +219,6 @@ export const EditorRoot = forwardRef(function EditorRoot({ documentId, initialCo
|
|
|
227
219
|
},
|
|
228
220
|
}), [isDirty]);
|
|
229
221
|
const rootElementRef = useRef(null);
|
|
230
|
-
const editorInstanceRef = useRef(null);
|
|
231
222
|
const handleChange = (state) => {
|
|
232
223
|
editorStateRef.current = state;
|
|
233
224
|
const json = JSON.stringify(state.toJSON());
|
|
@@ -277,7 +268,7 @@ export const EditorRoot = forwardRef(function EditorRoot({ documentId, initialCo
|
|
|
277
268
|
const portalTargetSelector = `#${CSS.escape(portalTargetId)}`;
|
|
278
269
|
return (_jsx(EditorThemeProvider, { theme: theme, colorScheme: colorScheme, accentColor: accentColor, scopeElementId: portalTargetId, children: _jsxs("div", { className: "likhari-root", dir: dir, ref: rootElementRef, "data-document-id": documentId, style: { height: typeof height === 'number' ? `${height}px` : height }, children: [_jsx("div", { id: portalTargetId, className: "likhari-portal-target" }), _jsx(PortalTargetContext.Provider, { value: portalTargetSelector, children: _jsxs(UiStringsContext.Provider, { value: strings, children: [_jsx(ImageOptionsContext.Provider, { value: imageOptions, children: _jsxs(LexicalComposer, { initialConfig: initialConfig, children: [_jsx(Toolbar, { config: config, onSave: handleSave, isDirty: isDirty, showSave: showSave, fontOptions: fontOptions, direction: dir, locale: locale, drafts: autosave
|
|
279
270
|
? { currentId: draftId, maxBytes: autosaveMaxBytes, adoptOnRestore: !documentId, onRestored: handleDraftRestored }
|
|
280
|
-
: undefined }), documentId && (_jsx(DraftRestore, { draftId: documentId, mode: restoreDraft, initialJson: initialContentJsonRef.current, locale: locale, onRestored: handleDraftRestored })), _jsx("div", { className: "likhari-canvas", children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "likhari-content-editable", dir: dir, "aria-label": strings.editor.contentLabel }), placeholder: _jsx("div", { className: "likhari-placeholder", children: resolvedPlaceholder }), ErrorBoundary: LexicalErrorBoundary }) }), config.history && _jsx(HistoryPlugin, {}), (config.lists.bullet || config.lists.numbered || config.lists.check) && _jsx(ListPlugin, {}), config.lists.check && _jsx(CheckListPlugin, {}), config.links && _jsx(LinkPlugin, {}), config.links && _jsx(LinkPastePlugin, {}), config.blocks.pageBreak && _jsx(PageBreakPlugin, {}), config.tables && _jsx(TablePlugin, { hasCellMerge: false, hasTabHandler: true }), config.blocks.horizontalRule && _jsx(HorizontalRulePlugin, {}), _jsx(
|
|
271
|
+
: undefined }), documentId && (_jsx(DraftRestore, { draftId: documentId, mode: restoreDraft, initialJson: initialContentJsonRef.current, locale: locale, onRestored: handleDraftRestored })), _jsx("div", { className: "likhari-canvas", children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "likhari-content-editable", dir: dir, "aria-label": strings.editor.contentLabel }), placeholder: _jsx("div", { className: "likhari-placeholder", children: resolvedPlaceholder }), ErrorBoundary: LexicalErrorBoundary }) }), config.history && _jsx(HistoryPlugin, {}), (config.lists.bullet || config.lists.numbered || config.lists.check) && _jsx(ListPlugin, {}), config.lists.check && _jsx(CheckListPlugin, {}), config.links && _jsx(LinkPlugin, {}), config.links && _jsx(LinkPastePlugin, {}), config.blocks.pageBreak && _jsx(PageBreakPlugin, {}), config.tables && _jsx(TablePlugin, { hasCellMerge: false, hasTabHandler: true }), config.blocks.horizontalRule && _jsx(HorizontalRulePlugin, {}), _jsx(OnChangePlugin, { onChange: handleChange })] }) }), _jsx(LeaveDialog, { opened: leavePrompt !== null, canSave: Boolean(onSave), canSaveDraft: autosave || navigationGuard === 'save-draft', draftFailed: leavePrompt?.draftFailed ?? false, onSave: () => {
|
|
281
272
|
handleSave();
|
|
282
273
|
settleLeave(true);
|
|
283
274
|
}, onSaveDraft: () => {
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type MutableRefObject } from 'react';
|
|
2
|
-
import type { LexicalEditor } from 'lexical';
|
|
3
|
-
/** Hands the composer's editor to the component that owns the imperative ref. */
|
|
4
|
-
export declare function EditorInstancePlugin({ instanceRef }: {
|
|
5
|
-
instanceRef: MutableRefObject<LexicalEditor | null>;
|
|
6
|
-
}): null;
|
|
7
|
-
//# sourceMappingURL=EditorInstancePlugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EditorInstancePlugin.d.ts","sourceRoot":"","sources":["../../src/plugins/EditorInstancePlugin.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,iFAAiF;AACjF,wBAAgB,oBAAoB,CAAC,EAAE,WAAW,EAAE,EAAE;IAAE,WAAW,EAAE,gBAAgB,CAAC,aAAa,GAAG,IAAI,CAAC,CAAA;CAAE,GAAG,IAAI,CASnH"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
-
/** Hands the composer's editor to the component that owns the imperative ref. */
|
|
4
|
-
export function EditorInstancePlugin({ instanceRef }) {
|
|
5
|
-
const [editor] = useLexicalComposerContext();
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
instanceRef.current = editor;
|
|
8
|
-
return () => {
|
|
9
|
-
instanceRef.current = null;
|
|
10
|
-
};
|
|
11
|
-
}, [editor, instanceRef]);
|
|
12
|
-
return null;
|
|
13
|
-
}
|