Commit fe10b7ed authored by Enrique Alcantara's avatar Enrique Alcantara

Replace defaultOptions with addOptions method

Fix breaking change where the defaultOptions object
is replaced with an addOptions method
parent 84aa7a1d
...@@ -5,9 +5,11 @@ import { handleFileEvent } from '../services/upload_helpers'; ...@@ -5,9 +5,11 @@ import { handleFileEvent } from '../services/upload_helpers';
export default Extension.create({ export default Extension.create({
name: 'attachment', name: 'attachment',
defaultOptions: { addOptions() {
uploadsPath: null, return {
renderMarkdown: null, uploadsPath: null,
renderMarkdown: null,
};
}, },
addCommands() { addCommands() {
......
...@@ -2,8 +2,10 @@ import Playable from './playable'; ...@@ -2,8 +2,10 @@ import Playable from './playable';
export default Playable.extend({ export default Playable.extend({
name: 'audio', name: 'audio',
defaultOptions: { addOptions() {
...Playable.options, return {
mediaType: 'audio', ...this.parent?.(),
mediaType: 'audio',
};
}, },
}); });
...@@ -31,13 +31,12 @@ const attrs = { ...@@ -31,13 +31,12 @@ const attrs = {
export default marks.map((name) => export default marks.map((name) =>
Mark.create({ Mark.create({
name, name,
inclusive: false, inclusive: false,
addOptions() {
defaultOptions: { return {
HTMLAttributes: {}, HTMLAttributes: {},
};
}, },
addAttributes() { addAttributes() {
return (attrs[name] || []).reduce( return (attrs[name] || []).reduce(
(acc, attr) => ({ (acc, attr) => ({
......
...@@ -7,9 +7,11 @@ const resolveImageEl = (element) => ...@@ -7,9 +7,11 @@ const resolveImageEl = (element) =>
element.nodeName === 'IMG' ? element : element.querySelector('img'); element.nodeName === 'IMG' ? element : element.querySelector('img');
export default Image.extend({ export default Image.extend({
defaultOptions: { addOptions() {
...Image.options, return {
inline: true, ...this.parent?.(),
inline: true,
};
}, },
addAttributes() { addAttributes() {
return { return {
......
...@@ -3,8 +3,10 @@ import { Mark, markInputRule, mergeAttributes } from '@tiptap/core'; ...@@ -3,8 +3,10 @@ import { Mark, markInputRule, mergeAttributes } from '@tiptap/core';
export default Mark.create({ export default Mark.create({
name: 'inlineDiff', name: 'inlineDiff',
defaultOptions: { addOptions() {
HTMLAttributes: {}, return {
HTMLAttributes: {},
};
}, },
addAttributes() { addAttributes() {
......
...@@ -18,10 +18,13 @@ export const extractHrefFromMarkdownLink = (match) => { ...@@ -18,10 +18,13 @@ export const extractHrefFromMarkdownLink = (match) => {
}; };
export default Link.extend({ export default Link.extend({
defaultOptions: { addOptions() {
...Link.options, return {
openOnClick: false, ...this.parent?.(),
openOnClick: false,
};
}, },
addInputRules() { addInputRules() {
const markdownLinkSyntaxInputRuleRegExp = /(?:^|\s)\[([\w|\s|-]+)\]\((?<href>.+?)\)$/gm; const markdownLinkSyntaxInputRuleRegExp = /(?:^|\s)\[([\w|\s|-]+)\]\((?<href>.+?)\)$/gm;
const urlSyntaxRegExp = /(?:^|\s)(?<href>(?:https?:\/\/|www\.)[\S]+)(?:\s|\n)$/gim; const urlSyntaxRegExp = /(?:^|\s)(?<href>(?:https?:\/\/|www\.)[\S]+)(?:\s|\n)$/gim;
......
...@@ -2,9 +2,11 @@ import { TaskItem } from '@tiptap/extension-task-item'; ...@@ -2,9 +2,11 @@ import { TaskItem } from '@tiptap/extension-task-item';
import { PARSE_HTML_PRIORITY_HIGHEST } from '../constants'; import { PARSE_HTML_PRIORITY_HIGHEST } from '../constants';
export default TaskItem.extend({ export default TaskItem.extend({
defaultOptions: { addOptions() {
nested: true, return {
HTMLAttributes: {}, nested: true,
HTMLAttributes: {},
};
}, },
addAttributes() { addAttributes() {
......
...@@ -2,9 +2,11 @@ import Playable from './playable'; ...@@ -2,9 +2,11 @@ import Playable from './playable';
export default Playable.extend({ export default Playable.extend({
name: 'video', name: 'video',
defaultOptions: { addOptions() {
...Playable.options, return {
mediaType: 'video', ...this.parent?.(),
extraElementAttrs: { width: '400' }, mediaType: 'video',
extraElementAttrs: { width: '400' },
};
}, },
}); });
...@@ -7,10 +7,12 @@ export default Node.create({ ...@@ -7,10 +7,12 @@ export default Node.create({
selectable: false, selectable: false,
atom: true, atom: true,
defaultOptions: { addOptions() {
HTMLAttributes: { return {
class: 'gl-display-inline-flex gl-px-1 gl-bg-blue-100 gl-rounded-base gl-font-sm', HTMLAttributes: {
}, class: 'gl-display-inline-flex gl-px-1 gl-bg-blue-100 gl-rounded-base gl-font-sm',
},
};
}, },
parseHTML() { parseHTML() {
......
...@@ -28,7 +28,6 @@ import TableHeader from '~/content_editor/extensions/table_header'; ...@@ -28,7 +28,6 @@ import TableHeader from '~/content_editor/extensions/table_header';
import TableRow from '~/content_editor/extensions/table_row'; import TableRow from '~/content_editor/extensions/table_row';
import TaskItem from '~/content_editor/extensions/task_item'; import TaskItem from '~/content_editor/extensions/task_item';
import TaskList from '~/content_editor/extensions/task_list'; import TaskList from '~/content_editor/extensions/task_list';
import Text from '~/content_editor/extensions/text';
import markdownSerializer from '~/content_editor/services/markdown_serializer'; import markdownSerializer from '~/content_editor/services/markdown_serializer';
import { createTestEditor, createDocBuilder } from '../test_utils'; import { createTestEditor, createDocBuilder } from '../test_utils';
...@@ -62,7 +61,6 @@ const tiptapEditor = createTestEditor({ ...@@ -62,7 +61,6 @@ const tiptapEditor = createTestEditor({
Link, Link,
ListItem, ListItem,
OrderedList, OrderedList,
Paragraph,
Strike, Strike,
Table, Table,
TableCell, TableCell,
...@@ -70,7 +68,6 @@ const tiptapEditor = createTestEditor({ ...@@ -70,7 +68,6 @@ const tiptapEditor = createTestEditor({
TableRow, TableRow,
TaskItem, TaskItem,
TaskList, TaskList,
Text,
], ],
}); });
......
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