Commit 1c4eecd1 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch...

Merge branch '332042-wiki-editor-trims-leading-and-trailing-whitespace-breaking-formatting' into 'master'

Do not trim wiki content by default

See merge request gitlab-org/gitlab!63930
parents 2c6b1c39 e8e492d0
...@@ -119,7 +119,7 @@ export default { ...@@ -119,7 +119,7 @@ export default {
return { return {
title: this.pageInfo.title?.trim() || '', title: this.pageInfo.title?.trim() || '',
format: this.pageInfo.format || 'markdown', format: this.pageInfo.format || 'markdown',
content: this.pageInfo.content?.trim() || '', content: this.pageInfo.content || '',
isContentEditorLoading: true, isContentEditorLoading: true,
useContentEditor: false, useContentEditor: false,
commitMessage: '', commitMessage: '',
...@@ -131,7 +131,7 @@ export default { ...@@ -131,7 +131,7 @@ export default {
computed: { computed: {
noContent() { noContent() {
if (this.isContentEditorActive) return this.contentEditor?.empty; if (this.isContentEditorActive) return this.contentEditor?.empty;
return !this.content; return !this.content.trim();
}, },
csrfToken() { csrfToken() {
return csrf.token; return csrf.token;
...@@ -326,7 +326,7 @@ export default { ...@@ -326,7 +326,7 @@ export default {
<div class="col-sm-10"> <div class="col-sm-10">
<input <input
id="wiki_title" id="wiki_title"
v-model.trim="title" v-model="title"
name="wiki[title]" name="wiki[title]"
type="text" type="text"
class="form-control" class="form-control"
...@@ -418,7 +418,7 @@ export default { ...@@ -418,7 +418,7 @@ export default {
<textarea <textarea
id="wiki_content" id="wiki_content"
ref="textarea" ref="textarea"
v-model.trim="content" v-model="content"
name="wiki[content]" name="wiki[content]"
class="note-textarea js-gfm-input js-autosize markdown-area" class="note-textarea js-gfm-input js-autosize markdown-area"
dir="auto" dir="auto"
......
...@@ -63,7 +63,7 @@ describe('WikiForm', () => { ...@@ -63,7 +63,7 @@ describe('WikiForm', () => {
persisted: true, persisted: true,
title: 'My page', title: 'My page',
content: 'My page content', content: ' My page content ',
format: 'markdown', format: 'markdown',
path: '/project/path/-/wikis/home', path: '/project/path/-/wikis/home',
}; };
...@@ -129,6 +129,12 @@ describe('WikiForm', () => { ...@@ -129,6 +129,12 @@ describe('WikiForm', () => {
expect(findMessage().element.value).toBe('Update My page'); expect(findMessage().element.value).toBe('Update My page');
}); });
it('does not trim page content by default', () => {
createWrapper(true);
expect(findContent().element.value).toBe(' My page content ');
});
it.each` it.each`
value | text value | text
${'markdown'} | ${'[Link Title](page-slug)'} ${'markdown'} | ${'[Link Title](page-slug)'}
...@@ -183,10 +189,10 @@ describe('WikiForm', () => { ...@@ -183,10 +189,10 @@ describe('WikiForm', () => {
describe('when wiki content is updated', () => { describe('when wiki content is updated', () => {
beforeEach(() => { beforeEach(() => {
createWrapper(); createWrapper(true);
const input = findContent(); const input = findContent();
input.setValue('Lorem ipsum dolar sit!'); input.setValue(' Lorem ipsum dolar sit! ');
input.element.dispatchEvent(new Event('input')); input.element.dispatchEvent(new Event('input'));
return wrapper.vm.$nextTick(); return wrapper.vm.$nextTick();
...@@ -213,6 +219,10 @@ describe('WikiForm', () => { ...@@ -213,6 +219,10 @@ describe('WikiForm', () => {
it('does not trigger tracking event', async () => { it('does not trigger tracking event', async () => {
expect(trackingSpy).not.toHaveBeenCalled(); expect(trackingSpy).not.toHaveBeenCalled();
}); });
it('does not trim page content', () => {
expect(findContent().element.value).toBe(' Lorem ipsum dolar sit! ');
});
}); });
}); });
...@@ -434,7 +444,7 @@ describe('WikiForm', () => { ...@@ -434,7 +444,7 @@ describe('WikiForm', () => {
it('updates content from content editor on form submit', async () => { it('updates content from content editor on form submit', async () => {
// old value // old value
expect(findContent().element.value).toBe('My page content'); expect(findContent().element.value).toBe(' My page content ');
// wait for content editor to load // wait for content editor to load
await waitForPromises(); await waitForPromises();
...@@ -484,7 +494,7 @@ describe('WikiForm', () => { ...@@ -484,7 +494,7 @@ describe('WikiForm', () => {
}); });
it('the old editor retains its old value and does not use the content from the content editor', () => { it('the old editor retains its old value and does not use the content from the content editor', () => {
expect(findContent().element.value).toBe('My page content'); expect(findContent().element.value).toBe(' My page content ');
}); });
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment