Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-19 21:09:58 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-19 21:09:58 +0300
commit2a6df7f21e786ddbbedc664a54f6116589475477 (patch)
tree916d64753247a2400cdee6676754e0637660bfeb /app/assets/javascripts/content_editor
parent25ed642226db28550270b850280462dad124fd61 (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.js10
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);
},
},