@atlaskit/editor-plugin-base 1.10.1 → 1.11.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,25 @@
1
1
  # @atlaskit/editor-plugin-base
2
2
 
3
+ ## 1.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#136261](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/136261)
8
+ [`7e900c6a2ae84`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7e900c6a2ae84) -
9
+ Lazy node view loading without setProps
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 1.10.2
16
+
17
+ ### Patch Changes
18
+
19
+ - [#134213](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/134213)
20
+ [`93bd7032842ec`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/93bd7032842ec) -
21
+ [ux] [ED-24636] Bump ADF Schema package
22
+
3
23
  ## 1.10.1
4
24
 
5
25
  ### Patch Changes
@@ -11,11 +11,13 @@ var _adfSchema = require("@atlaskit/adf-schema");
11
11
  var _keymaps = require("@atlaskit/editor-common/keymaps");
12
12
  var _commands = require("@atlaskit/editor-prosemirror/commands");
13
13
  var _history = require("@atlaskit/editor-prosemirror/history");
14
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
15
  var _commands2 = require("./commands");
15
16
  var _disableSpellChecking = _interopRequireDefault(require("./pm-plugins/disable-spell-checking"));
16
17
  var _filterSteps = _interopRequireDefault(require("./pm-plugins/filter-steps"));
17
18
  var _frozenEditor = _interopRequireDefault(require("./pm-plugins/frozen-editor"));
18
19
  var _inlineCursorTarget = _interopRequireDefault(require("./pm-plugins/inline-cursor-target"));
20
+ var _lazyNodeViewDecoration = require("./pm-plugins/lazy-node-view-decoration");
19
21
  var _newlinePreserveMarks = _interopRequireDefault(require("./pm-plugins/newline-preserve-marks"));
20
22
  var _scrollGutter = _interopRequireWildcard(require("./pm-plugins/scroll-gutter"));
21
23
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -45,6 +47,14 @@ var basePlugin = function basePlugin(_ref) {
45
47
  return (0, _filterSteps.default)(dispatchAnalyticsEvent);
46
48
  }
47
49
  }];
50
+ if ((0, _platformFeatureFlags.fg)('platform_editor_lazy-node-views')) {
51
+ plugins.push({
52
+ name: 'lazyNodeViewDecorationsPlugin',
53
+ plugin: function plugin() {
54
+ return (0, _lazyNodeViewDecoration.createLazyNodeViewDecorationPlugin)();
55
+ }
56
+ });
57
+ }
48
58
 
49
59
  // In Chrome, when the selection is placed between adjacent nodes which are not contenteditatble
50
60
  // the cursor appears at the right most point of the parent container.
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createLazyNodeViewDecorationPlugin = createLazyNodeViewDecorationPlugin;
7
+ var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
8
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
9
+ var _view = require("@atlaskit/editor-prosemirror/view");
10
+ var LAZY_NODE_VIEW_DECORATION_CLASS = '__lazy-node-view-decoration__';
11
+ /**
12
+ * Plugin is used to force re-render NodeViews for a specific node type
13
+ * when LazyNodeView finishes loading the real NodeView.
14
+ *
15
+ * This is achieved by applying a decoration to a node.
16
+ *
17
+ * It's a blessed way that Marijn suggested multiple times in ProseMirror Discuss:
18
+ * – https://discuss.prosemirror.net/t/force-nodes-of-specific-type-to-re-render/2480
19
+ */
20
+ function createLazyNodeViewDecorationPlugin() {
21
+ return new _safePlugin.SafePlugin({
22
+ key: _lazyNodeView.lazyNodeViewDecorationPluginKey,
23
+ state: {
24
+ init: function init() {
25
+ return {
26
+ decorations: _view.DecorationSet.empty,
27
+ nodeTypes: []
28
+ };
29
+ },
30
+ apply: function apply(tr, _oldState, newState) {
31
+ var actionPayload = tr.getMeta(_lazyNodeView.lazyNodeViewDecorationPluginKey);
32
+ var pluginState = _lazyNodeView.lazyNodeViewDecorationPluginKey.getState(newState);
33
+ if ((actionPayload === null || actionPayload === void 0 ? void 0 : actionPayload.type) === 'add' && actionPayload.nodeTypes.size) {
34
+ var decorations = [];
35
+ tr.doc.nodesBetween(0, tr.doc.nodeSize - 2, function (node, pos) {
36
+ if (actionPayload.nodeTypes.has(node.type.name)) {
37
+ decorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
38
+ class: LAZY_NODE_VIEW_DECORATION_CLASS
39
+ }));
40
+ }
41
+ });
42
+ return {
43
+ decorations: _view.DecorationSet.create(tr.doc, decorations)
44
+ };
45
+ }
46
+ if ((actionPayload === null || actionPayload === void 0 ? void 0 : actionPayload.type) === 'clear') {
47
+ return {
48
+ decorations: _view.DecorationSet.empty
49
+ };
50
+ }
51
+ if (tr.docChanged) {
52
+ return {
53
+ decorations: pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations.map(tr.mapping, tr.doc)
54
+ };
55
+ }
56
+ return pluginState;
57
+ }
58
+ },
59
+ props: {
60
+ decorations: function decorations(state) {
61
+ var _lazyNodeViewDecorati;
62
+ return (_lazyNodeViewDecorati = _lazyNodeView.lazyNodeViewDecorationPluginKey.getState(state)) === null || _lazyNodeViewDecorati === void 0 ? void 0 : _lazyNodeViewDecorati.decorations;
63
+ }
64
+ },
65
+ view: function view(editorView) {
66
+ return {
67
+ update: function update() {
68
+ /**
69
+ * After view update can clean up decorations...
70
+ */
71
+ var pluginState = _lazyNodeView.lazyNodeViewDecorationPluginKey.getState(editorView.state);
72
+ if (pluginState.decorations !== _view.DecorationSet.empty) {
73
+ var tr = editorView.state.tr;
74
+ tr.setMeta(_lazyNodeView.lazyNodeViewDecorationPluginKey, {
75
+ type: 'clear'
76
+ });
77
+ editorView.dispatch(tr);
78
+ }
79
+ }
80
+ };
81
+ }
82
+ });
83
+ }
@@ -2,11 +2,13 @@ import { doc, paragraph, text } from '@atlaskit/adf-schema';
2
2
  import { keymap } from '@atlaskit/editor-common/keymaps';
3
3
  import { baseKeymap } from '@atlaskit/editor-prosemirror/commands';
4
4
  import { history } from '@atlaskit/editor-prosemirror/history';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { setKeyboardHeight } from './commands';
6
7
  import disableSpellcheckingPlugin from './pm-plugins/disable-spell-checking';
7
8
  import filterStepsPlugin from './pm-plugins/filter-steps';
8
9
  import frozenEditor from './pm-plugins/frozen-editor';
9
10
  import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
11
+ import { createLazyNodeViewDecorationPlugin } from './pm-plugins/lazy-node-view-decoration';
10
12
  import newlinePreserveMarksPlugin from './pm-plugins/newline-preserve-marks';
11
13
  import scrollGutter, { getKeyboardHeight } from './pm-plugins/scroll-gutter';
12
14
  const basePlugin = ({
@@ -32,6 +34,12 @@ const basePlugin = ({
32
34
  dispatchAnalyticsEvent
33
35
  }) => filterStepsPlugin(dispatchAnalyticsEvent)
34
36
  }];
37
+ if (fg('platform_editor_lazy-node-views')) {
38
+ plugins.push({
39
+ name: 'lazyNodeViewDecorationsPlugin',
40
+ plugin: () => createLazyNodeViewDecorationPlugin()
41
+ });
42
+ }
35
43
 
36
44
  // In Chrome, when the selection is placed between adjacent nodes which are not contenteditatble
37
45
  // the cursor appears at the right most point of the parent container.
@@ -0,0 +1,77 @@
1
+ import { lazyNodeViewDecorationPluginKey } from '@atlaskit/editor-common/lazy-node-view';
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
+ const LAZY_NODE_VIEW_DECORATION_CLASS = '__lazy-node-view-decoration__';
5
+ /**
6
+ * Plugin is used to force re-render NodeViews for a specific node type
7
+ * when LazyNodeView finishes loading the real NodeView.
8
+ *
9
+ * This is achieved by applying a decoration to a node.
10
+ *
11
+ * It's a blessed way that Marijn suggested multiple times in ProseMirror Discuss:
12
+ * – https://discuss.prosemirror.net/t/force-nodes-of-specific-type-to-re-render/2480
13
+ */
14
+ export function createLazyNodeViewDecorationPlugin() {
15
+ return new SafePlugin({
16
+ key: lazyNodeViewDecorationPluginKey,
17
+ state: {
18
+ init: () => {
19
+ return {
20
+ decorations: DecorationSet.empty,
21
+ nodeTypes: []
22
+ };
23
+ },
24
+ apply(tr, _oldState, newState) {
25
+ const actionPayload = tr.getMeta(lazyNodeViewDecorationPluginKey);
26
+ const pluginState = lazyNodeViewDecorationPluginKey.getState(newState);
27
+ if ((actionPayload === null || actionPayload === void 0 ? void 0 : actionPayload.type) === 'add' && actionPayload.nodeTypes.size) {
28
+ const decorations = [];
29
+ tr.doc.nodesBetween(0, tr.doc.nodeSize - 2, (node, pos) => {
30
+ if (actionPayload.nodeTypes.has(node.type.name)) {
31
+ decorations.push(Decoration.node(pos, pos + node.nodeSize, {
32
+ class: LAZY_NODE_VIEW_DECORATION_CLASS
33
+ }));
34
+ }
35
+ });
36
+ return {
37
+ decorations: DecorationSet.create(tr.doc, decorations)
38
+ };
39
+ }
40
+ if ((actionPayload === null || actionPayload === void 0 ? void 0 : actionPayload.type) === 'clear') {
41
+ return {
42
+ decorations: DecorationSet.empty
43
+ };
44
+ }
45
+ if (tr.docChanged) {
46
+ return {
47
+ decorations: pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations.map(tr.mapping, tr.doc)
48
+ };
49
+ }
50
+ return pluginState;
51
+ }
52
+ },
53
+ props: {
54
+ decorations: state => {
55
+ var _lazyNodeViewDecorati;
56
+ return (_lazyNodeViewDecorati = lazyNodeViewDecorationPluginKey.getState(state)) === null || _lazyNodeViewDecorati === void 0 ? void 0 : _lazyNodeViewDecorati.decorations;
57
+ }
58
+ },
59
+ view(editorView) {
60
+ return {
61
+ update() {
62
+ /**
63
+ * After view update can clean up decorations...
64
+ */
65
+ const pluginState = lazyNodeViewDecorationPluginKey.getState(editorView.state);
66
+ if (pluginState.decorations !== DecorationSet.empty) {
67
+ const tr = editorView.state.tr;
68
+ tr.setMeta(lazyNodeViewDecorationPluginKey, {
69
+ type: 'clear'
70
+ });
71
+ editorView.dispatch(tr);
72
+ }
73
+ }
74
+ };
75
+ }
76
+ });
77
+ }
@@ -5,11 +5,13 @@ import { doc, paragraph, text } from '@atlaskit/adf-schema';
5
5
  import { keymap } from '@atlaskit/editor-common/keymaps';
6
6
  import { baseKeymap } from '@atlaskit/editor-prosemirror/commands';
7
7
  import { history } from '@atlaskit/editor-prosemirror/history';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { setKeyboardHeight } from './commands';
9
10
  import disableSpellcheckingPlugin from './pm-plugins/disable-spell-checking';
10
11
  import filterStepsPlugin from './pm-plugins/filter-steps';
11
12
  import frozenEditor from './pm-plugins/frozen-editor';
12
13
  import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
14
+ import { createLazyNodeViewDecorationPlugin } from './pm-plugins/lazy-node-view-decoration';
13
15
  import newlinePreserveMarksPlugin from './pm-plugins/newline-preserve-marks';
14
16
  import scrollGutter, { getKeyboardHeight } from './pm-plugins/scroll-gutter';
15
17
  var basePlugin = function basePlugin(_ref) {
@@ -35,6 +37,14 @@ var basePlugin = function basePlugin(_ref) {
35
37
  return filterStepsPlugin(dispatchAnalyticsEvent);
36
38
  }
37
39
  }];
40
+ if (fg('platform_editor_lazy-node-views')) {
41
+ plugins.push({
42
+ name: 'lazyNodeViewDecorationsPlugin',
43
+ plugin: function plugin() {
44
+ return createLazyNodeViewDecorationPlugin();
45
+ }
46
+ });
47
+ }
38
48
 
39
49
  // In Chrome, when the selection is placed between adjacent nodes which are not contenteditatble
40
50
  // the cursor appears at the right most point of the parent container.
@@ -0,0 +1,77 @@
1
+ import { lazyNodeViewDecorationPluginKey } from '@atlaskit/editor-common/lazy-node-view';
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
+ var LAZY_NODE_VIEW_DECORATION_CLASS = '__lazy-node-view-decoration__';
5
+ /**
6
+ * Plugin is used to force re-render NodeViews for a specific node type
7
+ * when LazyNodeView finishes loading the real NodeView.
8
+ *
9
+ * This is achieved by applying a decoration to a node.
10
+ *
11
+ * It's a blessed way that Marijn suggested multiple times in ProseMirror Discuss:
12
+ * – https://discuss.prosemirror.net/t/force-nodes-of-specific-type-to-re-render/2480
13
+ */
14
+ export function createLazyNodeViewDecorationPlugin() {
15
+ return new SafePlugin({
16
+ key: lazyNodeViewDecorationPluginKey,
17
+ state: {
18
+ init: function init() {
19
+ return {
20
+ decorations: DecorationSet.empty,
21
+ nodeTypes: []
22
+ };
23
+ },
24
+ apply: function apply(tr, _oldState, newState) {
25
+ var actionPayload = tr.getMeta(lazyNodeViewDecorationPluginKey);
26
+ var pluginState = lazyNodeViewDecorationPluginKey.getState(newState);
27
+ if ((actionPayload === null || actionPayload === void 0 ? void 0 : actionPayload.type) === 'add' && actionPayload.nodeTypes.size) {
28
+ var decorations = [];
29
+ tr.doc.nodesBetween(0, tr.doc.nodeSize - 2, function (node, pos) {
30
+ if (actionPayload.nodeTypes.has(node.type.name)) {
31
+ decorations.push(Decoration.node(pos, pos + node.nodeSize, {
32
+ class: LAZY_NODE_VIEW_DECORATION_CLASS
33
+ }));
34
+ }
35
+ });
36
+ return {
37
+ decorations: DecorationSet.create(tr.doc, decorations)
38
+ };
39
+ }
40
+ if ((actionPayload === null || actionPayload === void 0 ? void 0 : actionPayload.type) === 'clear') {
41
+ return {
42
+ decorations: DecorationSet.empty
43
+ };
44
+ }
45
+ if (tr.docChanged) {
46
+ return {
47
+ decorations: pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations.map(tr.mapping, tr.doc)
48
+ };
49
+ }
50
+ return pluginState;
51
+ }
52
+ },
53
+ props: {
54
+ decorations: function decorations(state) {
55
+ var _lazyNodeViewDecorati;
56
+ return (_lazyNodeViewDecorati = lazyNodeViewDecorationPluginKey.getState(state)) === null || _lazyNodeViewDecorati === void 0 ? void 0 : _lazyNodeViewDecorati.decorations;
57
+ }
58
+ },
59
+ view: function view(editorView) {
60
+ return {
61
+ update: function update() {
62
+ /**
63
+ * After view update can clean up decorations...
64
+ */
65
+ var pluginState = lazyNodeViewDecorationPluginKey.getState(editorView.state);
66
+ if (pluginState.decorations !== DecorationSet.empty) {
67
+ var tr = editorView.state.tr;
68
+ tr.setMeta(lazyNodeViewDecorationPluginKey, {
69
+ type: 'clear'
70
+ });
71
+ editorView.dispatch(tr);
72
+ }
73
+ }
74
+ };
75
+ }
76
+ });
77
+ }
@@ -0,0 +1,16 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
+ type LazyNodeViewPluginState = {
4
+ decorations: DecorationSet;
5
+ };
6
+ /**
7
+ * Plugin is used to force re-render NodeViews for a specific node type
8
+ * when LazyNodeView finishes loading the real NodeView.
9
+ *
10
+ * This is achieved by applying a decoration to a node.
11
+ *
12
+ * It's a blessed way that Marijn suggested multiple times in ProseMirror Discuss:
13
+ * – https://discuss.prosemirror.net/t/force-nodes-of-specific-type-to-re-render/2480
14
+ */
15
+ export declare function createLazyNodeViewDecorationPlugin(): SafePlugin<LazyNodeViewPluginState>;
16
+ export {};
@@ -0,0 +1,16 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
+ type LazyNodeViewPluginState = {
4
+ decorations: DecorationSet;
5
+ };
6
+ /**
7
+ * Plugin is used to force re-render NodeViews for a specific node type
8
+ * when LazyNodeView finishes loading the real NodeView.
9
+ *
10
+ * This is achieved by applying a decoration to a node.
11
+ *
12
+ * It's a blessed way that Marijn suggested multiple times in ProseMirror Discuss:
13
+ * – https://discuss.prosemirror.net/t/force-nodes-of-specific-type-to-re-render/2480
14
+ */
15
+ export declare function createLazyNodeViewDecorationPlugin(): SafePlugin<LazyNodeViewPluginState>;
16
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-base",
3
- "version": "1.10.1",
3
+ "version": "1.11.0",
4
4
  "description": "Base plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -10,7 +10,6 @@
10
10
  "atlassian": {
11
11
  "team": "Editor: Lego",
12
12
  "singleton": true,
13
- "releaseModel": "continuous",
14
13
  "runReact18": false
15
14
  },
16
15
  "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
@@ -32,13 +31,19 @@
32
31
  ".": "./src/index.ts"
33
32
  },
34
33
  "dependencies": {
35
- "@atlaskit/adf-schema": "^40.8.1",
36
- "@atlaskit/editor-common": "^88.0.0",
34
+ "@atlaskit/adf-schema": "^40.9.0",
35
+ "@atlaskit/editor-common": "^88.7.0",
37
36
  "@atlaskit/editor-plugin-context-identifier": "^1.3.0",
38
37
  "@atlaskit/editor-plugin-feature-flags": "^1.2.0",
39
38
  "@atlaskit/editor-prosemirror": "5.0.1",
39
+ "@atlaskit/platform-feature-flags": "^0.3.0",
40
40
  "@babel/runtime": "^7.0.0"
41
41
  },
42
+ "platform-feature-flags": {
43
+ "platform_editor_lazy-node-views": {
44
+ "type": "boolean"
45
+ }
46
+ },
42
47
  "techstack": {
43
48
  "@atlassian/frontend": {
44
49
  "import-structure": [
package/tsconfig.app.json CHANGED
@@ -40,6 +40,9 @@
40
40
  },
41
41
  {
42
42
  "path": "../editor-plugin-feature-flags/tsconfig.app.json"
43
+ },
44
+ {
45
+ "path": "../../platform/feature-flags/tsconfig.app.json"
43
46
  }
44
47
  ]
45
48
  }