A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
editor: preserve all whitespaces while setting content (#1978)
Muhammad Ali87c7eccee45e
diff --git a/apps/web/src/components/editor/tiptap.tsx b/apps/web/src/components/editor/tiptap.tsxindex 461e43bea..0cd427692 100644--- a/apps/web/src/components/editor/tiptap.tsx+++ b/apps/web/src/components/editor/tiptap.tsx@@ -142,7 +142,6 @@ function TipTap(props: TipTapProps) {const hasText = event.clipboardData?.types?.some((type) =>type.startsWith("text/"));-// we always give preference to text over files & skip any attached// files if there is text.// TODO: give user an actionable hint to allow them to select what they@@ -163,6 +162,7 @@ function TipTap(props: TipTapProps) {isMobile: isMobile || false,element: editorContainer,editable: !readonly,+ parseOptions: { preserveWhitespace: "full" },content,autofocus: "start",onFocus,@@ -381,7 +381,7 @@ function toIEditor(editor: Editor): IEditor {tr.setMeta("preventSave", true);return true;})- .setContent(content, true)+ .setContent(content, true, { preserveWhitespace: "full" }).setTextSelection({from,todiff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsxindex eacde676b..7481916aa 100644--- a/packages/editor-mobile/src/components/editor.tsx+++ b/packages/editor-mobile/src/components/editor.tsx@@ -85,6 +85,7 @@ const Tiptap = ({editorProps: {editable: () => !settings.readonly},+ parseOptions: { preserveWhitespace: "full" },content: global.editorController?.content?.current,isMobile: true,isKeyboardOpen: settings.keyboardShown,diff --git a/packages/editor-mobile/src/hooks/useEditorController.ts b/packages/editor-mobile/src/hooks/useEditorController.tsindex 826e797b3..6528d0147 100644--- a/packages/editor-mobile/src/hooks/useEditorController.ts+++ b/packages/editor-mobile/src/hooks/useEditorController.ts@@ -115,7 +115,9 @@ export function useEditorController(update: () => void): EditorController {htmlContentRef.current = value;if (!editor) break;const { from, to } = editor.state.selection;- editor?.commands.setContent(htmlContentRef.current, false);+ editor?.commands.setContent(htmlContentRef.current, false, {+ preserveWhitespace: "full"+ });editor.commands.setTextSelection({from,to