本文整理匯總了TypeScript中@ephox/sugar.Traverse.parent方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Traverse.parent方法的具體用法?TypeScript Traverse.parent怎麽用?TypeScript Traverse.parent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ephox/sugar.Traverse
的用法示例。
在下文中一共展示了Traverse.parent方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
Step.sync(function () {
const active = Focus.active().getOrDie();
// The buttons are next and previous siblings
const prev = Traverse.parent(active).bind(Traverse.prevSibling).getOrDie('Could not find button to left');
const next = Traverse.parent(active).bind(Traverse.nextSibling).getOrDie('Could not find button to right');
const assertNavButton = function (buttonLabel, expected, button) {
Assertions.assertStructure(
'Checking ' + buttonLabel + ' button should be enabled = ' + expected,
ApproxStructure.build(function (s, str, arr) {
return s.element('span', {
attr: {
role: str.is('button')
},
classes: [
(expected ? arr.not : arr.has)('tinymce-mobile-toolbar-navigation-disabled')
]
});
}),
button
);
};
assertNavButton('previous', prevEnabled, prev);
assertNavButton('next', nextEnabled, next);
})
示例2: function
const hasSameParent = function (blockBoundary) {
return Traverse.parent(blockBoundary.from().block()).bind(function (parent1) {
return Traverse.parent(blockBoundary.to().block()).filter(function (parent2) {
return Compare.eq(parent1, parent2);
});
}).isSome();
};
示例3: if
const outdentDlItem = (editor: Editor, item: Element): void => {
if (Compare.is(item, 'DD')) {
Replication.mutate(item, 'DT');
} else if (Compare.is(item, 'DT')) {
Traverse.parent(item).each((dl) => SplitList.splitList(editor, dl.dom(), item.dom()));
}
};
示例4:
const isChild = (first: boolean, elm: Element): boolean => {
const start = Element.fromDom(elm);
const pointOp = first ? Arr.head : Arr.last;
return Traverse.parent(start)
.map((parent) => PredicateFilter.children(parent, (elm) => NodeType.isBogus(elm.dom()) === false))
.bind(pointOp)
.map((node) => Compare.eq(node, start))
.getOr(false);
};
示例5: function
const getInsertionPoint = function (fromBlock, toBlock) {
if (Compare.contains(toBlock, fromBlock)) {
return Traverse.parent(fromBlock).bind(function (parent) {
return Compare.eq(parent, toBlock) ? Option.some(fromBlock) : findParentInsertPoint(toBlock, fromBlock);
});
} else {
return Option.none();
}
};
示例6: getItemContent
const createEntry = (li: Element, depth: number, isSelected: boolean): Entry => {
const list = Traverse.parent(li);
return {
depth,
isSelected,
content: getItemContent(li),
listType: list.bind(getListType).getOr(ListType.OL),
listAttributes: list.map(Attr.clone).getOr({}),
itemAttributes: Attr.clone(li)
};
};
示例7: 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('');
};
示例8: function
const getRectsFromRange = function (range) {
if (! range.collapsed) {
return Arr.map(range.getClientRects(), toRect);
} else {
const start = Element.fromDom(range.startContainer);
return Traverse.parent(start).bind(function (parent) {
const selection = Selection.exact(start, range.startOffset, parent, Awareness.getEnd(parent));
const optRect = WindowSelection.getFirstRect(range.startContainer.ownerDocument.defaultView, selection);
return optRect.map(collapsedRect).map(Arr.pure);
}).getOr([ ]);
}
};
示例9: function
const directListWrappers = function (commonAnchorContainer) {
if (ElementType.isListItem(commonAnchorContainer)) {
return Traverse.parent(commonAnchorContainer).filter(ElementType.isList).fold(
Fun.constant([]),
function (listElm) {
return [ commonAnchorContainer, listElm ];
}
);
} else {
return ElementType.isList(commonAnchorContainer) ? [ commonAnchorContainer ] : [ ];
}
};
示例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 = TransformFind.closest(start, function (elem) {
return Css.getRaw(elem, 'font-size');
}, isRoot);
return inline.getOrThunk(function () {
return Css.get(start, 'font-size');
});
}).getOr('');
};