@atlaskit/editor-common 112.8.2 → 112.8.3
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 +9 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/preset/core-plugin/index.js +36 -1
- package/dist/cjs/preset/core-plugin/pm-plugins/appearance-plugin.js +36 -0
- package/dist/cjs/preset/plugin-injection-api.js +27 -2
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/preset/core-plugin/index.js +34 -1
- package/dist/es2019/preset/core-plugin/pm-plugins/appearance-plugin.js +24 -0
- package/dist/es2019/preset/plugin-injection-api.js +25 -2
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/preset/core-plugin/index.js +36 -1
- package/dist/esm/preset/core-plugin/pm-plugins/appearance-plugin.js +28 -0
- package/dist/esm/preset/plugin-injection-api.js +27 -2
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/preset/core-plugin/pm-plugins/appearance-plugin.d.ts +9 -0
- package/dist/types/preset/plugin-injection-api.d.ts +11 -1
- package/dist/types/types/next-editor-plugin.d.ts +15 -0
- package/dist/types-ts4.5/preset/core-plugin/pm-plugins/appearance-plugin.d.ts +9 -0
- package/dist/types-ts4.5/preset/plugin-injection-api.d.ts +11 -1
- package/dist/types-ts4.5/types/next-editor-plugin.d.ts +15 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 112.8.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`14174d5130d27`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/14174d5130d27) -
|
|
8
|
+
Adding editorAppearance in coreplugin shared state so that plugins can access appearance value
|
|
9
|
+
when updated
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 112.8.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -19,7 +19,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
19
19
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
20
20
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
21
21
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
22
|
-
var packageVersion = "112.8.
|
|
22
|
+
var packageVersion = "112.8.2";
|
|
23
23
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
24
24
|
// Remove URL as it has UGC
|
|
25
25
|
// Ignored via go/ees007
|
|
@@ -9,6 +9,7 @@ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
|
9
9
|
var _nodeAnchorProvider = require("../../node-anchor/node-anchor-provider");
|
|
10
10
|
var _processRawValue = require("../../utils/processRawValue");
|
|
11
11
|
var _editorCommands = require("../editor-commands");
|
|
12
|
+
var _appearancePlugin = require("./pm-plugins/appearance-plugin");
|
|
12
13
|
var _requestDocument = require("./requestDocument");
|
|
13
14
|
/**
|
|
14
15
|
* Core plugin that is always included in the preset.
|
|
@@ -22,10 +23,23 @@ var corePlugin = exports.corePlugin = function corePlugin(_ref) {
|
|
|
22
23
|
return {
|
|
23
24
|
name: 'core',
|
|
24
25
|
getSharedState: function getSharedState(state) {
|
|
26
|
+
var pluginState = state && _appearancePlugin.appearancePluginKey.getState(state);
|
|
25
27
|
return {
|
|
26
|
-
schema: state === null || state === void 0 ? void 0 : state.schema
|
|
28
|
+
schema: state === null || state === void 0 ? void 0 : state.schema,
|
|
29
|
+
appearance: (0, _expValEquals.expValEquals)('platform_editor_appearance_shared_state', 'isEnabled', true) ? pluginState === null || pluginState === void 0 ? void 0 : pluginState.appearance : undefined
|
|
27
30
|
};
|
|
28
31
|
},
|
|
32
|
+
pmPlugins: function pmPlugins() {
|
|
33
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_appearance_shared_state', 'isEnabled', true)) {
|
|
34
|
+
return [{
|
|
35
|
+
name: 'appearancePlugin',
|
|
36
|
+
plugin: function plugin() {
|
|
37
|
+
return (0, _appearancePlugin.createAppearancePlugin)(config === null || config === void 0 ? void 0 : config.appearance);
|
|
38
|
+
}
|
|
39
|
+
}];
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
},
|
|
29
43
|
actions: {
|
|
30
44
|
execute: function execute(command) {
|
|
31
45
|
var editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
|
|
@@ -84,6 +98,27 @@ var corePlugin = exports.corePlugin = function corePlugin(_ref) {
|
|
|
84
98
|
dom.scrollIntoView(scrollOptions);
|
|
85
99
|
return true;
|
|
86
100
|
},
|
|
101
|
+
updateAppearance: function updateAppearance(newAppearance) {
|
|
102
|
+
var _appearancePluginKey$;
|
|
103
|
+
if (!(0, _expValEquals.expValEquals)('platform_editor_appearance_shared_state', 'isEnabled', true)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
var editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
|
|
107
|
+
if (!editorView) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
// Avoid dispatching a redundant transaction if appearance hasn't changed
|
|
111
|
+
var currentAppearance = (_appearancePluginKey$ = _appearancePlugin.appearancePluginKey.getState(editorView.state)) === null || _appearancePluginKey$ === void 0 ? void 0 : _appearancePluginKey$.appearance;
|
|
112
|
+
if (currentAppearance === newAppearance) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
var tr = editorView.state.tr.setMeta(_appearancePlugin.appearancePluginKey, {
|
|
116
|
+
appearance: newAppearance
|
|
117
|
+
});
|
|
118
|
+
tr.setMeta('addToHistory', false);
|
|
119
|
+
editorView.dispatch(tr);
|
|
120
|
+
return true;
|
|
121
|
+
},
|
|
87
122
|
replaceDocument: function replaceDocument(replaceValue, options) {
|
|
88
123
|
var editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
|
|
89
124
|
if (!editorView || replaceValue === undefined || replaceValue === null) {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.appearancePluginKey = void 0;
|
|
8
|
+
exports.createAppearancePlugin = createAppearancePlugin;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
+
var _safePlugin = require("../../../safe-plugin");
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
+
var appearancePluginKey = exports.appearancePluginKey = new _state.PluginKey('appearancePlugin');
|
|
15
|
+
var DEFAULT_APPEARANCE = 'comment';
|
|
16
|
+
function createAppearancePlugin(initialAppearance) {
|
|
17
|
+
return new _safePlugin.SafePlugin({
|
|
18
|
+
key: appearancePluginKey,
|
|
19
|
+
state: {
|
|
20
|
+
init: function init() {
|
|
21
|
+
return {
|
|
22
|
+
appearance: initialAppearance !== null && initialAppearance !== void 0 ? initialAppearance : DEFAULT_APPEARANCE
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
apply: function apply(tr, pluginState) {
|
|
26
|
+
var meta = tr.getMeta(appearancePluginKey);
|
|
27
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.appearance) !== undefined) {
|
|
28
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
29
|
+
appearance: meta.appearance
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return pluginState;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -288,7 +288,8 @@ var EditorPluginInjectionAPI = exports.EditorPluginInjectionAPI = /*#__PURE__*/f
|
|
|
288
288
|
var _this2 = this;
|
|
289
289
|
var getEditorState = _ref6.getEditorState,
|
|
290
290
|
getEditorView = _ref6.getEditorView,
|
|
291
|
-
fireAnalyticsEvent = _ref6.fireAnalyticsEvent
|
|
291
|
+
fireAnalyticsEvent = _ref6.fireAnalyticsEvent,
|
|
292
|
+
appearance = _ref6.appearance;
|
|
292
293
|
(0, _classCallCheck2.default)(this, EditorPluginInjectionAPI);
|
|
293
294
|
(0, _defineProperty2.default)(this, "onEditorViewUpdated", function (_ref7) {
|
|
294
295
|
var newEditorState = _ref7.newEditorState,
|
|
@@ -321,15 +322,39 @@ var EditorPluginInjectionAPI = exports.EditorPluginInjectionAPI = /*#__PURE__*/f
|
|
|
321
322
|
this.plugins = new Map();
|
|
322
323
|
this.actionsAPI = new ActionsAPI();
|
|
323
324
|
this.commandsAPI = new EditorCommandsAPI();
|
|
325
|
+
|
|
324
326
|
// Special core plugin that is always added
|
|
325
327
|
this.addPlugin((0, _corePlugin.corePlugin)({
|
|
326
328
|
config: {
|
|
327
329
|
getEditorView: getEditorView,
|
|
328
|
-
fireAnalyticsEvent: fireAnalyticsEvent
|
|
330
|
+
fireAnalyticsEvent: fireAnalyticsEvent,
|
|
331
|
+
appearance: appearance
|
|
329
332
|
}
|
|
330
333
|
}));
|
|
331
334
|
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Returns PM plugins from internally-registered plugins (e.g. the core plugin)
|
|
338
|
+
* that are not processed through the normal preset builder flow.
|
|
339
|
+
*/
|
|
340
|
+
// Ignored via go/ees005
|
|
341
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
332
342
|
return (0, _createClass2.default)(EditorPluginInjectionAPI, [{
|
|
343
|
+
key: "getInternalPMPlugins",
|
|
344
|
+
value: function getInternalPMPlugins() {
|
|
345
|
+
// Ignored via go/ees005
|
|
346
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
347
|
+
var result = [];
|
|
348
|
+
var corePlugin = this.plugins.get('core');
|
|
349
|
+
if (corePlugin && typeof corePlugin.pmPlugins === 'function') {
|
|
350
|
+
var pmPlugins = corePlugin.pmPlugins();
|
|
351
|
+
if (pmPlugins) {
|
|
352
|
+
result.push.apply(result, (0, _toConsumableArray2.default)(pmPlugins));
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return result;
|
|
356
|
+
}
|
|
357
|
+
}, {
|
|
333
358
|
key: "createAPI",
|
|
334
359
|
value: function createAPI() {
|
|
335
360
|
var sharedStateAPI = this.sharedStateAPI,
|
|
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
24
24
|
* @jsx jsx
|
|
25
25
|
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
26
26
|
var packageName = "@atlaskit/editor-common";
|
|
27
|
-
var packageVersion = "112.8.
|
|
27
|
+
var packageVersion = "112.8.2";
|
|
28
28
|
var halfFocusRing = 1;
|
|
29
29
|
var dropOffset = '0, 8';
|
|
30
30
|
var fadeIn = (0, _react2.keyframes)({
|
|
@@ -4,7 +4,7 @@ import { isFedRamp } from './environment';
|
|
|
4
4
|
import { normaliseSentryBreadcrumbs, SERIALIZABLE_ATTRIBUTES } from './normalise-sentry-breadcrumbs';
|
|
5
5
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
6
6
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
7
|
-
const packageVersion = "112.8.
|
|
7
|
+
const packageVersion = "112.8.2";
|
|
8
8
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
9
9
|
// Remove URL as it has UGC
|
|
10
10
|
// Ignored via go/ees007
|
|
@@ -3,6 +3,7 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
|
3
3
|
import { getNodeIdProvider } from '../../node-anchor/node-anchor-provider';
|
|
4
4
|
import { processRawFragmentValue, processRawValue, processRawValueWithoutValidation } from '../../utils/processRawValue';
|
|
5
5
|
import { editorCommandToPMCommand } from '../editor-commands';
|
|
6
|
+
import { appearancePluginKey, createAppearancePlugin } from './pm-plugins/appearance-plugin';
|
|
6
7
|
import { createThrottleSchedule, returnDocumentRequest, returnDocumentRequestNoThrowError } from './requestDocument';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -18,10 +19,21 @@ export const corePlugin = ({
|
|
|
18
19
|
return {
|
|
19
20
|
name: 'core',
|
|
20
21
|
getSharedState(state) {
|
|
22
|
+
const pluginState = state && appearancePluginKey.getState(state);
|
|
21
23
|
return {
|
|
22
|
-
schema: state === null || state === void 0 ? void 0 : state.schema
|
|
24
|
+
schema: state === null || state === void 0 ? void 0 : state.schema,
|
|
25
|
+
appearance: expValEquals('platform_editor_appearance_shared_state', 'isEnabled', true) ? pluginState === null || pluginState === void 0 ? void 0 : pluginState.appearance : undefined
|
|
23
26
|
};
|
|
24
27
|
},
|
|
28
|
+
pmPlugins() {
|
|
29
|
+
if (expValEquals('platform_editor_appearance_shared_state', 'isEnabled', true)) {
|
|
30
|
+
return [{
|
|
31
|
+
name: 'appearancePlugin',
|
|
32
|
+
plugin: () => createAppearancePlugin(config === null || config === void 0 ? void 0 : config.appearance)
|
|
33
|
+
}];
|
|
34
|
+
}
|
|
35
|
+
return [];
|
|
36
|
+
},
|
|
25
37
|
actions: {
|
|
26
38
|
execute: command => {
|
|
27
39
|
const editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
|
|
@@ -82,6 +94,27 @@ export const corePlugin = ({
|
|
|
82
94
|
dom.scrollIntoView(scrollOptions);
|
|
83
95
|
return true;
|
|
84
96
|
},
|
|
97
|
+
updateAppearance: newAppearance => {
|
|
98
|
+
var _appearancePluginKey$;
|
|
99
|
+
if (!expValEquals('platform_editor_appearance_shared_state', 'isEnabled', true)) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
const editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
|
|
103
|
+
if (!editorView) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
// Avoid dispatching a redundant transaction if appearance hasn't changed
|
|
107
|
+
const currentAppearance = (_appearancePluginKey$ = appearancePluginKey.getState(editorView.state)) === null || _appearancePluginKey$ === void 0 ? void 0 : _appearancePluginKey$.appearance;
|
|
108
|
+
if (currentAppearance === newAppearance) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
const tr = editorView.state.tr.setMeta(appearancePluginKey, {
|
|
112
|
+
appearance: newAppearance
|
|
113
|
+
});
|
|
114
|
+
tr.setMeta('addToHistory', false);
|
|
115
|
+
editorView.dispatch(tr);
|
|
116
|
+
return true;
|
|
117
|
+
},
|
|
85
118
|
replaceDocument: (replaceValue, options) => {
|
|
86
119
|
const editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
|
|
87
120
|
if (!editorView || replaceValue === undefined || replaceValue === null) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { SafePlugin } from '../../../safe-plugin';
|
|
3
|
+
export const appearancePluginKey = new PluginKey('appearancePlugin');
|
|
4
|
+
const DEFAULT_APPEARANCE = 'comment';
|
|
5
|
+
export function createAppearancePlugin(initialAppearance) {
|
|
6
|
+
return new SafePlugin({
|
|
7
|
+
key: appearancePluginKey,
|
|
8
|
+
state: {
|
|
9
|
+
init: () => ({
|
|
10
|
+
appearance: initialAppearance !== null && initialAppearance !== void 0 ? initialAppearance : DEFAULT_APPEARANCE
|
|
11
|
+
}),
|
|
12
|
+
apply: (tr, pluginState) => {
|
|
13
|
+
const meta = tr.getMeta(appearancePluginKey);
|
|
14
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.appearance) !== undefined) {
|
|
15
|
+
return {
|
|
16
|
+
...pluginState,
|
|
17
|
+
appearance: meta.appearance
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return pluginState;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -211,7 +211,8 @@ export class EditorPluginInjectionAPI {
|
|
|
211
211
|
constructor({
|
|
212
212
|
getEditorState,
|
|
213
213
|
getEditorView,
|
|
214
|
-
fireAnalyticsEvent
|
|
214
|
+
fireAnalyticsEvent,
|
|
215
|
+
appearance
|
|
215
216
|
}) {
|
|
216
217
|
_defineProperty(this, "onEditorViewUpdated", ({
|
|
217
218
|
newEditorState,
|
|
@@ -246,14 +247,36 @@ export class EditorPluginInjectionAPI {
|
|
|
246
247
|
this.plugins = new Map();
|
|
247
248
|
this.actionsAPI = new ActionsAPI();
|
|
248
249
|
this.commandsAPI = new EditorCommandsAPI();
|
|
250
|
+
|
|
249
251
|
// Special core plugin that is always added
|
|
250
252
|
this.addPlugin(corePlugin({
|
|
251
253
|
config: {
|
|
252
254
|
getEditorView,
|
|
253
|
-
fireAnalyticsEvent
|
|
255
|
+
fireAnalyticsEvent,
|
|
256
|
+
appearance
|
|
254
257
|
}
|
|
255
258
|
}));
|
|
256
259
|
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Returns PM plugins from internally-registered plugins (e.g. the core plugin)
|
|
263
|
+
* that are not processed through the normal preset builder flow.
|
|
264
|
+
*/
|
|
265
|
+
// Ignored via go/ees005
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
267
|
+
getInternalPMPlugins() {
|
|
268
|
+
// Ignored via go/ees005
|
|
269
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
270
|
+
const result = [];
|
|
271
|
+
const corePlugin = this.plugins.get('core');
|
|
272
|
+
if (corePlugin && typeof corePlugin.pmPlugins === 'function') {
|
|
273
|
+
const pmPlugins = corePlugin.pmPlugins();
|
|
274
|
+
if (pmPlugins) {
|
|
275
|
+
result.push(...pmPlugins);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return result;
|
|
279
|
+
}
|
|
257
280
|
createAPI() {
|
|
258
281
|
const {
|
|
259
282
|
sharedStateAPI,
|
|
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
|
14
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
15
|
import Layer from '../Layer';
|
|
16
16
|
const packageName = "@atlaskit/editor-common";
|
|
17
|
-
const packageVersion = "112.8.
|
|
17
|
+
const packageVersion = "112.8.2";
|
|
18
18
|
const halfFocusRing = 1;
|
|
19
19
|
const dropOffset = '0, 8';
|
|
20
20
|
const fadeIn = keyframes({
|
|
@@ -10,7 +10,7 @@ import { isFedRamp } from './environment';
|
|
|
10
10
|
import { normaliseSentryBreadcrumbs, SERIALIZABLE_ATTRIBUTES } from './normalise-sentry-breadcrumbs';
|
|
11
11
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
12
12
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
13
|
-
var packageVersion = "112.8.
|
|
13
|
+
var packageVersion = "112.8.2";
|
|
14
14
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
15
15
|
// Remove URL as it has UGC
|
|
16
16
|
// Ignored via go/ees007
|
|
@@ -3,6 +3,7 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
|
3
3
|
import { getNodeIdProvider } from '../../node-anchor/node-anchor-provider';
|
|
4
4
|
import { processRawFragmentValue, processRawValue, processRawValueWithoutValidation } from '../../utils/processRawValue';
|
|
5
5
|
import { editorCommandToPMCommand } from '../editor-commands';
|
|
6
|
+
import { appearancePluginKey, createAppearancePlugin } from './pm-plugins/appearance-plugin';
|
|
6
7
|
import { createThrottleSchedule, returnDocumentRequest, returnDocumentRequestNoThrowError } from './requestDocument';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -17,10 +18,23 @@ export var corePlugin = function corePlugin(_ref) {
|
|
|
17
18
|
return {
|
|
18
19
|
name: 'core',
|
|
19
20
|
getSharedState: function getSharedState(state) {
|
|
21
|
+
var pluginState = state && appearancePluginKey.getState(state);
|
|
20
22
|
return {
|
|
21
|
-
schema: state === null || state === void 0 ? void 0 : state.schema
|
|
23
|
+
schema: state === null || state === void 0 ? void 0 : state.schema,
|
|
24
|
+
appearance: expValEquals('platform_editor_appearance_shared_state', 'isEnabled', true) ? pluginState === null || pluginState === void 0 ? void 0 : pluginState.appearance : undefined
|
|
22
25
|
};
|
|
23
26
|
},
|
|
27
|
+
pmPlugins: function pmPlugins() {
|
|
28
|
+
if (expValEquals('platform_editor_appearance_shared_state', 'isEnabled', true)) {
|
|
29
|
+
return [{
|
|
30
|
+
name: 'appearancePlugin',
|
|
31
|
+
plugin: function plugin() {
|
|
32
|
+
return createAppearancePlugin(config === null || config === void 0 ? void 0 : config.appearance);
|
|
33
|
+
}
|
|
34
|
+
}];
|
|
35
|
+
}
|
|
36
|
+
return [];
|
|
37
|
+
},
|
|
24
38
|
actions: {
|
|
25
39
|
execute: function execute(command) {
|
|
26
40
|
var editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
|
|
@@ -79,6 +93,27 @@ export var corePlugin = function corePlugin(_ref) {
|
|
|
79
93
|
dom.scrollIntoView(scrollOptions);
|
|
80
94
|
return true;
|
|
81
95
|
},
|
|
96
|
+
updateAppearance: function updateAppearance(newAppearance) {
|
|
97
|
+
var _appearancePluginKey$;
|
|
98
|
+
if (!expValEquals('platform_editor_appearance_shared_state', 'isEnabled', true)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
var editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
|
|
102
|
+
if (!editorView) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
// Avoid dispatching a redundant transaction if appearance hasn't changed
|
|
106
|
+
var currentAppearance = (_appearancePluginKey$ = appearancePluginKey.getState(editorView.state)) === null || _appearancePluginKey$ === void 0 ? void 0 : _appearancePluginKey$.appearance;
|
|
107
|
+
if (currentAppearance === newAppearance) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
var tr = editorView.state.tr.setMeta(appearancePluginKey, {
|
|
111
|
+
appearance: newAppearance
|
|
112
|
+
});
|
|
113
|
+
tr.setMeta('addToHistory', false);
|
|
114
|
+
editorView.dispatch(tr);
|
|
115
|
+
return true;
|
|
116
|
+
},
|
|
82
117
|
replaceDocument: function replaceDocument(replaceValue, options) {
|
|
83
118
|
var editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
|
|
84
119
|
if (!editorView || replaceValue === undefined || replaceValue === null) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { SafePlugin } from '../../../safe-plugin';
|
|
6
|
+
export var appearancePluginKey = new PluginKey('appearancePlugin');
|
|
7
|
+
var DEFAULT_APPEARANCE = 'comment';
|
|
8
|
+
export function createAppearancePlugin(initialAppearance) {
|
|
9
|
+
return new SafePlugin({
|
|
10
|
+
key: appearancePluginKey,
|
|
11
|
+
state: {
|
|
12
|
+
init: function init() {
|
|
13
|
+
return {
|
|
14
|
+
appearance: initialAppearance !== null && initialAppearance !== void 0 ? initialAppearance : DEFAULT_APPEARANCE
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
apply: function apply(tr, pluginState) {
|
|
18
|
+
var meta = tr.getMeta(appearancePluginKey);
|
|
19
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.appearance) !== undefined) {
|
|
20
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
21
|
+
appearance: meta.appearance
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return pluginState;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -282,7 +282,8 @@ export var EditorPluginInjectionAPI = /*#__PURE__*/function () {
|
|
|
282
282
|
var _this2 = this;
|
|
283
283
|
var getEditorState = _ref6.getEditorState,
|
|
284
284
|
getEditorView = _ref6.getEditorView,
|
|
285
|
-
fireAnalyticsEvent = _ref6.fireAnalyticsEvent
|
|
285
|
+
fireAnalyticsEvent = _ref6.fireAnalyticsEvent,
|
|
286
|
+
appearance = _ref6.appearance;
|
|
286
287
|
_classCallCheck(this, EditorPluginInjectionAPI);
|
|
287
288
|
_defineProperty(this, "onEditorViewUpdated", function (_ref7) {
|
|
288
289
|
var newEditorState = _ref7.newEditorState,
|
|
@@ -315,15 +316,39 @@ export var EditorPluginInjectionAPI = /*#__PURE__*/function () {
|
|
|
315
316
|
this.plugins = new Map();
|
|
316
317
|
this.actionsAPI = new ActionsAPI();
|
|
317
318
|
this.commandsAPI = new EditorCommandsAPI();
|
|
319
|
+
|
|
318
320
|
// Special core plugin that is always added
|
|
319
321
|
this.addPlugin(corePlugin({
|
|
320
322
|
config: {
|
|
321
323
|
getEditorView: getEditorView,
|
|
322
|
-
fireAnalyticsEvent: fireAnalyticsEvent
|
|
324
|
+
fireAnalyticsEvent: fireAnalyticsEvent,
|
|
325
|
+
appearance: appearance
|
|
323
326
|
}
|
|
324
327
|
}));
|
|
325
328
|
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Returns PM plugins from internally-registered plugins (e.g. the core plugin)
|
|
332
|
+
* that are not processed through the normal preset builder flow.
|
|
333
|
+
*/
|
|
334
|
+
// Ignored via go/ees005
|
|
335
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
326
336
|
return _createClass(EditorPluginInjectionAPI, [{
|
|
337
|
+
key: "getInternalPMPlugins",
|
|
338
|
+
value: function getInternalPMPlugins() {
|
|
339
|
+
// Ignored via go/ees005
|
|
340
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
341
|
+
var result = [];
|
|
342
|
+
var corePlugin = this.plugins.get('core');
|
|
343
|
+
if (corePlugin && typeof corePlugin.pmPlugins === 'function') {
|
|
344
|
+
var pmPlugins = corePlugin.pmPlugins();
|
|
345
|
+
if (pmPlugins) {
|
|
346
|
+
result.push.apply(result, _toConsumableArray(pmPlugins));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return result;
|
|
350
|
+
}
|
|
351
|
+
}, {
|
|
327
352
|
key: "createAPI",
|
|
328
353
|
value: function createAPI() {
|
|
329
354
|
var sharedStateAPI = this.sharedStateAPI,
|
|
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
|
21
21
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
22
22
|
import Layer from '../Layer';
|
|
23
23
|
var packageName = "@atlaskit/editor-common";
|
|
24
|
-
var packageVersion = "112.8.
|
|
24
|
+
var packageVersion = "112.8.2";
|
|
25
25
|
var halfFocusRing = 1;
|
|
26
26
|
var dropOffset = '0, 8';
|
|
27
27
|
var fadeIn = keyframes({
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { SafePlugin } from '../../../safe-plugin';
|
|
3
|
+
import type { EditorAppearance } from '../../../types';
|
|
4
|
+
type AppearancePluginState = {
|
|
5
|
+
appearance: EditorAppearance | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare const appearancePluginKey: PluginKey<AppearancePluginState>;
|
|
8
|
+
export declare function createAppearancePlugin(initialAppearance: EditorAppearance | undefined): SafePlugin<AppearancePluginState>;
|
|
9
|
+
export {};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
3
|
import { type FireAnalyticsCallback } from '../analytics';
|
|
4
|
+
import type { EditorAppearance } from '../types';
|
|
4
5
|
import type { BasePluginDependenciesAPI, CorePlugin, NextEditorPlugin, PluginDependenciesAPI } from '../types/next-editor-plugin';
|
|
5
6
|
type NextEditorPluginInitializedType = ReturnType<NextEditorPlugin<any>>;
|
|
6
7
|
type SharedStateAPIProps = {
|
|
7
8
|
getEditorState: () => EditorState | undefined;
|
|
8
9
|
};
|
|
9
10
|
interface PluginInjectionAPIProps extends SharedStateAPIProps {
|
|
11
|
+
appearance?: EditorAppearance;
|
|
10
12
|
fireAnalyticsEvent?: FireAnalyticsCallback;
|
|
11
13
|
getEditorView: () => EditorView | undefined;
|
|
12
14
|
}
|
|
@@ -46,7 +48,15 @@ export declare class EditorPluginInjectionAPI implements PluginInjectionAPIDefin
|
|
|
46
48
|
private actionsAPI;
|
|
47
49
|
private commandsAPI;
|
|
48
50
|
private plugins;
|
|
49
|
-
constructor({ getEditorState, getEditorView, fireAnalyticsEvent }: PluginInjectionAPIProps);
|
|
51
|
+
constructor({ getEditorState, getEditorView, fireAnalyticsEvent, appearance }: PluginInjectionAPIProps);
|
|
52
|
+
/**
|
|
53
|
+
* Returns PM plugins from internally-registered plugins (e.g. the core plugin)
|
|
54
|
+
* that are not processed through the normal preset builder flow.
|
|
55
|
+
*/
|
|
56
|
+
getInternalPMPlugins(): Array<{
|
|
57
|
+
name: string;
|
|
58
|
+
plugin: (...args: any[]) => any;
|
|
59
|
+
}>;
|
|
50
60
|
private createAPI;
|
|
51
61
|
api(): GenericAPIWithCore;
|
|
52
62
|
onEditorViewUpdated: ({ newEditorState, oldEditorState }: EditorStateDiff) => void;
|
|
@@ -9,6 +9,7 @@ import type { Fragment, Node, Schema, Node as PMNode } from '@atlaskit/editor-pr
|
|
|
9
9
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
10
10
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
11
11
|
import type { FireAnalyticsCallback } from '../analytics';
|
|
12
|
+
import type { EditorAppearance } from './editor-appearance';
|
|
12
13
|
import type { EditorCommand, EditorCommandWithMetadata } from './editor-command';
|
|
13
14
|
import type { EditorPlugin } from './editor-plugin';
|
|
14
15
|
export interface Transformer<T> {
|
|
@@ -115,12 +116,26 @@ export type CorePlugin = NextEditorPlugin<'core', {
|
|
|
115
116
|
* @returns (boolean) if scroll was successful
|
|
116
117
|
*/
|
|
117
118
|
scrollToPos: (pos: number, scrollOptions?: boolean | ScrollIntoViewOptions) => boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Updates the editor appearance in shared state. Dispatches a ProseMirror transaction
|
|
121
|
+
* so that shared state subscribers are correctly notified of the change.
|
|
122
|
+
*
|
|
123
|
+
* @param appearance - The new editor appearance value
|
|
124
|
+
* @returns true if the update was dispatched, false if the experiment is off or the view was unavailable
|
|
125
|
+
*/
|
|
126
|
+
updateAppearance: (appearance: EditorAppearance | undefined) => boolean;
|
|
118
127
|
};
|
|
119
128
|
pluginConfiguration: {
|
|
129
|
+
appearance?: EditorAppearance;
|
|
120
130
|
fireAnalyticsEvent?: FireAnalyticsCallback;
|
|
121
131
|
getEditorView: () => EditorView | undefined;
|
|
122
132
|
};
|
|
123
133
|
sharedState: {
|
|
134
|
+
/**
|
|
135
|
+
* The appearance configuration of the editor. Used as fallback when individual
|
|
136
|
+
* plugins don't have explicit appearance configuration.
|
|
137
|
+
*/
|
|
138
|
+
appearance: EditorAppearance | undefined;
|
|
124
139
|
/**
|
|
125
140
|
* The schema of the editor. It is guarranteed to be static for its lifecycle
|
|
126
141
|
* so is safe to use `currentState`
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { SafePlugin } from '../../../safe-plugin';
|
|
3
|
+
import type { EditorAppearance } from '../../../types';
|
|
4
|
+
type AppearancePluginState = {
|
|
5
|
+
appearance: EditorAppearance | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare const appearancePluginKey: PluginKey<AppearancePluginState>;
|
|
8
|
+
export declare function createAppearancePlugin(initialAppearance: EditorAppearance | undefined): SafePlugin<AppearancePluginState>;
|
|
9
|
+
export {};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
3
|
import { type FireAnalyticsCallback } from '../analytics';
|
|
4
|
+
import type { EditorAppearance } from '../types';
|
|
4
5
|
import type { BasePluginDependenciesAPI, CorePlugin, NextEditorPlugin, PluginDependenciesAPI } from '../types/next-editor-plugin';
|
|
5
6
|
type NextEditorPluginInitializedType = ReturnType<NextEditorPlugin<any>>;
|
|
6
7
|
type SharedStateAPIProps = {
|
|
7
8
|
getEditorState: () => EditorState | undefined;
|
|
8
9
|
};
|
|
9
10
|
interface PluginInjectionAPIProps extends SharedStateAPIProps {
|
|
11
|
+
appearance?: EditorAppearance;
|
|
10
12
|
fireAnalyticsEvent?: FireAnalyticsCallback;
|
|
11
13
|
getEditorView: () => EditorView | undefined;
|
|
12
14
|
}
|
|
@@ -46,7 +48,15 @@ export declare class EditorPluginInjectionAPI implements PluginInjectionAPIDefin
|
|
|
46
48
|
private actionsAPI;
|
|
47
49
|
private commandsAPI;
|
|
48
50
|
private plugins;
|
|
49
|
-
constructor({ getEditorState, getEditorView, fireAnalyticsEvent }: PluginInjectionAPIProps);
|
|
51
|
+
constructor({ getEditorState, getEditorView, fireAnalyticsEvent, appearance }: PluginInjectionAPIProps);
|
|
52
|
+
/**
|
|
53
|
+
* Returns PM plugins from internally-registered plugins (e.g. the core plugin)
|
|
54
|
+
* that are not processed through the normal preset builder flow.
|
|
55
|
+
*/
|
|
56
|
+
getInternalPMPlugins(): Array<{
|
|
57
|
+
name: string;
|
|
58
|
+
plugin: (...args: any[]) => any;
|
|
59
|
+
}>;
|
|
50
60
|
private createAPI;
|
|
51
61
|
api(): GenericAPIWithCore;
|
|
52
62
|
onEditorViewUpdated: ({ newEditorState, oldEditorState }: EditorStateDiff) => void;
|
|
@@ -9,6 +9,7 @@ import type { Fragment, Node, Schema, Node as PMNode } from '@atlaskit/editor-pr
|
|
|
9
9
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
10
10
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
11
11
|
import type { FireAnalyticsCallback } from '../analytics';
|
|
12
|
+
import type { EditorAppearance } from './editor-appearance';
|
|
12
13
|
import type { EditorCommand, EditorCommandWithMetadata } from './editor-command';
|
|
13
14
|
import type { EditorPlugin } from './editor-plugin';
|
|
14
15
|
export interface Transformer<T> {
|
|
@@ -115,12 +116,26 @@ export type CorePlugin = NextEditorPlugin<'core', {
|
|
|
115
116
|
* @returns (boolean) if scroll was successful
|
|
116
117
|
*/
|
|
117
118
|
scrollToPos: (pos: number, scrollOptions?: boolean | ScrollIntoViewOptions) => boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Updates the editor appearance in shared state. Dispatches a ProseMirror transaction
|
|
121
|
+
* so that shared state subscribers are correctly notified of the change.
|
|
122
|
+
*
|
|
123
|
+
* @param appearance - The new editor appearance value
|
|
124
|
+
* @returns true if the update was dispatched, false if the experiment is off or the view was unavailable
|
|
125
|
+
*/
|
|
126
|
+
updateAppearance: (appearance: EditorAppearance | undefined) => boolean;
|
|
118
127
|
};
|
|
119
128
|
pluginConfiguration: {
|
|
129
|
+
appearance?: EditorAppearance;
|
|
120
130
|
fireAnalyticsEvent?: FireAnalyticsCallback;
|
|
121
131
|
getEditorView: () => EditorView | undefined;
|
|
122
132
|
};
|
|
123
133
|
sharedState: {
|
|
134
|
+
/**
|
|
135
|
+
* The appearance configuration of the editor. Used as fallback when individual
|
|
136
|
+
* plugins don't have explicit appearance configuration.
|
|
137
|
+
*/
|
|
138
|
+
appearance: EditorAppearance | undefined;
|
|
124
139
|
/**
|
|
125
140
|
* The schema of the editor. It is guarranteed to be static for its lifecycle
|
|
126
141
|
* so is safe to use `currentState`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "112.8.
|
|
3
|
+
"version": "112.8.3",
|
|
4
4
|
"description": "A package that contains common classes and components for editor and renderer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@atlaskit/status": "^3.1.0",
|
|
82
82
|
"@atlaskit/task-decision": "^19.3.0",
|
|
83
83
|
"@atlaskit/textfield": "^8.2.0",
|
|
84
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
84
|
+
"@atlaskit/tmp-editor-statsig": "^45.0.0",
|
|
85
85
|
"@atlaskit/tokens": "^11.1.0",
|
|
86
86
|
"@atlaskit/tooltip": "^21.0.0",
|
|
87
87
|
"@atlaskit/width-detector": "^5.0.0",
|