当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript katamari.Adt类代码示例

本文整理汇总了TypeScript中@ephox/katamari.Adt的典型用法代码示例。如果您正苦于以下问题:TypeScript Adt类的具体用法?TypeScript Adt怎么用?TypeScript Adt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Adt类的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
开发者ID:abstask,项目名称:tinymce,代码行数:30,代码来源:CefDeleteAction.ts

示例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) {
开发者ID:danielpunkass,项目名称:tinymce,代码行数:31,代码来源:NewLineAction.ts

示例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;
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:31,代码来源:TableDeleteAction.ts

示例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);
};
开发者ID:abstask,项目名称:tinymce,代码行数:30,代码来源:IosViewport.ts

示例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))
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:32,代码来源:BoundaryLocation.ts

示例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
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:25,代码来源:SelectionTypes.ts


注:本文中的@ephox/katamari.Adt类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。