How to use the prosemirror-state.Transaction function in prosemirror-state

To help you get started, we’ve selected a few prosemirror-state examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chanzuckerberg / czi-prosemirror / dist / ui / Editor.js View on Github external
};

var AUTO_FOCUS_DELAY = 350;

// Default custom node views.
var DEFAULT_NODE_VIEWS = exports.DEFAULT_NODE_VIEWS = (0, _freeze2.default)((_Object$freeze2 = {}, (0, _defineProperty3.default)(_Object$freeze2, _NodeNames.IMAGE, _ImageNodeView2.default), (0, _defineProperty3.default)(_Object$freeze2, _NodeNames.MATH, _MathNodeView2.default), (0, _defineProperty3.default)(_Object$freeze2, _NodeNames.BOOKMARK, _BookmarkNodeView2.default), (0, _defineProperty3.default)(_Object$freeze2, _NodeNames.LIST_ITEM, _ListItemNodeView2.default), _Object$freeze2));

var EDITOR_EMPTY_STATE = (0, _freeze2.default)((0, _createEmptyEditorState2.default)());

// 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.
var scrollIntoView = _prosemirrorState.Transaction.prototype.scrollIntoView;
var scrollIntoViewPatched = function scrollIntoViewPatched(forced) {
  if (forced === true && scrollIntoView) {
    return scrollIntoView.call(this);
  } else {
    return this;
  }
};
_prosemirrorState.Transaction.prototype.scrollIntoView = scrollIntoViewPatched;

// Sets the implementation so that `FontTypeMarkSpec` can load custom fonts.
_WebFontLoader2.default.setImplementation(_webfontloader2.default);

var handleDOMEvents = {
  drop: _handleEditorDrop2.default,
  keydown: _handleEditorKeyDown2.default,
  paste: _handleEditorPaste2.default
github chanzuckerberg / czi-prosemirror / dist / ui / Editor.js View on Github external
// 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.
var scrollIntoView = _prosemirrorState.Transaction.prototype.scrollIntoView;
var scrollIntoViewPatched = function scrollIntoViewPatched(forced) {
  if (forced === true && scrollIntoView) {
    return scrollIntoView.call(this);
  } else {
    return this;
  }
};
_prosemirrorState.Transaction.prototype.scrollIntoView = scrollIntoViewPatched;

// Sets the implementation so that `FontTypeMarkSpec` can load custom fonts.
_WebFontLoader2.default.setImplementation(_webfontloader2.default);

var handleDOMEvents = {
  drop: _handleEditorDrop2.default,
  keydown: _handleEditorKeyDown2.default,
  paste: _handleEditorPaste2.default
};

function bindNodeView(NodeView) {
  return function (node, view, getPos, decorations) {
    return new NodeView(node, view, getPos, decorations);
  };
}