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>2020-07-29 12:09:33 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-29 12:09:33 +0300
commitb4dc6516ae8662e23e6fd8331656a91f9e853417 (patch)
treedc661c605af627ea9306dc592433c40b9cc0e832 /app/assets/javascripts/static_site_editor
parent3fa28959b9c657503c98caa0e535d39f51ad2c31 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/static_site_editor')
-rw-r--r--app/assets/javascripts/static_site_editor/components/edit_area.vue7
-rw-r--r--app/assets/javascripts/static_site_editor/services/formatter.js14
2 files changed, 19 insertions, 2 deletions
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 84a16f327d9..3c09640c78b 100644
--- a/app/assets/javascripts/static_site_editor/components/edit_area.vue
+++ b/app/assets/javascripts/static_site_editor/components/edit_area.vue
@@ -7,6 +7,7 @@ import parseSourceFile from '~/static_site_editor/services/parse_source_file';
import { EDITOR_TYPES } from '~/vue_shared/components/rich_content_editor/constants';
import { DEFAULT_IMAGE_UPLOAD_PATH } from '../constants';
import imageRepository from '../image_repository';
+import formatter from '../services/formatter';
export default {
components: {
@@ -64,14 +65,16 @@ export default {
},
onModeChange(mode) {
this.editorMode = mode;
- this.$refs.editor.resetInitialValue(this.editableContent);
+ const formattedContent = formatter(this.editableContent);
+ this.$refs.editor.resetInitialValue(formattedContent);
},
onUploadImage({ file, imageUrl }) {
this.$options.imageRepository.add(file, imageUrl);
},
onSubmit() {
+ const formattedContent = formatter(this.parsedSource.content());
this.$emit('submit', {
- content: this.parsedSource.content(),
+ content: formattedContent,
images: this.$options.imageRepository.getAll(),
});
},
diff --git a/app/assets/javascripts/static_site_editor/services/formatter.js b/app/assets/javascripts/static_site_editor/services/formatter.js
new file mode 100644
index 00000000000..92d5e8a5df8
--- /dev/null
+++ b/app/assets/javascripts/static_site_editor/services/formatter.js
@@ -0,0 +1,14 @@
+const removeOrphanedBrTags = source => {
+ /* Until the underlying Squire editor of Toast UI Editor resolves duplicate `<br>` tags, this
+ `replace` solution will clear out orphaned `<br>` tags that it generates. Additionally,
+ it cleans up orphaned `<br>` tags in the source markdown document that should be new lines.
+ https://gitlab.com/gitlab-org/gitlab/-/issues/227602#note_380765330
+ */
+ return source.replace(/\n^<br>$/gm, '');
+};
+
+const format = source => {
+ return removeOrphanedBrTags(source);
+};
+
+export default format;