@atlaskit/editor-plugin-interaction
Version:
Interaction plugin for @atlaskit/editor-core
44 lines (43 loc) • 1.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.interactionPlugin = void 0;
var _main = require("./pm-plugins/main");
var interactionPlugin = exports.interactionPlugin = function interactionPlugin() {
return {
name: 'interaction',
getSharedState: function getSharedState(editorState) {
var _key$getState;
if (!editorState) {
return {
interactionState: 'hasNotHadInteraction'
};
}
return {
/**
* Interaction state can either be null or 'hasNotHadInteraction'. We
* are specifically only returning an explicit value for 'hasNotHadInteraction'
* because behaviour should only change when the user has _not_ ineteracted
* with the editor. The behaviour of when `hasHadInteraction` is true and
* when the plugin is undefined should be the same.
*/
interactionState: (_key$getState = _main.key.getState(editorState)) !== null && _key$getState !== void 0 && _key$getState.hasHadInteraction ? null : 'hasNotHadInteraction'
};
},
commands: {
handleInteraction: function handleInteraction(_ref) {
var tr = _ref.tr;
return tr.setMeta(_main.key, {
hasHadInteraction: true
});
}
},
pmPlugins: function pmPlugins() {
return [{
name: 'interactionHandlerPlugin',
plugin: _main.createPlugin
}];
}
};
};