π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix(nc-gui): task list new line getting removed
Ramesh Mane15abe6e81054
diff --git a/packages/nc-gui/helpers/tiptap-markdown/extensions/nodes/hard-break.ts b/packages/nc-gui/helpers/tiptap-markdown/extensions/nodes/hard-break.tsindex 088e548b7e..4fcf8565a6 100644--- a/packages/nc-gui/helpers/tiptap-markdown/extensions/nodes/hard-break.ts+++ b/packages/nc-gui/helpers/tiptap-markdown/extensions/nodes/hard-break.ts@@ -7,11 +7,12 @@ export const HardBreak = TiptapHardBreak.extend<HardBreakOptions, { markdown: Mareturn {markdown: {serialize(state, node, parent, index) {- for (let i = index + 1; i < parent.childCount; i++)+ for (let i = index + 1; i < parent.childCount; i++) {if (parent.child(i).type !== node.type) {state.write(state?.inTable ? HTMLNode.storage.markdown.serialize.call(this, state, node, parent) : '<br>')return}+ }},parse: {// handled by markdown-itdiff --git a/packages/nc-gui/helpers/tiptap-markdown/extensions/nodes/paragraph.ts b/packages/nc-gui/helpers/tiptap-markdown/extensions/nodes/paragraph.tsindex b159c1fe2e..17a559db52 100644--- a/packages/nc-gui/helpers/tiptap-markdown/extensions/nodes/paragraph.ts+++ b/packages/nc-gui/helpers/tiptap-markdown/extensions/nodes/paragraph.ts@@ -1,5 +1,5 @@import { Node } from '@tiptap/core'-import { defaultMarkdownSerializer } from '@tiptap/pm/markdown'+import { defaultMarkdownSerializer, defaultMarkdownParser } from '@tiptap/pm/markdown'import type { MarkdownNodeSpec } from '../../types'// TODO: Extend from tiptap extension@@ -16,16 +16,8 @@ export const Paragraph = Node.create<any, { markdown: MarkdownNodeSpec }>({// Check if it's the last block in the documentconst isLastNode = parent && parent.child(parent.childCount - 1) === node- // Handle empty paragraphsif (isEmpty && !isLastNode) {- // Add `<br>` with a newline if the next node is a block- const nextNode = parent.child(parent.children.indexOf(node) + 1)-- if (nextNode?.isBlock && !['hardBreak', 'paragraph'].includes(nextNode.type.name)) {- state.write(' <br>\n\n ') // Ensure block starts correctly- } else {- state.write(' <br> ') // Inline <br>` for non-block contexts- }+ state.write(' <br>\n\n ')return}diff --git a/packages/nc-gui/helpers/tiptap-markdown/parse/MarkdownParser.ts b/packages/nc-gui/helpers/tiptap-markdown/parse/MarkdownParser.tsindex 1a0cdc2ba5..825a8f582b 100644--- a/packages/nc-gui/helpers/tiptap-markdown/parse/MarkdownParser.ts+++ b/packages/nc-gui/helpers/tiptap-markdown/parse/MarkdownParser.ts@@ -27,6 +27,19 @@ export class MarkdownParser {}}+ replaceBlockBrWithEmptyParagraph(html: string): string {+ const container = document.createElement('div')+ container.innerHTML = html+ ;[...container.children].forEach((child) => {+ if (child.tagName === 'BR') {+ const p = document.createElement('p')+ child.replaceWith(p)+ }+ })++ return container.innerHTML+ }+parse<T>(content: T, { inline }: { inline?: boolean } = {}): T | string {if (!ncIsString(content)) return content@@ -37,13 +50,13 @@ export class MarkdownParser {const renderedHTML = this.md.render(content)const element = elementFromString(renderedHTML)- this.editor.extensionManager.extensions.forEach((extension) =>- getMarkdownSpec(extension)?.parse?.updateDOM?.call({ editor: this.editor, options: extension.options }, element),- )+ this.editor.extensionManager.extensions.forEach((extension) => {+ getMarkdownSpec(extension)?.parse?.updateDOM?.call({ editor: this.editor, options: extension.options }, element)+ })this.normalizeDOM(element, { inline, content })- return element.innerHTML+ return this.replaceBlockBrWithEmptyParagraph(element.innerHTML)}normalizeDOM(node: HTMLElement, { inline, content }: { inline?: boolean; content: string }) {