diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-24 18:10:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-24 18:10:36 +0300 |
commit | 234dc40a12a1cdaef0cdb825ca4acc3f271c6394 (patch) | |
tree | fb9875dca8b558acafa54c36a591b4d2ed10fc49 /app/assets/javascripts/editor | |
parent | c7864d3d50b4002c621c7cba2e1ebfb5d23ac7ed (diff) |
Add latest changes from gitlab-org/gitlab@master
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')); |