@atlaskit/editor-plugin-editor-disabled 5.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/editorDisabledPlugin.js +49 -14
- package/dist/cjs/pm-plugins/reducer.js +31 -0
- package/dist/es2019/editorDisabledPlugin.js +42 -7
- package/dist/es2019/pm-plugins/reducer.js +21 -0
- package/dist/esm/editorDisabledPlugin.js +47 -12
- package/dist/esm/pm-plugins/reducer.js +23 -0
- package/dist/types/editorDisabledPlugin.d.ts +3 -1
- package/dist/types/editorDisabledPluginType.d.ts +6 -2
- package/dist/types/pm-plugins/reducer.d.ts +10 -0
- package/dist/types-ts4.5/editorDisabledPlugin.d.ts +3 -1
- package/dist/types-ts4.5/editorDisabledPluginType.d.ts +6 -2
- package/dist/types-ts4.5/pm-plugins/reducer.d.ts +10 -0
- package/package.json +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-editor-disabled
|
|
2
2
|
|
|
3
|
+
## 6.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`237dbc5b33f36`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/237dbc5b33f36) -
|
|
8
|
+
EDITOR-1919 - add toggleDisabled command to editor-plugin-editor-disabled
|
|
9
|
+
|
|
10
|
+
## 6.0.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 5.0.0
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -4,19 +4,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.editorDisabledPlugin = void 0;
|
|
7
|
+
exports.pluginKey = exports.editorDisabledPlugin = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
10
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
11
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
|
+
var _reducer = require("./pm-plugins/reducer");
|
|
13
15
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
16
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
-
var pluginKey = new _state.PluginKey('editorDisabledPlugin');
|
|
16
|
-
|
|
17
|
-
return meta;
|
|
18
|
-
}
|
|
19
|
-
var _pluginFactory = (0, _utils.pluginFactory)(pluginKey, reducer),
|
|
17
|
+
var pluginKey = exports.pluginKey = new _state.PluginKey('editorDisabledPlugin');
|
|
18
|
+
var _pluginFactory = (0, _utils.pluginFactory)(pluginKey, _reducer.reducer),
|
|
20
19
|
getPluginState = _pluginFactory.getPluginState;
|
|
21
20
|
|
|
22
21
|
/*
|
|
@@ -28,7 +27,8 @@ function createPlugin(dispatch, options) {
|
|
|
28
27
|
var scheduleEditorDisabledUpdate = (0, _rafSchd.default)(function (view) {
|
|
29
28
|
if (getPluginState(view.state).editorDisabled !== !view.editable) {
|
|
30
29
|
var disabledMeta = {
|
|
31
|
-
editorDisabled: !view.editable
|
|
30
|
+
editorDisabled: !view.editable,
|
|
31
|
+
disabledByPlugin: getPluginState(view.state).disabledByPlugin
|
|
32
32
|
};
|
|
33
33
|
var tr = view.state.tr.setMeta(pluginKey, disabledMeta).setMeta('editorDisabledPlugin', disabledMeta);
|
|
34
34
|
tr.setMeta('isLocal', true);
|
|
@@ -41,17 +41,36 @@ function createPlugin(dispatch, options) {
|
|
|
41
41
|
init: function init() {
|
|
42
42
|
var _options$initialDisab;
|
|
43
43
|
return {
|
|
44
|
-
editorDisabled: (_options$initialDisab = options === null || options === void 0 ? void 0 : options.initialDisabledState) !== null && _options$initialDisab !== void 0 ? _options$initialDisab : false
|
|
44
|
+
editorDisabled: (_options$initialDisab = options === null || options === void 0 ? void 0 : options.initialDisabledState) !== null && _options$initialDisab !== void 0 ? _options$initialDisab : false,
|
|
45
|
+
disabledByPlugin: false
|
|
45
46
|
};
|
|
46
47
|
},
|
|
47
48
|
apply: function apply(tr, pluginState) {
|
|
48
49
|
var meta = tr.getMeta(pluginKey);
|
|
49
50
|
if (meta) {
|
|
51
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta')) {
|
|
52
|
+
if ('action' in meta) {
|
|
53
|
+
return (0, _reducer.reducer)(pluginState, meta);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
50
56
|
return pluginState.editorDisabled !== meta.editorDisabled ? _objectSpread(_objectSpread({}, pluginState), meta) : pluginState;
|
|
51
57
|
}
|
|
52
58
|
return pluginState;
|
|
53
59
|
}
|
|
54
60
|
},
|
|
61
|
+
props: {
|
|
62
|
+
// If we set to undefined it respects the previous value.
|
|
63
|
+
// Prosemirror doesn't have this typed correctly for this type of behaviour
|
|
64
|
+
// @ts-expect-error
|
|
65
|
+
editable: (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta') ? function (state) {
|
|
66
|
+
var _pluginKey$getState;
|
|
67
|
+
var _ref = (_pluginKey$getState = pluginKey.getState(state)) !== null && _pluginKey$getState !== void 0 ? _pluginKey$getState : {
|
|
68
|
+
disabledByPlugin: false
|
|
69
|
+
},
|
|
70
|
+
disabledByPlugin = _ref.disabledByPlugin;
|
|
71
|
+
return disabledByPlugin ? false : undefined;
|
|
72
|
+
} : undefined
|
|
73
|
+
},
|
|
55
74
|
view: function view(_view) {
|
|
56
75
|
// schedule on mount
|
|
57
76
|
scheduleEditorDisabledUpdate(_view);
|
|
@@ -83,10 +102,10 @@ function createPlugin(dispatch, options) {
|
|
|
83
102
|
* .add(editorDisabledPlugin, { initialDisabledState: true })
|
|
84
103
|
* ```
|
|
85
104
|
*/
|
|
86
|
-
var editorDisabledPlugin = exports.editorDisabledPlugin = function editorDisabledPlugin(
|
|
87
|
-
var
|
|
88
|
-
options =
|
|
89
|
-
api =
|
|
105
|
+
var editorDisabledPlugin = exports.editorDisabledPlugin = function editorDisabledPlugin(_ref2) {
|
|
106
|
+
var _ref2$config = _ref2.config,
|
|
107
|
+
options = _ref2$config === void 0 ? {} : _ref2$config,
|
|
108
|
+
api = _ref2.api;
|
|
90
109
|
return {
|
|
91
110
|
name: 'editorDisabled',
|
|
92
111
|
getSharedState: function getSharedState(editorState) {
|
|
@@ -101,16 +120,32 @@ var editorDisabledPlugin = exports.editorDisabledPlugin = function editorDisable
|
|
|
101
120
|
editorDisabled: false
|
|
102
121
|
};
|
|
103
122
|
}
|
|
123
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta')) {
|
|
124
|
+
return {
|
|
125
|
+
editorDisabled: pluginState.disabledByPlugin || pluginState.editorDisabled
|
|
126
|
+
};
|
|
127
|
+
}
|
|
104
128
|
return pluginState;
|
|
105
129
|
},
|
|
106
130
|
pmPlugins: function pmPlugins() {
|
|
107
131
|
return [{
|
|
108
132
|
name: 'editorDisabled',
|
|
109
|
-
plugin: function plugin(
|
|
110
|
-
var dispatch =
|
|
133
|
+
plugin: function plugin(_ref3) {
|
|
134
|
+
var dispatch = _ref3.dispatch;
|
|
111
135
|
return createPlugin(dispatch, options);
|
|
112
136
|
}
|
|
113
137
|
}];
|
|
138
|
+
},
|
|
139
|
+
commands: {
|
|
140
|
+
toggleDisabled: function toggleDisabled(disabled) {
|
|
141
|
+
return function (_ref4) {
|
|
142
|
+
var tr = _ref4.tr;
|
|
143
|
+
return (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta') ? tr.setMeta(pluginKey, {
|
|
144
|
+
action: _reducer.ACTION.TOGGLE_DISABLED,
|
|
145
|
+
disabled: disabled
|
|
146
|
+
}) : null;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
114
149
|
}
|
|
115
150
|
};
|
|
116
151
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ACTION = void 0;
|
|
8
|
+
exports.reducer = reducer;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
+
var ACTION = exports.ACTION = /*#__PURE__*/function (ACTION) {
|
|
13
|
+
ACTION["TOGGLE_DISABLED"] = "TOGGLE_DISABLED";
|
|
14
|
+
return ACTION;
|
|
15
|
+
}({});
|
|
16
|
+
function reducer(pluginState, meta) {
|
|
17
|
+
if (meta && 'action' in meta) {
|
|
18
|
+
switch (meta.action) {
|
|
19
|
+
case ACTION.TOGGLE_DISABLED:
|
|
20
|
+
if (meta.disabled === pluginState.disabledByPlugin) {
|
|
21
|
+
return pluginState;
|
|
22
|
+
}
|
|
23
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
24
|
+
disabledByPlugin: Boolean(meta.disabled)
|
|
25
|
+
});
|
|
26
|
+
default:
|
|
27
|
+
return pluginState;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return pluginState;
|
|
31
|
+
}
|
|
@@ -2,10 +2,9 @@ import rafSchedule from 'raf-schd';
|
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { ACTION, reducer } from './pm-plugins/reducer';
|
|
7
|
+
export const pluginKey = new PluginKey('editorDisabledPlugin');
|
|
9
8
|
const {
|
|
10
9
|
getPluginState
|
|
11
10
|
} = pluginFactory(pluginKey, reducer);
|
|
@@ -19,7 +18,8 @@ function createPlugin(dispatch, options) {
|
|
|
19
18
|
const scheduleEditorDisabledUpdate = rafSchedule(view => {
|
|
20
19
|
if (getPluginState(view.state).editorDisabled !== !view.editable) {
|
|
21
20
|
const disabledMeta = {
|
|
22
|
-
editorDisabled: !view.editable
|
|
21
|
+
editorDisabled: !view.editable,
|
|
22
|
+
disabledByPlugin: getPluginState(view.state).disabledByPlugin
|
|
23
23
|
};
|
|
24
24
|
const tr = view.state.tr.setMeta(pluginKey, disabledMeta).setMeta('editorDisabledPlugin', disabledMeta);
|
|
25
25
|
tr.setMeta('isLocal', true);
|
|
@@ -32,12 +32,18 @@ function createPlugin(dispatch, options) {
|
|
|
32
32
|
init: () => {
|
|
33
33
|
var _options$initialDisab;
|
|
34
34
|
return {
|
|
35
|
-
editorDisabled: (_options$initialDisab = options === null || options === void 0 ? void 0 : options.initialDisabledState) !== null && _options$initialDisab !== void 0 ? _options$initialDisab : false
|
|
35
|
+
editorDisabled: (_options$initialDisab = options === null || options === void 0 ? void 0 : options.initialDisabledState) !== null && _options$initialDisab !== void 0 ? _options$initialDisab : false,
|
|
36
|
+
disabledByPlugin: false
|
|
36
37
|
};
|
|
37
38
|
},
|
|
38
39
|
apply: (tr, pluginState) => {
|
|
39
40
|
const meta = tr.getMeta(pluginKey);
|
|
40
41
|
if (meta) {
|
|
42
|
+
if (fg('platform_editor_ai_aifc_patch_beta')) {
|
|
43
|
+
if ('action' in meta) {
|
|
44
|
+
return reducer(pluginState, meta);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
41
47
|
return pluginState.editorDisabled !== meta.editorDisabled ? {
|
|
42
48
|
...pluginState,
|
|
43
49
|
...meta
|
|
@@ -46,6 +52,20 @@ function createPlugin(dispatch, options) {
|
|
|
46
52
|
return pluginState;
|
|
47
53
|
}
|
|
48
54
|
},
|
|
55
|
+
props: {
|
|
56
|
+
// If we set to undefined it respects the previous value.
|
|
57
|
+
// Prosemirror doesn't have this typed correctly for this type of behaviour
|
|
58
|
+
// @ts-expect-error
|
|
59
|
+
editable: fg('platform_editor_ai_aifc_patch_beta') ? state => {
|
|
60
|
+
var _pluginKey$getState;
|
|
61
|
+
const {
|
|
62
|
+
disabledByPlugin
|
|
63
|
+
} = (_pluginKey$getState = pluginKey.getState(state)) !== null && _pluginKey$getState !== void 0 ? _pluginKey$getState : {
|
|
64
|
+
disabledByPlugin: false
|
|
65
|
+
};
|
|
66
|
+
return disabledByPlugin ? false : undefined;
|
|
67
|
+
} : undefined
|
|
68
|
+
},
|
|
49
69
|
view: view => {
|
|
50
70
|
// schedule on mount
|
|
51
71
|
scheduleEditorDisabledUpdate(view);
|
|
@@ -94,6 +114,11 @@ export const editorDisabledPlugin = ({
|
|
|
94
114
|
editorDisabled: false
|
|
95
115
|
};
|
|
96
116
|
}
|
|
117
|
+
if (fg('platform_editor_ai_aifc_patch_beta')) {
|
|
118
|
+
return {
|
|
119
|
+
editorDisabled: pluginState.disabledByPlugin || pluginState.editorDisabled
|
|
120
|
+
};
|
|
121
|
+
}
|
|
97
122
|
return pluginState;
|
|
98
123
|
},
|
|
99
124
|
pmPlugins: () => [{
|
|
@@ -101,5 +126,15 @@ export const editorDisabledPlugin = ({
|
|
|
101
126
|
plugin: ({
|
|
102
127
|
dispatch
|
|
103
128
|
}) => createPlugin(dispatch, options)
|
|
104
|
-
}]
|
|
129
|
+
}],
|
|
130
|
+
commands: {
|
|
131
|
+
toggleDisabled: disabled => ({
|
|
132
|
+
tr
|
|
133
|
+
}) => {
|
|
134
|
+
return fg('platform_editor_ai_aifc_patch_beta') ? tr.setMeta(pluginKey, {
|
|
135
|
+
action: ACTION.TOGGLE_DISABLED,
|
|
136
|
+
disabled
|
|
137
|
+
}) : null;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
105
140
|
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export let ACTION = /*#__PURE__*/function (ACTION) {
|
|
2
|
+
ACTION["TOGGLE_DISABLED"] = "TOGGLE_DISABLED";
|
|
3
|
+
return ACTION;
|
|
4
|
+
}({});
|
|
5
|
+
export function reducer(pluginState, meta) {
|
|
6
|
+
if (meta && 'action' in meta) {
|
|
7
|
+
switch (meta.action) {
|
|
8
|
+
case ACTION.TOGGLE_DISABLED:
|
|
9
|
+
if (meta.disabled === pluginState.disabledByPlugin) {
|
|
10
|
+
return pluginState;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
...pluginState,
|
|
14
|
+
disabledByPlugin: Boolean(meta.disabled)
|
|
15
|
+
};
|
|
16
|
+
default:
|
|
17
|
+
return pluginState;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return pluginState;
|
|
21
|
+
}
|
|
@@ -5,10 +5,9 @@ import rafSchedule from 'raf-schd';
|
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
6
|
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
|
+
import { ACTION, reducer } from './pm-plugins/reducer';
|
|
10
|
+
export var pluginKey = new PluginKey('editorDisabledPlugin');
|
|
12
11
|
var _pluginFactory = pluginFactory(pluginKey, reducer),
|
|
13
12
|
getPluginState = _pluginFactory.getPluginState;
|
|
14
13
|
|
|
@@ -21,7 +20,8 @@ function createPlugin(dispatch, options) {
|
|
|
21
20
|
var scheduleEditorDisabledUpdate = rafSchedule(function (view) {
|
|
22
21
|
if (getPluginState(view.state).editorDisabled !== !view.editable) {
|
|
23
22
|
var disabledMeta = {
|
|
24
|
-
editorDisabled: !view.editable
|
|
23
|
+
editorDisabled: !view.editable,
|
|
24
|
+
disabledByPlugin: getPluginState(view.state).disabledByPlugin
|
|
25
25
|
};
|
|
26
26
|
var tr = view.state.tr.setMeta(pluginKey, disabledMeta).setMeta('editorDisabledPlugin', disabledMeta);
|
|
27
27
|
tr.setMeta('isLocal', true);
|
|
@@ -34,17 +34,36 @@ function createPlugin(dispatch, options) {
|
|
|
34
34
|
init: function init() {
|
|
35
35
|
var _options$initialDisab;
|
|
36
36
|
return {
|
|
37
|
-
editorDisabled: (_options$initialDisab = options === null || options === void 0 ? void 0 : options.initialDisabledState) !== null && _options$initialDisab !== void 0 ? _options$initialDisab : false
|
|
37
|
+
editorDisabled: (_options$initialDisab = options === null || options === void 0 ? void 0 : options.initialDisabledState) !== null && _options$initialDisab !== void 0 ? _options$initialDisab : false,
|
|
38
|
+
disabledByPlugin: false
|
|
38
39
|
};
|
|
39
40
|
},
|
|
40
41
|
apply: function apply(tr, pluginState) {
|
|
41
42
|
var meta = tr.getMeta(pluginKey);
|
|
42
43
|
if (meta) {
|
|
44
|
+
if (fg('platform_editor_ai_aifc_patch_beta')) {
|
|
45
|
+
if ('action' in meta) {
|
|
46
|
+
return reducer(pluginState, meta);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
43
49
|
return pluginState.editorDisabled !== meta.editorDisabled ? _objectSpread(_objectSpread({}, pluginState), meta) : pluginState;
|
|
44
50
|
}
|
|
45
51
|
return pluginState;
|
|
46
52
|
}
|
|
47
53
|
},
|
|
54
|
+
props: {
|
|
55
|
+
// If we set to undefined it respects the previous value.
|
|
56
|
+
// Prosemirror doesn't have this typed correctly for this type of behaviour
|
|
57
|
+
// @ts-expect-error
|
|
58
|
+
editable: fg('platform_editor_ai_aifc_patch_beta') ? function (state) {
|
|
59
|
+
var _pluginKey$getState;
|
|
60
|
+
var _ref = (_pluginKey$getState = pluginKey.getState(state)) !== null && _pluginKey$getState !== void 0 ? _pluginKey$getState : {
|
|
61
|
+
disabledByPlugin: false
|
|
62
|
+
},
|
|
63
|
+
disabledByPlugin = _ref.disabledByPlugin;
|
|
64
|
+
return disabledByPlugin ? false : undefined;
|
|
65
|
+
} : undefined
|
|
66
|
+
},
|
|
48
67
|
view: function view(_view) {
|
|
49
68
|
// schedule on mount
|
|
50
69
|
scheduleEditorDisabledUpdate(_view);
|
|
@@ -76,10 +95,10 @@ function createPlugin(dispatch, options) {
|
|
|
76
95
|
* .add(editorDisabledPlugin, { initialDisabledState: true })
|
|
77
96
|
* ```
|
|
78
97
|
*/
|
|
79
|
-
export var editorDisabledPlugin = function editorDisabledPlugin(
|
|
80
|
-
var
|
|
81
|
-
options =
|
|
82
|
-
api =
|
|
98
|
+
export var editorDisabledPlugin = function editorDisabledPlugin(_ref2) {
|
|
99
|
+
var _ref2$config = _ref2.config,
|
|
100
|
+
options = _ref2$config === void 0 ? {} : _ref2$config,
|
|
101
|
+
api = _ref2.api;
|
|
83
102
|
return {
|
|
84
103
|
name: 'editorDisabled',
|
|
85
104
|
getSharedState: function getSharedState(editorState) {
|
|
@@ -94,16 +113,32 @@ export var editorDisabledPlugin = function editorDisabledPlugin(_ref) {
|
|
|
94
113
|
editorDisabled: false
|
|
95
114
|
};
|
|
96
115
|
}
|
|
116
|
+
if (fg('platform_editor_ai_aifc_patch_beta')) {
|
|
117
|
+
return {
|
|
118
|
+
editorDisabled: pluginState.disabledByPlugin || pluginState.editorDisabled
|
|
119
|
+
};
|
|
120
|
+
}
|
|
97
121
|
return pluginState;
|
|
98
122
|
},
|
|
99
123
|
pmPlugins: function pmPlugins() {
|
|
100
124
|
return [{
|
|
101
125
|
name: 'editorDisabled',
|
|
102
|
-
plugin: function plugin(
|
|
103
|
-
var dispatch =
|
|
126
|
+
plugin: function plugin(_ref3) {
|
|
127
|
+
var dispatch = _ref3.dispatch;
|
|
104
128
|
return createPlugin(dispatch, options);
|
|
105
129
|
}
|
|
106
130
|
}];
|
|
131
|
+
},
|
|
132
|
+
commands: {
|
|
133
|
+
toggleDisabled: function toggleDisabled(disabled) {
|
|
134
|
+
return function (_ref4) {
|
|
135
|
+
var tr = _ref4.tr;
|
|
136
|
+
return fg('platform_editor_ai_aifc_patch_beta') ? tr.setMeta(pluginKey, {
|
|
137
|
+
action: ACTION.TOGGLE_DISABLED,
|
|
138
|
+
disabled: disabled
|
|
139
|
+
}) : null;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
107
142
|
}
|
|
108
143
|
};
|
|
109
144
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
export var ACTION = /*#__PURE__*/function (ACTION) {
|
|
5
|
+
ACTION["TOGGLE_DISABLED"] = "TOGGLE_DISABLED";
|
|
6
|
+
return ACTION;
|
|
7
|
+
}({});
|
|
8
|
+
export function reducer(pluginState, meta) {
|
|
9
|
+
if (meta && 'action' in meta) {
|
|
10
|
+
switch (meta.action) {
|
|
11
|
+
case ACTION.TOGGLE_DISABLED:
|
|
12
|
+
if (meta.disabled === pluginState.disabledByPlugin) {
|
|
13
|
+
return pluginState;
|
|
14
|
+
}
|
|
15
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
16
|
+
disabledByPlugin: Boolean(meta.disabled)
|
|
17
|
+
});
|
|
18
|
+
default:
|
|
19
|
+
return pluginState;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return pluginState;
|
|
23
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { EditorDisabledPlugin, EditorDisabledPluginState } from './editorDisabledPluginType';
|
|
3
|
+
export declare const pluginKey: PluginKey<EditorDisabledPluginState>;
|
|
2
4
|
/**
|
|
3
5
|
* Editor disabled plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
4
6
|
* from `@atlaskit/editor-core`.
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { EditorCommand, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
export type EditorDisabledPluginState = {
|
|
3
|
+
disabledByPlugin: boolean;
|
|
3
4
|
editorDisabled: boolean;
|
|
4
5
|
};
|
|
5
6
|
export interface EditorDisabledPluginOptions {
|
|
6
7
|
initialDisabledState?: boolean;
|
|
7
8
|
}
|
|
8
9
|
export type EditorDisabledPlugin = NextEditorPlugin<'editorDisabled', {
|
|
10
|
+
commands: {
|
|
11
|
+
toggleDisabled: (disabled: boolean) => EditorCommand;
|
|
12
|
+
};
|
|
9
13
|
pluginConfiguration: EditorDisabledPluginOptions | undefined;
|
|
10
|
-
sharedState: EditorDisabledPluginState
|
|
14
|
+
sharedState: Pick<EditorDisabledPluginState, 'editorDisabled'>;
|
|
11
15
|
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EditorDisabledPluginState } from '../editorDisabledPluginType';
|
|
2
|
+
export declare enum ACTION {
|
|
3
|
+
TOGGLE_DISABLED = "TOGGLE_DISABLED"
|
|
4
|
+
}
|
|
5
|
+
type ToggleDisabledMeta = {
|
|
6
|
+
action: ACTION.TOGGLE_DISABLED;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function reducer(pluginState: EditorDisabledPluginState, meta: ToggleDisabledMeta | EditorDisabledPluginState): EditorDisabledPluginState;
|
|
10
|
+
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { EditorDisabledPlugin, EditorDisabledPluginState } from './editorDisabledPluginType';
|
|
3
|
+
export declare const pluginKey: PluginKey<EditorDisabledPluginState>;
|
|
2
4
|
/**
|
|
3
5
|
* Editor disabled plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
4
6
|
* from `@atlaskit/editor-core`.
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { EditorCommand, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
export type EditorDisabledPluginState = {
|
|
3
|
+
disabledByPlugin: boolean;
|
|
3
4
|
editorDisabled: boolean;
|
|
4
5
|
};
|
|
5
6
|
export interface EditorDisabledPluginOptions {
|
|
6
7
|
initialDisabledState?: boolean;
|
|
7
8
|
}
|
|
8
9
|
export type EditorDisabledPlugin = NextEditorPlugin<'editorDisabled', {
|
|
10
|
+
commands: {
|
|
11
|
+
toggleDisabled: (disabled: boolean) => EditorCommand;
|
|
12
|
+
};
|
|
9
13
|
pluginConfiguration: EditorDisabledPluginOptions | undefined;
|
|
10
|
-
sharedState: EditorDisabledPluginState
|
|
14
|
+
sharedState: Pick<EditorDisabledPluginState, 'editorDisabled'>;
|
|
11
15
|
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EditorDisabledPluginState } from '../editorDisabledPluginType';
|
|
2
|
+
export declare enum ACTION {
|
|
3
|
+
TOGGLE_DISABLED = "TOGGLE_DISABLED"
|
|
4
|
+
}
|
|
5
|
+
type ToggleDisabledMeta = {
|
|
6
|
+
action: ACTION.TOGGLE_DISABLED;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function reducer(pluginState: EditorDisabledPluginState, meta: ToggleDisabledMeta | EditorDisabledPluginState): EditorDisabledPluginState;
|
|
10
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-editor-disabled",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "Editor disabled plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -18,13 +18,19 @@
|
|
|
18
18
|
"types": "dist/types/index.d.ts",
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"atlaskit:src": "src/index.ts",
|
|
21
|
+
"platform-feature-flags": {
|
|
22
|
+
"platform_editor_ai_aifc_patch_beta": {
|
|
23
|
+
"type": "boolean"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
21
26
|
"dependencies": {
|
|
22
27
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
28
|
+
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
23
29
|
"@babel/runtime": "^7.0.0",
|
|
24
30
|
"raf-schd": "^4.0.3"
|
|
25
31
|
},
|
|
26
32
|
"peerDependencies": {
|
|
27
|
-
"@atlaskit/editor-common": "^
|
|
33
|
+
"@atlaskit/editor-common": "^110.9.0",
|
|
28
34
|
"react": "^18.2.0",
|
|
29
35
|
"react-dom": "^18.2.0"
|
|
30
36
|
},
|