diff --git a/packages/devextreme/js/__internal/ui/html_editor/converters/m_delta.ts b/packages/devextreme/js/__internal/ui/html_editor/converters/m_delta.ts index a50ebeb0488f..eebca0a33cf8 100644 --- a/packages/devextreme/js/__internal/ui/html_editor/converters/m_delta.ts +++ b/packages/devextreme/js/__internal/ui/html_editor/converters/m_delta.ts @@ -1,30 +1,31 @@ -import ConverterController from '../converterController'; +import ConverterController from '../m_converterController'; class DeltaConverter { + quillInstance: any; - setQuillInstance(quillInstance) { - this.quillInstance = quillInstance; - } - - toHtml() { - if(!this.quillInstance) { - return; - } + setQuillInstance(quillInstance) { + this.quillInstance = quillInstance; + } - return this._isQuillEmpty() ? - '' : - this.quillInstance.getSemanticHTML(0, this.quillInstance.getLength() + 1); + toHtml() { + if (!this.quillInstance) { + return; } - _isQuillEmpty() { - const delta = this.quillInstance.getContents(); + return this._isQuillEmpty() + ? '' + : this.quillInstance.getSemanticHTML(0, this.quillInstance.getLength() + 1); + } - return delta.length() === 1 && this._isDeltaEmpty(delta); - } + _isQuillEmpty() { + const delta = this.quillInstance.getContents(); - _isDeltaEmpty(delta) { - return delta.reduce((__, { insert }) => insert.indexOf('\n') !== -1); - } + return delta.length() === 1 && this._isDeltaEmpty(delta); + } + + _isDeltaEmpty(delta) { + return delta.reduce((__, { insert }) => insert.indexOf('\n') !== -1); + } } ConverterController.addConverter('delta', DeltaConverter); diff --git a/packages/devextreme/js/__internal/ui/html_editor/converters/m_markdown.ts b/packages/devextreme/js/__internal/ui/html_editor/converters/m_markdown.ts index 4fbfda530d9c..79f9d2319043 100644 --- a/packages/devextreme/js/__internal/ui/html_editor/converters/m_markdown.ts +++ b/packages/devextreme/js/__internal/ui/html_editor/converters/m_markdown.ts @@ -1,59 +1,63 @@ - -import TurnDown from 'turndown'; +import { getWindow } from '@js/core/utils/window'; +import Errors from '@js/ui/widget/ui.errors'; import ShowDown from 'showdown'; +import TurnDown from 'turndown'; -import { getWindow } from '../../../core/utils/window'; -import Errors from '../../widget/ui.errors'; -import converterController from '../converterController'; +import converterController from '../m_converterController'; class MarkdownConverter { - constructor() { - const window = getWindow(); - const turndown = window && window.TurndownService || TurnDown; - const showdown = window && window.showdown || ShowDown; - - if(!turndown) { - throw Errors.Error('E1041', 'Turndown'); - } - - if(!showdown) { - throw Errors.Error('E1041', 'Showdown'); - } - - this._html2Markdown = new turndown(); - - if(this._html2Markdown?.addRule) { - this._html2Markdown.addRule('emptyLine', { - filter: (element) => { - return element.nodeName.toLowerCase() === 'p' && element.innerHTML === '
'; - }, - replacement: function() { - return '
'; - } - }); - this._html2Markdown.keep(['table']); - } - - this._markdown2Html = new showdown.Converter({ - simpleLineBreaks: true, - strikethrough: true, - tables: true - }); + _markdown2Html: any; + + _html2Markdown: any; + + constructor() { + const window = getWindow(); + // @ts-expect-error + const turndown = window && window.TurndownService || TurnDown; + // @ts-expect-error + const showdown = window && window.showdown || ShowDown; + + if (!turndown) { + throw Errors.Error('E1041', 'Turndown'); } - toMarkdown(htmlMarkup) { - return this._html2Markdown.turndown(htmlMarkup || ''); + if (!showdown) { + throw Errors.Error('E1041', 'Showdown'); } - toHtml(markdownMarkup) { - let markup = this._markdown2Html.makeHtml(markdownMarkup); + // eslint-disable-next-line new-cap + this._html2Markdown = new turndown(); - if(markup) { - markup = markup.replace(new RegExp('\\r?\\n', 'g'), ''); - } + if (this._html2Markdown?.addRule) { + this._html2Markdown.addRule('emptyLine', { + filter: (element) => element.nodeName.toLowerCase() === 'p' && element.innerHTML === '
', + replacement() { + return '
'; + }, + }); + this._html2Markdown.keep(['table']); + } + + this._markdown2Html = new showdown.Converter({ + simpleLineBreaks: true, + strikethrough: true, + tables: true, + }); + } + + toMarkdown(htmlMarkup) { + return this._html2Markdown.turndown(htmlMarkup || ''); + } - return markup; + toHtml(markdownMarkup) { + let markup = this._markdown2Html.makeHtml(markdownMarkup); + + if (markup) { + markup = markup.replace(new RegExp('\\r?\\n', 'g'), ''); } + + return markup; + } } converterController.addConverter('markdown', MarkdownConverter); diff --git a/packages/devextreme/js/__internal/ui/html_editor/formats/m_align.ts b/packages/devextreme/js/__internal/ui/html_editor/formats/m_align.ts index 1702eca11688..9a682a84eaaf 100644 --- a/packages/devextreme/js/__internal/ui/html_editor/formats/m_align.ts +++ b/packages/devextreme/js/__internal/ui/html_editor/formats/m_align.ts @@ -1,10 +1,12 @@ import Quill from 'devextreme-quill'; +// eslint-disable-next-line import/no-mutable-exports let AlignStyle = {}; -if(Quill) { - AlignStyle = Quill.import('attributors/style/align'); - AlignStyle.whitelist.push('left'); +if (Quill) { + AlignStyle = Quill.import('attributors/style/align'); + // @ts-expect-error + AlignStyle.whitelist.push('left'); } export default AlignStyle; diff --git a/packages/devextreme/js/__internal/ui/html_editor/formats/m_font.ts b/packages/devextreme/js/__internal/ui/html_editor/formats/m_font.ts index b79646b5a795..191158554a2c 100644 --- a/packages/devextreme/js/__internal/ui/html_editor/formats/m_font.ts +++ b/packages/devextreme/js/__internal/ui/html_editor/formats/m_font.ts @@ -1,10 +1,12 @@ import Quill from 'devextreme-quill'; +// eslint-disable-next-line import/no-mutable-exports let FontStyle = {}; -if(Quill) { - FontStyle = Quill.import('attributors/style/font'); - FontStyle.whitelist = null; +if (Quill) { + FontStyle = Quill.import('attributors/style/font'); + // @ts-expect-error + FontStyle.whitelist = null; } export default FontStyle; diff --git a/packages/devextreme/js/__internal/ui/html_editor/formats/m_image.ts b/packages/devextreme/js/__internal/ui/html_editor/formats/m_image.ts index 4ed7f113ce80..ca2d89145438 100644 --- a/packages/devextreme/js/__internal/ui/html_editor/formats/m_image.ts +++ b/packages/devextreme/js/__internal/ui/html_editor/formats/m_image.ts @@ -1,67 +1,70 @@ +import { isObject } from '@js/core/utils/type'; import Quill from 'devextreme-quill'; -import { isObject } from '../../../core/utils/type'; +// eslint-disable-next-line import/no-mutable-exports let ExtImage = {}; -if(Quill) { - const Image = Quill.import('formats/image'); - - ExtImage = class ExtImage extends Image { - static create(data) { - const SRC = data && data.src || data; - const node = super.create(SRC); - - if(isObject(data)) { - const setAttribute = (attr, value) => { - data[attr] && node.setAttribute(attr, value); - }; - - setAttribute('alt', data.alt); - setAttribute('width', data.width); - setAttribute('height', data.height); - } - - return node; - } - - static formats(domNode) { - const formats = super.formats(domNode); - - formats['imageSrc'] = domNode.getAttribute('src'); - - return formats; - } - - formats() { - const formats = super.formats(); - const floatValue = this.domNode.style['float']; - - if(floatValue) { - formats['float'] = floatValue; - } - - return formats; - } - - format(name, value) { - if(name === 'float') { - this.domNode.style[name] = value; - } else { - super.format(name, value); - } - } - - static value(domNode) { - return { - src: domNode.getAttribute('src'), - width: domNode.getAttribute('width'), - height: domNode.getAttribute('height'), - alt: domNode.getAttribute('alt') - }; - } - }; - - ExtImage.blotName = 'extendedImage'; +if (Quill) { + const Image = Quill.import('formats/image'); + + ExtImage = class ExtImage extends Image { + static create(data) { + const SRC = data && data.src || data; + const node = super.create(SRC); + + if (isObject(data)) { + const setAttribute = (attr, value) => { + data[attr] && node.setAttribute(attr, value); + }; + // @ts-expect-error + setAttribute('alt', data.alt); + // @ts-expect-error + setAttribute('width', data.width); + // @ts-expect-error + setAttribute('height', data.height); + } + + return node; + } + + static formats(domNode) { + const formats = super.formats(domNode); + + formats.imageSrc = domNode.getAttribute('src'); + + return formats; + } + + formats() { + const formats = super.formats(); + const floatValue = this.domNode.style.float; + + if (floatValue) { + formats.float = floatValue; + } + + return formats; + } + + format(name, value) { + if (name === 'float') { + this.domNode.style[name] = value; + } else { + super.format(name, value); + } + } + + static value(domNode) { + return { + src: domNode.getAttribute('src'), + width: domNode.getAttribute('width'), + height: domNode.getAttribute('height'), + alt: domNode.getAttribute('alt'), + }; + } + }; + // @ts-expect-error + ExtImage.blotName = 'extendedImage'; } export default ExtImage; diff --git a/packages/devextreme/js/__internal/ui/html_editor/formats/m_link.ts b/packages/devextreme/js/__internal/ui/html_editor/formats/m_link.ts index ada55c58f394..7ab6be4b609c 100644 --- a/packages/devextreme/js/__internal/ui/html_editor/formats/m_link.ts +++ b/packages/devextreme/js/__internal/ui/html_editor/formats/m_link.ts @@ -1,70 +1,77 @@ +import { isObject } from '@js/core/utils/type'; import Quill from 'devextreme-quill'; -import { isObject } from '../../../core/utils/type'; +// eslint-disable-next-line import/no-mutable-exports let ExtLink = {}; -if(Quill) { - const Link = Quill.import('formats/link'); +if (Quill) { + const Link = Quill.import('formats/link'); - ExtLink = class ExtLink extends Link { - static create(data) { - const HREF = data?.href ?? data; - const node = super.create(HREF); + ExtLink = class ExtLink extends Link { + static create(data) { + const HREF = data?.href ?? data; + const node = super.create(HREF); - if(isObject(data)) { - if(data.text) { - node.innerText = data.text; - } - if(!data.target) { - node.removeAttribute('target'); - } - } - - return node; + if (isObject(data)) { + // @ts-expect-error + if (data.text) { + // @ts-expect-error + node.innerText = data.text; } - - static formats(domNode) { - return { - href: domNode.getAttribute('href'), - target: domNode.getAttribute('target') - }; + // @ts-expect-error + if (!data.target) { + node.removeAttribute('target'); } + } - formats() { - const formats = super.formats(); - const { href, target } = ExtLink.formats(this.domNode); + return node; + } - formats.link = href; - formats.target = target; + static formats(domNode) { + return { + href: domNode.getAttribute('href'), + target: domNode.getAttribute('target'), + }; + } - return formats; - } + formats() { + const formats = super.formats(); + const { href, target } = ExtLink.formats(this.domNode); - format(name, value) { - if(name === 'link' && isObject(value)) { - if(value.text) { - this.domNode.innerText = value.text; - } - if(value.target) { - this.domNode.setAttribute('target', '_blank'); - } else { - this.domNode.removeAttribute('target'); - } - this.domNode.setAttribute('href', value.href); - } else { - super.format(name, value); - } - } + formats.link = href; + formats.target = target; - static value(domNode) { - return { - href: domNode.getAttribute('href'), - text: domNode.innerText, - target: !!domNode.getAttribute('target') - }; + return formats; + } + + format(name, value) { + if (name === 'link' && isObject(value)) { + // @ts-expect-error + if (value.text) { + // @ts-expect-error + this.domNode.innerText = value.text; } - }; -} + // @ts-expect-error + if (value.target) { + this.domNode.setAttribute('target', '_blank'); + } else { + this.domNode.removeAttribute('target'); + } + // @ts-expect-error + this.domNode.setAttribute('href', value.href); + } else { + super.format(name, value); + } + } + static value(domNode) { + return { + href: domNode.getAttribute('href'), + text: domNode.innerText, + target: !!domNode.getAttribute('target'), + }; + } + }; +} export default ExtLink; diff --git a/packages/devextreme/js/__internal/ui/html_editor/formats/m_mention.ts b/packages/devextreme/js/__internal/ui/html_editor/formats/m_mention.ts index db5c090860b2..7cdb3d3144b5 100644 --- a/packages/devextreme/js/__internal/ui/html_editor/formats/m_mention.ts +++ b/packages/devextreme/js/__internal/ui/html_editor/formats/m_mention.ts @@ -1,75 +1,77 @@ - +import $ from '@js/core/renderer'; import Quill from 'devextreme-quill'; -import $ from '../../../core/renderer'; -import TemplatesStorage from '../utils/templates_storage'; - -let Mention = {}; - -if(Quill) { - const Embed = Quill.import('blots/embed'); - const MENTION_CLASS = 'dx-mention'; - - Mention = class Mention extends Embed { - constructor(scroll, node) { - super(scroll, node); - this.renderContent(this.contentNode, Mention.value(node)); - } - - static create(data) { - const node = super.create(); - - node.setAttribute('spellcheck', false); - node.dataset.marker = data.marker; - node.dataset.mentionValue = data.value; - node.dataset.id = data.id; - - return node; - } - static value(node) { - return { - marker: node.dataset.marker, - id: node.dataset.id, - value: node.dataset.mentionValue - }; - } +import TemplatesStorage from '../utils/m_templates_storage'; - renderContent(node, data) { - const template = Mention._templatesStorage.get({ editorKey: data.keyInTemplateStorage, marker: data.marker }); - - if(template) { - template.render({ - model: data, - container: node - }); - } else { - this.baseContentRender(node, data); - } - - } - - baseContentRender(node, data) { - const $marker = $('').text(data.marker); - - $(node) - .append($marker) - .append(data.value); - } - - static addTemplate(data, template) { - this._templatesStorage.set(data, template); - } - - static removeTemplate(data) { - this._templatesStorage.delete(data); - } - }; +// eslint-disable-next-line import/no-mutable-exports +let Mention = {}; - Mention.blotName = 'mention'; - Mention.tagName = 'span'; - Mention.className = MENTION_CLASS; - Mention._templatesStorage = new TemplatesStorage(); +if (Quill) { + const Embed = Quill.import('blots/embed'); + const MENTION_CLASS = 'dx-mention'; + + Mention = class Mention extends Embed { + constructor(scroll, node) { + super(scroll, node); + this.renderContent(this.contentNode, Mention.value(node)); + } + + static create(data) { + const node = super.create(); + + node.setAttribute('spellcheck', false); + node.dataset.marker = data.marker; + node.dataset.mentionValue = data.value; + node.dataset.id = data.id; + + return node; + } + + static value(node) { + return { + marker: node.dataset.marker, + id: node.dataset.id, + value: node.dataset.mentionValue, + }; + } + + renderContent(node, data) { + const template = Mention._templatesStorage.get({ editorKey: data.keyInTemplateStorage, marker: data.marker }); + + if (template) { + template.render({ + model: data, + container: node, + }); + } else { + this.baseContentRender(node, data); + } + } + + baseContentRender(node, data) { + const $marker = $('').text(data.marker); + + $(node) + .append($marker) + .append(data.value); + } + + static addTemplate(data, template) { + this._templatesStorage.set(data, template); + } + + static removeTemplate(data) { + this._templatesStorage.delete(data); + } + }; + // @ts-expect-error + Mention.blotName = 'mention'; + // @ts-expect-error + Mention.tagName = 'span'; + // @ts-expect-error + Mention.className = MENTION_CLASS; + // @ts-expect-error + Mention._templatesStorage = new TemplatesStorage(); } - export default Mention; diff --git a/packages/devextreme/js/__internal/ui/html_editor/formats/m_size.ts b/packages/devextreme/js/__internal/ui/html_editor/formats/m_size.ts index dc11343aa6e1..a7310e82fd0a 100644 --- a/packages/devextreme/js/__internal/ui/html_editor/formats/m_size.ts +++ b/packages/devextreme/js/__internal/ui/html_editor/formats/m_size.ts @@ -1,10 +1,12 @@ import Quill from 'devextreme-quill'; +// eslint-disable-next-line import/no-mutable-exports let SizeStyle = {}; -if(Quill) { - SizeStyle = Quill.import('attributors/style/size'); - SizeStyle.whitelist = null; +if (Quill) { + SizeStyle = Quill.import('attributors/style/size'); + // @ts-expect-error + SizeStyle.whitelist = null; } export default SizeStyle; diff --git a/packages/devextreme/js/__internal/ui/html_editor/formats/m_variable.ts b/packages/devextreme/js/__internal/ui/html_editor/formats/m_variable.ts index 0ab3ca714170..ef7406570042 100644 --- a/packages/devextreme/js/__internal/ui/html_editor/formats/m_variable.ts +++ b/packages/devextreme/js/__internal/ui/html_editor/formats/m_variable.ts @@ -1,50 +1,53 @@ +import { ensureDefined } from '@js/core/utils/common'; +import { extend } from '@js/core/utils/extend'; import Quill from 'devextreme-quill'; -import { ensureDefined } from '../../../core/utils/common'; -import { extend } from '../../../core/utils/extend'; +// eslint-disable-next-line import/no-mutable-exports let Variable = {}; -if(Quill) { - const Embed = Quill.import('blots/embed'); - - const VARIABLE_CLASS = 'dx-variable'; - - Variable = class Variable extends Embed { - static create(data) { - const node = super.create(); - let startEscapeChar; - let endEscapeChar; - const text = data.value; - - if(Array.isArray(data.escapeChar)) { - startEscapeChar = ensureDefined(data.escapeChar[0], ''); - endEscapeChar = ensureDefined(data.escapeChar[1], ''); - } else { - startEscapeChar = endEscapeChar = data.escapeChar; - } - - node.innerText = startEscapeChar + text + endEscapeChar; - node.dataset.varStartEscChar = startEscapeChar; - node.dataset.varEndEscChar = endEscapeChar; - node.dataset.varValue = data.value; - - return node; - } - - static value(node) { - return extend({}, { - value: node.dataset.varValue, - escapeChar: [ - node.dataset.varStartEscChar || '', - node.dataset.varEndEscChar || '' - ] - }); - } - }; - - Variable.blotName = 'variable'; - Variable.tagName = 'span'; - Variable.className = VARIABLE_CLASS; +if (Quill) { + const Embed = Quill.import('blots/embed'); + + const VARIABLE_CLASS = 'dx-variable'; + + Variable = class Variable extends Embed { + static create(data) { + const node = super.create(); + let startEscapeChar; + let endEscapeChar; + const text = data.value; + + if (Array.isArray(data.escapeChar)) { + startEscapeChar = ensureDefined(data.escapeChar[0], ''); + endEscapeChar = ensureDefined(data.escapeChar[1], ''); + } else { + startEscapeChar = endEscapeChar = data.escapeChar; + } + + node.innerText = startEscapeChar + text + endEscapeChar; + node.dataset.varStartEscChar = startEscapeChar; + node.dataset.varEndEscChar = endEscapeChar; + node.dataset.varValue = data.value; + + return node; + } + + static value(node) { + return extend({}, { + value: node.dataset.varValue, + escapeChar: [ + node.dataset.varStartEscChar || '', + node.dataset.varEndEscChar || '', + ], + }); + } + }; + // @ts-expect-error + Variable.blotName = 'variable'; + // @ts-expect-error + Variable.tagName = 'span'; + // @ts-expect-error + Variable.className = VARIABLE_CLASS; } export default Variable; diff --git a/packages/devextreme/js/__internal/ui/html_editor/m_converterController.ts b/packages/devextreme/js/__internal/ui/html_editor/m_converterController.ts index 0f189556507f..a2971f25e1ee 100644 --- a/packages/devextreme/js/__internal/ui/html_editor/m_converterController.ts +++ b/packages/devextreme/js/__internal/ui/html_editor/m_converterController.ts @@ -1,16 +1,17 @@ - class ConverterController { - constructor() { - this._converters = {}; - } + _converters = {}; + + constructor() { + this._converters = {}; + } - addConverter(name, converter) { - this._converters[name] = converter; - } + addConverter(name, converter) { + this._converters[name] = converter; + } - getConverter(name) { - return this._converters[name]; - } + getConverter(name) { + return this._converters[name]; + } } const controller = new ConverterController(); diff --git a/packages/devextreme/js/__internal/ui/html_editor/m_html_editor.ts b/packages/devextreme/js/__internal/ui/html_editor/m_html_editor.ts index e19a3271e061..d6ce109e3896 100644 --- a/packages/devextreme/js/__internal/ui/html_editor/m_html_editor.ts +++ b/packages/devextreme/js/__internal/ui/html_editor/m_html_editor.ts @@ -1,32 +1,37 @@ -import $ from '../../core/renderer'; -import { extend } from '../../core/utils/extend'; -import { isDefined, isFunction } from '../../core/utils/type'; -import { getPublicElement } from '../../core/element'; -import { executeAsync, noop, ensureDefined, deferRender } from '../../core/utils/common'; -import registerComponent from '../../core/component_registrator'; -import { EmptyTemplate } from '../../core/templates/empty_template'; -import Editor from '../editor/editor'; -import Errors from '../widget/ui.errors'; -import Callbacks from '../../core/utils/callbacks'; -import { Deferred } from '../../core/utils/deferred'; -import eventsEngine from '../../events/core/events_engine'; -import { addNamespace } from '../../events/utils/index'; -import { Event as dxEvent } from '../../events/index'; -import scrollEvents from '../../events/gesture/emitter.gesture.scroll'; -import { prepareScrollData } from '../../__internal/ui/text_box/m_utils.scroll'; - -import pointerEvents from '../../events/pointer'; -import devices from '../../core/devices'; - -import QuillRegistrator from './quill_registrator'; -import './converters/delta'; -import ConverterController from './converterController'; -import getWordMatcher from './matchers/wordLists'; -import FormDialog from './ui/formDialog'; -import config from '../../core/config'; -import { getQuill } from './quill_importer'; - -// STYLE htmlEditor +import './converters/m_delta'; + +import registerComponent from '@js/core/component_registrator'; +import config from '@js/core/config'; +import devices from '@js/core/devices'; +import { getPublicElement } from '@js/core/element'; +import $ from '@js/core/renderer'; +import { EmptyTemplate } from '@js/core/templates/empty_template'; +import Callbacks from '@js/core/utils/callbacks'; +import { + deferRender, + ensureDefined, + // @ts-expect-error + executeAsync, + noop, +} from '@js/core/utils/common'; +import { Deferred } from '@js/core/utils/deferred'; +import { extend } from '@js/core/utils/extend'; +import { isDefined, isFunction } from '@js/core/utils/type'; +import eventsEngine from '@js/events/core/events_engine'; +import scrollEvents from '@js/events/gesture/emitter.gesture.scroll'; +// @ts-expect-error +import { Event as dxEvent } from '@js/events/index'; +import pointerEvents from '@js/events/pointer'; +import { addNamespace } from '@js/events/utils/index'; +import Editor from '@js/ui/editor/editor'; +import Errors from '@js/ui/widget/ui.errors'; +import { prepareScrollData } from '@ts/ui/text_box/m_utils.scroll'; + +import ConverterController from './m_converterController'; +import { getQuill } from './m_quill_importer'; +import QuillRegistrator from './m_quill_registrator'; +import getWordMatcher from './matchers/m_wordLists'; +import FormDialog from './ui/m_formDialog'; const HTML_EDITOR_CLASS = 'dx-htmleditor'; const QUILL_CONTAINER_CLASS = 'dx-quill-container'; @@ -41,738 +46,739 @@ const ANONYMOUS_TEMPLATE_NAME = 'htmlContent'; const isIos = devices.current().platform === 'ios'; let editorsCount = 0; - +// @ts-expect-error const HtmlEditor = Editor.inherit({ - _getDefaultOptions: function() { - return extend(this.callBase(), { - focusStateEnabled: true, - valueType: 'html', - placeholder: '', - toolbar: null, - variables: null, - mediaResizing: null, - tableResizing: null, - mentions: null, - customizeModules: null, - tableContextMenu: null, - allowSoftLineBreak: false, - - formDialogOptions: null, - - imageUpload: null, - - stylingMode: config().editorStylingMode || 'outlined', - }); - }, - - _init: function() { - this._mentionKeyInTemplateStorage = editorsCount++; - this.callBase(); - this._cleanCallback = Callbacks(); - this._contentInitializedCallback = Callbacks(); - }, - - _getAnonymousTemplateName: function() { - return ANONYMOUS_TEMPLATE_NAME; - }, - - _initTemplates: function() { - this._templateManager.addDefaultTemplates({ - [ANONYMOUS_TEMPLATE_NAME]: new EmptyTemplate() - }); - this.callBase(); - }, - - _focusTarget: function() { - return this._getContent(); - }, - - _getContent: function() { - return this.$element().find(`.${HTML_EDITOR_CONTENT_CLASS}`); - }, - - _focusInHandler: function({ relatedTarget }) { - if(this._shouldSkipFocusEvent(relatedTarget)) { - return; - } + _getDefaultOptions() { + return extend(this.callBase(), { + focusStateEnabled: true, + valueType: 'html', + placeholder: '', + toolbar: null, + variables: null, + mediaResizing: null, + tableResizing: null, + mentions: null, + customizeModules: null, + tableContextMenu: null, + allowSoftLineBreak: false, + + formDialogOptions: null, + + imageUpload: null, + + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + stylingMode: config().editorStylingMode || 'outlined', + }); + }, + + _init() { + this._mentionKeyInTemplateStorage = editorsCount++; + this.callBase(); + this._cleanCallback = Callbacks(); + this._contentInitializedCallback = Callbacks(); + }, + + _getAnonymousTemplateName() { + return ANONYMOUS_TEMPLATE_NAME; + }, + + _initTemplates() { + this._templateManager.addDefaultTemplates({ + [ANONYMOUS_TEMPLATE_NAME]: new EmptyTemplate(), + }); + this.callBase(); + }, + + _focusTarget() { + return this._getContent(); + }, + + _getContent() { + return this.$element().find(`.${HTML_EDITOR_CONTENT_CLASS}`); + }, + + _focusInHandler({ relatedTarget }) { + if (this._shouldSkipFocusEvent(relatedTarget)) { + return; + } - this._toggleFocusClass(true, this.$element()); + this._toggleFocusClass(true, this.$element()); - this.callBase.apply(this, arguments); - }, + this.callBase.apply(this, arguments); + }, - _focusOutHandler: function({ relatedTarget }) { - if(this._shouldSkipFocusEvent(relatedTarget)) { - return; - } + _focusOutHandler({ relatedTarget }) { + if (this._shouldSkipFocusEvent(relatedTarget)) { + return; + } - this._toggleFocusClass(false, this.$element()); + this._toggleFocusClass(false, this.$element()); - this.callBase.apply(this, arguments); - }, + this.callBase.apply(this, arguments); + }, - _shouldSkipFocusEvent: function(relatedTarget) { - return $(relatedTarget).hasClass(QUILL_CLIPBOARD_CLASS); - }, + _shouldSkipFocusEvent(relatedTarget) { + return $(relatedTarget).hasClass(QUILL_CLIPBOARD_CLASS); + }, - _initMarkup: function() { - this._$htmlContainer = $('
').addClass(QUILL_CONTAINER_CLASS); + _initMarkup() { + this._$htmlContainer = $('
').addClass(QUILL_CONTAINER_CLASS); - this.$element() - .attr('role', 'application') - .addClass(HTML_EDITOR_CLASS) - .wrapInner(this._$htmlContainer); + this.$element() + .attr('role', 'application') + .addClass(HTML_EDITOR_CLASS) + .wrapInner(this._$htmlContainer); - this._renderStylingMode(); + this._renderStylingMode(); - const template = this._getTemplate(ANONYMOUS_TEMPLATE_NAME); - const transclude = true; + const template = this._getTemplate(ANONYMOUS_TEMPLATE_NAME); + const transclude = true; - this._$templateResult = template && template.render({ - container: getPublicElement(this._$htmlContainer), - noModel: true, - transclude - }); + this._$templateResult = template && template.render({ + container: getPublicElement(this._$htmlContainer), + noModel: true, + transclude, + }); - this._renderSubmitElement(); - this.callBase(); - this._updateContainerMarkup(); - }, + this._renderSubmitElement(); + this.callBase(); + this._updateContainerMarkup(); + }, - _renderValidationState() { - const $content = this._getContent(); + _renderValidationState() { + const $content = this._getContent(); - if($content.length === 1) { - this.callBase(); + if ($content.length === 1) { + this.callBase(); + } + }, + + _renderSubmitElement() { + this._$submitElement = $('