@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
38 lines (37 loc) • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createEditorStateNotificationPlugin = void 0;
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
var _state = require("@atlaskit/editor-prosemirror/state");
var key = new _state.PluginKey('editorStateNotificationPlugin');
var createEditorStateNotificationPlugin = exports.createEditorStateNotificationPlugin = function createEditorStateNotificationPlugin(onEditorStateUpdated, onEditorViewStateUpdatedCallbacks) {
var transactions = [];
return new _safePlugin.SafePlugin({
key: key,
state: {
init: function init() {
return {
latestTransaction: undefined
};
},
apply: function apply(tr) {
transactions.push(tr);
return {
latestTransaction: tr
};
}
},
view: function view() {
return {
update: function update(view, oldEditorState) {
onEditorStateUpdated({
oldEditorState: oldEditorState,
newEditorState: view.state
});
}
};
}
});
};