本文整理匯總了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('');
};