@atlaskit/editor-plugin-limited-mode 0.0.2 → 1.0.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 +15 -0
- package/afm-cc/tsconfig.json +3 -3
- package/dist/cjs/pm-plugins/main.js +13 -38
- package/dist/es2019/pm-plugins/main.js +9 -35
- package/dist/esm/pm-plugins/main.js +13 -39
- package/package.json +3 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-limited-mode
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 0.0.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`e33be5daddd2b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e33be5daddd2b) -
|
|
14
|
+
ED-28892 Limited mode: adjust how we're triggering cleanup logic for block control plugin. Hook up
|
|
15
|
+
banner. Other misc setup.
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 0.0.2
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"extends": "../../../../tsconfig.entry-points.confluence.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"target": "es5",
|
|
5
|
-
"composite": true,
|
|
6
5
|
"outDir": "../../../../../confluence/tsDist/@atlaskit__editor-plugin-limited-mode",
|
|
7
|
-
"rootDir": "../"
|
|
6
|
+
"rootDir": "../",
|
|
7
|
+
"composite": true
|
|
8
8
|
},
|
|
9
9
|
"include": [
|
|
10
10
|
"../src/**/*.ts",
|
|
@@ -24,4 +24,4 @@
|
|
|
24
24
|
"path": "../../editor-common/afm-cc/tsconfig.json"
|
|
25
25
|
}
|
|
26
26
|
]
|
|
27
|
-
}
|
|
27
|
+
}
|
|
@@ -1,38 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.limitedModePluginKey = exports.createPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
9
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
11
|
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
10
14
|
var limitedModePluginKey = exports.limitedModePluginKey = new _state.PluginKey('limitedModePlugin');
|
|
11
15
|
var createPlugin = exports.createPlugin = function createPlugin() {
|
|
12
|
-
var _view2;
|
|
13
|
-
var stateUpdated = false;
|
|
14
|
-
function updateState(view) {
|
|
15
|
-
var newState = _state.EditorState.create({
|
|
16
|
-
schema: view.state.schema,
|
|
17
|
-
doc: view.state.doc,
|
|
18
|
-
// remove the state plugin to trigger the view cleanup function
|
|
19
|
-
// @ts-ignore This plugin interaction is expected to be temporary - we can't pass the key via standard inter plugin communication as that would introduce cyclical dependencies
|
|
20
|
-
plugins: view.state.plugins.filter(function (p) {
|
|
21
|
-
return p.key !== 'blockControls$';
|
|
22
|
-
}) // Filter out the unwanted plugin
|
|
23
|
-
});
|
|
24
|
-
view.updateState(newState);
|
|
25
|
-
stateUpdated = true;
|
|
26
|
-
}
|
|
27
16
|
return new _safePlugin.SafePlugin({
|
|
28
17
|
key: limitedModePluginKey,
|
|
29
18
|
view: function view(_view) {
|
|
30
|
-
_view2 = _view;
|
|
31
19
|
return {};
|
|
32
20
|
},
|
|
33
21
|
state: {
|
|
34
22
|
init: function init(config, editorState) {
|
|
35
|
-
if (editorState.doc.
|
|
23
|
+
if (editorState.doc.nodeSize > (0, _expVal.expVal)('cc_editor_limited_mode', 'nodeSize', 100)) {
|
|
36
24
|
return {
|
|
37
25
|
documentSizeBreachesThreshold: true
|
|
38
26
|
};
|
|
@@ -41,30 +29,17 @@ var createPlugin = exports.createPlugin = function createPlugin() {
|
|
|
41
29
|
documentSizeBreachesThreshold: false
|
|
42
30
|
};
|
|
43
31
|
},
|
|
44
|
-
apply: function apply(tr,
|
|
45
|
-
if
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// to the controls plug-in without putting in limited mode specific logic inside the controls plug-in as well.
|
|
49
|
-
// to mitigate this we call the update state here. Which will mean the editor does not have state divergence
|
|
50
|
-
// between when limited mode kicks in on first load versus mid edit session.
|
|
51
|
-
updateState(_view2);
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
documentSizeBreachesThreshold: true
|
|
55
|
-
};
|
|
32
|
+
apply: function apply(tr, currentPluginState) {
|
|
33
|
+
// Don't check the document size if we're already in limited mode.
|
|
34
|
+
if (currentPluginState.documentSizeBreachesThreshold) {
|
|
35
|
+
return currentPluginState;
|
|
56
36
|
}
|
|
57
|
-
if (tr.doc.
|
|
58
|
-
|
|
59
|
-
document.dispatchEvent(customEvent);
|
|
60
|
-
updateState(_view2);
|
|
61
|
-
return {
|
|
37
|
+
if (tr.doc.nodeSize > (0, _expVal.expVal)('cc_editor_limited_mode', 'nodeSize', 100)) {
|
|
38
|
+
return _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
62
39
|
documentSizeBreachesThreshold: true
|
|
63
|
-
};
|
|
40
|
+
});
|
|
64
41
|
}
|
|
65
|
-
return
|
|
66
|
-
documentSizeBreachesThreshold: false
|
|
67
|
-
};
|
|
42
|
+
return currentPluginState;
|
|
68
43
|
}
|
|
69
44
|
}
|
|
70
45
|
});
|
|
@@ -1,30 +1,16 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import {
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
4
4
|
export const limitedModePluginKey = new PluginKey('limitedModePlugin');
|
|
5
5
|
export const createPlugin = () => {
|
|
6
|
-
let view;
|
|
7
|
-
let stateUpdated = false;
|
|
8
|
-
function updateState(view) {
|
|
9
|
-
const newState = EditorState.create({
|
|
10
|
-
schema: view.state.schema,
|
|
11
|
-
doc: view.state.doc,
|
|
12
|
-
// remove the state plugin to trigger the view cleanup function
|
|
13
|
-
// @ts-ignore This plugin interaction is expected to be temporary - we can't pass the key via standard inter plugin communication as that would introduce cyclical dependencies
|
|
14
|
-
plugins: view.state.plugins.filter(p => p.key !== 'blockControls$') // Filter out the unwanted plugin
|
|
15
|
-
});
|
|
16
|
-
view.updateState(newState);
|
|
17
|
-
stateUpdated = true;
|
|
18
|
-
}
|
|
19
6
|
return new SafePlugin({
|
|
20
7
|
key: limitedModePluginKey,
|
|
21
8
|
view: _view => {
|
|
22
|
-
view = _view;
|
|
23
9
|
return {};
|
|
24
10
|
},
|
|
25
11
|
state: {
|
|
26
12
|
init(config, editorState) {
|
|
27
|
-
if (editorState.doc.
|
|
13
|
+
if (editorState.doc.nodeSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)) {
|
|
28
14
|
return {
|
|
29
15
|
documentSizeBreachesThreshold: true
|
|
30
16
|
};
|
|
@@ -33,30 +19,18 @@ export const createPlugin = () => {
|
|
|
33
19
|
documentSizeBreachesThreshold: false
|
|
34
20
|
};
|
|
35
21
|
},
|
|
36
|
-
apply: (tr,
|
|
37
|
-
if
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// to the controls plug-in without putting in limited mode specific logic inside the controls plug-in as well.
|
|
41
|
-
// to mitigate this we call the update state here. Which will mean the editor does not have state divergence
|
|
42
|
-
// between when limited mode kicks in on first load versus mid edit session.
|
|
43
|
-
updateState(view);
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
documentSizeBreachesThreshold: true
|
|
47
|
-
};
|
|
22
|
+
apply: (tr, currentPluginState) => {
|
|
23
|
+
// Don't check the document size if we're already in limited mode.
|
|
24
|
+
if (currentPluginState.documentSizeBreachesThreshold) {
|
|
25
|
+
return currentPluginState;
|
|
48
26
|
}
|
|
49
|
-
if (tr.doc.
|
|
50
|
-
const customEvent = new CustomEvent('limited-mode-activated');
|
|
51
|
-
document.dispatchEvent(customEvent);
|
|
52
|
-
updateState(view);
|
|
27
|
+
if (tr.doc.nodeSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)) {
|
|
53
28
|
return {
|
|
29
|
+
...currentPluginState,
|
|
54
30
|
documentSizeBreachesThreshold: true
|
|
55
31
|
};
|
|
56
32
|
}
|
|
57
|
-
return
|
|
58
|
-
documentSizeBreachesThreshold: false
|
|
59
|
-
};
|
|
33
|
+
return currentPluginState;
|
|
60
34
|
}
|
|
61
35
|
}
|
|
62
36
|
});
|
|
@@ -1,32 +1,19 @@
|
|
|
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; }
|
|
1
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import {
|
|
5
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
6
|
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
4
7
|
export var limitedModePluginKey = new PluginKey('limitedModePlugin');
|
|
5
8
|
export var createPlugin = function createPlugin() {
|
|
6
|
-
var _view2;
|
|
7
|
-
var stateUpdated = false;
|
|
8
|
-
function updateState(view) {
|
|
9
|
-
var newState = EditorState.create({
|
|
10
|
-
schema: view.state.schema,
|
|
11
|
-
doc: view.state.doc,
|
|
12
|
-
// remove the state plugin to trigger the view cleanup function
|
|
13
|
-
// @ts-ignore This plugin interaction is expected to be temporary - we can't pass the key via standard inter plugin communication as that would introduce cyclical dependencies
|
|
14
|
-
plugins: view.state.plugins.filter(function (p) {
|
|
15
|
-
return p.key !== 'blockControls$';
|
|
16
|
-
}) // Filter out the unwanted plugin
|
|
17
|
-
});
|
|
18
|
-
view.updateState(newState);
|
|
19
|
-
stateUpdated = true;
|
|
20
|
-
}
|
|
21
9
|
return new SafePlugin({
|
|
22
10
|
key: limitedModePluginKey,
|
|
23
11
|
view: function view(_view) {
|
|
24
|
-
_view2 = _view;
|
|
25
12
|
return {};
|
|
26
13
|
},
|
|
27
14
|
state: {
|
|
28
15
|
init: function init(config, editorState) {
|
|
29
|
-
if (editorState.doc.
|
|
16
|
+
if (editorState.doc.nodeSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)) {
|
|
30
17
|
return {
|
|
31
18
|
documentSizeBreachesThreshold: true
|
|
32
19
|
};
|
|
@@ -35,30 +22,17 @@ export var createPlugin = function createPlugin() {
|
|
|
35
22
|
documentSizeBreachesThreshold: false
|
|
36
23
|
};
|
|
37
24
|
},
|
|
38
|
-
apply: function apply(tr,
|
|
39
|
-
if
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// to the controls plug-in without putting in limited mode specific logic inside the controls plug-in as well.
|
|
43
|
-
// to mitigate this we call the update state here. Which will mean the editor does not have state divergence
|
|
44
|
-
// between when limited mode kicks in on first load versus mid edit session.
|
|
45
|
-
updateState(_view2);
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
documentSizeBreachesThreshold: true
|
|
49
|
-
};
|
|
25
|
+
apply: function apply(tr, currentPluginState) {
|
|
26
|
+
// Don't check the document size if we're already in limited mode.
|
|
27
|
+
if (currentPluginState.documentSizeBreachesThreshold) {
|
|
28
|
+
return currentPluginState;
|
|
50
29
|
}
|
|
51
|
-
if (tr.doc.
|
|
52
|
-
|
|
53
|
-
document.dispatchEvent(customEvent);
|
|
54
|
-
updateState(_view2);
|
|
55
|
-
return {
|
|
30
|
+
if (tr.doc.nodeSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)) {
|
|
31
|
+
return _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
56
32
|
documentSizeBreachesThreshold: true
|
|
57
|
-
};
|
|
33
|
+
});
|
|
58
34
|
}
|
|
59
|
-
return
|
|
60
|
-
documentSizeBreachesThreshold: false
|
|
61
|
-
};
|
|
35
|
+
return currentPluginState;
|
|
62
36
|
}
|
|
63
37
|
}
|
|
64
38
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-limited-mode",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "LimitedMode plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -27,16 +27,13 @@
|
|
|
27
27
|
},
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
|
-
"af:exports": {
|
|
31
|
-
".": "./src/index.ts"
|
|
32
|
-
},
|
|
33
30
|
"dependencies": {
|
|
34
31
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
35
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
32
|
+
"@atlaskit/tmp-editor-statsig": "^12.0.0",
|
|
36
33
|
"@babel/runtime": "^7.0.0"
|
|
37
34
|
},
|
|
38
35
|
"peerDependencies": {
|
|
39
|
-
"@atlaskit/editor-common": "^
|
|
36
|
+
"@atlaskit/editor-common": "^108.0.0",
|
|
40
37
|
"react": "^18.2.0"
|
|
41
38
|
},
|
|
42
39
|
"devDependencies": {
|