Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const changeFileInput = (helpers: Helpers, info: ImageDialogInfo, state: ImageDialogState, api: API) => {
const data = api.getData();
api.block('Uploading image'); // What msg do we pass to the lock?
Arr.head(data.fileinput)
.fold(() => {
api.unblock();
}, (file) => {
const blobUri: string = URL.createObjectURL(file);
const uploader = Uploader({
url: info.url,
basePath: info.basePath,
credentials: info.credentials,
handler: info.handler
});
const finalize = () => {
api.unblock();
URL.revokeObjectURL(blobUri);
};
const appendSegments = (head: Segment[], tail: Segment[]): void => {
Options.lift2(Arr.last(head), Arr.head(tail), joinSegment);
};
const getMaxHeight = (heights: number[]) => {
return Arr.head(Arr.sort(heights, (a, b) => {
if (a > b) {
return -1;
} else if (a < b) {
return +1;
} else {
return 0;
}
}));
};
(lastPos) => {
return Options.lift2(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);
}
);
const composeList = (scope: Document, entries: Entry[]): Option<element> => {
const cast: Segment[] = Arr.foldl(entries, (cast, entry) => {
return entry.depth > cast.length ? writeDeep(scope, cast, entry) : writeShallow(scope, cast, entry);
}, []);
return Arr.head(cast).map((segment) => segment.list);
};
</element>
const findClosestPositionInAboveCell = (table: HTMLElement, pos: CaretPosition): Option => {
return Arr.head(pos.getClientRects()).bind((rect) => {
return getClosestCellAbove(table, rect.left, rect.top);
}).bind((cell) => findClosestHorizontalPosition(getLastLinePositions(cell), pos));
};
find: (comp) => Arr.head(AlloyTabSection.getViewItems(comp))
}),
const findBr = (forward: boolean, root: Element, pos: CaretPosition) => {
const parentBlocks = Arr.filter(Parents.parentsAndSelf(Element.fromDom(pos.container()), root), ElementType.isBlock);
const scope = Arr.head(parentBlocks).getOr(root);
return CaretFinder.fromPosition(forward, scope.dom(), pos).filter(isBr);
};