2020-05-24 23:13:21 +05:30
|
|
|
import { __ } from '~/locale';
|
2020-07-28 23:09:34 +05:30
|
|
|
import { generateToolbarItem } from './services/editor_service';
|
|
|
|
import buildCustomHTMLRenderer from './services/build_custom_renderer';
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
export const CUSTOM_EVENTS = {
|
|
|
|
openAddImageModal: 'gl_openAddImageModal',
|
|
|
|
};
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
/* eslint-disable @gitlab/require-i18n-strings */
|
|
|
|
const TOOLBAR_ITEM_CONFIGS = [
|
|
|
|
{ icon: 'heading', event: 'openHeadingSelect', classes: 'tui-heading', tooltip: __('Headings') },
|
|
|
|
{ icon: 'bold', command: 'Bold', tooltip: __('Add bold text') },
|
|
|
|
{ icon: 'italic', command: 'Italic', tooltip: __('Add italic text') },
|
|
|
|
{ icon: 'strikethrough', command: 'Strike', tooltip: __('Add strikethrough text') },
|
|
|
|
{ isDivider: true },
|
|
|
|
{ icon: 'quote', command: 'Blockquote', tooltip: __('Insert a quote') },
|
|
|
|
{ icon: 'link', event: 'openPopupAddLink', tooltip: __('Add a link') },
|
|
|
|
{ isDivider: true },
|
|
|
|
{ icon: 'list-bulleted', command: 'UL', tooltip: __('Add a bullet list') },
|
|
|
|
{ icon: 'list-numbered', command: 'OL', tooltip: __('Add a numbered list') },
|
|
|
|
{ icon: 'list-task', command: 'Task', tooltip: __('Add a task list') },
|
|
|
|
{ icon: 'list-indent', command: 'Indent', tooltip: __('Indent') },
|
|
|
|
{ icon: 'list-outdent', command: 'Outdent', tooltip: __('Outdent') },
|
|
|
|
{ isDivider: true },
|
|
|
|
{ icon: 'dash', command: 'HR', tooltip: __('Add a line') },
|
|
|
|
{ icon: 'table', event: 'openPopupAddTable', classes: 'tui-table', tooltip: __('Add a table') },
|
2020-06-23 00:09:42 +05:30
|
|
|
{ icon: 'doc-image', event: CUSTOM_EVENTS.openAddImageModal, tooltip: __('Insert an image') },
|
2020-05-24 23:13:21 +05:30
|
|
|
{ isDivider: true },
|
|
|
|
{ icon: 'code', command: 'Code', tooltip: __('Insert inline code') },
|
2020-06-23 00:09:42 +05:30
|
|
|
{ icon: 'doc-code', command: 'CodeBlock', tooltip: __('Insert a code block') },
|
2020-05-24 23:13:21 +05:30
|
|
|
];
|
|
|
|
|
|
|
|
export const EDITOR_OPTIONS = {
|
|
|
|
toolbarItems: TOOLBAR_ITEM_CONFIGS.map(config => generateToolbarItem(config)),
|
2020-07-28 23:09:34 +05:30
|
|
|
customHTMLRenderer: buildCustomHTMLRenderer(),
|
2020-05-24 23:13:21 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
export const EDITOR_TYPES = {
|
2020-06-23 00:09:42 +05:30
|
|
|
markdown: 'markdown',
|
2020-05-24 23:13:21 +05:30
|
|
|
wysiwyg: 'wysiwyg',
|
|
|
|
};
|
|
|
|
|
|
|
|
export const EDITOR_HEIGHT = '100%';
|
|
|
|
|
|
|
|
export const EDITOR_PREVIEW_STYLE = 'horizontal';
|
2020-07-28 23:09:34 +05:30
|
|
|
|
|
|
|
export const IMAGE_TABS = { UPLOAD_TAB: 0, URL_TAB: 1 };
|
|
|
|
|
|
|
|
export const MAX_FILE_SIZE = 2097152; // 2Mb
|