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