From b7b83a569062082806bddc490ecfdca53eb8c885 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 7 Jun 2024 09:44:17 +0800 Subject: [PATCH 1/2] fix: initial content --- src/RichText/RichText.tsx | 2 +- src/RichText/useEditorBridge.tsx | 2 +- website/docs/api/useEditorBridge.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/RichText/RichText.tsx b/src/RichText/RichText.tsx index cd0fecf..6b32ba8 100644 --- a/src/RichText/RichText.tsx +++ b/src/RichText/RichText.tsx @@ -135,7 +135,7 @@ export const RichText = ({ editor, ...props }: RichTextProps) => { : '' }${ editor.initialContent - ? `window.initialContent = '${editor.initialContent}';` + ? `window.initialContent = ${JSON.stringify(editor.initialContent)};` : '' } window.editable = ${editor.editable}; diff --git a/src/RichText/useEditorBridge.tsx b/src/RichText/useEditorBridge.tsx index 69a2add..1fd8678 100644 --- a/src/RichText/useEditorBridge.tsx +++ b/src/RichText/useEditorBridge.tsx @@ -24,7 +24,7 @@ export type RecursivePartial = { export const useEditorBridge = (options?: { bridgeExtensions?: BridgeExtension[]; - initialContent?: string; + initialContent?: string | object; autofocus?: boolean; avoidIosKeyboard?: boolean; customSource?: string; diff --git a/website/docs/api/useEditorBridge.md b/website/docs/api/useEditorBridge.md index 7f2c211..73e0204 100644 --- a/website/docs/api/useEditorBridge.md +++ b/website/docs/api/useEditorBridge.md @@ -14,7 +14,7 @@ A list of BridgeExtensions that will be added to the editor on the native side #### initialContent -`string` +`string | json` default: `undefined`
initial content that will be loaded first on the editor From 97eb2c943edb3d91dc13183c7d9f8cf6e05b9f9c Mon Sep 17 00:00:00 2001 From: Amir Angel <36531255+17Amir17@users.noreply.github.com> Date: Sun, 9 Jun 2024 16:47:49 +0300 Subject: [PATCH 2/2] fix: initial content --- src/RichText/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RichText/utils.ts b/src/RichText/utils.ts index aed69b0..a91e127 100644 --- a/src/RichText/utils.ts +++ b/src/RichText/utils.ts @@ -62,7 +62,7 @@ export const getInjectedJSBeforeContentLoad = (editor: EditorBridge) => { : '' }${ editor.initialContent - ? `window.initialContent = '${editor.initialContent}';` + ? `window.initialContent = ${JSON.stringify(editor.initialContent)};` : '' } window.editable = ${editor.editable};