OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
_backup
/
tinymce
/
tinymce
/
src
/
themes
/
silver
/
main
/
ts
/
ui
/
core
/
complex
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/20/2020 06:40:30 AM
rwxr-xr-x
📄
AlignSelect.ts
2.7 KB
02/20/2020 06:40:33 AM
rw-r--r--
📄
BespokeSelect.ts
6.28 KB
02/20/2020 06:40:33 AM
rw-r--r--
📄
FontSelect.ts
5.13 KB
02/20/2020 06:40:34 AM
rw-r--r--
📄
FontsizeSelect.ts
3.12 KB
02/20/2020 06:40:34 AM
rw-r--r--
📄
FormatSelect.ts
2.63 KB
02/20/2020 06:40:35 AM
rw-r--r--
📄
SelectDatasets.ts
1.7 KB
02/20/2020 06:40:35 AM
rw-r--r--
📄
StyleFormat.ts
5.07 KB
02/20/2020 06:40:36 AM
rw-r--r--
📄
StyleSelect.ts
2.79 KB
02/20/2020 06:40:36 AM
rw-r--r--
📁
utils
-
02/20/2020 06:42:40 AM
rwxr-xr-x
Editing: AlignSelect.ts
Close
/** * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ */ import { AlloyComponent, AlloyTriggers } from '@ephox/alloy'; import { Arr, Option } from '@ephox/katamari'; import Editor from 'tinymce/core/api/Editor'; import { UiFactoryBackstage } from 'tinymce/themes/silver/backstage/Backstage'; import { updateMenuIcon } from '../../dropdown/CommonDropdown'; import { onActionToggleFormat } from './utils/Utils'; import { createMenuItems, createSelectButton, FormatItem, PreviewSpec } from './BespokeSelect'; import { buildBasicStaticDataset } from './SelectDatasets'; import { IsSelectedForType } from './utils/FormatRegister'; const alignMenuItems = [ { title: 'Left', icon: 'align-left', format: 'alignleft'}, { title: 'Center', icon: 'align-center', format: 'aligncenter' }, { title: 'Right', icon: 'align-right', format: 'alignright' }, { title: 'Justify', icon: 'align-justify', format: 'alignjustify' } ]; const getSpec = (editor: Editor) => { const getMatchingValue = (): Option<Partial<FormatItem>> => { return Arr.find(alignMenuItems, (item) => editor.formatter.match(item.format)); }; const isSelectedFor: IsSelectedForType = (format: string) => () => editor.formatter.match(format); const getPreviewFor = (format: string) => () => { return Option.none<PreviewSpec>(); }; const nodeChangeHandler = Option.some((comp: AlloyComponent) => { return () => { const match = getMatchingValue(); const alignment = match.fold(() => 'left', (item) => item.title.toLowerCase()); AlloyTriggers.emitWith(comp, updateMenuIcon, { icon: `align-${alignment}` }); }; }); const dataset = buildBasicStaticDataset(alignMenuItems); return { tooltip: 'Align', icon: Option.some('align-left'), isSelectedFor, getPreviewFor, onAction: onActionToggleFormat(editor), nodeChangeHandler, dataset, shouldHide: false, isInvalid: (item) => !editor.formatter.canApply(item.format) }; }; const createAlignSelect = (editor, backstage) => { const spec = getSpec(editor); return createSelectButton(editor, backstage, spec.dataset, spec); }; const alignSelectMenu = (editor: Editor, backstage: UiFactoryBackstage) => { const spec = getSpec(editor); const menuItems = createMenuItems(editor, backstage, spec.dataset, spec); editor.ui.registry.addNestedMenuItem('align', { text: backstage.shared.providers.translate('Align'), getSubmenuItems: () => menuItems.items.validateItems(menuItems.getStyleItems()) }); }; export { createAlignSelect, alignSelectMenu };