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

View File

@@ -102,7 +102,6 @@ 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,

View File

@@ -118,7 +118,7 @@ export function useEditorController(update: () => void): EditorController {
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" preserveWhitespace: true
}); });
editor.commands.setTextSelection({ editor.commands.setTextSelection({
from, from,

View File

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

View File

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

View File

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

View File

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