From 85dc423f7090da0a52c73eb66faf22ddb20efff9 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Sat, 19 Sep 2020 01:45:44 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-4-stable-ee --- .../static_site_editor/components/edit_area.vue | 43 ++++++++++++++-- .../static_site_editor/components/edit_drawer.vue | 32 ++++++++++++ .../components/front_matter_controls.vue | 57 ++++++++++++++++++++++ .../components/publish_toolbar.vue | 16 +++++- 4 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 app/assets/javascripts/static_site_editor/components/edit_drawer.vue create mode 100644 app/assets/javascripts/static_site_editor/components/front_matter_controls.vue (limited to 'app/assets/javascripts/static_site_editor/components') diff --git a/app/assets/javascripts/static_site_editor/components/edit_area.vue b/app/assets/javascripts/static_site_editor/components/edit_area.vue index 53fbb2a330d..e602f26acdf 100644 --- a/app/assets/javascripts/static_site_editor/components/edit_area.vue +++ b/app/assets/javascripts/static_site_editor/components/edit_area.vue @@ -2,6 +2,7 @@ import RichContentEditor from '~/vue_shared/components/rich_content_editor/rich_content_editor.vue'; import PublishToolbar from './publish_toolbar.vue'; import EditHeader from './edit_header.vue'; +import EditDrawer from './edit_drawer.vue'; import UnsavedChangesConfirmDialog from './unsaved_changes_confirm_dialog.vue'; import parseSourceFile from '~/static_site_editor/services/parse_source_file'; import { EDITOR_TYPES } from '~/vue_shared/components/rich_content_editor/constants'; @@ -15,6 +16,7 @@ export default { RichContentEditor, PublishToolbar, EditHeader, + EditDrawer, UnsavedChangesConfirmDialog, }, props: { @@ -48,6 +50,8 @@ export default { parsedSource: parseSourceFile(this.preProcess(true, this.content)), editorMode: EDITOR_TYPES.wysiwyg, isModified: false, + hasMatter: false, + isDrawerOpen: false, }; }, imageRepository: imageRepository(), @@ -55,10 +59,19 @@ export default { editableContent() { return this.parsedSource.content(this.isWysiwygMode); }, + editableMatter() { + return this.isDrawerOpen ? this.parsedSource.matter() : {}; + }, + hasSettings() { + return this.hasMatter && this.isWysiwygMode; + }, isWysiwygMode() { return this.editorMode === EDITOR_TYPES.wysiwyg; }, }, + created() { + this.refreshEditHelpers(); + }, methods: { preProcess(isWrap, value) { const formattedContent = formatter(value); @@ -67,9 +80,21 @@ export default { : templater.unwrap(formattedContent); return templatedContent; }, - onInputChange(newVal) { - this.parsedSource.sync(newVal, this.isWysiwygMode); + refreshEditHelpers() { this.isModified = this.parsedSource.isModified(); + this.hasMatter = this.parsedSource.hasMatter(); + }, + onDrawerOpen() { + this.isDrawerOpen = true; + this.refreshEditHelpers(); + }, + onDrawerClose() { + this.isDrawerOpen = false; + this.refreshEditHelpers(); + }, + onInputChange(newVal) { + this.parsedSource.syncContent(newVal, this.isWysiwygMode); + this.refreshEditHelpers(); }, onModeChange(mode) { this.editorMode = mode; @@ -77,6 +102,9 @@ export default { const preProcessedContent = this.preProcess(this.isWysiwygMode, this.editableContent); this.$refs.editor.resetInitialValue(preProcessedContent); }, + onUpdateSettings(settings) { + this.parsedSource.syncMatter(settings); + }, onUploadImage({ file, imageUrl }) { this.$options.imageRepository.add(file, imageUrl); }, @@ -93,12 +121,19 @@ export default {