本文整理汇总了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,
示例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;
};
示例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), []);
}
示例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));
示例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) {
示例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;