本文整理匯總了TypeScript中@ephox/katamari.Options.liftN方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Options.liftN方法的具體用法?TypeScript Options.liftN怎麽用?TypeScript Options.liftN使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ephox/katamari.Options
的用法示例。
在下文中一共展示了Options.liftN方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: prependData
const rngSetContent = (rng: Range, fragment: DocumentFragment): void => {
const firstChild = Option.from(fragment.firstChild).map(Element.fromDom);
const lastChild = Option.from(fragment.lastChild).map(Element.fromDom);
rng.deleteContents();
rng.insertNode(fragment);
const prevText = firstChild.bind(Traverse.prevSibling).filter(Node.isText).bind(removeEmpty);
const nextText = lastChild.bind(Traverse.nextSibling).filter(Node.isText).bind(removeEmpty);
// Join start
Options.liftN([prevText, firstChild.filter(Node.isText)], (prev: Element, start: Element) => {
prependData(start.dom(), prev.dom().data);
Remove.remove(prev);
});
// Join end
Options.liftN([nextText, lastChild.filter(Node.isText)], (next: Element, end: Element) => {
const oldLength = end.dom().length;
end.dom().appendData(next.dom().data);
rng.setEnd(end.dom(), oldLength);
Remove.remove(next);
});
rng.collapse(false);
};
示例2: function
const deleteNormalized = function (elm, afterDeletePosOpt) {
return Options.liftN([Traverse.prevSibling(elm), Traverse.nextSibling(elm), afterDeletePosOpt], function (prev, next, afterDeletePos) {
let offset;
const prevNode = prev.dom();
const nextNode = next.dom();
if (NodeType.isText(prevNode) && NodeType.isText(nextNode)) {
offset = prevNode.data.length;
prevNode.appendData(nextNode.data);
Remove.remove(next);
Remove.remove(elm);
if (afterDeletePos.container() === nextNode) {
return new CaretPosition(prevNode, offset);
} else {
return afterDeletePos;
}
} else {
Remove.remove(elm);
return afterDeletePos;
}
}).orThunk(function () {
Remove.remove(elm);
return afterDeletePosOpt;
});
};
示例3:
(lastPos) => {
return Options.liftN([Arr.head(lastPos.getClientRects()), Arr.head(newPos.getClientRects())], (lastRect, newRect) => {
const lastDist = Math.abs(x - lastRect.left);
const newDist = Math.abs(x - newRect.left);
return newDist <= lastDist ? newPos : lastPos;
}).or(acc);
}
示例4: function
const getCellRng = function (rng, isRoot) {
return Options.liftN([ // get start and end cell
getClosestCell(rng.startContainer, isRoot),
getClosestCell(rng.endContainer, isRoot)
], tableCellRng)
.filter(isExpandedCellRng);
};
示例5: function
const hasAllContentsSelected = function (elm, rng) {
return Options.liftN([getStartNode(rng), getEndNode(rng)], function (startNode, endNode) {
const start = Arr.find(getFirstChildren(elm), Fun.curry(Compare.eq, startNode));
const end = Arr.find(getLastChildren(elm), Fun.curry(Compare.eq, endNode));
return start.isSome() && end.isSome();
}).getOr(false);
};
示例6: getCellIndex
const getSelectedCells = (tableSelection) => {
return Options.liftN([
getCellIndex(tableSelection.cells(), tableSelection.rng().start()),
getCellIndex(tableSelection.cells(), tableSelection.rng().end())
], (startIndex, endIndex) => {
return tableSelection.cells().slice(startIndex, endIndex + 1);
});
};
示例7:
const getItemSelection = (editor: Editor): Option<ItemSelection> => {
const selectedListItems = Arr.map(Selection.getSelectedListItems(editor), Element.fromDom);
return Options.liftN([
Arr.find(selectedListItems, Fun.not(hasFirstChildList)),
Arr.find(Arr.reverse(selectedListItems), Fun.not(hasFirstChildList))
], (start, end) => ({ start, end }));
};
示例8: parseSize
export const makeRatioConverter = (currentFieldText: string, otherFieldText: string): SizeConversion => {
const cValue = parseSize(currentFieldText).toOption();
const oValue = parseSize(otherFieldText).toOption();
return Options.liftN([cValue, oValue], (cSize: Size, oSize: Size) => {
return convertUnit(cSize, oSize.unit).map((val) => oSize.value / val).map(
(r) => ratioSizeConversion(r, oSize.unit)
).getOr(noSizeConversion);
}).getOr(noSizeConversion);
};
示例9: getClosestCell
const getCellRng = (rng: Range, isRoot) => {
const startCell = getClosestCell(rng.startContainer, isRoot);
const endCell = getClosestCell(rng.endContainer, isRoot);
return Options.liftN([startCell, endCell], tableCellRng)
.filter(isExpandedCellRng)
.filter((cellRng) => isWithinSameTable(isRoot, cellRng))
.orThunk(() => partialSelection(isRoot, rng));
};
示例10: createJoinedSections
const writeDeep = (scope: Document, outline: Section[], entry: Entry): Section[] => {
const newSections = createJoinedSections(scope, entry.depth - outline.length, entry.listType);
populateSections(newSections, entry);
Options.liftN([
Arr.last(outline),
Arr.head(newSections)
], joinSections);
return outline.concat(newSections);
};