@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
32 lines • 927 B
JavaScript
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
var key = new PluginKey('editorStateNotificationPlugin');
export var createEditorStateNotificationPlugin = function createEditorStateNotificationPlugin(onEditorStateUpdated, onEditorViewStateUpdatedCallbacks) {
var transactions = [];
return new 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
});
}
};
}
});
};