1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 | var _adfSchema = require("@atlaskit/adf-schema");
|
8 | var _indentation = require("@atlaskit/editor-common/indentation");
|
9 | var _commands = require("./commands");
|
10 | var _keymap = require("./pm-plugins/keymap");
|
11 | var indentationPlugin = function indentationPlugin(_ref) {
|
12 | var _api$analytics, _api$analytics2;
|
13 | var api = _ref.api;
|
14 | return {
|
15 | name: 'indentation',
|
16 | marks: function marks() {
|
17 | return [{
|
18 | name: 'indentation',
|
19 | mark: _adfSchema.indentation
|
20 | }];
|
21 | },
|
22 | actions: {
|
23 | indentParagraphOrHeading: (0, _commands.getIndentCommand)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
|
24 | outdentParagraphOrHeading: (0, _commands.getOutdentCommand)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
25 | },
|
26 | getSharedState: function getSharedState(editorState) {
|
27 | var _ref2;
|
28 | if (!editorState) {
|
29 | return undefined;
|
30 | }
|
31 | var selection = editorState.tr.selection,
|
32 | indentation = editorState.schema.marks.indentation;
|
33 | var node = selection.$from.node();
|
34 | var indentationMark = node.marks.find(function (mark) {
|
35 | return mark.type === indentation;
|
36 | });
|
37 | return {
|
38 | isIndentationAllowed: (0, _commands.isIndentationAllowed)(editorState.schema, node),
|
39 | indentDisabled: (_ref2 = (indentationMark === null || indentationMark === void 0 ? void 0 : indentationMark.attrs.level) >= _indentation.MAX_INDENTATION_LEVEL) !== null && _ref2 !== void 0 ? _ref2 : false,
|
40 | outdentDisabled: !indentationMark
|
41 | };
|
42 | },
|
43 | pmPlugins: function pmPlugins() {
|
44 | return [{
|
45 | name: 'indentationKeymap',
|
46 | plugin: function plugin() {
|
47 | var _api$analytics3;
|
48 | return (0, _keymap.keymapPlugin)(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
49 | }
|
50 | }];
|
51 | }
|
52 | };
|
53 | };
|
54 | var _default = exports.default = indentationPlugin; |
\ | No newline at end of file |