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>2021-05-19 18:44:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 18:44:42 +0300
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /app/assets/javascripts/notebook
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'app/assets/javascripts/notebook')
-rw-r--r--app/assets/javascripts/notebook/cells/markdown.vue35
1 files changed, 35 insertions, 0 deletions
diff --git a/app/assets/javascripts/notebook/cells/markdown.vue b/app/assets/javascripts/notebook/cells/markdown.vue
index c09db6851e5..9bf26e5a182 100644
--- a/app/assets/javascripts/notebook/cells/markdown.vue
+++ b/app/assets/javascripts/notebook/cells/markdown.vue
@@ -3,6 +3,7 @@
import katex from 'katex';
import marked from 'marked';
import { sanitize } from '~/lib/dompurify';
+import { hasContent } from '~/lib/utils/text_utility';
import Prompt from './prompt.vue';
const renderer = new marked.Renderer();
@@ -88,6 +89,38 @@ renderer.listitem = (t) => {
const [text, inline] = renderKatex(t);
return `<li class="${inline ? 'inline-katex' : ''}">${text}</li>`;
};
+renderer.originalImage = renderer.image;
+
+renderer.image = function image(href, title, text) {
+ const attachmentHeader = `attachment:`; // eslint-disable-line @gitlab/require-i18n-strings
+
+ if (!this.attachments || !href.startsWith(attachmentHeader)) {
+ return this.originalImage(href, title, text);
+ }
+
+ let img = ``;
+ const filename = href.substring(attachmentHeader.length);
+
+ if (hasContent(filename)) {
+ const attachment = this.attachments[filename];
+
+ if (attachment) {
+ const imageType = Object.keys(attachment)[0];
+
+ if (hasContent(imageType)) {
+ const data = attachment[imageType];
+ const inlined = `data:${imageType};base64,${data}"`; // eslint-disable-line @gitlab/require-i18n-strings
+ img = this.originalImage(inlined, title, text);
+ }
+ }
+ }
+
+ if (!hasContent(img)) {
+ return this.originalImage(href, title, text);
+ }
+
+ return sanitize(img);
+};
marked.setOptions({
renderer,
@@ -105,6 +138,8 @@ export default {
},
computed: {
markdown() {
+ renderer.attachments = this.cell.attachments;
+
return sanitize(marked(this.cell.source.join('').replace(/\\/g, '\\\\')), {
// allowedTags from GitLab's inline HTML guidelines
// https://docs.gitlab.com/ee/user/markdown.html#inline-html