diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-01 10:13:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-01 10:13:49 +0300 |
commit | fb58d337f0b8b6f685c1e94a9327d8d12ebfbf81 (patch) | |
tree | a285b8beb8303a81a7af0db968822fa05595e529 /app/assets/javascripts/editor | |
parent | 3333112d46dd179a55295ebed754544a97b49b7f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-ee
Diffstat (limited to 'app/assets/javascripts/editor')
-rw-r--r-- | app/assets/javascripts/editor/extensions/source_editor_markdown_ext.js | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/app/assets/javascripts/editor/extensions/source_editor_markdown_ext.js b/app/assets/javascripts/editor/extensions/source_editor_markdown_ext.js index 76e009164f7..57de21c933e 100644 --- a/app/assets/javascripts/editor/extensions/source_editor_markdown_ext.js +++ b/app/assets/javascripts/editor/extensions/source_editor_markdown_ext.js @@ -14,17 +14,9 @@ import { } from '../constants'; import { SourceEditorExtension } from './source_editor_extension_base'; -const getPreview = (text, projectPath = '') => { - let url; - - if (projectPath) { - url = `/${projectPath}/preview_markdown`; - } else { - const { group, project } = document.body.dataset; - url = `/${group}/${project}/preview_markdown`; - } +const getPreview = (text, previewMarkdownPath) => { return axios - .post(url, { + .post(previewMarkdownPath, { text, }) .then(({ data }) => { @@ -43,10 +35,10 @@ const setupDomElement = ({ injectToEl = null } = {}) => { }; export class EditorMarkdownExtension extends SourceEditorExtension { - constructor({ instance, projectPath, ...args } = {}) { + constructor({ instance, previewMarkdownPath, ...args } = {}) { super({ instance, ...args }); Object.assign(instance, { - projectPath, + previewMarkdownPath, preview: { el: undefined, action: undefined, @@ -112,7 +104,7 @@ export class EditorMarkdownExtension extends SourceEditorExtension { fetchPreview() { const { el: previewEl } = this.preview; - getPreview(this.getValue(), this.projectPath) + getPreview(this.getValue(), this.previewMarkdownPath) .then((data) => { previewEl.innerHTML = sanitize(data); syntaxHighlight(previewEl.querySelectorAll('.js-syntax-highlight')); |