@atlaskit/editor-plugin-base 1.10.2 → 1.11.1
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 +21 -0
- package/dist/cjs/plugin.js +10 -0
- package/dist/cjs/pm-plugins/frozen-editor.js +7 -5
- package/dist/cjs/pm-plugins/lazy-node-view-decoration.js +83 -0
- package/dist/cjs/utils/getTimeSince.js +16 -0
- package/dist/cjs/utils/input-latency-tracking.js +4 -3
- package/dist/es2019/plugin.js +8 -0
- package/dist/es2019/pm-plugins/frozen-editor.js +3 -1
- package/dist/es2019/pm-plugins/lazy-node-view-decoration.js +77 -0
- package/dist/es2019/utils/getTimeSince.js +8 -0
- package/dist/es2019/utils/input-latency-tracking.js +2 -1
- package/dist/esm/plugin.js +10 -0
- package/dist/esm/pm-plugins/frozen-editor.js +3 -1
- package/dist/esm/pm-plugins/lazy-node-view-decoration.js +77 -0
- package/dist/esm/utils/getTimeSince.js +10 -0
- package/dist/esm/utils/input-latency-tracking.js +2 -1
- package/dist/types/pm-plugins/lazy-node-view-decoration.d.ts +16 -0
- package/dist/types/utils/getTimeSince.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/lazy-node-view-decoration.d.ts +16 -0
- package/dist/types-ts4.5/utils/getTimeSince.d.ts +8 -0
- package/package.json +8 -3
- package/tsconfig.app.json +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-base
|
|
2
2
|
|
|
3
|
+
## 1.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#137736](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/137736)
|
|
8
|
+
[`2a88fdd213838`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2a88fdd213838) -
|
|
9
|
+
Introducing new smaller refined entry-points for editor-common to reduce bundle size.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 1.11.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#136261](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/136261)
|
|
17
|
+
[`7e900c6a2ae84`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7e900c6a2ae84) -
|
|
18
|
+
Lazy node view loading without setProps
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 1.10.2
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -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.
|
|
@@ -7,9 +7,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.frozenEditorPluginKey = exports.default = exports.NORMAL_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = exports.DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = exports.DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = exports.DEFAULT_FREEZE_THRESHOLD = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
+
var _countNodes = require("@atlaskit/editor-common/count-nodes");
|
|
11
|
+
var _isPerformanceApiAvailable = require("@atlaskit/editor-common/is-performance-api-available");
|
|
10
12
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
13
|
var _ufo = require("@atlaskit/editor-common/ufo");
|
|
12
|
-
var
|
|
14
|
+
var _analytics2 = require("@atlaskit/editor-common/utils/analytics");
|
|
13
15
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
16
|
var _frozenEditor = require("../utils/frozen-editor");
|
|
15
17
|
var _inputLatencyTracking = _interopRequireDefault(require("../utils/input-latency-tracking"));
|
|
@@ -66,7 +68,7 @@ var _default = exports.default = function _default(contextIdentifierPlugin) {
|
|
|
66
68
|
if (state === prevNodeCountState) {
|
|
67
69
|
return prevNodeCount;
|
|
68
70
|
}
|
|
69
|
-
prevNodeCount = allowCountNodes ? (0,
|
|
71
|
+
prevNodeCount = allowCountNodes ? (0, _countNodes.countNodes)(state) : {};
|
|
70
72
|
prevNodeCountState = state;
|
|
71
73
|
return prevNodeCount;
|
|
72
74
|
};
|
|
@@ -120,7 +122,7 @@ var _default = exports.default = function _default(contextIdentifierPlugin) {
|
|
|
120
122
|
};
|
|
121
123
|
return new _safePlugin.SafePlugin({
|
|
122
124
|
key: frozenEditorPluginKey,
|
|
123
|
-
props: (0,
|
|
125
|
+
props: (0, _isPerformanceApiAvailable.isPerformanceAPIAvailable)() ? {
|
|
124
126
|
handleTextInput: function handleTextInput(view) {
|
|
125
127
|
if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
|
|
126
128
|
interactionType = _analytics.BROWSER_FREEZE_INTERACTION_TYPE.TYPING;
|
|
@@ -159,7 +161,7 @@ var _default = exports.default = function _default(contextIdentifierPlugin) {
|
|
|
159
161
|
} : undefined
|
|
160
162
|
} : undefined,
|
|
161
163
|
view: function view(_view) {
|
|
162
|
-
if (!(0,
|
|
164
|
+
if (!(0, _isPerformanceApiAvailable.isPerformanceObserverAvailable)()) {
|
|
163
165
|
return {};
|
|
164
166
|
}
|
|
165
167
|
var experienceStore = ufo ? _ufo.ExperienceStore.getInstance(_view) : undefined;
|
|
@@ -238,7 +240,7 @@ var _default = exports.default = function _default(contextIdentifierPlugin) {
|
|
|
238
240
|
for (var i = 0; i < perfEntries.length; i++) {
|
|
239
241
|
var duration = perfEntries[i].duration;
|
|
240
242
|
if (duration > freezeThreshold) {
|
|
241
|
-
dispatchLongTaskEvent(contextIdentifierPlugin)(dispatchAnalyticsEvent, _view, duration, getNodeCount, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? interactionType : undefined, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackSeverity ? (0,
|
|
243
|
+
dispatchLongTaskEvent(contextIdentifierPlugin)(dispatchAnalyticsEvent, _view, duration, getNodeCount, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? interactionType : undefined, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackSeverity ? (0, _analytics2.getAnalyticsEventSeverity)(duration, browserFreezeTracking.severityNormalThreshold || NORMAL_SEVERITY_THRESHOLD, browserFreezeTracking.severityDegradedThreshold || DEGRADED_SEVERITY_THRESHOLD) : undefined);
|
|
242
244
|
}
|
|
243
245
|
}
|
|
244
246
|
});
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getTimeSince = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Calculate the difference between performance.now() and the given startTime.
|
|
9
|
+
* This allows for the timing to be overridable during tests.
|
|
10
|
+
*
|
|
11
|
+
* @param startTime DOMHighResTimeStamp
|
|
12
|
+
* @returns DOMHighResTimeStamp
|
|
13
|
+
*/
|
|
14
|
+
var getTimeSince = exports.getTimeSince = function getTimeSince(startTime) {
|
|
15
|
+
return performance.now() - startTime;
|
|
16
|
+
};
|
|
@@ -8,7 +8,8 @@ exports.default = void 0;
|
|
|
8
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var
|
|
11
|
+
var _analytics = require("@atlaskit/editor-common/utils/analytics");
|
|
12
|
+
var _getTimeSince = require("./getTimeSince");
|
|
12
13
|
var InputLatencyTracker = exports.default = /*#__PURE__*/function () {
|
|
13
14
|
function InputLatencyTracker(_ref) {
|
|
14
15
|
var samplingRate = _ref.samplingRate,
|
|
@@ -47,7 +48,7 @@ var InputLatencyTracker = exports.default = /*#__PURE__*/function () {
|
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
50
|
var isSlow = false;
|
|
50
|
-
var time = (0,
|
|
51
|
+
var time = (0, _getTimeSince.getTimeSince)(currentStart);
|
|
51
52
|
_this.push(time);
|
|
52
53
|
if (time > _this.slowThreshold) {
|
|
53
54
|
var _this$onSlowInput;
|
|
@@ -97,7 +98,7 @@ var InputLatencyTracker = exports.default = /*#__PURE__*/function () {
|
|
|
97
98
|
}, {
|
|
98
99
|
key: "severity",
|
|
99
100
|
value: function severity(time) {
|
|
100
|
-
return (0,
|
|
101
|
+
return (0, _analytics.getAnalyticsEventSeverity)(time, this.normalThreshold, this.degradedThreshold);
|
|
101
102
|
}
|
|
102
103
|
}, {
|
|
103
104
|
key: "getLast",
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -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.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, BROWSER_FREEZE_INTERACTION_TYPE, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { countNodes } from '@atlaskit/editor-common/count-nodes';
|
|
3
|
+
import { isPerformanceAPIAvailable, isPerformanceObserverAvailable } from '@atlaskit/editor-common/is-performance-api-available';
|
|
2
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
5
|
import { EditorExperience, ExperienceStore } from '@atlaskit/editor-common/ufo';
|
|
4
|
-
import {
|
|
6
|
+
import { getAnalyticsEventSeverity } from '@atlaskit/editor-common/utils/analytics';
|
|
5
7
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
6
8
|
import { setInteractionType } from '../utils/frozen-editor';
|
|
7
9
|
import InputLatencyTracker from '../utils/input-latency-tracking';
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate the difference between performance.now() and the given startTime.
|
|
3
|
+
* This allows for the timing to be overridable during tests.
|
|
4
|
+
*
|
|
5
|
+
* @param startTime DOMHighResTimeStamp
|
|
6
|
+
* @returns DOMHighResTimeStamp
|
|
7
|
+
*/
|
|
8
|
+
export const getTimeSince = startTime => performance.now() - startTime;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import { getAnalyticsEventSeverity
|
|
2
|
+
import { getAnalyticsEventSeverity } from '@atlaskit/editor-common/utils/analytics';
|
|
3
|
+
import { getTimeSince } from './getTimeSince';
|
|
3
4
|
export default class InputLatencyTracker {
|
|
4
5
|
constructor({
|
|
5
6
|
samplingRate,
|
package/dist/esm/plugin.js
CHANGED
|
@@ -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.
|
|
@@ -2,9 +2,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
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
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
4
|
import { ACTION, ACTION_SUBJECT, BROWSER_FREEZE_INTERACTION_TYPE, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import { countNodes } from '@atlaskit/editor-common/count-nodes';
|
|
6
|
+
import { isPerformanceAPIAvailable, isPerformanceObserverAvailable } from '@atlaskit/editor-common/is-performance-api-available';
|
|
5
7
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
8
|
import { EditorExperience, ExperienceStore } from '@atlaskit/editor-common/ufo';
|
|
7
|
-
import {
|
|
9
|
+
import { getAnalyticsEventSeverity } from '@atlaskit/editor-common/utils/analytics';
|
|
8
10
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
9
11
|
import { setInteractionType } from '../utils/frozen-editor';
|
|
10
12
|
import InputLatencyTracker from '../utils/input-latency-tracking';
|
|
@@ -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,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate the difference between performance.now() and the given startTime.
|
|
3
|
+
* This allows for the timing to be overridable during tests.
|
|
4
|
+
*
|
|
5
|
+
* @param startTime DOMHighResTimeStamp
|
|
6
|
+
* @returns DOMHighResTimeStamp
|
|
7
|
+
*/
|
|
8
|
+
export var getTimeSince = function getTimeSince(startTime) {
|
|
9
|
+
return performance.now() - startTime;
|
|
10
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
import { getAnalyticsEventSeverity
|
|
4
|
+
import { getAnalyticsEventSeverity } from '@atlaskit/editor-common/utils/analytics';
|
|
5
|
+
import { getTimeSince } from './getTimeSince';
|
|
5
6
|
var InputLatencyTracker = /*#__PURE__*/function () {
|
|
6
7
|
function InputLatencyTracker(_ref) {
|
|
7
8
|
var samplingRate = _ref.samplingRate,
|
|
@@ -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,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate the difference between performance.now() and the given startTime.
|
|
3
|
+
* This allows for the timing to be overridable during tests.
|
|
4
|
+
*
|
|
5
|
+
* @param startTime DOMHighResTimeStamp
|
|
6
|
+
* @returns DOMHighResTimeStamp
|
|
7
|
+
*/
|
|
8
|
+
export declare const getTimeSince: (startTime: DOMHighResTimeStamp) => DOMHighResTimeStamp;
|
|
@@ -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,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate the difference between performance.now() and the given startTime.
|
|
3
|
+
* This allows for the timing to be overridable during tests.
|
|
4
|
+
*
|
|
5
|
+
* @param startTime DOMHighResTimeStamp
|
|
6
|
+
* @returns DOMHighResTimeStamp
|
|
7
|
+
*/
|
|
8
|
+
export declare const getTimeSince: (startTime: DOMHighResTimeStamp) => DOMHighResTimeStamp;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-base",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.1",
|
|
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",
|
|
@@ -33,12 +32,18 @@
|
|
|
33
32
|
},
|
|
34
33
|
"dependencies": {
|
|
35
34
|
"@atlaskit/adf-schema": "^40.9.0",
|
|
36
|
-
"@atlaskit/editor-common": "^88.
|
|
35
|
+
"@atlaskit/editor-common": "^88.11.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": [
|