本文整理汇总了TypeScript中@ephox/sugar.Node类的典型用法代码示例。如果您正苦于以下问题:TypeScript Node类的具体用法?TypeScript Node怎么用?TypeScript Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Node类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
return table.map((table) => {
if (Node.name(cellOrCaption) === 'caption') {
return TableTargets.notCell(cellOrCaption);
} else {
return TableTargets.forMenu(selections, table, cellOrCaption);
}
});
示例2: context
const processElement = (elem) => {
const ctx = context(editor, elem, 'span', Node.name(elem));
switch (ctx) {
case ChildContext.InvalidChild: {
finishWrapper();
const children = Traverse.children(elem);
processElements(children);
finishWrapper();
break;
}
case ChildContext.Valid: {
const w = getOrOpenWrapper();
Insert.wrap(elem, w);
break;
}
// INVESTIGATE: Are these sensible things to do?
case ChildContext.Skipping:
case ChildContext.Existing:
case ChildContext.Caret: {
// Do nothing.
}
}
};
示例3:
return selectionTargets.targets().fold(() => '', (targets) => {
// If clicking in a caption, then we shouldn't show the cell/row/column options
if (Node.name(targets.element()) === 'caption') {
return 'tableprops deletetable';
} else {
return 'cell row column | tableprops deletetable';
}
});
示例4: function
function (child) {
if (Node.name(child) === 'br') {
return Traverse.prevSibling(child).map(function (sibling) {
return [node].concat(getLastChildren(sibling));
}).getOr([]);
} else {
return [node].concat(getLastChildren(child));
}
}
示例5: if
Chain.op((element) => {
if (element.dom().type === 'checkbox') {
Checked.set(element, value);
} else if (Node.name(element) === 'select' && typeof value === 'number') {
SelectTag.setSelected(element, value);
} else {
Value.set(element, value);
}
})
示例6: function
Arr.each(nodeList, function (n) {
const withSpans = Nodes.replaceWithSpans(Node.value(n));
div = editor.dom.create('div', null, withSpans);
while ((node = div.lastChild)) {
editor.dom.insertAfter(node, n.dom());
}
editor.dom.remove(n.dom());
});
示例7: function
const captureInput = DomEvent.bind(page, 'keydown', function (evt) {
// Think about killing the event.
if (! Arr.contains([ 'input', 'textarea' ], Node.name(evt.target()))) {
// FIX: Close the menus
// closeMenus()
toEditing();
}
});
示例8: cloneItemContent
return Traverse.parent(li).map((list) => {
return {
depth,
isSelected,
content: cloneItemContent(li),
itemAttributes: Attr.clone(li),
listAttributes: Attr.clone(list),
listType: Node.name(list) as ListType
};
});
示例9: function
const clamp = function (offset, element) {
const max = Node.isText(element) ? Text.get(element).length : Traverse.children(element).length + 1;
if (offset > max) {
return max;
} else if (offset < 0) {
return 0;
}
return offset;
};
示例10: function
const getRawOrComputed = function (isRoot, rawStart) {
const optStart = Node.isElement(rawStart) ? Option.some(rawStart) : Traverse.parent(rawStart);
return optStart.map(function (start) {
const inline = PredicateFind.closest(start, (elem) => Css.getRaw(elem, 'font-size').isSome(), isRoot)
.bind((elem) => Css.getRaw(elem, 'font-size'));
return inline.getOrThunk(function () {
return Css.get(start, 'font-size');
});
}).getOr('');
};