mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-21 22:19:41 +01:00
editor: preserve all whitespaces while setting content (#1978)
Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
This commit is contained in:
@@ -142,7 +142,6 @@ function TipTap(props: TipTapProps) {
|
|||||||
const hasText = event.clipboardData?.types?.some((type) =>
|
const hasText = event.clipboardData?.types?.some((type) =>
|
||||||
type.startsWith("text/")
|
type.startsWith("text/")
|
||||||
);
|
);
|
||||||
|
|
||||||
// we always give preference to text over files & skip any attached
|
// we always give preference to text over files & skip any attached
|
||||||
// files if there is text.
|
// files if there is text.
|
||||||
// TODO: give user an actionable hint to allow them to select what they
|
// TODO: give user an actionable hint to allow them to select what they
|
||||||
@@ -163,6 +162,7 @@ function TipTap(props: TipTapProps) {
|
|||||||
isMobile: isMobile || false,
|
isMobile: isMobile || false,
|
||||||
element: editorContainer,
|
element: editorContainer,
|
||||||
editable: !readonly,
|
editable: !readonly,
|
||||||
|
parseOptions: { preserveWhitespace: "full" },
|
||||||
content,
|
content,
|
||||||
autofocus: "start",
|
autofocus: "start",
|
||||||
onFocus,
|
onFocus,
|
||||||
@@ -381,7 +381,7 @@ function toIEditor(editor: Editor): IEditor {
|
|||||||
tr.setMeta("preventSave", true);
|
tr.setMeta("preventSave", true);
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.setContent(content, true)
|
.setContent(content, true, { preserveWhitespace: "full" })
|
||||||
.setTextSelection({
|
.setTextSelection({
|
||||||
from,
|
from,
|
||||||
to
|
to
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ const Tiptap = ({
|
|||||||
editorProps: {
|
editorProps: {
|
||||||
editable: () => !settings.readonly
|
editable: () => !settings.readonly
|
||||||
},
|
},
|
||||||
|
parseOptions: { preserveWhitespace: "full" },
|
||||||
content: global.editorController?.content?.current,
|
content: global.editorController?.content?.current,
|
||||||
isMobile: true,
|
isMobile: true,
|
||||||
isKeyboardOpen: settings.keyboardShown,
|
isKeyboardOpen: settings.keyboardShown,
|
||||||
|
|||||||
@@ -115,7 +115,9 @@ export function useEditorController(update: () => void): EditorController {
|
|||||||
htmlContentRef.current = value;
|
htmlContentRef.current = value;
|
||||||
if (!editor) break;
|
if (!editor) break;
|
||||||
const { from, to } = editor.state.selection;
|
const { from, to } = editor.state.selection;
|
||||||
editor?.commands.setContent(htmlContentRef.current, false);
|
editor?.commands.setContent(htmlContentRef.current, false, {
|
||||||
|
preserveWhitespace: "full"
|
||||||
|
});
|
||||||
editor.commands.setTextSelection({
|
editor.commands.setTextSelection({
|
||||||
from,
|
from,
|
||||||
to
|
to
|
||||||
|
|||||||
Reference in New Issue
Block a user