diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-19 21:09:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-19 21:09:58 +0300 |
commit | 2a6df7f21e786ddbbedc664a54f6116589475477 (patch) | |
tree | 916d64753247a2400cdee6676754e0637660bfeb /app/assets/javascripts/content_editor | |
parent | 25ed642226db28550270b850280462dad124fd61 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/content_editor')
-rw-r--r-- | app/assets/javascripts/content_editor/extensions/copy_paste.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/assets/javascripts/content_editor/extensions/copy_paste.js b/app/assets/javascripts/content_editor/extensions/copy_paste.js index f484ce98e90..ab9e5619600 100644 --- a/app/assets/javascripts/content_editor/extensions/copy_paste.js +++ b/app/assets/javascripts/content_editor/extensions/copy_paste.js @@ -182,6 +182,16 @@ export default Extension.create({ ); } + const preStartRegex = /^<pre[^>]*lang="markdown"[^>]*>/; + const preEndRegex = /<\/pre>$/; + const htmlContentWithoutMeta = htmlContent?.replace(/^<meta[^>]*>/, ''); + const pastingMarkdownBlock = + hasHTML && + preStartRegex.test(htmlContentWithoutMeta) && + preEndRegex.test(htmlContentWithoutMeta); + + if (pastingMarkdownBlock) return this.editor.commands.pasteContent(textContent, true); + return this.editor.commands.pasteContent(hasHTML ? htmlContent : textContent, !hasHTML); }, }, |