Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getMatchingValue = () => {
let matchOpt = Option.none();
const items = dataset.data;
const px = editor.queryCommandValue('FontSize');
if (px) {
// checking for three digits after decimal point, should be precise enough
for (let precision = 3; matchOpt.isNone() && precision >= 0; precision--) {
const pt = toPt(px, precision);
const legacy = toLegacy(pt);
matchOpt = Arr.find(items, (item) => item.format === px || item.format === pt || item.format === legacy);
}
}
return { matchOpt, px };
};
return Options.lift2(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);
};
const getClosestBlock = (root: Element, pos: CaretPosition) => {
return Arr.find(Parents.parentsAndSelf(Element.fromDom(pos.container()), root), ElementType.isBlock);
};
const getMatchingValue = (): Option> => {
return Arr.find(alignMenuItems, (item) => editor.formatter.match(item.format));
};
const scanAndSet = (dialogApi: Types.Dialog.DialogInstanceApi, pattern: string) => {
Arr.find(charMap, (group) => group.name === currentTab.get()).each((f) => {
const items = Scan.scan(f, pattern);
dialogApi.setData({
results: items
});
});
};
const findPattern = <p pattern="">(patterns: P[], text: string): Option</p><p> => {
const nuText = text.replace('\u00a0', ' ');
return Arr.find(patterns, (pattern) => {
if (text.indexOf(pattern.start) !== 0 && nuText.indexOf(pattern.start) !== 0) {
return false;
}
return true;
});
};
</p>
const findTemplate = (templates: InternalTemplate[], templateTitle: string) => {
return Arr.find(templates, (t) => {
return t.text === templateTitle;
});
};
return Options.lift2(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);
};