@atlaskit/editor-plugin-limited-mode 3.0.3 → 3.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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-plugin-limited-mode
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`c6c113481c118`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c6c113481c118) -
8
+ Updates limited mode to include lcm sizes in decision to engage.
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 3.0.4
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 3.0.3
4
21
 
5
22
  ### Patch Changes
@@ -0,0 +1,30 @@
1
+ {
2
+ "extends": "../../../../tsconfig.entry-points.products.json",
3
+ "compilerOptions": {
4
+ "target": "es5",
5
+ "outDir": "../../../../../tsDist/@atlaskit__editor-plugin-limited-mode/app",
6
+ "rootDir": "../",
7
+ "composite": true
8
+ },
9
+ "include": [
10
+ "../src/**/*.ts",
11
+ "../src/**/*.tsx"
12
+ ],
13
+ "exclude": [
14
+ "../src/**/__tests__/*",
15
+ "../src/**/*.test.*",
16
+ "../src/**/test.*",
17
+ "../src/**/examples.*"
18
+ ],
19
+ "references": [
20
+ {
21
+ "path": "../../../design-system/primitives/afm-products/tsconfig.json"
22
+ },
23
+ {
24
+ "path": "../../tmp-editor-statsig/afm-products/tsconfig.json"
25
+ },
26
+ {
27
+ "path": "../../editor-common/afm-products/tsconfig.json"
28
+ }
29
+ ]
30
+ }
@@ -54,6 +54,10 @@ var limitedModePlugin = exports.limitedModePlugin = function limitedModePlugin(_
54
54
  // eslint-disable-next-line react-hooks/exhaustive-deps
55
55
  }, [options.contentId]);
56
56
  var checkAndShowFlag = (0, _react.useCallback)(function (isLimitedModeEnabled) {
57
+ if (!((0, _expVal.expVal)('cc_editor_limited_mode', 'flagEnabled', true) === true)) {
58
+ // Disable the flag behavior entirely if the flag is off
59
+ return;
60
+ }
57
61
  var _learnMoreLink = (0, _expVal.expVal)('cc_editor_limited_mode', 'learnMoreLink', '');
58
62
  if (isLimitedModeEnabled && hasEditorBeenFocusedRef.current && !hasShownFlagRef.current) {
59
63
  var _options$showFlag;
@@ -20,14 +20,31 @@ var createPlugin = exports.createPlugin = function createPlugin() {
20
20
  },
21
21
  state: {
22
22
  init: function init(config, editorState) {
23
- if (editorState.doc.nodeSize > (0, _expVal.expVal)('cc_editor_limited_mode', 'nodeSize', 100)) {
23
+ if ((0, _expVal.expVal)('cc_editor_limited_mode_include_lcm', 'isEnabled', true)) {
24
+ // calculates the size of the doc, where when there are legacy content macros, the content
25
+ // is stored in the attrs.
26
+ // This is essentiall doc.nod
27
+ var customDocSize = editorState.doc.nodeSize;
28
+ editorState.doc.descendants(function (node) {
29
+ var _node$attrs;
30
+ if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.extensionKey) === 'legacy-content') {
31
+ var _node$attrs$parameter, _node$attrs2;
32
+ customDocSize += (_node$attrs$parameter = (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 || (_node$attrs2 = _node$attrs2.parameters) === null || _node$attrs2 === void 0 || (_node$attrs2 = _node$attrs2.adf) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.length) !== null && _node$attrs$parameter !== void 0 ? _node$attrs$parameter : 0;
33
+ }
34
+ });
35
+ return {
36
+ documentSizeBreachesThreshold: customDocSize > (0, _expVal.expVal)('cc_editor_limited_mode', 'nodeSize', 100)
37
+ };
38
+ } else {
39
+ if (editorState.doc.nodeSize > (0, _expVal.expVal)('cc_editor_limited_mode', 'nodeSize', 100)) {
40
+ return {
41
+ documentSizeBreachesThreshold: true
42
+ };
43
+ }
24
44
  return {
25
- documentSizeBreachesThreshold: true
45
+ documentSizeBreachesThreshold: false
26
46
  };
27
47
  }
28
- return {
29
- documentSizeBreachesThreshold: false
30
- };
31
48
  },
32
49
  apply: function apply(tr, currentPluginState) {
33
50
  // Don't check the document size if we're already in limited mode.
@@ -35,14 +52,31 @@ var createPlugin = exports.createPlugin = function createPlugin() {
35
52
  if (currentPluginState.documentSizeBreachesThreshold && !tr.getMeta('replaceDocument')) {
36
53
  return currentPluginState;
37
54
  }
38
- if (tr.doc.nodeSize > (0, _expVal.expVal)('cc_editor_limited_mode', 'nodeSize', 100)) {
55
+ if ((0, _expVal.expVal)('cc_editor_limited_mode_include_lcm', 'isEnabled', true)) {
56
+ // calculates the size of the doc, where when there are legacy content macros, the content
57
+ // is stored in the attrs.
58
+ // This is essentiall doc.nod
59
+ var customDocSize = tr.doc.nodeSize;
60
+ tr.doc.descendants(function (node) {
61
+ var _node$attrs3;
62
+ if (((_node$attrs3 = node.attrs) === null || _node$attrs3 === void 0 ? void 0 : _node$attrs3.extensionKey) === 'legacy-content') {
63
+ var _node$attrs$parameter2, _node$attrs4;
64
+ customDocSize += (_node$attrs$parameter2 = (_node$attrs4 = node.attrs) === null || _node$attrs4 === void 0 || (_node$attrs4 = _node$attrs4.parameters) === null || _node$attrs4 === void 0 || (_node$attrs4 = _node$attrs4.adf) === null || _node$attrs4 === void 0 ? void 0 : _node$attrs4.length) !== null && _node$attrs$parameter2 !== void 0 ? _node$attrs$parameter2 : 0;
65
+ }
66
+ });
67
+ return {
68
+ documentSizeBreachesThreshold: customDocSize > (0, _expVal.expVal)('cc_editor_limited_mode', 'nodeSize', 100)
69
+ };
70
+ } else {
71
+ if (tr.doc.nodeSize > (0, _expVal.expVal)('cc_editor_limited_mode', 'nodeSize', 100)) {
72
+ return _objectSpread(_objectSpread({}, currentPluginState), {}, {
73
+ documentSizeBreachesThreshold: true
74
+ });
75
+ }
39
76
  return _objectSpread(_objectSpread({}, currentPluginState), {}, {
40
- documentSizeBreachesThreshold: true
77
+ documentSizeBreachesThreshold: false
41
78
  });
42
79
  }
43
- return _objectSpread(_objectSpread({}, currentPluginState), {}, {
44
- documentSizeBreachesThreshold: false
45
- });
46
80
  }
47
81
  }
48
82
  });
@@ -48,6 +48,10 @@ export const limitedModePlugin = ({
48
48
  // eslint-disable-next-line react-hooks/exhaustive-deps
49
49
  }, [options.contentId]);
50
50
  const checkAndShowFlag = useCallback(isLimitedModeEnabled => {
51
+ if (!(expVal('cc_editor_limited_mode', 'flagEnabled', true) === true)) {
52
+ // Disable the flag behavior entirely if the flag is off
53
+ return;
54
+ }
51
55
  const learnMoreLink = expVal('cc_editor_limited_mode', 'learnMoreLink', '');
52
56
  if (isLimitedModeEnabled && hasEditorBeenFocusedRef.current && !hasShownFlagRef.current) {
53
57
  var _options$showFlag;
@@ -10,14 +10,31 @@ export const createPlugin = () => {
10
10
  },
11
11
  state: {
12
12
  init(config, editorState) {
13
- if (editorState.doc.nodeSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)) {
13
+ if (expVal('cc_editor_limited_mode_include_lcm', 'isEnabled', true)) {
14
+ // calculates the size of the doc, where when there are legacy content macros, the content
15
+ // is stored in the attrs.
16
+ // This is essentiall doc.nod
17
+ let customDocSize = editorState.doc.nodeSize;
18
+ editorState.doc.descendants(node => {
19
+ var _node$attrs;
20
+ if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.extensionKey) === 'legacy-content') {
21
+ var _node$attrs$parameter, _node$attrs2, _node$attrs2$paramete, _node$attrs2$paramete2;
22
+ customDocSize += (_node$attrs$parameter = (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : (_node$attrs2$paramete = _node$attrs2.parameters) === null || _node$attrs2$paramete === void 0 ? void 0 : (_node$attrs2$paramete2 = _node$attrs2$paramete.adf) === null || _node$attrs2$paramete2 === void 0 ? void 0 : _node$attrs2$paramete2.length) !== null && _node$attrs$parameter !== void 0 ? _node$attrs$parameter : 0;
23
+ }
24
+ });
14
25
  return {
15
- documentSizeBreachesThreshold: true
26
+ documentSizeBreachesThreshold: customDocSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)
27
+ };
28
+ } else {
29
+ if (editorState.doc.nodeSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)) {
30
+ return {
31
+ documentSizeBreachesThreshold: true
32
+ };
33
+ }
34
+ return {
35
+ documentSizeBreachesThreshold: false
16
36
  };
17
37
  }
18
- return {
19
- documentSizeBreachesThreshold: false
20
- };
21
38
  },
22
39
  apply: (tr, currentPluginState) => {
23
40
  // Don't check the document size if we're already in limited mode.
@@ -25,16 +42,33 @@ export const createPlugin = () => {
25
42
  if (currentPluginState.documentSizeBreachesThreshold && !tr.getMeta('replaceDocument')) {
26
43
  return currentPluginState;
27
44
  }
28
- if (tr.doc.nodeSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)) {
45
+ if (expVal('cc_editor_limited_mode_include_lcm', 'isEnabled', true)) {
46
+ // calculates the size of the doc, where when there are legacy content macros, the content
47
+ // is stored in the attrs.
48
+ // This is essentiall doc.nod
49
+ let customDocSize = tr.doc.nodeSize;
50
+ tr.doc.descendants(node => {
51
+ var _node$attrs3;
52
+ if (((_node$attrs3 = node.attrs) === null || _node$attrs3 === void 0 ? void 0 : _node$attrs3.extensionKey) === 'legacy-content') {
53
+ var _node$attrs$parameter2, _node$attrs4, _node$attrs4$paramete, _node$attrs4$paramete2;
54
+ customDocSize += (_node$attrs$parameter2 = (_node$attrs4 = node.attrs) === null || _node$attrs4 === void 0 ? void 0 : (_node$attrs4$paramete = _node$attrs4.parameters) === null || _node$attrs4$paramete === void 0 ? void 0 : (_node$attrs4$paramete2 = _node$attrs4$paramete.adf) === null || _node$attrs4$paramete2 === void 0 ? void 0 : _node$attrs4$paramete2.length) !== null && _node$attrs$parameter2 !== void 0 ? _node$attrs$parameter2 : 0;
55
+ }
56
+ });
57
+ return {
58
+ documentSizeBreachesThreshold: customDocSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)
59
+ };
60
+ } else {
61
+ if (tr.doc.nodeSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)) {
62
+ return {
63
+ ...currentPluginState,
64
+ documentSizeBreachesThreshold: true
65
+ };
66
+ }
29
67
  return {
30
68
  ...currentPluginState,
31
- documentSizeBreachesThreshold: true
69
+ documentSizeBreachesThreshold: false
32
70
  };
33
71
  }
34
- return {
35
- ...currentPluginState,
36
- documentSizeBreachesThreshold: false
37
- };
38
72
  }
39
73
  }
40
74
  });
@@ -46,6 +46,10 @@ export var limitedModePlugin = function limitedModePlugin(_ref) {
46
46
  // eslint-disable-next-line react-hooks/exhaustive-deps
47
47
  }, [options.contentId]);
48
48
  var checkAndShowFlag = useCallback(function (isLimitedModeEnabled) {
49
+ if (!(expVal('cc_editor_limited_mode', 'flagEnabled', true) === true)) {
50
+ // Disable the flag behavior entirely if the flag is off
51
+ return;
52
+ }
49
53
  var _learnMoreLink = expVal('cc_editor_limited_mode', 'learnMoreLink', '');
50
54
  if (isLimitedModeEnabled && hasEditorBeenFocusedRef.current && !hasShownFlagRef.current) {
51
55
  var _options$showFlag;
@@ -13,14 +13,31 @@ export var createPlugin = function createPlugin() {
13
13
  },
14
14
  state: {
15
15
  init: function init(config, editorState) {
16
- if (editorState.doc.nodeSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)) {
16
+ if (expVal('cc_editor_limited_mode_include_lcm', 'isEnabled', true)) {
17
+ // calculates the size of the doc, where when there are legacy content macros, the content
18
+ // is stored in the attrs.
19
+ // This is essentiall doc.nod
20
+ var customDocSize = editorState.doc.nodeSize;
21
+ editorState.doc.descendants(function (node) {
22
+ var _node$attrs;
23
+ if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.extensionKey) === 'legacy-content') {
24
+ var _node$attrs$parameter, _node$attrs2;
25
+ customDocSize += (_node$attrs$parameter = (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 || (_node$attrs2 = _node$attrs2.parameters) === null || _node$attrs2 === void 0 || (_node$attrs2 = _node$attrs2.adf) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.length) !== null && _node$attrs$parameter !== void 0 ? _node$attrs$parameter : 0;
26
+ }
27
+ });
28
+ return {
29
+ documentSizeBreachesThreshold: customDocSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)
30
+ };
31
+ } else {
32
+ if (editorState.doc.nodeSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)) {
33
+ return {
34
+ documentSizeBreachesThreshold: true
35
+ };
36
+ }
17
37
  return {
18
- documentSizeBreachesThreshold: true
38
+ documentSizeBreachesThreshold: false
19
39
  };
20
40
  }
21
- return {
22
- documentSizeBreachesThreshold: false
23
- };
24
41
  },
25
42
  apply: function apply(tr, currentPluginState) {
26
43
  // Don't check the document size if we're already in limited mode.
@@ -28,14 +45,31 @@ export var createPlugin = function createPlugin() {
28
45
  if (currentPluginState.documentSizeBreachesThreshold && !tr.getMeta('replaceDocument')) {
29
46
  return currentPluginState;
30
47
  }
31
- if (tr.doc.nodeSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)) {
48
+ if (expVal('cc_editor_limited_mode_include_lcm', 'isEnabled', true)) {
49
+ // calculates the size of the doc, where when there are legacy content macros, the content
50
+ // is stored in the attrs.
51
+ // This is essentiall doc.nod
52
+ var customDocSize = tr.doc.nodeSize;
53
+ tr.doc.descendants(function (node) {
54
+ var _node$attrs3;
55
+ if (((_node$attrs3 = node.attrs) === null || _node$attrs3 === void 0 ? void 0 : _node$attrs3.extensionKey) === 'legacy-content') {
56
+ var _node$attrs$parameter2, _node$attrs4;
57
+ customDocSize += (_node$attrs$parameter2 = (_node$attrs4 = node.attrs) === null || _node$attrs4 === void 0 || (_node$attrs4 = _node$attrs4.parameters) === null || _node$attrs4 === void 0 || (_node$attrs4 = _node$attrs4.adf) === null || _node$attrs4 === void 0 ? void 0 : _node$attrs4.length) !== null && _node$attrs$parameter2 !== void 0 ? _node$attrs$parameter2 : 0;
58
+ }
59
+ });
60
+ return {
61
+ documentSizeBreachesThreshold: customDocSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)
62
+ };
63
+ } else {
64
+ if (tr.doc.nodeSize > expVal('cc_editor_limited_mode', 'nodeSize', 100)) {
65
+ return _objectSpread(_objectSpread({}, currentPluginState), {}, {
66
+ documentSizeBreachesThreshold: true
67
+ });
68
+ }
32
69
  return _objectSpread(_objectSpread({}, currentPluginState), {}, {
33
- documentSizeBreachesThreshold: true
70
+ documentSizeBreachesThreshold: false
34
71
  });
35
72
  }
36
- return _objectSpread(_objectSpread({}, currentPluginState), {}, {
37
- documentSizeBreachesThreshold: false
38
- });
39
73
  }
40
74
  }
41
75
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-limited-mode",
3
- "version": "3.0.3",
3
+ "version": "3.1.0",
4
4
  "description": "LimitedMode plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,14 +29,14 @@
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
31
  "@atlaskit/editor-prosemirror": "7.0.0",
32
- "@atlaskit/primitives": "^15.0.0",
33
- "@atlaskit/tmp-editor-statsig": "^13.10.0",
32
+ "@atlaskit/primitives": "^16.1.0",
33
+ "@atlaskit/tmp-editor-statsig": "^13.23.0",
34
34
  "@babel/runtime": "^7.0.0",
35
35
  "bind-event-listener": "^3.0.0",
36
36
  "react-intl-next": "npm:react-intl@^5.18.1"
37
37
  },
38
38
  "peerDependencies": {
39
- "@atlaskit/editor-common": "^110.12.0",
39
+ "@atlaskit/editor-common": "^110.20.0",
40
40
  "react": "^18.2.0"
41
41
  },
42
42
  "devDependencies": {
@@ -1,30 +0,0 @@
1
- {
2
- "extends": "../../../../tsconfig.entry-points.dev-agents.json",
3
- "compilerOptions": {
4
- "target": "es5",
5
- "outDir": "../../../../../dev-agents/tsDist/@atlaskit__editor-plugin-limited-mode/app",
6
- "rootDir": "../",
7
- "composite": true
8
- },
9
- "include": [
10
- "../src/**/*.ts",
11
- "../src/**/*.tsx"
12
- ],
13
- "exclude": [
14
- "../src/**/__tests__/*",
15
- "../src/**/*.test.*",
16
- "../src/**/test.*",
17
- "../src/**/examples.*"
18
- ],
19
- "references": [
20
- {
21
- "path": "../../../design-system/primitives/afm-dev-agents/tsconfig.json"
22
- },
23
- {
24
- "path": "../../tmp-editor-statsig/afm-dev-agents/tsconfig.json"
25
- },
26
- {
27
- "path": "../../editor-common/afm-dev-agents/tsconfig.json"
28
- }
29
- ]
30
- }
@@ -1,30 +0,0 @@
1
- {
2
- "extends": "../../../../tsconfig.entry-points.passionfruit.json",
3
- "compilerOptions": {
4
- "target": "es5",
5
- "outDir": "../../../../../passionfruit/tsDist/@atlaskit__editor-plugin-limited-mode/app",
6
- "rootDir": "../",
7
- "composite": true
8
- },
9
- "include": [
10
- "../src/**/*.ts",
11
- "../src/**/*.tsx"
12
- ],
13
- "exclude": [
14
- "../src/**/__tests__/*",
15
- "../src/**/*.test.*",
16
- "../src/**/test.*",
17
- "../src/**/examples.*"
18
- ],
19
- "references": [
20
- {
21
- "path": "../../../design-system/primitives/afm-passionfruit/tsconfig.json"
22
- },
23
- {
24
- "path": "../../tmp-editor-statsig/afm-passionfruit/tsconfig.json"
25
- },
26
- {
27
- "path": "../../editor-common/afm-passionfruit/tsconfig.json"
28
- }
29
- ]
30
- }
@@ -1,30 +0,0 @@
1
- {
2
- "extends": "../../../../tsconfig.entry-points.rovo-extension.json",
3
- "compilerOptions": {
4
- "target": "es5",
5
- "outDir": "../../../../../rovo-extension/tsDist/@atlaskit__editor-plugin-limited-mode/app",
6
- "rootDir": "../",
7
- "composite": true
8
- },
9
- "include": [
10
- "../src/**/*.ts",
11
- "../src/**/*.tsx"
12
- ],
13
- "exclude": [
14
- "../src/**/__tests__/*",
15
- "../src/**/*.test.*",
16
- "../src/**/test.*",
17
- "../src/**/examples.*"
18
- ],
19
- "references": [
20
- {
21
- "path": "../../../design-system/primitives/afm-rovo-extension/tsconfig.json"
22
- },
23
- {
24
- "path": "../../tmp-editor-statsig/afm-rovo-extension/tsconfig.json"
25
- },
26
- {
27
- "path": "../../editor-common/afm-rovo-extension/tsconfig.json"
28
- }
29
- ]
30
- }
@@ -1,30 +0,0 @@
1
- {
2
- "extends": "../../../../tsconfig.entry-points.townsquare.json",
3
- "compilerOptions": {
4
- "target": "es5",
5
- "outDir": "../../../../../townsquare/tsDist/@atlaskit__editor-plugin-limited-mode/app",
6
- "rootDir": "../",
7
- "composite": true
8
- },
9
- "include": [
10
- "../src/**/*.ts",
11
- "../src/**/*.tsx"
12
- ],
13
- "exclude": [
14
- "../src/**/__tests__/*",
15
- "../src/**/*.test.*",
16
- "../src/**/test.*",
17
- "../src/**/examples.*"
18
- ],
19
- "references": [
20
- {
21
- "path": "../../../design-system/primitives/afm-townsquare/tsconfig.json"
22
- },
23
- {
24
- "path": "../../tmp-editor-statsig/afm-townsquare/tsconfig.json"
25
- },
26
- {
27
- "path": "../../editor-common/afm-townsquare/tsconfig.json"
28
- }
29
- ]
30
- }