summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-09-01 07:13:49 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-09-01 07:13:49 +0000
commitfb58d337f0b8b6f685c1e94a9327d8d12ebfbf81 (patch)
treea285b8beb8303a81a7af0db968822fa05595e529 /app/assets
parent3333112d46dd179a55295ebed754544a97b49b7f (diff)
downloadgitlab-ce-fb58d337f0b8b6f685c1e94a9327d8d12ebfbf81.tar.gz
Add latest changes from gitlab-org/gitlab@14-2-stable-ee
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/blob_edit/blob_bundle.js2
-rw-r--r--app/assets/javascripts/blob_edit/edit_blob.js7
-rw-r--r--app/assets/javascripts/editor/extensions/source_editor_markdown_ext.js18
-rw-r--r--app/assets/javascripts/ide/components/repo_editor.vue6
-rw-r--r--app/assets/javascripts/ide/index.js1
-rw-r--r--app/assets/javascripts/ide/stores/state.js1
6 files changed, 18 insertions, 17 deletions
diff --git a/app/assets/javascripts/blob_edit/blob_bundle.js b/app/assets/javascripts/blob_edit/blob_bundle.js
index 76d9b18b777..2d9ffda06d0 100644
--- a/app/assets/javascripts/blob_edit/blob_bundle.js
+++ b/app/assets/javascripts/blob_edit/blob_bundle.js
@@ -69,6 +69,7 @@ export default () => {
const currentAction = $('.js-file-title').data('currentAction');
const projectId = editBlobForm.data('project-id');
const isMarkdown = editBlobForm.data('is-markdown');
+ const previewMarkdownPath = editBlobForm.data('previewMarkdownPath');
const commitButton = $('.js-commit-button');
const cancelLink = $('.btn.btn-cancel');
@@ -80,6 +81,7 @@ export default () => {
currentAction,
projectId,
isMarkdown,
+ previewMarkdownPath,
});
initPopovers();
initCodeQualityWalkthroughStep();
diff --git a/app/assets/javascripts/blob_edit/edit_blob.js b/app/assets/javascripts/blob_edit/edit_blob.js
index e068910c626..118cef59d5a 100644
--- a/app/assets/javascripts/blob_edit/edit_blob.js
+++ b/app/assets/javascripts/blob_edit/edit_blob.js
@@ -11,7 +11,7 @@ import { BLOB_EDITOR_ERROR, BLOB_PREVIEW_ERROR } from './constants';
export default class EditBlob {
// The options object has:
- // assetsPath, filePath, currentAction, projectId, isMarkdown
+ // assetsPath, filePath, currentAction, projectId, isMarkdown, previewMarkdownPath
constructor(options) {
this.options = options;
this.configureMonacoEditor();
@@ -30,7 +30,10 @@ export default class EditBlob {
import('~/editor/extensions/source_editor_markdown_ext')
.then(({ EditorMarkdownExtension: MarkdownExtension } = {}) => {
this.editor.use(
- new MarkdownExtension({ instance: this.editor, projectPath: this.options.projectPath }),
+ new MarkdownExtension({
+ instance: this.editor,
+ previewMarkdownPath: this.options.previewMarkdownPath,
+ }),
);
this.hasMarkdownExtension = true;
addEditorMarkdownListeners(this.editor);
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'));
diff --git a/app/assets/javascripts/ide/components/repo_editor.vue b/app/assets/javascripts/ide/components/repo_editor.vue
index 2f990280367..2bf99550bf2 100644
--- a/app/assets/javascripts/ide/components/repo_editor.vue
+++ b/app/assets/javascripts/ide/components/repo_editor.vue
@@ -79,6 +79,7 @@ export default {
'editorTheme',
'entries',
'currentProjectId',
+ 'previewMarkdownPath',
]),
...mapGetters([
'getAlert',
@@ -314,14 +315,15 @@ export default {
if (
this.fileType === MARKDOWN_FILE_TYPE &&
- this.editor?.getEditorType() === EDITOR_TYPE_CODE
+ this.editor?.getEditorType() === EDITOR_TYPE_CODE &&
+ this.previewMarkdownPath
) {
import('~/editor/extensions/source_editor_markdown_ext')
.then(({ EditorMarkdownExtension: MarkdownExtension } = {}) => {
this.editor.use(
new MarkdownExtension({
instance: this.editor,
- projectPath: this.currentProjectId,
+ previewMarkdownPath: this.previewMarkdownPath,
}),
);
})
diff --git a/app/assets/javascripts/ide/index.js b/app/assets/javascripts/ide/index.js
index e8c726d6184..bdffed70882 100644
--- a/app/assets/javascripts/ide/index.js
+++ b/app/assets/javascripts/ide/index.js
@@ -63,6 +63,7 @@ export function initIde(el, options = {}) {
editorTheme: window.gon?.user_color_scheme || DEFAULT_THEME,
codesandboxBundlerUrl: el.dataset.codesandboxBundlerUrl,
environmentsGuidanceAlertDismissed: !parseBoolean(el.dataset.enableEnvironmentsGuidance),
+ previewMarkdownPath: el.dataset.previewMarkdownPath,
});
},
beforeDestroy() {
diff --git a/app/assets/javascripts/ide/stores/state.js b/app/assets/javascripts/ide/stores/state.js
index 83551e87f09..526987c750a 100644
--- a/app/assets/javascripts/ide/stores/state.js
+++ b/app/assets/javascripts/ide/stores/state.js
@@ -32,4 +32,5 @@ export default () => ({
codesandboxBundlerUrl: null,
environmentsGuidanceAlertDismissed: false,
environmentsGuidanceAlertDetected: false,
+ previewMarkdownPath: '',
});