-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3480 from nextcloud/backport/3330/stable25
[stable25] Combined code block backport
- Loading branch information
Showing
14 changed files
with
46 additions
and
18 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
/* | ||
/** | ||
* @copyright Copyright (c) 2022 Max <[email protected]> | ||
* | ||
* @author Max <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* @license AGPL-3.0-or-later | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import TiptapCodeBlock from '@tiptap/extension-code-block' | ||
import { defaultMarkdownSerializer } from 'prosemirror-markdown' | ||
|
||
const CodeBlock = TiptapCodeBlock.extend({ | ||
parseHTML() { | ||
return [ | ||
{ | ||
tag: 'pre', | ||
preserveWhitespace: 'full', | ||
// Remove trailing newline from code blocks (Github issue #2344) | ||
getContent: (node, schema) => { | ||
return schema.nodes.codeBlock.create(null, [schema.text(node.textContent.replace(/\n$/, ''))]) | ||
}, | ||
}, | ||
] | ||
}, | ||
|
||
toMarkdown(state, node, parent, index) { | ||
// prosemirror-markdown uses `params` instead of `language` attribute | ||
node.attrs.params = node.attrs.language | ||
return defaultMarkdownSerializer.nodes.code_block(state, node, parent, index) | ||
}, | ||
|
||
}) | ||
|
||
export default CodeBlock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters