Skip to content
代码片段 群组 项目
提交 c308788f 编辑于 作者: Himanshu Kapoor's avatar Himanshu Kapoor
浏览文件

Remove code behind preserve_unchanged_markdown

Since it is not used in production and never was, we remove it.

Changelog: changed
上级 3ca49cd0
No related branches found
No related tags found
无相关合并请求
......@@ -6,7 +6,6 @@ import * as builtInExtensions from '../extensions';
import { ContentEditor } from './content_editor';
import MarkdownSerializer from './markdown_serializer';
import createGlApiMarkdownDeserializer from './gl_api_markdown_deserializer';
import createRemarkMarkdownDeserializer from './remark_markdown_deserializer';
import AssetResolver from './asset_resolver';
import trackInputRulesAndShortcuts from './track_input_rules_and_shortcuts';
import AutocompleteHelper from './autocomplete_helper';
......@@ -40,11 +39,9 @@ export const createContentEditor = ({
dataSourceUrls: autocompleteDataSources,
sidebarMediator,
});
const deserializer = window.gon?.features?.preserveUnchangedMarkdown
? createRemarkMarkdownDeserializer()
: createGlApiMarkdownDeserializer({
render: renderMarkdown,
});
const deserializer = createGlApiMarkdownDeserializer({
render: renderMarkdown,
});
const { Suggestions, DrawioDiagram, ...otherExtensions } = builtInExtensions;
......
......@@ -32,10 +32,6 @@ module WikiActions
before_action :page, only: [:show, :edit, :update, :history, :destroy, :diff]
before_action :load_sidebar, except: [:pages]
before_action do
push_frontend_feature_flag(:preserve_unchanged_markdown, @group)
end
before_action only: [:show, :edit, :update] do
@valid_encoding = valid_encoding?
end
......
......@@ -44,7 +44,6 @@ class Projects::IssuesController < Projects::ApplicationController
before_action :authorize_read_code!, only: [:related_branches]
before_action do
push_frontend_feature_flag(:preserve_unchanged_markdown, project)
push_frontend_feature_flag(:issues_grid_view)
push_frontend_feature_flag(:service_desk_ticket)
push_frontend_feature_flag(:issues_list_drawer, project)
......
---
name: preserve_unchanged_markdown
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/86060
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/360713
milestone: '15.0'
type: development
group: group::knowledge
default_enabled: false
......@@ -17,7 +17,6 @@ class Groups::EpicsController < Groups::ApplicationController
after_action :log_epic_show, only: :show
before_action do
push_frontend_feature_flag(:preserve_unchanged_markdown, @group)
push_frontend_feature_flag(:notifications_todos_buttons, current_user)
push_frontend_feature_flag(:namespace_level_work_items, @group)
push_force_frontend_feature_flag(:namespace_level_work_items, @group&.namespace_work_items_enabled?)
......
import { PROVIDE_SERIALIZER_OR_RENDERER_ERROR } from '~/content_editor/constants';
import { createContentEditor } from '~/content_editor/services/create_content_editor';
import createGlApiMarkdownDeserializer from '~/content_editor/services/gl_api_markdown_deserializer';
import createRemarkMarkdownDeserializer from '~/content_editor/services/remark_markdown_deserializer';
import AssetResolver from '~/content_editor/services/asset_resolver';
import { createTestContentEditorExtension } from '../test_utils';
jest.mock('~/emoji');
jest.mock('~/content_editor/services/remark_markdown_deserializer');
jest.mock('~/content_editor/services/gl_api_markdown_deserializer');
describe('content_editor/services/create_content_editor', () => {
......@@ -16,36 +13,9 @@ describe('content_editor/services/create_content_editor', () => {
beforeEach(() => {
renderMarkdown = jest.fn();
window.gon = {
features: {
preserveUnchangedMarkdown: false,
},
};
editor = createContentEditor({ renderMarkdown, uploadsPath, drawioEnabled: true });
});
describe('when preserveUnchangedMarkdown feature is on', () => {
beforeEach(() => {
window.gon.features.preserveUnchangedMarkdown = true;
});
it('provides a remark markdown deserializer to the content editor class', () => {
createContentEditor({ renderMarkdown, uploadsPath });
expect(createRemarkMarkdownDeserializer).toHaveBeenCalled();
});
});
describe('when preserveUnchangedMarkdown feature is off', () => {
beforeEach(() => {
window.gon.features.preserveUnchangedMarkdown = false;
});
it('provides a gl api markdown deserializer to the content editor class', () => {
createContentEditor({ renderMarkdown, uploadsPath });
expect(createGlApiMarkdownDeserializer).toHaveBeenCalledWith({ render: renderMarkdown });
});
});
it('allows providing external content editor extensions', () => {
const labelReference = 'this is a ~group::editor';
const { tiptapExtension, serializer } = createTestContentEditorExtension();
......
import { builders } from 'prosemirror-test-builder';
import Sourcemap from '~/content_editor/extensions/sourcemap';
import MarkdownSerializer from '~/content_editor/services/markdown_serializer';
import remarkMarkdownDeserializer from '~/content_editor/services/remark_markdown_deserializer';
import { createTiptapEditor } from '../test_utils';
jest.mock('~/emoji');
......@@ -1676,94 +1675,4 @@ paragraph
![audio](audio.mp3) and ![video](video.mov)`.trimLeft(),
);
});
const defaultEditAction = (initialContent) => {
tiptapEditor.chain().setContent(initialContent.toJSON()).insertContent(' modified').run();
};
const prependContentEditAction = (initialContent) => {
tiptapEditor
.chain()
.setContent(initialContent.toJSON())
.setTextSelection(0)
.insertContent('modified ')
.run();
};
const editNonInclusiveMarkAction = (initialContent) => {
tiptapEditor.commands.setContent(initialContent.toJSON());
tiptapEditor.commands.selectTextblockEnd();
let { from } = tiptapEditor.state.selection;
tiptapEditor.commands.setTextSelection({
from: from - 1,
to: from - 1,
});
const sel = tiptapEditor.state.doc.textBetween(from - 1, from, ' ');
tiptapEditor.commands.insertContent(`${sel} modified`);
tiptapEditor.commands.selectTextblockEnd();
from = tiptapEditor.state.selection.from;
tiptapEditor.commands.deleteRange({ from: from - 1, to: from });
};
it.each`
mark | markdown | modifiedMarkdown | editAction
${'bold'} | ${'**bold**'} | ${'**bold modified**'} | ${defaultEditAction}
${'bold'} | ${'__bold__'} | ${'__bold modified__'} | ${defaultEditAction}
${'bold'} | ${'<strong>bold</strong>'} | ${'<strong>bold modified</strong>'} | ${defaultEditAction}
${'bold'} | ${'<b>bold</b>'} | ${'<b>bold modified</b>'} | ${defaultEditAction}
${'italic'} | ${'_italic_'} | ${'_italic modified_'} | ${defaultEditAction}
${'italic'} | ${'*italic*'} | ${'*italic modified*'} | ${defaultEditAction}
${'italic'} | ${'<em>italic</em>'} | ${'<em>italic modified</em>'} | ${defaultEditAction}
${'italic'} | ${'<i>italic</i>'} | ${'<i>italic modified</i>'} | ${defaultEditAction}
${'link'} | ${'[gitlab](https://gitlab.com)'} | ${'[gitlab modified](https://gitlab.com)'} | ${editNonInclusiveMarkAction}
${'link'} | ${'<a href="https://gitlab.com">link</a>'} | ${'<a href="https://gitlab.com">link modified</a>'} | ${editNonInclusiveMarkAction}
${'link'} | ${'link www.gitlab.com'} | ${'modified link www.gitlab.com'} | ${prependContentEditAction}
${'link'} | ${'link https://www.gitlab.com'} | ${'modified link https://www.gitlab.com'} | ${prependContentEditAction}
${'link'} | ${'link(https://www.gitlab.com)'} | ${'modified link(https://www.gitlab.com)'} | ${prependContentEditAction}
${'link'} | ${'link(engineering@gitlab.com)'} | ${'modified link(engineering@gitlab.com)'} | ${prependContentEditAction}
${'link'} | ${'link <https://www.gitlab.com>'} | ${'modified link <https://www.gitlab.com>'} | ${prependContentEditAction}
${'link'} | ${'link https://www.gitlab.com/path'} | ${'modified link https://www.gitlab.com/path'} | ${prependContentEditAction}
${'link'} | ${'link https://www.gitlab.com?query=search'} | ${'modified link https://www.gitlab.com?query=search'} | ${prependContentEditAction}
${'link'} | ${'link https://www.gitlab.com/#fragment'} | ${'modified link https://www.gitlab.com/#fragment'} | ${prependContentEditAction}
${'link'} | ${'link https://www.gitlab.com/?query=search'} | ${'modified link https://www.gitlab.com/?query=search'} | ${prependContentEditAction}
${'link'} | ${'link https://www.gitlab.com#fragment'} | ${'modified link https://www.gitlab.com#fragment'} | ${prependContentEditAction}
${'link'} | ${'link **https://www.gitlab.com]**'} | ${'modified link **https://www.gitlab.com\\]**'} | ${prependContentEditAction}
${'code'} | ${'`code`'} | ${'`code modified`'} | ${defaultEditAction}
${'code'} | ${'<code>code</code>'} | ${'<code>code modified</code>'} | ${defaultEditAction}
${'strike'} | ${'~~striked~~'} | ${'~~striked modified~~'} | ${defaultEditAction}
${'strike'} | ${'<del>striked</del>'} | ${'<del>striked modified</del>'} | ${defaultEditAction}
${'strike'} | ${'<strike>striked</strike>'} | ${'<strike>striked modified</strike>'} | ${defaultEditAction}
${'strike'} | ${'<s>striked</s>'} | ${'<s>striked modified</s>'} | ${defaultEditAction}
${'list'} | ${'- list item'} | ${'- list item modified'} | ${defaultEditAction}
${'list'} | ${'* list item'} | ${'* list item modified'} | ${defaultEditAction}
${'list'} | ${'+ list item'} | ${'+ list item modified'} | ${defaultEditAction}
${'list'} | ${'- list item 1\n- list item 2'} | ${'- list item 1\n- list item 2 modified'} | ${defaultEditAction}
${'list'} | ${'2) list item'} | ${'2) list item modified'} | ${defaultEditAction}
${'list'} | ${'1. list item'} | ${'1. list item modified'} | ${defaultEditAction}
${'taskList'} | ${'2) [ ] task list item'} | ${'2) [ ] task list item modified'} | ${defaultEditAction}
${'taskList'} | ${'2) [x] task list item'} | ${'2) [x] task list item modified'} | ${defaultEditAction}
${'image'} | ${'![image](image.png)'} | ${'![image](image.png) modified'} | ${defaultEditAction}
${'footnoteReference'} | ${'[^1] footnote\n\n[^1]: footnote definition'} | ${'modified [^1] footnote\n\n[^1]: footnote definition'} | ${prependContentEditAction}
`(
'preserves original $mark syntax when sourceMarkdown is available for $markdown',
async ({ markdown, modifiedMarkdown, editAction }) => {
const { document } = await remarkMarkdownDeserializer().deserialize({
schema: tiptapEditor.schema,
markdown,
});
editAction(document);
const serialized = new MarkdownSerializer().serialize({
pristineDoc: document,
doc: tiptapEditor.state.doc,
});
expect(serialized).toEqual(modifiedMarkdown);
},
);
});
......@@ -82,44 +82,6 @@ describe('content_editor', () => {
});
});
describe('when preserveUnchangedMarkdown feature flag is enabled', () => {
beforeEach(() => {
gon.features = { preserveUnchangedMarkdown: true };
});
afterEach(() => {
gon.features = { preserveUnchangedMarkdown: false };
});
it('processes and renders footnote ids alongside the footnote definition', async () => {
buildWrapper({
markdown: `
This reference tag is a mix of letters and numbers [^footnote].
[^footnote]: This is another footnote.
`,
});
await waitUntilContentIsLoaded();
expect(wrapper.text()).toContain('footnote:');
expect(wrapper.text()).toContain('This is another footnote.');
});
it('processes and displays reference definitions', async () => {
buildWrapper({
markdown: `
[GitLab][gitlab]
[gitlab]: https://gitlab.com
`,
});
await waitUntilContentIsLoaded();
expect(wrapper.find('pre').text()).toContain('[gitlab]: https://gitlab.com');
});
});
it('renders table of contents', async () => {
renderMarkdown.mockResolvedValueOnce({
body: `
......
......@@ -11,6 +11,9 @@ def switch_to_markdown_editor
def switch_to_content_editor
click_button("Switch to rich text editing")
# wait for the editor to be focused
find("#{content_editor_testid}:focus")
end
def type_in_content_editor(keys)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册