Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const DEFAULT_NODE_VIEWS = Object.freeze({
[IMAGE]: ImageNodeView,
[MATH]: MathNodeView,
[BOOKMARK]: BookmarkNodeView,
[LIST_ITEM]: ListItemNodeView,
});
const EDITOR_EMPTY_STATE = Object.freeze(createEmptyEditorState());
// Monkey patch the `scrollIntoView` mathod of 'Transaction'.
// Why this is necessary?
// It appears that promse-mirror does call `scrollIntoView` extensively
// from many of the built-in transformations, thus cause unwanted page
// scrolls. To make the behavior more manageable, this patched method asks
// developer to explicitly use `scrollIntoView(true)` to enforce page scroll.
const scrollIntoView = Transaction.prototype.scrollIntoView;
const scrollIntoViewPatched = function(forced: boolean): Transaction {
if (forced === true && scrollIntoView) {
return scrollIntoView.call(this);
} else {
return this;
}
};
Transaction.prototype.scrollIntoView = scrollIntoViewPatched;
// Sets the implementation so that `FontTypeMarkSpec` can load custom fonts.
WebFontLoader.setImplementation(webfontloader);
const handleDOMEvents = {
drop: handleEditorDrop,
keydown: handleEditorKeyDown,
paste: handleEditorPaste,
// Monkey patch the `scrollIntoView` mathod of 'Transaction'.
// Why this is necessary?
// It appears that promse-mirror does call `scrollIntoView` extensively
// from many of the built-in transformations, thus cause unwanted page
// scrolls. To make the behavior more manageable, this patched method asks
// developer to explicitly use `scrollIntoView(true)` to enforce page scroll.
const scrollIntoView = Transaction.prototype.scrollIntoView;
const scrollIntoViewPatched = function(forced: boolean): Transaction {
if (forced === true && scrollIntoView) {
return scrollIntoView.call(this);
} else {
return this;
}
};
Transaction.prototype.scrollIntoView = scrollIntoViewPatched;
// Sets the implementation so that `FontTypeMarkSpec` can load custom fonts.
WebFontLoader.setImplementation(webfontloader);
const handleDOMEvents = {
drop: handleEditorDrop,
keydown: handleEditorKeyDown,
paste: handleEditorPaste,
};
function bindNodeView(NodeView: CustomNodeView): Function {
return (node, view, getPos, decorations) => {
return new NodeView(node, view, getPos, decorations);
};
}