editor: do not convert \n characters to paragraphs

This commit is contained in:
Abdullah Atta
2023-04-06 01:40:55 +05:00
parent 851364c0bf
commit f1609aaa46
7 changed files with 6 additions and 8 deletions

View File

@@ -162,7 +162,6 @@ function TipTap(props: TipTapProps) {
isMobile: isMobile || false,
element: editorContainer,
editable: !readonly,
parseOptions: { preserveWhitespace: "full" },
content,
autofocus: "start",
onFocus,
@@ -383,7 +382,7 @@ function toIEditor(editor: Editor): IEditor {
tr.setMeta("preventSave", true);
return true;
})
.setContent(content, true, { preserveWhitespace: "full" })
.setContent(content, true, { preserveWhitespace: true })
.setTextSelection({
from,
to

View File

@@ -102,7 +102,6 @@ const Tiptap = ({
editorProps: {
editable: () => !settings.readonly
},
parseOptions: { preserveWhitespace: "full" },
content: global.editorController?.content?.current,
isMobile: true,
isKeyboardOpen: settings.keyboardShown,

View File

@@ -118,7 +118,7 @@ export function useEditorController(update: () => void): EditorController {
if (!editor) break;
const { from, to } = editor.state.selection;
editor?.commands.setContent(htmlContentRef.current, false, {
preserveWhitespace: "full"
preserveWhitespace: true
});
editor.commands.setTextSelection({
from,

View File

@@ -630,7 +630,7 @@ function indentOnEnter(editor: Editor, $from: ResolvedPos, options: Indent) {
return editor
.chain()
.insertContent(`${newline}${indentation}`, {
parseOptions: { preserveWhitespace: "full" }
parseOptions: { preserveWhitespace: true }
})
.focus()
.run();

View File

@@ -57,7 +57,7 @@ test("codeblocks should get highlighted after pasting", async () => {
});
editor.commands.setContent(CODEBLOCKS_HTML, true, {
preserveWhitespace: "full"
preserveWhitespace: true
});
await new Promise((resolve) => setTimeout(resolve, 100));

View File

@@ -241,7 +241,8 @@ const useTiptap = (
editor.storage.portalProviderAPI = PortalProviderAPI;
if (onBeforeCreate) onBeforeCreate({ editor });
},
injectCSS: false
injectCSS: false,
parseOptions: { preserveWhitespace: true }
}),
[
onPreviewAttachment,

View File

@@ -39,7 +39,6 @@ export function createEditor<TNodes extends string>(
const editor = new Editor({
element,
content: initialContent,
parseOptions: { preserveWhitespace: "full" },
extensions: [
StarterKit.configure({
bulletList: false,