本文整理汇总了TypeScript中@ephox/katamari.Adt.generate方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Adt.generate方法的具体用法?TypeScript Adt.generate怎么用?TypeScript Adt.generate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/katamari.Adt
的用法示例。
在下文中一共展示了Adt.generate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
import { Adt, Fun , Option } from '@ephox/katamari';
import { Element } from '@ephox/sugar';
import CaretFinder from '../caret/CaretFinder';
import CaretPosition from '../caret/CaretPosition';
import * as CaretUtils from '../caret/CaretUtils';
import DeleteUtils from './DeleteUtils';
import Empty from '../dom/Empty';
import NodeType from '../dom/NodeType';
import * as ElementType from 'tinymce/core/dom/ElementType';
const isCompoundElement = (node: Node) => ElementType.isTableCell(Element.fromDom(node)) || ElementType.isListItem(Element.fromDom(node));
const DeleteAction = Adt.generate([
{ remove: [ 'element' ] },
{ moveToElement: [ 'element' ] },
{ moveToPosition: [ 'position' ] }
]);
const isAtContentEditableBlockCaret = (forward: boolean, from: CaretPosition) => {
const elm = from.getNode(forward === false);
const caretLocation = forward ? 'after' : 'before';
return NodeType.isElement(elm) && elm.getAttribute('data-mce-caret') === caretLocation;
};
const isDeleteFromCefDifferentBlocks = (root: Node, forward: boolean, from: CaretPosition, to: CaretPosition) => {
const inSameBlock = (elm) => ElementType.isInline(Element.fromDom(elm)) && !CaretUtils.isInSameBlock(from, to, root);
return CaretUtils.getRelativeCefElm(!forward, from).fold(
() => CaretUtils.getRelativeCefElm(forward, to).fold(Fun.constant(false), inSameBlock),
inSameBlock
示例2: function
/**
* 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 { Adt, Arr, Option } from '@ephox/katamari';
import Settings from '../api/Settings';
import ContextSelectors from './ContextSelectors';
import NewLineUtils from './NewLineUtils';
import LazyEvaluator from '../util/LazyEvaluator';
const newLineAction = Adt.generate([
{ br: [ ] },
{ block: [ ] },
{ none: [ ] }
]);
const shouldBlockNewLine = function (editor, shiftKey) {
return ContextSelectors.shouldBlockNewLine(editor);
};
const isBrMode = function (requiredState) {
return function (editor, shiftKey) {
const brMode = Settings.getForcedRootBlock(editor) === '';
return brMode === requiredState;
};
};
const inListBlock = function (requiredState) {
示例3:
/**
* 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 { Adt, Arr, Fun, Option, Options, Struct } from '@ephox/katamari';
import { Compare, Element, SelectorFilter, SelectorFind } from '@ephox/sugar';
import { Range } from '@ephox/dom-globals';
const tableCellRng = Struct.immutable('start', 'end');
const tableSelection = Struct.immutable('rng', 'table', 'cells');
const deleteAction = Adt.generate([
{ removeTable: [ 'element' ] },
{ emptyCells: [ 'cells' ] }
]);
const isRootFromElement = (root) => Fun.curry(Compare.eq, root);
const getClosestCell = (container, isRoot) => {
return SelectorFind.closest(Element.fromDom(container), 'td,th', isRoot);
};
const getClosestTable = (cell, isRoot) => {
return SelectorFind.ancestor(cell, 'table', isRoot);
};
const isExpandedCellRng = (cellRng) => {
return Compare.eq(cellRng.start(), cellRng.end()) === false;
};
示例4: function
import { Adt, Arr, Fun } from '@ephox/katamari';
import { Attr, Css, Height, SelectorFilter, Traverse } from '@ephox/sugar';
import Styles from '../../style/Styles';
import Scrollable from '../../touch/scroll/Scrollable';
import DataAttributes from '../../util/DataAttributes';
import DeviceZones from './DeviceZones';
const fixture = Adt.generate([
{ fixed: [ 'element', 'property', 'offsetY' ] },
// Not supporting property yet
{ scroller : [ 'element', 'offsetY' ] }
]);
const yFixedData = 'data-' + Styles.resolve('position-y-fixed');
const yFixedProperty = 'data-' + Styles.resolve('y-property');
const yScrollingData = 'data-' + Styles.resolve('scrolling');
const windowSizeData = 'data-' + Styles.resolve('last-window-height');
const getYFixedData = function (element) {
return DataAttributes.safeParse(element, yFixedData);
};
const getYFixedProperty = function (element) {
return Attr.get(element, yFixedProperty);
};
const getLastWindowSize = function (element) {
return DataAttributes.safeParse(element, windowSizeData);
};
示例5: function
* Contributing: http://www.tinymce.com/contributing
*/
import { Adt } from '@ephox/katamari';
import { Fun } from '@ephox/katamari';
import { Option } from '@ephox/katamari';
import { Options } from '@ephox/katamari';
import CaretFinder from '../caret/CaretFinder';
import CaretUtils from '../caret/CaretUtils';
import CaretFormat from '../fmt/CaretFormat';
import InlineUtils from './InlineUtils';
import LazyEvaluator from '../util/LazyEvaluator';
const Location = Adt.generate([
{ before: [ 'element' ] },
{ start: [ 'element' ] },
{ end: [ 'element' ] },
{ after: [ 'element' ] }
]);
const rescope = function (rootNode, node) {
const parentBlock = CaretUtils.getParentBlock(node, rootNode);
return parentBlock ? parentBlock : rootNode;
};
const before = function (isInlineTarget, rootNode, pos) {
const nPos = InlineUtils.normalizeForwards(pos);
const scope = rescope(rootNode, nPos.container());
return InlineUtils.findRootInline(isInlineTarget, scope, nPos).fold(
function () {
return CaretFinder.nextPosition(scope, nPos)
.bind(Fun.curry(InlineUtils.findRootInline, isInlineTarget, scope))
示例6: function
/**
* 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 { Adt } from '@ephox/katamari';
const type = Adt.generate([
{ none: [] },
{ multiple: [ 'elements' ] },
{ single: [ 'selection' ] }
]);
const cata = function (subject, onNone, onMultiple, onSingle) {
return subject.fold(onNone, onMultiple, onSingle);
};
export default {
cata,
none: type.none,
multiple: type.multiple,
single: type.single
};