import { AddEventsBehaviour, AlloyComponent, AlloyEvents, AlloyParts, AlloySpec, Behaviour, Button, Container, DomFactory, Focusing, Keying, ModalDialog, NativeEvents, SketchSpec, SystemEvents, Tabstopping } from '@ephox/alloy'; import { Optional, Result } from '@ephox/katamari'; import { Class, SugarBody } from '@ephox/sugar'; import Env from 'tinymce/core/api/Env'; import { UiFactoryBackstageProviders } from '../../backstage/Backstage'; import * as HtmlSanitizer from '../core/HtmlSanitizer'; import * as NavigableObject from '../general/NavigableObject'; const isTouch = Env.deviceType.isTouch(); const hiddenHeader = (title: AlloyParts.ConfiguredPart, close: AlloyParts.ConfiguredPart): AlloySpec => ({ dom: { tag: 'div', styles: { display: 'none' }, classes: [ 'tox-dialog__header' ] }, components: [ title, close ] }); const defaultHeader = (title: AlloyParts.ConfiguredPart, close: AlloyParts.ConfiguredPart): AlloySpec => ({ dom: { tag: 'div', classes: [ 'tox-dialog__header' ] }, components: [ title, close ] }); const pClose = (onClose: () => void, providersBackstage: UiFactoryBackstageProviders): AlloyParts.ConfiguredPart => ModalDialog.parts.close( // Need to find a way to make it clear in the docs whether parts can be sketches Button.sketch({ dom: { tag: 'button', classes: [ 'tox-button', 'tox-button--icon', 'tox-button--naked' ], attributes: { 'type': 'button', 'aria-label': providersBackstage.translate('Close') } }, action: onClose, buttonBehaviours: Behaviour.derive([ Tabstopping.config({ }) ]) }) ); const pUntitled = (): AlloyParts.ConfiguredPart => ModalDialog.parts.title({ dom: { tag: 'div', classes: [ 'tox-dialog__title' ], innerHtml: '', styles: { display: 'none' } } }); const pBodyMessage = (message: string, providersBackstage: UiFactoryBackstageProviders): AlloyParts.ConfiguredPart => ModalDialog.parts.body({ dom: { tag: 'div', classes: [ 'tox-dialog__body' ] }, components: [ { dom: { tag: 'div', classes: [ 'tox-dialog__body-content' ] }, components: [ { dom: DomFactory.fromHtml(`
${HtmlSanitizer.sanitizeHtmlString(providersBackstage.translate(message))}
`) } ] } ] }); const pFooter = (buttons: AlloySpec[]): AlloyParts.ConfiguredPart => ModalDialog.parts.footer({ dom: { tag: 'div', classes: [ 'tox-dialog__footer' ] }, components: buttons }); const pFooterGroup = (startButtons: AlloySpec[], endButtons: AlloySpec[]): SketchSpec[] => [ Container.sketch({ dom: { tag: 'div', classes: [ 'tox-dialog__footer-start' ] }, components: startButtons }), Container.sketch({ dom: { tag: 'div', classes: [ 'tox-dialog__footer-end' ] }, components: endButtons }) ]; export interface DialogSpec { lazySink: () => Result