當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Struct.immutable方法代碼示例

本文整理匯總了TypeScript中@ephox/katamari.Struct.immutable方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Struct.immutable方法的具體用法?TypeScript Struct.immutable怎麽用?TypeScript Struct.immutable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@ephox/katamari.Struct的用法示例。


在下文中一共展示了Struct.immutable方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

};

const forMenu = function (selections, table, cell) {
  return {
    element: Fun.constant(cell),
    mergable: Fun.constant(CellOperations.mergable(table, selections)),
    unmergable: Fun.constant(CellOperations.unmergable(cell, selections)),
    selection: Fun.constant(CellOperations.selection(cell, selections))
  };
};

const notCell = function (element) {
  return noMenu(element);
};

const paste = Struct.immutable('element', 'clipboard', 'generators');

const pasteRows = function (selections, table, cell, clipboard, generators) {
  return {
    element: Fun.constant(cell),
    mergable: Option.none,
    unmergable: Option.none,
    selection: Fun.constant(CellOperations.selection(cell, selections)),
    clipboard: Fun.constant(clipboard),
    generators: Fun.constant(generators)
  };
};

export default {
  noMenu,
  forMenu,
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:31,代碼來源:TableTargets.ts

示例2:

/**
 * 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

示例3: isNaN

/**
 * SimpleTableModel.js
 *
 * Released under LGPL License.
 * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
 *
 * License: http://www.tinymce.com/license
 * Contributing: http://www.tinymce.com/contributing
 */

import { Arr, Option, Struct } from '@ephox/katamari';
import { Compare, Insert, InsertAll, Replication, Element, Attr, SelectorFilter } from '@ephox/sugar';

const tableModel = Struct.immutable('element', 'width', 'rows');
const tableRow = Struct.immutable('element', 'cells');
const cellPosition = Struct.immutable('x', 'y');

const getSpan = function (td, key) {
  const value = parseInt(Attr.get(td, key), 10);
  return isNaN(value) ? 1 : value;
};

const fillout = function (table, x, y, tr, td) {
  const rowspan = getSpan(td, 'rowspan');
  const colspan = getSpan(td, 'colspan');
  const rows = table.rows();

  for (let y2 = y; y2 < y + rowspan; y2++) {
    if (!rows[y2]) {
      rows[y2] = tableRow(Replication.deep(tr), []);
    }
開發者ID:abstask,項目名稱:tinymce,代碼行數:31,代碼來源:SimpleTableModel.ts

示例4: function

import { Arr, Fun, Obj, Option, Strings, Struct, Type } from '@ephox/katamari';
import { PlatformDetection } from '@ephox/sand';
import Tools from './api/util/Tools';
import { Editor } from 'tinymce/core/api/Editor';

export interface ParamTypeMap {
  'hash': Record<string, string>;
  'string': string;
  'number': number;
  'boolean': boolean;
  'string[]': string[];
  'array': any[];
}

const sectionResult = Struct.immutable('sections', 'settings');
const detection = PlatformDetection.detect();
const isTouch = detection.deviceType.isTouch();
const mobilePlugins = [ 'lists', 'autolink', 'autosave' ];
const defaultMobileSettings = { theme: 'mobile' };

const normalizePlugins = function (plugins) {
  const pluginNames = Type.isArray(plugins) ? plugins.join(' ') : plugins;
  const trimmedPlugins = Arr.map(Type.isString(pluginNames) ? pluginNames.split(' ') : [ ], Strings.trim);
  return Arr.filter(trimmedPlugins, function (item) {
    return item.length > 0;
  });
};

const filterMobilePlugins = function (plugins) {
  return Arr.filter(plugins, Fun.curry(Arr.contains, mobilePlugins));
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:30,代碼來源:EditorSettings.ts

示例5: BlockPosition

 * Released under LGPL License.
 * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
 *
 * License: http://www.tinymce.com/license
 * Contributing: http://www.tinymce.com/contributing
 */

import { Option, Options, Struct } from '@ephox/katamari';
import { Compare, Element, Traverse } from '@ephox/sugar';
import CaretFinder from '../caret/CaretFinder';
import CaretPosition from '../caret/CaretPosition';
import DeleteUtils from './DeleteUtils';
import Empty from '../dom/Empty';
import NodeType from '../dom/NodeType';

const BlockPosition = Struct.immutable('block', 'position');
const BlockBoundary = Struct.immutable('from', 'to');

const getBlockPosition = function (rootNode, pos) {
  const rootElm = Element.fromDom(rootNode);
  const containerElm = Element.fromDom(pos.container());
  return DeleteUtils.getParentBlock(rootElm, containerElm).map(function (block) {
    return BlockPosition(block, pos);
  });
};

const isDifferentBlocks = function (blockBoundary) {
  return Compare.eq(blockBoundary.from().block(), blockBoundary.to().block()) === false;
};

const hasSameParent = function (blockBoundary) {
開發者ID:abstask,項目名稱:tinymce,代碼行數:31,代碼來源:BlockBoundary.ts

示例6: findParent

 * Released under LGPL License.
 * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
 *
 * License: http://www.tinymce.com/license
 * Contributing: http://www.tinymce.com/contributing
 */

import { Option } from '@ephox/katamari';
import { Struct } from '@ephox/katamari';
import CaretContainer from '../caret/CaretContainer';
import NodeType from '../dom/NodeType';
import TreeWalker from '../dom/TreeWalker';
import CaretFormat from '../fmt/CaretFormat';
import RangeCompare from './RangeCompare';

const position = Struct.immutable('container', 'offset');

const findParent = function (node, rootNode, predicate) {
  while (node && node !== rootNode) {
    if (predicate(node)) {
      return node;
    }

    node = node.parentNode;
  }

  return null;
};

const hasParent = function (node, rootNode, predicate) {
  return findParent(node, rootNode, predicate) !== null;
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:31,代碼來源:NormalizeRange.ts


注:本文中的@ephox/katamari.Struct.immutable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。