@atlaskit/editor-core 187.19.1 → 187.20.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 +13 -0
- package/dist/cjs/plugins/emoji/commands/insert-emoji.js +21 -20
- package/dist/cjs/plugins/emoji/index.js +16 -5
- package/dist/cjs/plugins/index.js +2 -2
- package/dist/cjs/plugins/insert-block/index.js +3 -7
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
- package/dist/cjs/plugins/media/pm-plugins/main.js +13 -1
- package/dist/cjs/plugins/media/toolbar/index.js +21 -8
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +15 -3
- package/dist/cjs/plugins/text-color/commands/toggle-color.js +3 -2
- package/dist/cjs/utils/document.js +6 -24
- package/dist/cjs/utils/index.js +33 -105
- package/dist/cjs/utils/prosemirror/position.js +33 -41
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/emoji/commands/insert-emoji.js +24 -20
- package/dist/es2019/plugins/emoji/index.js +14 -4
- package/dist/es2019/plugins/index.js +1 -1
- package/dist/es2019/plugins/insert-block/index.js +3 -7
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +6 -3
- package/dist/es2019/plugins/media/pm-plugins/main.js +9 -0
- package/dist/es2019/plugins/media/toolbar/index.js +22 -10
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +17 -4
- package/dist/es2019/plugins/text-color/commands/toggle-color.js +3 -2
- package/dist/es2019/utils/document.js +1 -20
- package/dist/es2019/utils/index.js +1 -99
- package/dist/es2019/utils/prosemirror/position.js +1 -51
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/emoji/commands/insert-emoji.js +21 -20
- package/dist/esm/plugins/emoji/index.js +14 -4
- package/dist/esm/plugins/index.js +1 -1
- package/dist/esm/plugins/insert-block/index.js +3 -7
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
- package/dist/esm/plugins/media/pm-plugins/main.js +11 -0
- package/dist/esm/plugins/media/toolbar/index.js +23 -10
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +16 -4
- package/dist/esm/plugins/text-color/commands/toggle-color.js +3 -2
- package/dist/esm/utils/document.js +1 -22
- package/dist/esm/utils/index.js +1 -97
- package/dist/esm/utils/prosemirror/position.js +1 -39
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/labs/next/presets/default.d.ts +32 -32
- package/dist/types/plugins/emoji/commands/insert-emoji.d.ts +2 -2
- package/dist/types/plugins/emoji/index.d.ts +9 -4
- package/dist/types/plugins/index.d.ts +1 -1
- package/dist/types/plugins/insert-block/index.d.ts +3 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -1
- package/dist/types/plugins/media/pm-plugins/main.d.ts +3 -0
- package/dist/types/plugins/media/pm-plugins/types.d.ts +2 -0
- package/dist/types/plugins/media/toolbar/index.d.ts +1 -2
- package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -0
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/utils/document.d.ts +2 -7
- package/dist/types/utils/index.d.ts +2 -6
- package/dist/types/utils/prosemirror/position.d.ts +1 -8
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +32 -32
- package/dist/types-ts4.5/plugins/emoji/commands/insert-emoji.d.ts +2 -2
- package/dist/types-ts4.5/plugins/emoji/index.d.ts +9 -4
- package/dist/types-ts4.5/plugins/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/insert-block/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +3 -0
- package/dist/types-ts4.5/plugins/media/pm-plugins/types.d.ts +2 -0
- package/dist/types-ts4.5/plugins/media/toolbar/index.d.ts +1 -2
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -0
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/utils/document.d.ts +2 -7
- package/dist/types-ts4.5/utils/index.d.ts +2 -6
- package/dist/types-ts4.5/utils/prosemirror/position.d.ts +1 -8
- package/package.json +4 -4
- package/report.api.md +4 -0
- package/tmp/api-report-tmp.d.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 187.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`644c7942b34`](https://bitbucket.org/atlassian/atlassian-frontend/commits/644c7942b34) - [ux] support updating pixel entry in media toolbar when resize media single
|
|
8
|
+
- [`43c51e0a282`](https://bitbucket.org/atlassian/atlassian-frontend/commits/43c51e0a282) - [ED-19431] Migrate all text-formatting plugin actions over to plugin commands
|
|
9
|
+
- [`a867b562d62`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a867b562d62) - Add insertEmoji command and sharedState to emoji plugin.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`8375e041861`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8375e041861) - [ED-16733] Extract common functions used by media plugin to editor-common
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 187.19.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -14,32 +14,33 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
14
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
15
|
var insertEmoji = function insertEmoji(editorAnalyticsAPI) {
|
|
16
16
|
return function (emojiId, inputMethod) {
|
|
17
|
-
return function (
|
|
18
|
-
var
|
|
17
|
+
return function (_ref) {
|
|
18
|
+
var tr = _ref.tr;
|
|
19
|
+
var doc = tr.doc,
|
|
20
|
+
selection = tr.selection;
|
|
21
|
+
var emoji = tr.doc.type.schema.nodes.emoji;
|
|
19
22
|
if (emoji && emojiId) {
|
|
20
23
|
var node = emoji.createChecked(_objectSpread(_objectSpread({}, emojiId), {}, {
|
|
21
24
|
text: emojiId.fallback || emojiId.shortName
|
|
22
25
|
}));
|
|
23
|
-
var textNode =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})(tr);
|
|
37
|
-
}
|
|
38
|
-
dispatch(tr.setSelection(_state.Selection.near(tr.doc.resolve(state.selection.$from.pos + fragment.size))));
|
|
26
|
+
var textNode = doc.type.schema.text(' ');
|
|
27
|
+
var fragment = _model.Fragment.fromArray([node, textNode]);
|
|
28
|
+
var newTr = (0, _utils.safeInsert)(fragment)(tr);
|
|
29
|
+
if (inputMethod) {
|
|
30
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
31
|
+
action: _analytics.ACTION.INSERTED,
|
|
32
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
33
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.EMOJI,
|
|
34
|
+
attributes: {
|
|
35
|
+
inputMethod: inputMethod
|
|
36
|
+
},
|
|
37
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
38
|
+
})(newTr);
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
newTr.setSelection(_state.Selection.near(newTr.doc.resolve(selection.$from.pos + fragment.size)));
|
|
41
|
+
return newTr;
|
|
41
42
|
}
|
|
42
|
-
return
|
|
43
|
+
return null;
|
|
43
44
|
};
|
|
44
45
|
};
|
|
45
46
|
};
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.ACTIONS = void 0;
|
|
8
8
|
exports.createEmojiPlugin = createEmojiPlugin;
|
|
9
|
-
exports.emojiToTypeaheadItem = exports.emojiPluginKey = exports.
|
|
9
|
+
exports.emojiToTypeaheadItem = exports.emojiPluginKey = exports.emojiPlugin = exports.defaultListLimit = void 0;
|
|
10
10
|
exports.getEmojiPluginState = getEmojiPluginState;
|
|
11
11
|
exports.memoize = memoize;
|
|
12
12
|
exports.setProvider = void 0;
|
|
@@ -25,6 +25,7 @@ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
|
25
25
|
var _emoji3 = require("./nodeviews/emoji");
|
|
26
26
|
var _messages = require("../insert-block/ui/ToolbarInsertBlock/messages");
|
|
27
27
|
var _openTypeaheadAtCursor = require("../type-ahead/transforms/open-typeahead-at-cursor");
|
|
28
|
+
var _insertEmoji = require("./commands/insert-emoji");
|
|
28
29
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
29
30
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
30
31
|
var emojiToTypeaheadItem = function emojiToTypeaheadItem(emoji, emojiProvider) {
|
|
@@ -75,6 +76,7 @@ var isFullShortName = function isFullShortName(query) {
|
|
|
75
76
|
};
|
|
76
77
|
var TRIGGER = ':';
|
|
77
78
|
var emojiPlugin = function emojiPlugin(options, api) {
|
|
79
|
+
var _api$dependencies$ana9;
|
|
78
80
|
var typeAhead = {
|
|
79
81
|
id: _typeAhead.TypeAheadAvailableNodes.EMOJI,
|
|
80
82
|
trigger: TRIGGER,
|
|
@@ -196,6 +198,15 @@ var emojiPlugin = function emojiPlugin(options, api) {
|
|
|
196
198
|
}
|
|
197
199
|
}];
|
|
198
200
|
},
|
|
201
|
+
getSharedState: function getSharedState(editorState) {
|
|
202
|
+
if (!editorState) {
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
return emojiPluginKey.getState(editorState);
|
|
206
|
+
},
|
|
207
|
+
commands: {
|
|
208
|
+
insertEmoji: (0, _insertEmoji.insertEmoji)(api === null || api === void 0 ? void 0 : (_api$dependencies$ana9 = api.dependencies.analytics) === null || _api$dependencies$ana9 === void 0 ? void 0 : _api$dependencies$ana9.actions)
|
|
209
|
+
},
|
|
199
210
|
pluginsOptions: {
|
|
200
211
|
quickInsert: function quickInsert(_ref7) {
|
|
201
212
|
var formatMessage = _ref7.formatMessage;
|
|
@@ -209,13 +220,13 @@ var emojiPlugin = function emojiPlugin(options, api) {
|
|
|
209
220
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconEmoji, null);
|
|
210
221
|
},
|
|
211
222
|
action: function action(insert, state) {
|
|
212
|
-
var _api$dependencies$
|
|
223
|
+
var _api$dependencies$ana10;
|
|
213
224
|
var tr = insert(undefined);
|
|
214
225
|
(0, _openTypeaheadAtCursor.openTypeAheadAtCursor)({
|
|
215
226
|
triggerHandler: typeAhead,
|
|
216
227
|
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
|
|
217
228
|
})(tr);
|
|
218
|
-
api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
229
|
+
api === null || api === void 0 ? void 0 : (_api$dependencies$ana10 = api.dependencies.analytics) === null || _api$dependencies$ana10 === void 0 ? void 0 : _api$dependencies$ana10.actions.attachAnalyticsEvent({
|
|
219
230
|
action: _analytics.ACTION.INVOKED,
|
|
220
231
|
actionSubject: _analytics.ACTION_SUBJECT.TYPEAHEAD,
|
|
221
232
|
actionSubjectId: _analytics.ACTION_SUBJECT_ID.TYPEAHEAD_EMOJI,
|
|
@@ -232,11 +243,11 @@ var emojiPlugin = function emojiPlugin(options, api) {
|
|
|
232
243
|
}
|
|
233
244
|
};
|
|
234
245
|
};
|
|
235
|
-
|
|
246
|
+
|
|
236
247
|
/**
|
|
237
248
|
* Actions
|
|
238
249
|
*/
|
|
239
|
-
exports.
|
|
250
|
+
exports.emojiPlugin = emojiPlugin;
|
|
240
251
|
var ACTIONS = {
|
|
241
252
|
SET_PROVIDER: 'SET_PROVIDER',
|
|
242
253
|
SET_RESULTS: 'SET_RESULTS',
|
|
@@ -134,7 +134,7 @@ Object.defineProperty(exports, "datePlugin", {
|
|
|
134
134
|
Object.defineProperty(exports, "emojiPlugin", {
|
|
135
135
|
enumerable: true,
|
|
136
136
|
get: function get() {
|
|
137
|
-
return _emoji.
|
|
137
|
+
return _emoji.emojiPlugin;
|
|
138
138
|
}
|
|
139
139
|
});
|
|
140
140
|
Object.defineProperty(exports, "expandPlugin", {
|
|
@@ -378,7 +378,7 @@ var _clearMarksOnChangeToEmptyDocument = _interopRequireDefault(require("./clear
|
|
|
378
378
|
var _codeBlock = _interopRequireDefault(require("./code-block"));
|
|
379
379
|
var _collabEdit = _interopRequireDefault(require("./collab-edit"));
|
|
380
380
|
var _date = _interopRequireDefault(require("./date"));
|
|
381
|
-
var _emoji =
|
|
381
|
+
var _emoji = require("./emoji");
|
|
382
382
|
var _extension = _interopRequireDefault(require("./extension"));
|
|
383
383
|
var _fakeTextCursor = _interopRequireDefault(require("./fake-text-cursor"));
|
|
384
384
|
var _helpDialog = _interopRequireDefault(require("./help-dialog"));
|
|
@@ -12,7 +12,6 @@ var _pluginKey = require("../media/pm-plugins/plugin-key");
|
|
|
12
12
|
var _utils = require("../type-ahead/utils");
|
|
13
13
|
var _layout = require("../layout");
|
|
14
14
|
var _macro = require("../macro");
|
|
15
|
-
var _emoji = require("../emoji");
|
|
16
15
|
var _WithPluginState = _interopRequireDefault(require("../../ui/WithPluginState"));
|
|
17
16
|
var _ToolbarInsertBlock = _interopRequireDefault(require("./ui/ToolbarInsertBlock"));
|
|
18
17
|
var _key = require("../type-ahead/pm-plugins/key");
|
|
@@ -72,7 +71,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
|
|
|
72
71
|
blockTypeState: _main.pluginKey,
|
|
73
72
|
mediaState: _pluginKey.stateKey,
|
|
74
73
|
macroState: _pluginKey3.pluginKey,
|
|
75
|
-
emojiState: _emoji.emojiPluginKey,
|
|
76
74
|
placeholderTextState: _pluginKey2.pluginKey,
|
|
77
75
|
layoutState: _layout.pluginKey
|
|
78
76
|
},
|
|
@@ -81,7 +79,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
|
|
|
81
79
|
mediaState = _ref2.mediaState,
|
|
82
80
|
_ref2$macroState = _ref2.macroState,
|
|
83
81
|
macroState = _ref2$macroState === void 0 ? {} : _ref2$macroState,
|
|
84
|
-
emojiState = _ref2.emojiState,
|
|
85
82
|
placeholderTextState = _ref2.placeholderTextState,
|
|
86
83
|
layoutState = _ref2.layoutState;
|
|
87
84
|
return /*#__PURE__*/_react.default.createElement(ToolbarInsertBlockWithInjectionApi, {
|
|
@@ -101,7 +98,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
|
|
|
101
98
|
blockTypeState: blockTypeState,
|
|
102
99
|
mediaState: mediaState,
|
|
103
100
|
macroState: macroState,
|
|
104
|
-
emojiState: emojiState,
|
|
105
101
|
placeholderTextState: placeholderTextState,
|
|
106
102
|
layoutState: layoutState,
|
|
107
103
|
providers: providers,
|
|
@@ -137,16 +133,16 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
|
|
|
137
133
|
blockTypeState = _ref3.blockTypeState,
|
|
138
134
|
mediaState = _ref3.mediaState,
|
|
139
135
|
macroState = _ref3.macroState,
|
|
140
|
-
emojiState = _ref3.emojiState,
|
|
141
136
|
placeholderTextState = _ref3.placeholderTextState,
|
|
142
137
|
layoutState = _ref3.layoutState,
|
|
143
138
|
featureFlags = _ref3.featureFlags;
|
|
144
139
|
var buttons = toolbarSizeToButtons(toolbarSize);
|
|
145
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention']),
|
|
140
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji']),
|
|
146
141
|
dateState = _useSharedPluginState.dateState,
|
|
147
142
|
hyperlinkState = _useSharedPluginState.hyperlinkState,
|
|
148
143
|
imageUploadState = _useSharedPluginState.imageUploadState,
|
|
149
|
-
mentionState = _useSharedPluginState.mentionState
|
|
144
|
+
mentionState = _useSharedPluginState.mentionState,
|
|
145
|
+
emojiState = _useSharedPluginState.emojiState;
|
|
150
146
|
return /*#__PURE__*/_react.default.createElement(_ToolbarInsertBlock.default, {
|
|
151
147
|
pluginInjectionApi: pluginInjectionApi,
|
|
152
148
|
buttons: buttons,
|
|
@@ -29,8 +29,7 @@ var _commands2 = require("../../../tasks-and-decisions/commands");
|
|
|
29
29
|
var _commands3 = require("../../../expand/commands");
|
|
30
30
|
var _api = require("../../../type-ahead/api");
|
|
31
31
|
var _actions4 = require("../../../status/actions");
|
|
32
|
-
var _analytics = require("
|
|
33
|
-
var _insertEmoji = require("../../../emoji/commands/insert-emoji");
|
|
32
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
34
33
|
var _messages = require("./messages");
|
|
35
34
|
var _createItems3 = require("./create-items");
|
|
36
35
|
var _blockInsertMenu = require("./block-insert-menu");
|
|
@@ -282,8 +281,10 @@ var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
282
281
|
};
|
|
283
282
|
});
|
|
284
283
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleSelectedEmoji", function (emojiId) {
|
|
284
|
+
var _pluginInjectionApi$d8;
|
|
285
|
+
var pluginInjectionApi = _this.props.pluginInjectionApi;
|
|
285
286
|
_this.props.editorView.focus();
|
|
286
|
-
|
|
287
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.executeCommand((_pluginInjectionApi$d8 = pluginInjectionApi.dependencies.emoji) === null || _pluginInjectionApi$d8 === void 0 ? void 0 : _pluginInjectionApi$d8.commands.insertEmoji(emojiId, _analytics.INPUT_METHOD.PICKER));
|
|
287
288
|
_this.toggleEmojiPicker();
|
|
288
289
|
return true;
|
|
289
290
|
});
|
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.getMediaPluginState = exports.createPlugin = exports.MediaPluginStateImplementation = exports.MEDIA_PLUGIN_IS_RESIZING_KEY = exports.MEDIA_CONTENT_WRAP_CLASS_NAME = void 0;
|
|
8
|
+
exports.getMediaPluginState = exports.createPlugin = exports.MediaPluginStateImplementation = exports.MEDIA_PLUGIN_RESIZING_WIDTH_KEY = exports.MEDIA_PLUGIN_IS_RESIZING_KEY = exports.MEDIA_CONTENT_WRAP_CLASS_NAME = void 0;
|
|
9
9
|
Object.defineProperty(exports, "stateKey", {
|
|
10
10
|
enumerable: true,
|
|
11
11
|
get: function get() {
|
|
@@ -52,6 +52,8 @@ var MEDIA_CONTENT_WRAP_CLASS_NAME = 'media-content-wrap';
|
|
|
52
52
|
exports.MEDIA_CONTENT_WRAP_CLASS_NAME = MEDIA_CONTENT_WRAP_CLASS_NAME;
|
|
53
53
|
var MEDIA_PLUGIN_IS_RESIZING_KEY = 'mediaSinglePlugin.isResizing';
|
|
54
54
|
exports.MEDIA_PLUGIN_IS_RESIZING_KEY = MEDIA_PLUGIN_IS_RESIZING_KEY;
|
|
55
|
+
var MEDIA_PLUGIN_RESIZING_WIDTH_KEY = 'mediaSinglePlugin.resizing-width';
|
|
56
|
+
exports.MEDIA_PLUGIN_RESIZING_WIDTH_KEY = MEDIA_PLUGIN_RESIZING_WIDTH_KEY;
|
|
55
57
|
var createDropPlaceholder = function createDropPlaceholder(intl, allowDropLine) {
|
|
56
58
|
var dropPlaceholder = document.createElement('div');
|
|
57
59
|
var createElement = _react.default.createElement;
|
|
@@ -82,6 +84,7 @@ var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
82
84
|
(0, _defineProperty2.default)(this, "layout", 'center');
|
|
83
85
|
(0, _defineProperty2.default)(this, "mediaNodes", []);
|
|
84
86
|
(0, _defineProperty2.default)(this, "isResizing", false);
|
|
87
|
+
(0, _defineProperty2.default)(this, "resizingWidth", 0);
|
|
85
88
|
(0, _defineProperty2.default)(this, "destroyed", false);
|
|
86
89
|
(0, _defineProperty2.default)(this, "removeOnCloseListener", function () {});
|
|
87
90
|
(0, _defineProperty2.default)(this, "onPopupToggleCallback", function () {});
|
|
@@ -501,6 +504,11 @@ var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
501
504
|
value: function setIsResizing(isResizing) {
|
|
502
505
|
this.isResizing = isResizing;
|
|
503
506
|
}
|
|
507
|
+
}, {
|
|
508
|
+
key: "setResizingWidth",
|
|
509
|
+
value: function setResizingWidth(width) {
|
|
510
|
+
this.resizingWidth = width;
|
|
511
|
+
}
|
|
504
512
|
}, {
|
|
505
513
|
key: "updateElement",
|
|
506
514
|
value: function updateElement() {
|
|
@@ -644,9 +652,13 @@ var createPlugin = function createPlugin(_schema, options, reactContext, getIntl
|
|
|
644
652
|
},
|
|
645
653
|
apply: function apply(tr, pluginState) {
|
|
646
654
|
var isResizing = tr.getMeta(MEDIA_PLUGIN_IS_RESIZING_KEY);
|
|
655
|
+
var resizingWidth = tr.getMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY);
|
|
647
656
|
if (isResizing !== undefined) {
|
|
648
657
|
pluginState.setIsResizing(isResizing);
|
|
649
658
|
}
|
|
659
|
+
if (resizingWidth) {
|
|
660
|
+
pluginState.setResizingWidth(resizingWidth);
|
|
661
|
+
}
|
|
650
662
|
|
|
651
663
|
// remap editing media single position if we're in collab
|
|
652
664
|
if (typeof pluginState.editingMediaSinglePos === 'number') {
|
|
@@ -265,12 +265,15 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
265
265
|
type: 'custom',
|
|
266
266
|
fallback: [],
|
|
267
267
|
render: function render(editorView) {
|
|
268
|
+
var _widthPlugin$sharedSt2, _widthPlugin$sharedSt3;
|
|
268
269
|
if (!editorView) {
|
|
269
270
|
return null;
|
|
270
271
|
}
|
|
271
272
|
var state = editorView.state,
|
|
272
273
|
dispatch = editorView.dispatch;
|
|
273
274
|
var selectedMediaSingleNode = (0, _utils2.getSelectedMediaSingle)(state);
|
|
275
|
+
var contentWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || _editorSharedStyles.akEditorDefaultLayoutWidth;
|
|
276
|
+
var containerWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.width) || _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
274
277
|
if (!selectedMediaSingleNode) {
|
|
275
278
|
return null;
|
|
276
279
|
}
|
|
@@ -278,13 +281,25 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
278
281
|
if (!selectedMediaNode) {
|
|
279
282
|
return null;
|
|
280
283
|
}
|
|
281
|
-
var
|
|
284
|
+
var _selectedMediaSingleN = selectedMediaSingleNode.node.attrs,
|
|
285
|
+
singleMediaWidth = _selectedMediaSingleN.width,
|
|
286
|
+
widthType = _selectedMediaSingleN.widthType,
|
|
287
|
+
layout = _selectedMediaSingleN.layout;
|
|
282
288
|
var _selectedMediaNode$at = selectedMediaNode.attrs,
|
|
283
289
|
mediaWidth = _selectedMediaNode$at.width,
|
|
284
290
|
mediaHeight = _selectedMediaNode$at.height;
|
|
291
|
+
var pixelWidth = (0, _mediaSingle.calcMediaSinglePixelWidth)({
|
|
292
|
+
width: singleMediaWidth,
|
|
293
|
+
widthType: widthType,
|
|
294
|
+
origWidth: mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH,
|
|
295
|
+
layout: layout,
|
|
296
|
+
contentWidth: contentWidth,
|
|
297
|
+
containerWidth: containerWidth,
|
|
298
|
+
gutterOffset: _mediaSingle.MEDIA_SINGLE_GUTTER_SIZE
|
|
299
|
+
});
|
|
285
300
|
return /*#__PURE__*/_react.default.createElement(_PixelEntry.PixelEntry, {
|
|
286
301
|
intl: intl,
|
|
287
|
-
width:
|
|
302
|
+
width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
|
|
288
303
|
mediaWidth: mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH,
|
|
289
304
|
mediaHeight: mediaHeight || _mediaSingle.DEFAULT_IMAGE_HEIGHT,
|
|
290
305
|
validate: function validate(value) {
|
|
@@ -304,11 +319,9 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
304
319
|
});
|
|
305
320
|
}
|
|
306
321
|
});
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
});
|
|
311
|
-
}
|
|
322
|
+
toolbarButtons.push({
|
|
323
|
+
type: 'separator'
|
|
324
|
+
});
|
|
312
325
|
}
|
|
313
326
|
if (allowLinking && (0, _linking.shouldShowMediaLinkToolbar)(state)) {
|
|
314
327
|
toolbarButtons.push({
|
|
@@ -406,7 +419,7 @@ var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
406
419
|
var mediaLinkingState = (0, _linking2.getMediaLinkingState)(state);
|
|
407
420
|
var _ref3 = (_pluginInjectionApi$d9 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d9 !== void 0 ? _pluginInjectionApi$d9 : {},
|
|
408
421
|
hoverDecoration = _ref3.hoverDecoration;
|
|
409
|
-
if (!mediaPluginState
|
|
422
|
+
if (!mediaPluginState) {
|
|
410
423
|
return;
|
|
411
424
|
}
|
|
412
425
|
var nodeType = allowMediaInline ? [mediaInline, mediaSingle, media] : [mediaSingle];
|
|
@@ -30,6 +30,8 @@ var _styles = require("@atlaskit/editor-common/styles");
|
|
|
30
30
|
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
31
31
|
var _guideline = require("@atlaskit/editor-common/guideline");
|
|
32
32
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
33
|
+
var _throttle = _interopRequireDefault(require("lodash/throttle"));
|
|
34
|
+
var _main = require("../../pm-plugins/main");
|
|
33
35
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
34
36
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
|
|
35
37
|
var resizerNextTestId = 'mediaSingle.resizerNext.testid';
|
|
@@ -137,7 +139,15 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
137
139
|
state = _this$props$view.state,
|
|
138
140
|
dispatch = _this$props$view.dispatch;
|
|
139
141
|
var tr = state.tr;
|
|
140
|
-
tr.setMeta(
|
|
142
|
+
tr.setMeta(_main.MEDIA_PLUGIN_IS_RESIZING_KEY, isResizing);
|
|
143
|
+
return dispatch(tr);
|
|
144
|
+
});
|
|
145
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateSizeInPluginState", function (width) {
|
|
146
|
+
var _this$props$view2 = _this.props.view,
|
|
147
|
+
state = _this$props$view2.state,
|
|
148
|
+
dispatch = _this$props$view2.dispatch;
|
|
149
|
+
var tr = state.tr;
|
|
150
|
+
tr.setMeta(_main.MEDIA_PLUGIN_RESIZING_WIDTH_KEY, width);
|
|
141
151
|
return dispatch(tr);
|
|
142
152
|
});
|
|
143
153
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calcMaxWidth", (0, _memoizeOne.default)(function (contentWidth, containerWidth, fullWidthMode) {
|
|
@@ -191,11 +201,12 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
191
201
|
});
|
|
192
202
|
_this.selectCurrentMediaNode();
|
|
193
203
|
_this.setIsResizing(true);
|
|
204
|
+
_this.updateSizeInPluginState(_this.state.size.width);
|
|
194
205
|
// re-calucate guidelines
|
|
195
206
|
_this.guidelines = _this.getAllGuidelines();
|
|
196
207
|
return 0;
|
|
197
208
|
});
|
|
198
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResize", function (size, delta) {
|
|
209
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResize", (0, _throttle.default)(function (size, delta) {
|
|
199
210
|
var _this$props4 = _this.props,
|
|
200
211
|
originalWidth = _this$props4.width,
|
|
201
212
|
originalHeight = _this$props4.height,
|
|
@@ -215,10 +226,11 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
215
226
|
},
|
|
216
227
|
snaps: guidelineSnaps.snaps
|
|
217
228
|
});
|
|
229
|
+
_this.updateSizeInPluginState(width);
|
|
218
230
|
if (calculatedWidthWithLayout.layout !== layout) {
|
|
219
231
|
updateSize(width, calculatedWidthWithLayout.layout);
|
|
220
232
|
}
|
|
221
|
-
});
|
|
233
|
+
}, _mediaSingle.MEDIA_SINGLE_RESIZE_THROTTLE_TIME));
|
|
222
234
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResizeStop", function (size, delta) {
|
|
223
235
|
var _this$props5 = _this.props,
|
|
224
236
|
originalWidth = _this$props5.width,
|
|
@@ -7,6 +7,7 @@ exports.toggleColor = void 0;
|
|
|
7
7
|
var _mark = require("@atlaskit/editor-common/mark");
|
|
8
8
|
var _main = require("../pm-plugins/main");
|
|
9
9
|
var _disabled = require("../utils/disabled");
|
|
10
|
+
var _preset = require("@atlaskit/editor-common/preset");
|
|
10
11
|
var toggleColor = function toggleColor(color) {
|
|
11
12
|
return function (state, dispatch) {
|
|
12
13
|
var textColor = state.schema.marks.textColor;
|
|
@@ -26,9 +27,9 @@ var toggleColor = function toggleColor(color) {
|
|
|
26
27
|
color: color
|
|
27
28
|
});
|
|
28
29
|
state.tr.scrollIntoView();
|
|
29
|
-
(0, _mark.toggleMark)(textColor, {
|
|
30
|
+
(0, _preset.pluginCommandToPMCommand)((0, _mark.toggleMark)(textColor, {
|
|
30
31
|
color: color
|
|
31
|
-
})(state, dispatch);
|
|
32
|
+
}))(state, dispatch);
|
|
32
33
|
}
|
|
33
34
|
return true;
|
|
34
35
|
};
|
|
@@ -4,7 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
7
|
+
Object.defineProperty(exports, "findFarthestParentNode", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _utils.findFarthestParentNode;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
8
13
|
exports.getChangedNodes = getChangedNodes;
|
|
9
14
|
exports.getChangedNodesIn = getChangedNodesIn;
|
|
10
15
|
exports.getChildBreakoutModes = getChildBreakoutModes;
|
|
@@ -65,29 +70,6 @@ function processRawFragmentValue(schema, value, providerFactory, sanitizePrivate
|
|
|
65
70
|
}
|
|
66
71
|
return _model.Fragment.from(adfEntities);
|
|
67
72
|
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Find the farthest node given a condition
|
|
71
|
-
* @param predicate Function to check the node
|
|
72
|
-
*/
|
|
73
|
-
var findFarthestParentNode = function findFarthestParentNode(predicate) {
|
|
74
|
-
return function ($pos) {
|
|
75
|
-
var candidate = null;
|
|
76
|
-
for (var i = $pos.depth; i > 0; i--) {
|
|
77
|
-
var _node = $pos.node(i);
|
|
78
|
-
if (predicate(_node)) {
|
|
79
|
-
candidate = {
|
|
80
|
-
pos: i > 0 ? $pos.before(i) : 0,
|
|
81
|
-
start: $pos.start(i),
|
|
82
|
-
depth: i,
|
|
83
|
-
node: _node
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return candidate;
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
exports.findFarthestParentNode = findFarthestParentNode;
|
|
91
73
|
var isSelectionEndOfParagraph = function isSelectionEndOfParagraph(state) {
|
|
92
74
|
return state.selection.$to.parent.type === state.schema.nodes.paragraph && state.selection.$to.pos === state.doc.resolve(state.selection.$to.pos).end();
|
|
93
75
|
};
|