@atlaskit/editor-plugin-base 2.0.11 → 2.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 +20 -0
- package/dist/cjs/basePlugin.js +65 -6
- package/dist/cjs/pm-plugins/disable-spell-checking.js +4 -1
- package/dist/cjs/pm-plugins/frozen-editor.js +4 -1
- package/dist/cjs/pm-plugins/scroll-gutter/plugin.js +6 -0
- package/dist/es2019/basePlugin.js +66 -2
- package/dist/es2019/pm-plugins/disable-spell-checking.js +4 -1
- package/dist/es2019/pm-plugins/frozen-editor.js +4 -1
- package/dist/es2019/pm-plugins/scroll-gutter/plugin.js +6 -0
- package/dist/esm/basePlugin.js +65 -6
- package/dist/esm/pm-plugins/disable-spell-checking.js +4 -1
- package/dist/esm/pm-plugins/frozen-editor.js +4 -1
- package/dist/esm/pm-plugins/scroll-gutter/plugin.js +6 -0
- package/dist/types/basePlugin.d.ts +3 -1
- package/dist/types/basePluginType.d.ts +11 -0
- package/dist/types-ts4.5/basePlugin.d.ts +3 -1
- package/dist/types-ts4.5/basePluginType.d.ts +11 -0
- package/package.json +3 -3
- package/tsconfig.app.json +0 -1
- package/tsconfig.dev.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-base
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#97984](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97984)
|
|
8
|
+
[`8ffeab9aaf1ab`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8ffeab9aaf1ab) -
|
|
9
|
+
[ux] [ED-23573] Added new actions (resolveMarks and registerMarks) to basePlugin. Callbacks added
|
|
10
|
+
to mentions, card, emoji and base plugins to handle conversion to inline code. Deprecated code
|
|
11
|
+
removed from editor-common.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
17
|
+
## 2.0.12
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 2.0.11
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/cjs/basePlugin.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
exports.resolveCallbacks = resolveCallbacks;
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
11
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
@@ -25,11 +26,63 @@ var _getKeyboardHeight = require("./pm-plugins/scroll-gutter/util/get-keyboard-h
|
|
|
25
26
|
var _inputTrackingConfig = require("./pm-plugins/utils/inputTrackingConfig");
|
|
26
27
|
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; }
|
|
27
28
|
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; }
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
30
|
+
function resolveCallbacks(from, to, tr, callbacks) {
|
|
31
|
+
var doc = tr.doc;
|
|
32
|
+
doc.nodesBetween(from, to, function (node, pos) {
|
|
33
|
+
callbacks.forEach(function (cb) {
|
|
34
|
+
return cb({
|
|
35
|
+
tr: tr,
|
|
36
|
+
node: node,
|
|
37
|
+
pos: pos,
|
|
38
|
+
from: from,
|
|
39
|
+
to: to
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
var SMART_TO_ASCII = {
|
|
45
|
+
'…': '...',
|
|
46
|
+
'→': '->',
|
|
47
|
+
'←': '<-',
|
|
48
|
+
'–': '--',
|
|
49
|
+
'“': '"',
|
|
50
|
+
'”': '"',
|
|
51
|
+
'‘': "'",
|
|
52
|
+
'’': "'"
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
56
|
+
var FIND_SMART_CHAR = new RegExp("[".concat(Object.keys(SMART_TO_ASCII).join(''), "]"), 'g');
|
|
28
57
|
var basePlugin = function basePlugin(_ref) {
|
|
29
|
-
var _api$featureFlags;
|
|
58
|
+
var _api$featureFlags, _api$base;
|
|
30
59
|
var options = _ref.config,
|
|
31
60
|
api = _ref.api;
|
|
32
61
|
var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
62
|
+
var callbacks = [];
|
|
63
|
+
api === null || api === void 0 || (_api$base = api.base) === null || _api$base === void 0 || _api$base.actions.registerMarks(function (_ref2) {
|
|
64
|
+
var tr = _ref2.tr,
|
|
65
|
+
node = _ref2.node,
|
|
66
|
+
pos = _ref2.pos,
|
|
67
|
+
from = _ref2.from,
|
|
68
|
+
to = _ref2.to;
|
|
69
|
+
var doc = tr.doc;
|
|
70
|
+
var schema = doc.type.schema;
|
|
71
|
+
var textNodeType = schema.nodes.text;
|
|
72
|
+
if (node.type === textNodeType && node.text) {
|
|
73
|
+
// Find a valid start and end position because the text may be partially selected.
|
|
74
|
+
var startPositionInSelection = Math.max(pos, from);
|
|
75
|
+
var endPositionInSelection = Math.min(pos + node.nodeSize, to);
|
|
76
|
+
var textForReplacing = doc.textBetween(startPositionInSelection, endPositionInSelection);
|
|
77
|
+
var newText = textForReplacing.replace(FIND_SMART_CHAR, function (match) {
|
|
78
|
+
var _SMART_TO_ASCII$match;
|
|
79
|
+
return (_SMART_TO_ASCII$match = SMART_TO_ASCII[match]) !== null && _SMART_TO_ASCII$match !== void 0 ? _SMART_TO_ASCII$match : match;
|
|
80
|
+
});
|
|
81
|
+
var currentStartPos = tr.mapping.map(startPositionInSelection);
|
|
82
|
+
var currentEndPos = tr.mapping.map(endPositionInSelection);
|
|
83
|
+
tr.replaceWith(currentStartPos, currentEndPos, schema.text(newText, node.marks));
|
|
84
|
+
}
|
|
85
|
+
});
|
|
33
86
|
return {
|
|
34
87
|
name: 'base',
|
|
35
88
|
getSharedState: function getSharedState(editorState) {
|
|
@@ -38,13 +91,19 @@ var basePlugin = function basePlugin(_ref) {
|
|
|
38
91
|
};
|
|
39
92
|
},
|
|
40
93
|
actions: {
|
|
41
|
-
setKeyboardHeight: _setKeyboardHeight.setKeyboardHeight
|
|
94
|
+
setKeyboardHeight: _setKeyboardHeight.setKeyboardHeight,
|
|
95
|
+
resolveMarks: function resolveMarks(from, to, tr) {
|
|
96
|
+
return resolveCallbacks(from, to, tr, callbacks);
|
|
97
|
+
},
|
|
98
|
+
registerMarks: function registerMarks(callback) {
|
|
99
|
+
callbacks.push(callback);
|
|
100
|
+
}
|
|
42
101
|
},
|
|
43
102
|
pmPlugins: function pmPlugins() {
|
|
44
103
|
var plugins = [{
|
|
45
104
|
name: 'filterStepsPlugin',
|
|
46
|
-
plugin: function plugin(
|
|
47
|
-
var dispatchAnalyticsEvent =
|
|
105
|
+
plugin: function plugin(_ref3) {
|
|
106
|
+
var dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
|
|
48
107
|
return (0, _filterSteps.default)(dispatchAnalyticsEvent);
|
|
49
108
|
}
|
|
50
109
|
}];
|
|
@@ -81,8 +140,8 @@ var basePlugin = function basePlugin(_ref) {
|
|
|
81
140
|
plugin: _newlinePreserveMarks.default
|
|
82
141
|
}, {
|
|
83
142
|
name: 'frozenEditor',
|
|
84
|
-
plugin: function plugin(
|
|
85
|
-
var dispatchAnalyticsEvent =
|
|
143
|
+
plugin: function plugin(_ref4) {
|
|
144
|
+
var dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
|
|
86
145
|
return (0, _frozenEditor.default)(api === null || api === void 0 ? void 0 : api.contextIdentifier)(dispatchAnalyticsEvent, _inputTrackingConfig.inputTracking, undefined);
|
|
87
146
|
}
|
|
88
147
|
}, {
|
|
@@ -45,7 +45,10 @@ var _default = exports.default = function _default(featureFlags) {
|
|
|
45
45
|
if (!userCurrentBrowserAndVersion || !browserConfigFeatureFlag) {
|
|
46
46
|
return {};
|
|
47
47
|
}
|
|
48
|
-
var browserVersionDisableRange =
|
|
48
|
+
var browserVersionDisableRange =
|
|
49
|
+
// Ignored via go/ees005
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
51
|
+
browserConfigFeatureFlag[userCurrentBrowserAndVersion.browser];
|
|
49
52
|
if (!browserVersionDisableRange || !_browser.browser[userCurrentBrowserAndVersion.browser]) {
|
|
50
53
|
return {};
|
|
51
54
|
}
|
|
@@ -26,7 +26,10 @@ var DEFAULT_TRACK_SEVERITY_ENABLED = false;
|
|
|
26
26
|
var DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = exports.DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = 100;
|
|
27
27
|
var DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = exports.DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = 500;
|
|
28
28
|
var dispatchLongTaskEvent = function dispatchLongTaskEvent(contextIdentifierPlugin) {
|
|
29
|
-
return function (dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity
|
|
29
|
+
return function (dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity
|
|
30
|
+
// Ignored via go/ees005
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
32
|
+
) {
|
|
30
33
|
var _contextIdentifierPlu;
|
|
31
34
|
var state = view.state;
|
|
32
35
|
var nodesCount = getNodeCount(state);
|
|
@@ -120,6 +120,8 @@ function getCaretTopPosition() {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
// Return container top
|
|
123
|
+
// Ignored via go/ees005
|
|
124
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
123
125
|
var container = range.startContainer;
|
|
124
126
|
if (container && container.getBoundingClientRect) {
|
|
125
127
|
return container.getBoundingClientRect().top;
|
|
@@ -196,12 +198,16 @@ var _default = exports.default = function _default() {
|
|
|
196
198
|
view: function view(_view) {
|
|
197
199
|
// Store references to avoid lookups on successive checks.
|
|
198
200
|
scrollElement = getScrollElement(_view);
|
|
201
|
+
// Ignored via go/ees005
|
|
202
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
199
203
|
var editorElement = _view.dom;
|
|
200
204
|
var editorParentElement = editorElement.parentElement;
|
|
201
205
|
var viewportElementHeight = 0;
|
|
202
206
|
var contentElementHeight = 0;
|
|
203
207
|
var addAndObserveGutter = function addAndObserveGutter() {
|
|
204
208
|
if (!gutter.isMounted()) {
|
|
209
|
+
// Ignored via go/ees005
|
|
210
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
205
211
|
gutter.observe(scrollElement);
|
|
206
212
|
gutter.addGutter(editorParentElement ? new WeakRef(editorParentElement) : null);
|
|
207
213
|
}
|
|
@@ -15,12 +15,72 @@ import scrollGutter from './pm-plugins/scroll-gutter/plugin';
|
|
|
15
15
|
import scrollGutterNext from './pm-plugins/scroll-gutter/plugin-next';
|
|
16
16
|
import { getKeyboardHeight } from './pm-plugins/scroll-gutter/util/get-keyboard-height';
|
|
17
17
|
import { inputTracking } from './pm-plugins/utils/inputTrackingConfig';
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
20
|
+
export function resolveCallbacks(from, to, tr, callbacks) {
|
|
21
|
+
const {
|
|
22
|
+
doc
|
|
23
|
+
} = tr;
|
|
24
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
25
|
+
callbacks.forEach(cb => cb({
|
|
26
|
+
tr,
|
|
27
|
+
node,
|
|
28
|
+
pos,
|
|
29
|
+
from,
|
|
30
|
+
to
|
|
31
|
+
}));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const SMART_TO_ASCII = {
|
|
35
|
+
'…': '...',
|
|
36
|
+
'→': '->',
|
|
37
|
+
'←': '<-',
|
|
38
|
+
'–': '--',
|
|
39
|
+
'“': '"',
|
|
40
|
+
'”': '"',
|
|
41
|
+
'‘': "'",
|
|
42
|
+
'’': "'"
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
46
|
+
const FIND_SMART_CHAR = new RegExp(`[${Object.keys(SMART_TO_ASCII).join('')}]`, 'g');
|
|
18
47
|
const basePlugin = ({
|
|
19
48
|
config: options,
|
|
20
49
|
api
|
|
21
50
|
}) => {
|
|
22
|
-
var _api$featureFlags;
|
|
51
|
+
var _api$featureFlags, _api$base;
|
|
23
52
|
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
53
|
+
const callbacks = [];
|
|
54
|
+
api === null || api === void 0 ? void 0 : (_api$base = api.base) === null || _api$base === void 0 ? void 0 : _api$base.actions.registerMarks(({
|
|
55
|
+
tr,
|
|
56
|
+
node,
|
|
57
|
+
pos,
|
|
58
|
+
from,
|
|
59
|
+
to
|
|
60
|
+
}) => {
|
|
61
|
+
const {
|
|
62
|
+
doc
|
|
63
|
+
} = tr;
|
|
64
|
+
const {
|
|
65
|
+
schema
|
|
66
|
+
} = doc.type;
|
|
67
|
+
const {
|
|
68
|
+
text: textNodeType
|
|
69
|
+
} = schema.nodes;
|
|
70
|
+
if (node.type === textNodeType && node.text) {
|
|
71
|
+
// Find a valid start and end position because the text may be partially selected.
|
|
72
|
+
const startPositionInSelection = Math.max(pos, from);
|
|
73
|
+
const endPositionInSelection = Math.min(pos + node.nodeSize, to);
|
|
74
|
+
const textForReplacing = doc.textBetween(startPositionInSelection, endPositionInSelection);
|
|
75
|
+
const newText = textForReplacing.replace(FIND_SMART_CHAR, match => {
|
|
76
|
+
var _SMART_TO_ASCII$match;
|
|
77
|
+
return (_SMART_TO_ASCII$match = SMART_TO_ASCII[match]) !== null && _SMART_TO_ASCII$match !== void 0 ? _SMART_TO_ASCII$match : match;
|
|
78
|
+
});
|
|
79
|
+
const currentStartPos = tr.mapping.map(startPositionInSelection);
|
|
80
|
+
const currentEndPos = tr.mapping.map(endPositionInSelection);
|
|
81
|
+
tr.replaceWith(currentStartPos, currentEndPos, schema.text(newText, node.marks));
|
|
82
|
+
}
|
|
83
|
+
});
|
|
24
84
|
return {
|
|
25
85
|
name: 'base',
|
|
26
86
|
getSharedState(editorState) {
|
|
@@ -29,7 +89,11 @@ const basePlugin = ({
|
|
|
29
89
|
};
|
|
30
90
|
},
|
|
31
91
|
actions: {
|
|
32
|
-
setKeyboardHeight
|
|
92
|
+
setKeyboardHeight,
|
|
93
|
+
resolveMarks: (from, to, tr) => resolveCallbacks(from, to, tr, callbacks),
|
|
94
|
+
registerMarks: callback => {
|
|
95
|
+
callbacks.push(callback);
|
|
96
|
+
}
|
|
33
97
|
},
|
|
34
98
|
pmPlugins() {
|
|
35
99
|
const plugins = [{
|
|
@@ -38,7 +38,10 @@ export default (featureFlags => new SafePlugin({
|
|
|
38
38
|
if (!userCurrentBrowserAndVersion || !browserConfigFeatureFlag) {
|
|
39
39
|
return {};
|
|
40
40
|
}
|
|
41
|
-
const browserVersionDisableRange =
|
|
41
|
+
const browserVersionDisableRange =
|
|
42
|
+
// Ignored via go/ees005
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
44
|
+
browserConfigFeatureFlag[userCurrentBrowserAndVersion.browser];
|
|
42
45
|
if (!browserVersionDisableRange || !browserEnv[userCurrentBrowserAndVersion.browser]) {
|
|
43
46
|
return {};
|
|
44
47
|
}
|
|
@@ -15,7 +15,10 @@ export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
15
15
|
const DEFAULT_TRACK_SEVERITY_ENABLED = false;
|
|
16
16
|
export const DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = 100;
|
|
17
17
|
export const DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = 500;
|
|
18
|
-
const dispatchLongTaskEvent = contextIdentifierPlugin => (dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity
|
|
18
|
+
const dispatchLongTaskEvent = contextIdentifierPlugin => (dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity
|
|
19
|
+
// Ignored via go/ees005
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
21
|
+
) => {
|
|
19
22
|
var _contextIdentifierPlu, _contextIdentifierPlu2;
|
|
20
23
|
const {
|
|
21
24
|
state
|
|
@@ -109,6 +109,8 @@ function getCaretTopPosition() {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
// Return container top
|
|
112
|
+
// Ignored via go/ees005
|
|
113
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
112
114
|
const container = range.startContainer;
|
|
113
115
|
if (container && container.getBoundingClientRect) {
|
|
114
116
|
return container.getBoundingClientRect().top;
|
|
@@ -183,12 +185,16 @@ export default ((pluginOptions = {}) => {
|
|
|
183
185
|
view(view) {
|
|
184
186
|
// Store references to avoid lookups on successive checks.
|
|
185
187
|
scrollElement = getScrollElement(view);
|
|
188
|
+
// Ignored via go/ees005
|
|
189
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
186
190
|
let editorElement = view.dom;
|
|
187
191
|
let editorParentElement = editorElement.parentElement;
|
|
188
192
|
let viewportElementHeight = 0;
|
|
189
193
|
let contentElementHeight = 0;
|
|
190
194
|
const addAndObserveGutter = () => {
|
|
191
195
|
if (!gutter.isMounted()) {
|
|
196
|
+
// Ignored via go/ees005
|
|
197
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
192
198
|
gutter.observe(scrollElement);
|
|
193
199
|
gutter.addGutter(editorParentElement ? new WeakRef(editorParentElement) : null);
|
|
194
200
|
}
|
package/dist/esm/basePlugin.js
CHANGED
|
@@ -18,11 +18,64 @@ import scrollGutter from './pm-plugins/scroll-gutter/plugin';
|
|
|
18
18
|
import scrollGutterNext from './pm-plugins/scroll-gutter/plugin-next';
|
|
19
19
|
import { getKeyboardHeight } from './pm-plugins/scroll-gutter/util/get-keyboard-height';
|
|
20
20
|
import { inputTracking } from './pm-plugins/utils/inputTrackingConfig';
|
|
21
|
+
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
23
|
+
export function resolveCallbacks(from, to, tr, callbacks) {
|
|
24
|
+
var doc = tr.doc;
|
|
25
|
+
doc.nodesBetween(from, to, function (node, pos) {
|
|
26
|
+
callbacks.forEach(function (cb) {
|
|
27
|
+
return cb({
|
|
28
|
+
tr: tr,
|
|
29
|
+
node: node,
|
|
30
|
+
pos: pos,
|
|
31
|
+
from: from,
|
|
32
|
+
to: to
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
var SMART_TO_ASCII = {
|
|
38
|
+
'…': '...',
|
|
39
|
+
'→': '->',
|
|
40
|
+
'←': '<-',
|
|
41
|
+
'–': '--',
|
|
42
|
+
'“': '"',
|
|
43
|
+
'”': '"',
|
|
44
|
+
'‘': "'",
|
|
45
|
+
'’': "'"
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
49
|
+
var FIND_SMART_CHAR = new RegExp("[".concat(Object.keys(SMART_TO_ASCII).join(''), "]"), 'g');
|
|
21
50
|
var basePlugin = function basePlugin(_ref) {
|
|
22
|
-
var _api$featureFlags;
|
|
51
|
+
var _api$featureFlags, _api$base;
|
|
23
52
|
var options = _ref.config,
|
|
24
53
|
api = _ref.api;
|
|
25
54
|
var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
55
|
+
var callbacks = [];
|
|
56
|
+
api === null || api === void 0 || (_api$base = api.base) === null || _api$base === void 0 || _api$base.actions.registerMarks(function (_ref2) {
|
|
57
|
+
var tr = _ref2.tr,
|
|
58
|
+
node = _ref2.node,
|
|
59
|
+
pos = _ref2.pos,
|
|
60
|
+
from = _ref2.from,
|
|
61
|
+
to = _ref2.to;
|
|
62
|
+
var doc = tr.doc;
|
|
63
|
+
var schema = doc.type.schema;
|
|
64
|
+
var textNodeType = schema.nodes.text;
|
|
65
|
+
if (node.type === textNodeType && node.text) {
|
|
66
|
+
// Find a valid start and end position because the text may be partially selected.
|
|
67
|
+
var startPositionInSelection = Math.max(pos, from);
|
|
68
|
+
var endPositionInSelection = Math.min(pos + node.nodeSize, to);
|
|
69
|
+
var textForReplacing = doc.textBetween(startPositionInSelection, endPositionInSelection);
|
|
70
|
+
var newText = textForReplacing.replace(FIND_SMART_CHAR, function (match) {
|
|
71
|
+
var _SMART_TO_ASCII$match;
|
|
72
|
+
return (_SMART_TO_ASCII$match = SMART_TO_ASCII[match]) !== null && _SMART_TO_ASCII$match !== void 0 ? _SMART_TO_ASCII$match : match;
|
|
73
|
+
});
|
|
74
|
+
var currentStartPos = tr.mapping.map(startPositionInSelection);
|
|
75
|
+
var currentEndPos = tr.mapping.map(endPositionInSelection);
|
|
76
|
+
tr.replaceWith(currentStartPos, currentEndPos, schema.text(newText, node.marks));
|
|
77
|
+
}
|
|
78
|
+
});
|
|
26
79
|
return {
|
|
27
80
|
name: 'base',
|
|
28
81
|
getSharedState: function getSharedState(editorState) {
|
|
@@ -31,13 +84,19 @@ var basePlugin = function basePlugin(_ref) {
|
|
|
31
84
|
};
|
|
32
85
|
},
|
|
33
86
|
actions: {
|
|
34
|
-
setKeyboardHeight: setKeyboardHeight
|
|
87
|
+
setKeyboardHeight: setKeyboardHeight,
|
|
88
|
+
resolveMarks: function resolveMarks(from, to, tr) {
|
|
89
|
+
return resolveCallbacks(from, to, tr, callbacks);
|
|
90
|
+
},
|
|
91
|
+
registerMarks: function registerMarks(callback) {
|
|
92
|
+
callbacks.push(callback);
|
|
93
|
+
}
|
|
35
94
|
},
|
|
36
95
|
pmPlugins: function pmPlugins() {
|
|
37
96
|
var plugins = [{
|
|
38
97
|
name: 'filterStepsPlugin',
|
|
39
|
-
plugin: function plugin(
|
|
40
|
-
var dispatchAnalyticsEvent =
|
|
98
|
+
plugin: function plugin(_ref3) {
|
|
99
|
+
var dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
|
|
41
100
|
return filterStepsPlugin(dispatchAnalyticsEvent);
|
|
42
101
|
}
|
|
43
102
|
}];
|
|
@@ -74,8 +133,8 @@ var basePlugin = function basePlugin(_ref) {
|
|
|
74
133
|
plugin: newlinePreserveMarksPlugin
|
|
75
134
|
}, {
|
|
76
135
|
name: 'frozenEditor',
|
|
77
|
-
plugin: function plugin(
|
|
78
|
-
var dispatchAnalyticsEvent =
|
|
136
|
+
plugin: function plugin(_ref4) {
|
|
137
|
+
var dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
|
|
79
138
|
return frozenEditor(api === null || api === void 0 ? void 0 : api.contextIdentifier)(dispatchAnalyticsEvent, inputTracking, undefined);
|
|
80
139
|
}
|
|
81
140
|
}, {
|
|
@@ -39,7 +39,10 @@ export default (function (featureFlags) {
|
|
|
39
39
|
if (!userCurrentBrowserAndVersion || !browserConfigFeatureFlag) {
|
|
40
40
|
return {};
|
|
41
41
|
}
|
|
42
|
-
var browserVersionDisableRange =
|
|
42
|
+
var browserVersionDisableRange =
|
|
43
|
+
// Ignored via go/ees005
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
45
|
+
browserConfigFeatureFlag[userCurrentBrowserAndVersion.browser];
|
|
43
46
|
if (!browserVersionDisableRange || !browserEnv[userCurrentBrowserAndVersion.browser]) {
|
|
44
47
|
return {};
|
|
45
48
|
}
|
|
@@ -19,7 +19,10 @@ var DEFAULT_TRACK_SEVERITY_ENABLED = false;
|
|
|
19
19
|
export var DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = 100;
|
|
20
20
|
export var DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = 500;
|
|
21
21
|
var dispatchLongTaskEvent = function dispatchLongTaskEvent(contextIdentifierPlugin) {
|
|
22
|
-
return function (dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity
|
|
22
|
+
return function (dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity
|
|
23
|
+
// Ignored via go/ees005
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
25
|
+
) {
|
|
23
26
|
var _contextIdentifierPlu;
|
|
24
27
|
var state = view.state;
|
|
25
28
|
var nodesCount = getNodeCount(state);
|
|
@@ -114,6 +114,8 @@ function getCaretTopPosition() {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
// Return container top
|
|
117
|
+
// Ignored via go/ees005
|
|
118
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
117
119
|
var container = range.startContainer;
|
|
118
120
|
if (container && container.getBoundingClientRect) {
|
|
119
121
|
return container.getBoundingClientRect().top;
|
|
@@ -190,12 +192,16 @@ export default (function () {
|
|
|
190
192
|
view: function view(_view) {
|
|
191
193
|
// Store references to avoid lookups on successive checks.
|
|
192
194
|
scrollElement = getScrollElement(_view);
|
|
195
|
+
// Ignored via go/ees005
|
|
196
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
193
197
|
var editorElement = _view.dom;
|
|
194
198
|
var editorParentElement = editorElement.parentElement;
|
|
195
199
|
var viewportElementHeight = 0;
|
|
196
200
|
var contentElementHeight = 0;
|
|
197
201
|
var addAndObserveGutter = function addAndObserveGutter() {
|
|
198
202
|
if (!gutter.isMounted()) {
|
|
203
|
+
// Ignored via go/ees005
|
|
204
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
199
205
|
gutter.observe(scrollElement);
|
|
200
206
|
gutter.addGutter(editorParentElement ? new WeakRef(editorParentElement) : null);
|
|
201
207
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { BasePlugin, Callback } from './basePluginType';
|
|
3
|
+
export declare function resolveCallbacks(from: number, to: number, tr: Transaction, callbacks: Callback[]): void;
|
|
2
4
|
declare const basePlugin: BasePlugin;
|
|
3
5
|
export default basePlugin;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { BrowserFreezetracking, InputTracking, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
3
3
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
4
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
6
|
import { type setKeyboardHeight } from './editor-commands/set-keyboard-height';
|
|
5
7
|
import type { ScrollGutterPluginOptions } from './pm-plugins/scroll-gutter/plugin';
|
|
6
8
|
export interface BasePluginOptions {
|
|
@@ -25,5 +27,14 @@ export type BasePlugin = NextEditorPlugin<'base', {
|
|
|
25
27
|
sharedState: BasePluginState;
|
|
26
28
|
actions: {
|
|
27
29
|
setKeyboardHeight: typeof setKeyboardHeight;
|
|
30
|
+
registerMarks: (callback: Callback) => void;
|
|
31
|
+
resolveMarks: (from: number, to: number, tr: Transaction) => void;
|
|
28
32
|
};
|
|
29
33
|
}>;
|
|
34
|
+
export type Callback = ({ node, tr, pos, from, to, }: {
|
|
35
|
+
node: PMNode;
|
|
36
|
+
tr: Transaction;
|
|
37
|
+
pos: number;
|
|
38
|
+
from: number;
|
|
39
|
+
to: number;
|
|
40
|
+
}) => void;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { BasePlugin, Callback } from './basePluginType';
|
|
3
|
+
export declare function resolveCallbacks(from: number, to: number, tr: Transaction, callbacks: Callback[]): void;
|
|
2
4
|
declare const basePlugin: BasePlugin;
|
|
3
5
|
export default basePlugin;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { BrowserFreezetracking, InputTracking, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
3
3
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
4
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
6
|
import { type setKeyboardHeight } from './editor-commands/set-keyboard-height';
|
|
5
7
|
import type { ScrollGutterPluginOptions } from './pm-plugins/scroll-gutter/plugin';
|
|
6
8
|
export interface BasePluginOptions {
|
|
@@ -28,5 +30,14 @@ export type BasePlugin = NextEditorPlugin<'base', {
|
|
|
28
30
|
sharedState: BasePluginState;
|
|
29
31
|
actions: {
|
|
30
32
|
setKeyboardHeight: typeof setKeyboardHeight;
|
|
33
|
+
registerMarks: (callback: Callback) => void;
|
|
34
|
+
resolveMarks: (from: number, to: number, tr: Transaction) => void;
|
|
31
35
|
};
|
|
32
36
|
}>;
|
|
37
|
+
export type Callback = ({ node, tr, pos, from, to, }: {
|
|
38
|
+
node: PMNode;
|
|
39
|
+
tr: Transaction;
|
|
40
|
+
pos: number;
|
|
41
|
+
from: number;
|
|
42
|
+
to: number;
|
|
43
|
+
}) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-base",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Base plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
35
|
-
"@atlaskit/editor-common": "^
|
|
35
|
+
"@atlaskit/editor-common": "^99.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-context-identifier": "^1.3.0",
|
|
37
37
|
"@atlaskit/editor-plugin-feature-flags": "^1.2.0",
|
|
38
38
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
39
39
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
40
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
40
|
+
"@atlaskit/tmp-editor-statsig": "^2.33.0",
|
|
41
41
|
"@babel/runtime": "^7.0.0"
|
|
42
42
|
},
|
|
43
43
|
"techstack": {
|
package/tsconfig.app.json
CHANGED