@atlaskit/editor-core 187.34.2 → 187.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cjs/index.js +10 -42
- package/dist/cjs/plugins/block-type/commands/block-type.js +19 -211
- package/dist/cjs/plugins/block-type/commands/index.js +2 -28
- package/dist/cjs/plugins/block-type/index.js +21 -4
- package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +9 -64
- package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +1 -1
- package/dist/cjs/plugins/code-block/actions.js +83 -6
- package/dist/cjs/plugins/code-block/index.js +27 -12
- package/dist/cjs/plugins/code-block/pm-plugins/input-rule.js +68 -0
- package/dist/cjs/plugins/date/ui/DatePicker/index.js +3 -2
- package/dist/cjs/plugins/expand/commands.js +3 -3
- package/dist/cjs/plugins/expand/index.js +2 -2
- package/dist/cjs/plugins/index.js +1 -7
- package/dist/cjs/plugins/insert-block/index.js +34 -29
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +36 -26
- package/dist/cjs/plugins/panel/actions.js +26 -2
- package/dist/cjs/plugins/panel/index.js +9 -5
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/index.js +16 -2
- package/dist/es2019/plugins/block-type/commands/block-type.js +15 -217
- package/dist/es2019/plugins/block-type/commands/index.js +1 -3
- package/dist/es2019/plugins/block-type/index.js +21 -4
- package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +3 -56
- package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +2 -2
- package/dist/es2019/plugins/code-block/actions.js +84 -3
- package/dist/es2019/plugins/code-block/index.js +22 -7
- package/dist/es2019/plugins/code-block/pm-plugins/input-rule.js +60 -0
- package/dist/es2019/plugins/date/ui/DatePicker/index.js +3 -2
- package/dist/es2019/plugins/expand/commands.js +1 -1
- package/dist/es2019/plugins/expand/index.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/insert-block/index.js +47 -42
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +35 -26
- package/dist/es2019/plugins/panel/actions.js +26 -2
- package/dist/es2019/plugins/panel/index.js +8 -4
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/index.js +16 -2
- package/dist/esm/plugins/block-type/commands/block-type.js +17 -205
- package/dist/esm/plugins/block-type/commands/index.js +1 -3
- package/dist/esm/plugins/block-type/index.js +21 -4
- package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +3 -58
- package/dist/esm/plugins/block-type/pm-plugins/keymap.js +2 -2
- package/dist/esm/plugins/code-block/actions.js +76 -3
- package/dist/esm/plugins/code-block/index.js +25 -11
- package/dist/esm/plugins/code-block/pm-plugins/input-rule.js +62 -0
- package/dist/esm/plugins/date/ui/DatePicker/index.js +3 -2
- package/dist/esm/plugins/expand/commands.js +1 -1
- package/dist/esm/plugins/expand/index.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/insert-block/index.js +27 -22
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +37 -27
- package/dist/esm/plugins/panel/actions.js +24 -2
- package/dist/esm/plugins/panel/index.js +8 -4
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/index.d.ts +16 -3
- package/dist/types/labs/next/presets/default.d.ts +6 -0
- package/dist/types/plugins/block-type/commands/block-type.d.ts +1 -25
- package/dist/types/plugins/block-type/commands/index.d.ts +1 -3
- package/dist/types/plugins/block-type/index.d.ts +10 -2
- package/dist/types/plugins/code-block/actions.d.ts +11 -0
- package/dist/types/plugins/code-block/index.d.ts +6 -1
- package/dist/types/plugins/code-block/pm-plugins/input-rule.d.ts +3 -0
- package/dist/types/plugins/date/ui/DatePicker/index.d.ts +2 -2
- package/dist/types/plugins/index.d.ts +0 -2
- package/dist/types/plugins/insert-block/types.d.ts +7 -1
- package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -3
- package/dist/types/plugins/panel/actions.d.ts +4 -1
- package/dist/types/plugins/panel/index.d.ts +11 -2
- package/dist/types-ts4.5/index.d.ts +16 -3
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +6 -0
- package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +1 -25
- package/dist/types-ts4.5/plugins/block-type/commands/index.d.ts +1 -3
- package/dist/types-ts4.5/plugins/block-type/index.d.ts +10 -2
- package/dist/types-ts4.5/plugins/code-block/actions.d.ts +11 -0
- package/dist/types-ts4.5/plugins/code-block/index.d.ts +6 -1
- package/dist/types-ts4.5/plugins/code-block/pm-plugins/input-rule.d.ts +3 -0
- package/dist/types-ts4.5/plugins/date/ui/DatePicker/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +7 -1
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -3
- package/dist/types-ts4.5/plugins/panel/actions.d.ts +4 -1
- package/dist/types-ts4.5/plugins/panel/index.d.ts +9 -2
- package/package.json +3 -3
- package/report.api.md +62 -23
- package/tmp/api-report-tmp.d.ts +49 -15
- package/dist/cjs/plugins/block-type/commands/insert-block.js +0 -60
- package/dist/es2019/plugins/block-type/commands/insert-block.js +0 -55
- package/dist/esm/plugins/block-type/commands/insert-block.js +0 -53
- package/dist/types/plugins/block-type/commands/insert-block.d.ts +0 -5
- package/dist/types-ts4.5/plugins/block-type/commands/insert-block.d.ts +0 -5
- /package/dist/cjs/plugins/{block-type/commands → code-block}/transform-to-code-block.js +0 -0
- /package/dist/es2019/plugins/{block-type/commands → code-block}/transform-to-code-block.js +0 -0
- /package/dist/esm/plugins/{block-type/commands → code-block}/transform-to-code-block.js +0 -0
- /package/dist/types/plugins/{block-type/commands → code-block}/transform-to-code-block.d.ts +0 -0
- /package/dist/types-ts4.5/plugins/{block-type/commands → code-block}/transform-to-code-block.d.ts +0 -0
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.copyContentToClipboard = exports.changeLanguage = void 0;
|
|
7
|
+
exports.createInsertCodeBlockTransaction = createInsertCodeBlockTransaction;
|
|
8
|
+
exports.ignoreFollowingMutations = void 0;
|
|
9
|
+
exports.insertCodeBlockWithAnalytics = insertCodeBlockWithAnalytics;
|
|
10
|
+
exports.resetShouldIgnoreFollowingMutations = exports.resetCopiedState = exports.removeCodeBlock = void 0;
|
|
7
11
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
8
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
13
|
var _pluginKey = require("./plugin-key");
|
|
@@ -11,7 +15,10 @@ var _codeBlockCopySelectionPlugin = require("./pm-plugins/codeBlockCopySelection
|
|
|
11
15
|
var _actions = require("./pm-plugins/actions");
|
|
12
16
|
var _clipboard = require("../../utils/clipboard");
|
|
13
17
|
var _utils2 = require("../analytics/utils");
|
|
14
|
-
var
|
|
18
|
+
var _insert = require("@atlaskit/editor-common/insert");
|
|
19
|
+
var _transformToCodeBlock = require("./transform-to-code-block");
|
|
20
|
+
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
21
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
15
22
|
var removeCodeBlock = function removeCodeBlock(state, dispatch) {
|
|
16
23
|
var nodes = state.schema.nodes,
|
|
17
24
|
tr = state.tr;
|
|
@@ -42,12 +49,12 @@ var changeLanguage = function changeLanguage(language) {
|
|
|
42
49
|
var result = tr.setSelection(selection);
|
|
43
50
|
if (dispatch) {
|
|
44
51
|
dispatch((0, _utils2.addAnalytics)(state, result, {
|
|
45
|
-
action:
|
|
46
|
-
actionSubject:
|
|
52
|
+
action: _analytics.ACTION.LANGUAGE_SELECTED,
|
|
53
|
+
actionSubject: _analytics.ACTION_SUBJECT.CODE_BLOCK,
|
|
47
54
|
attributes: {
|
|
48
55
|
language: language
|
|
49
56
|
},
|
|
50
|
-
eventType:
|
|
57
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
51
58
|
}));
|
|
52
59
|
}
|
|
53
60
|
return true;
|
|
@@ -125,4 +132,74 @@ var resetShouldIgnoreFollowingMutations = function resetShouldIgnoreFollowingMut
|
|
|
125
132
|
}
|
|
126
133
|
return true;
|
|
127
134
|
};
|
|
128
|
-
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* This function creates a new transaction that inserts a code block,
|
|
138
|
+
* if there is text selected it will wrap the current selection if not it will
|
|
139
|
+
* append the codeblock to the end of the document.
|
|
140
|
+
*/
|
|
141
|
+
exports.resetShouldIgnoreFollowingMutations = resetShouldIgnoreFollowingMutations;
|
|
142
|
+
function createInsertCodeBlockTransaction(_ref) {
|
|
143
|
+
var _state$selection$$fro;
|
|
144
|
+
var state = _ref.state;
|
|
145
|
+
var tr = state.tr;
|
|
146
|
+
var from = state.selection.from;
|
|
147
|
+
var codeBlock = state.schema.nodes.codeBlock;
|
|
148
|
+
var grandParentNodeType = (_state$selection$$fro = state.selection.$from.node(-1)) === null || _state$selection$$fro === void 0 ? void 0 : _state$selection$$fro.type;
|
|
149
|
+
var parentNodeType = state.selection.$from.parent.type;
|
|
150
|
+
|
|
151
|
+
/** We always want to append a codeBlock unless we're inserting into a paragraph
|
|
152
|
+
* AND it's a valid child of the grandparent node.
|
|
153
|
+
* Insert the current selection as codeBlock content unless it contains nodes other
|
|
154
|
+
* than paragraphs and inline.
|
|
155
|
+
*/
|
|
156
|
+
var canInsertCodeBlock = (0, _insert.shouldSplitSelectedNodeOnNodeInsertion)({
|
|
157
|
+
parentNodeType: parentNodeType,
|
|
158
|
+
grandParentNodeType: grandParentNodeType,
|
|
159
|
+
content: codeBlock.createAndFill()
|
|
160
|
+
}) && contentAllowedInCodeBlock(state);
|
|
161
|
+
if (canInsertCodeBlock) {
|
|
162
|
+
tr = (0, _transformToCodeBlock.transformToCodeBlockAction)(state, from);
|
|
163
|
+
} else {
|
|
164
|
+
(0, _utils.safeInsert)(codeBlock.createAndFill())(tr).scrollIntoView();
|
|
165
|
+
}
|
|
166
|
+
return tr;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Check if the current selection contains any nodes that are not permitted
|
|
171
|
+
* as codeBlock child nodes. Note that this allows paragraphs and inline nodes
|
|
172
|
+
* as we extract their text content.
|
|
173
|
+
*/
|
|
174
|
+
function contentAllowedInCodeBlock(state) {
|
|
175
|
+
var _state$selection = state.selection,
|
|
176
|
+
$from = _state$selection.$from,
|
|
177
|
+
$to = _state$selection.$to;
|
|
178
|
+
var isAllowedChild = true;
|
|
179
|
+
state.doc.nodesBetween($from.pos, $to.pos, function (node) {
|
|
180
|
+
if (!isAllowedChild) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
return isAllowedChild = node.type === state.schema.nodes.listItem || node.type === state.schema.nodes.bulletList || node.type === state.schema.nodes.orderedList || node.type === state.schema.nodes.paragraph || node.isInline || node.isText;
|
|
184
|
+
});
|
|
185
|
+
return isAllowedChild;
|
|
186
|
+
}
|
|
187
|
+
function insertCodeBlockWithAnalytics(inputMethod, analyticsAPI) {
|
|
188
|
+
return (0, _editorAnalytics.withAnalytics)(analyticsAPI, {
|
|
189
|
+
action: _analytics.ACTION.INSERTED,
|
|
190
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
191
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.CODE_BLOCK,
|
|
192
|
+
attributes: {
|
|
193
|
+
inputMethod: inputMethod
|
|
194
|
+
},
|
|
195
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
196
|
+
})(function (state, dispatch) {
|
|
197
|
+
var tr = createInsertCodeBlockTransaction({
|
|
198
|
+
state: state
|
|
199
|
+
});
|
|
200
|
+
if (dispatch) {
|
|
201
|
+
dispatch(tr);
|
|
202
|
+
}
|
|
203
|
+
return true;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
@@ -17,11 +17,10 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
17
17
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
18
18
|
var _messages = require("../block-type/messages");
|
|
19
19
|
var _refreshBrowserSelection = _interopRequireDefault(require("./refresh-browser-selection"));
|
|
20
|
-
var
|
|
20
|
+
var _actions = require("./actions");
|
|
21
|
+
var _inputRule = require("./pm-plugins/input-rule");
|
|
21
22
|
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; }
|
|
22
|
-
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; }
|
|
23
|
-
// Insertions via the drop down menu
|
|
24
|
-
// tslint-ignore-next-line
|
|
23
|
+
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; }
|
|
25
24
|
var codeBlockPlugin = function codeBlockPlugin(_ref) {
|
|
26
25
|
var options = _ref.config,
|
|
27
26
|
api = _ref.api;
|
|
@@ -44,6 +43,13 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
|
|
|
44
43
|
appearance: (_options$appearance = options === null || options === void 0 ? void 0 : options.appearance) !== null && _options$appearance !== void 0 ? _options$appearance : 'comment'
|
|
45
44
|
}));
|
|
46
45
|
}
|
|
46
|
+
}, {
|
|
47
|
+
name: 'codeBlockInputRule',
|
|
48
|
+
plugin: function plugin(_ref3) {
|
|
49
|
+
var _api$analytics;
|
|
50
|
+
var schema = _ref3.schema;
|
|
51
|
+
return (0, _inputRule.createCodeBlockInputRule)(schema, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
|
|
52
|
+
}
|
|
47
53
|
}, {
|
|
48
54
|
name: 'codeBlockIDEKeyBindings',
|
|
49
55
|
plugin: function plugin() {
|
|
@@ -51,8 +57,8 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
|
|
|
51
57
|
}
|
|
52
58
|
}, {
|
|
53
59
|
name: 'codeBlockKeyMap',
|
|
54
|
-
plugin: function plugin(
|
|
55
|
-
var schema =
|
|
60
|
+
plugin: function plugin(_ref4) {
|
|
61
|
+
var schema = _ref4.schema;
|
|
56
62
|
return (0, _keymaps.default)(schema);
|
|
57
63
|
}
|
|
58
64
|
}, {
|
|
@@ -67,9 +73,18 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
|
|
|
67
73
|
onEditorViewStateUpdated: function onEditorViewStateUpdated(props) {
|
|
68
74
|
(0, _refreshBrowserSelection.default)(props.originalTransaction, props.newEditorState);
|
|
69
75
|
},
|
|
76
|
+
actions: {
|
|
77
|
+
/*
|
|
78
|
+
* Function will insert code block at current selection if block is empty or below current selection and set focus on it.
|
|
79
|
+
*/
|
|
80
|
+
insertCodeBlock: function insertCodeBlock(inputMethod) {
|
|
81
|
+
var _api$analytics2;
|
|
82
|
+
return (0, _actions.insertCodeBlockWithAnalytics)(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
70
85
|
pluginsOptions: {
|
|
71
|
-
quickInsert: function quickInsert(
|
|
72
|
-
var formatMessage =
|
|
86
|
+
quickInsert: function quickInsert(_ref5) {
|
|
87
|
+
var formatMessage = _ref5.formatMessage;
|
|
73
88
|
return [{
|
|
74
89
|
id: 'codeblock',
|
|
75
90
|
title: formatMessage(_messages.messages.codeblock),
|
|
@@ -80,12 +95,12 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
|
|
|
80
95
|
icon: function icon() {
|
|
81
96
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconCode, null);
|
|
82
97
|
},
|
|
83
|
-
action: function action(
|
|
84
|
-
var _api$
|
|
85
|
-
var tr = (0,
|
|
98
|
+
action: function action(_insert, state) {
|
|
99
|
+
var _api$analytics3;
|
|
100
|
+
var tr = (0, _actions.createInsertCodeBlockTransaction)({
|
|
86
101
|
state: state
|
|
87
102
|
});
|
|
88
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
103
|
+
api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.attachAnalyticsEvent({
|
|
89
104
|
action: _analytics.ACTION.INSERTED,
|
|
90
105
|
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
91
106
|
actionSubjectId: _analytics.ACTION_SUBJECT_ID.CODE_BLOCK,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createCodeBlockInputRule = createCodeBlockInputRule;
|
|
7
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
8
|
+
var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
|
|
9
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
+
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
11
|
+
var _transformToCodeBlock = require("../transform-to-code-block");
|
|
12
|
+
var _commands = require("@atlaskit/editor-common/commands");
|
|
13
|
+
function createCodeBlockInputRule(schema, editorAnalyticsAPI) {
|
|
14
|
+
var rules = getCodeBlockRules(editorAnalyticsAPI, schema);
|
|
15
|
+
return (0, _prosemirrorInputRules.createPlugin)('code-block-input-rule', rules, {
|
|
16
|
+
isBlockNodeRule: true
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get all code block input rules
|
|
22
|
+
*
|
|
23
|
+
* @param {Schema} schema
|
|
24
|
+
* @returns {InputRuleWithHandler[]}
|
|
25
|
+
*/
|
|
26
|
+
function getCodeBlockRules(editorAnalyticsAPI, schema) {
|
|
27
|
+
var ruleAnalytics = (0, _utils2.inputRuleWithAnalytics)({
|
|
28
|
+
action: _analytics.ACTION.INSERTED,
|
|
29
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
30
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.CODE_BLOCK,
|
|
31
|
+
attributes: {
|
|
32
|
+
inputMethod: _analytics.INPUT_METHOD.FORMATTING
|
|
33
|
+
},
|
|
34
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
35
|
+
}, editorAnalyticsAPI);
|
|
36
|
+
var validMatchLength = function validMatchLength(match) {
|
|
37
|
+
return match.length > 0 && match[0].length === 3;
|
|
38
|
+
};
|
|
39
|
+
var threeTildeRule = (0, _prosemirrorInputRules.createRule)(/(?!\s)(`{3,})$/, function (state, match, start, end) {
|
|
40
|
+
if (!validMatchLength(match)) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
var attributes = {};
|
|
44
|
+
if (match[4]) {
|
|
45
|
+
attributes.language = match[4];
|
|
46
|
+
}
|
|
47
|
+
if ((0, _transformToCodeBlock.isConvertableToCodeBlock)(state)) {
|
|
48
|
+
return (0, _transformToCodeBlock.transformToCodeBlockAction)(state, start, attributes);
|
|
49
|
+
}
|
|
50
|
+
var tr = state.tr;
|
|
51
|
+
tr.delete(start, end);
|
|
52
|
+
var codeBlock = tr.doc.type.schema.nodes.codeBlock.createChecked();
|
|
53
|
+
(0, _utils.safeInsert)(codeBlock)(tr);
|
|
54
|
+
return tr;
|
|
55
|
+
});
|
|
56
|
+
var leftNodeReplacementThreeTildeRule = (0, _prosemirrorInputRules.createRule)(new RegExp("((".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, "`{3,})|^\\s(`{3,}))(\\S*)$")), function (state, match, start, end) {
|
|
57
|
+
if (!validMatchLength(match)) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
var attributes = {};
|
|
61
|
+
if (match[4]) {
|
|
62
|
+
attributes.language = match[4];
|
|
63
|
+
}
|
|
64
|
+
var inlineStart = Math.max(match.index + state.selection.$from.start(), 1);
|
|
65
|
+
return (0, _commands.insertBlock)(state, schema.nodes.codeBlock, inlineStart, end, attributes);
|
|
66
|
+
});
|
|
67
|
+
return [ruleAnalytics(threeTildeRule), ruleAnalytics(leftNodeReplacementThreeTildeRule)];
|
|
68
|
+
}
|
|
@@ -31,7 +31,7 @@ var _templateObject;
|
|
|
31
31
|
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); }; }
|
|
32
32
|
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; } }
|
|
33
33
|
var PopupWithListeners = (0, _withOuterListeners.default)(_ui.Popup);
|
|
34
|
-
var popupContentWrapper = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n padding:
|
|
34
|
+
var popupContentWrapper = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n padding: ", ";\n border-radius: ", "px;\n box-shadow: ", ";\n background-color: ", ";\n"])), "var(--ds-space-025, 2px)", (0, _constants.borderRadius)(), "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(_colors.N60A, ", 0 0 1px ").concat(_colors.N60A), ")"), "var(--ds-surface-overlay, ".concat(_colors.N0, ")"));
|
|
35
35
|
var DatePicker = /*#__PURE__*/function (_React$Component) {
|
|
36
36
|
(0, _inherits2.default)(DatePicker, _React$Component);
|
|
37
37
|
var _super = _createSuper(DatePicker);
|
|
@@ -158,7 +158,8 @@ var DatePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
158
158
|
year: year,
|
|
159
159
|
selected: selected,
|
|
160
160
|
ref: this.handleRef,
|
|
161
|
-
weekStartDay: weekStartDay
|
|
161
|
+
weekStartDay: weekStartDay,
|
|
162
|
+
testId: 'datepicker'
|
|
162
163
|
})));
|
|
163
164
|
}
|
|
164
165
|
}]);
|
|
@@ -12,8 +12,8 @@ var _analytics = require("../analytics");
|
|
|
12
12
|
var _gapCursorSelection = require("../selection/gap-cursor-selection");
|
|
13
13
|
var _utils2 = require("./utils");
|
|
14
14
|
var _pluginFactory = require("./pm-plugins/plugin-factory");
|
|
15
|
-
var
|
|
16
|
-
var
|
|
15
|
+
var _utils3 = require("@atlaskit/editor-common/utils");
|
|
16
|
+
var _utils4 = require("@atlaskit/editor-prosemirror/utils");
|
|
17
17
|
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; }
|
|
18
18
|
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; }
|
|
19
19
|
var setExpandRef = function setExpandRef(ref) {
|
|
@@ -124,7 +124,7 @@ var insertExpand = function insertExpand(state, dispatch) {
|
|
|
124
124
|
if (!expandNode) {
|
|
125
125
|
return false;
|
|
126
126
|
}
|
|
127
|
-
var tr = state.selection.empty ? (0,
|
|
127
|
+
var tr = state.selection.empty ? (0, _utils4.safeInsert)(expandNode)(state.tr).scrollIntoView() : (0, _utils3.createWrapSelectionTransaction)({
|
|
128
128
|
state: state,
|
|
129
129
|
type: expandNode.type
|
|
130
130
|
});
|
|
@@ -22,7 +22,7 @@ var _analytics = require("../analytics");
|
|
|
22
22
|
var _toolbar = require("./toolbar");
|
|
23
23
|
var _commands = require("./commands");
|
|
24
24
|
var _messages = require("../insert-block/ui/ToolbarInsertBlock/messages");
|
|
25
|
-
var
|
|
25
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
26
26
|
var _pluginFactory = require("./pm-plugins/plugin-factory");
|
|
27
27
|
var expandPlugin = function expandPlugin(_ref) {
|
|
28
28
|
var _api$featureFlags;
|
|
@@ -75,7 +75,7 @@ var expandPlugin = function expandPlugin(_ref) {
|
|
|
75
75
|
if (!node) {
|
|
76
76
|
return false;
|
|
77
77
|
}
|
|
78
|
-
var tr = state.selection.empty ? insert(node) : (0,
|
|
78
|
+
var tr = state.selection.empty ? insert(node) : (0, _utils.createWrapSelectionTransaction)({
|
|
79
79
|
state: state,
|
|
80
80
|
type: node.type
|
|
81
81
|
});
|
|
@@ -47,12 +47,6 @@ Object.defineProperty(exports, "betterTypeHistoryPlugin", {
|
|
|
47
47
|
return _betterTypeHistory.default;
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
|
-
Object.defineProperty(exports, "blockPluginStateKey", {
|
|
51
|
-
enumerable: true,
|
|
52
|
-
get: function get() {
|
|
53
|
-
return _blockType.pluginKey;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
50
|
Object.defineProperty(exports, "blockTypePlugin", {
|
|
57
51
|
enumerable: true,
|
|
58
52
|
get: function get() {
|
|
@@ -354,7 +348,7 @@ Object.defineProperty(exports, "viewUpdateSubscriptionPlugin", {
|
|
|
354
348
|
}
|
|
355
349
|
});
|
|
356
350
|
var _base = require("./base");
|
|
357
|
-
var _blockType =
|
|
351
|
+
var _blockType = _interopRequireDefault(require("./block-type"));
|
|
358
352
|
var _betterTypeHistory = _interopRequireDefault(require("./better-type-history"));
|
|
359
353
|
var _clearMarksOnChangeToEmptyDocument = _interopRequireDefault(require("./clear-marks-on-change-to-empty-document"));
|
|
360
354
|
var _codeBlock = _interopRequireDefault(require("./code-block"));
|
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
10
|
-
var _main = require("../block-type/pm-plugins/main");
|
|
11
10
|
var _pluginKey = require("../media/pm-plugins/plugin-key");
|
|
12
11
|
var _utils = require("../type-ahead/utils");
|
|
13
12
|
var _layout = require("../layout");
|
|
@@ -15,25 +14,45 @@ var _macro = require("../macro");
|
|
|
15
14
|
var _WithPluginState = _interopRequireDefault(require("../../ui/WithPluginState"));
|
|
16
15
|
var _ToolbarInsertBlock = _interopRequireDefault(require("./ui/ToolbarInsertBlock"));
|
|
17
16
|
var _key = require("../type-ahead/pm-plugins/key");
|
|
18
|
-
var
|
|
17
|
+
var _types = require("../block-type/types");
|
|
19
18
|
var _analytics = require("../analytics");
|
|
20
19
|
var _pluginKey2 = require("../placeholder-text/plugin-key");
|
|
21
20
|
var _pluginKey3 = require("../macro/plugin-key");
|
|
22
|
-
var
|
|
21
|
+
var _types2 = require("../../ui/Toolbar/types");
|
|
23
22
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
24
23
|
var toolbarSizeToButtons = function toolbarSizeToButtons(toolbarSize) {
|
|
25
24
|
switch (toolbarSize) {
|
|
26
|
-
case
|
|
27
|
-
case
|
|
28
|
-
case
|
|
29
|
-
case
|
|
25
|
+
case _types2.ToolbarSize.XXL:
|
|
26
|
+
case _types2.ToolbarSize.XL:
|
|
27
|
+
case _types2.ToolbarSize.L:
|
|
28
|
+
case _types2.ToolbarSize.M:
|
|
30
29
|
return 7;
|
|
31
|
-
case
|
|
30
|
+
case _types2.ToolbarSize.S:
|
|
32
31
|
return 2;
|
|
33
32
|
default:
|
|
34
33
|
return 0;
|
|
35
34
|
}
|
|
36
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* Wrapper over insertBlockTypeWithAnalytics to autobind toolbar input method
|
|
38
|
+
* @param name Block name
|
|
39
|
+
*/
|
|
40
|
+
function handleInsertBlockType(insertCodeBlock, insertPanel, insertBlockQuote) {
|
|
41
|
+
return function (name) {
|
|
42
|
+
if (name === _types.CODE_BLOCK.name && insertCodeBlock) {
|
|
43
|
+
return insertCodeBlock(_analytics.INPUT_METHOD.TOOLBAR);
|
|
44
|
+
}
|
|
45
|
+
if (name === _types.PANEL.name && insertPanel) {
|
|
46
|
+
return insertPanel(_analytics.INPUT_METHOD.TOOLBAR);
|
|
47
|
+
}
|
|
48
|
+
if (name === _types.BLOCK_QUOTE.name && insertBlockQuote) {
|
|
49
|
+
return insertBlockQuote(_analytics.INPUT_METHOD.TOOLBAR);
|
|
50
|
+
}
|
|
51
|
+
return function () {
|
|
52
|
+
return false;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}
|
|
37
56
|
var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
38
57
|
var _api$featureFlags;
|
|
39
58
|
var _ref$config = _ref.config,
|
|
@@ -60,16 +79,13 @@ var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
60
79
|
return /*#__PURE__*/_react.default.createElement(_WithPluginState.default, {
|
|
61
80
|
plugins: {
|
|
62
81
|
typeAheadState: _key.pluginKey,
|
|
63
|
-
// needed to check isTypeAheadAllowed in ToolbarInsertBlock
|
|
64
|
-
blockTypeState: _main.pluginKey,
|
|
65
82
|
mediaState: _pluginKey.stateKey,
|
|
66
83
|
macroState: _pluginKey3.pluginKey,
|
|
67
84
|
placeholderTextState: _pluginKey2.pluginKey,
|
|
68
85
|
layoutState: _layout.pluginKey
|
|
69
86
|
},
|
|
70
87
|
render: function render(_ref3) {
|
|
71
|
-
var
|
|
72
|
-
mediaState = _ref3.mediaState,
|
|
88
|
+
var mediaState = _ref3.mediaState,
|
|
73
89
|
_ref3$macroState = _ref3.macroState,
|
|
74
90
|
macroState = _ref3$macroState === void 0 ? {} : _ref3$macroState,
|
|
75
91
|
placeholderTextState = _ref3.placeholderTextState,
|
|
@@ -88,7 +104,6 @@ var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
88
104
|
isToolbarReducedSpacing: isToolbarReducedSpacing,
|
|
89
105
|
isLastItem: isLastItem,
|
|
90
106
|
featureFlags: featureFlags,
|
|
91
|
-
blockTypeState: blockTypeState,
|
|
92
107
|
mediaState: mediaState,
|
|
93
108
|
macroState: macroState,
|
|
94
109
|
placeholderTextState: placeholderTextState,
|
|
@@ -108,11 +123,10 @@ var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
108
123
|
};
|
|
109
124
|
};
|
|
110
125
|
function ToolbarInsertBlockWithInjectionApi(_ref4) {
|
|
111
|
-
var _pluginInjectionApi$
|
|
126
|
+
var _pluginInjectionApi$i, _pluginInjectionApi$c, _pluginInjectionApi$p, _pluginInjectionApi$b;
|
|
112
127
|
var editorView = _ref4.editorView,
|
|
113
128
|
editorActions = _ref4.editorActions,
|
|
114
129
|
dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent,
|
|
115
|
-
providerFactory = _ref4.providerFactory,
|
|
116
130
|
popupsMountPoint = _ref4.popupsMountPoint,
|
|
117
131
|
popupsBoundariesElement = _ref4.popupsBoundariesElement,
|
|
118
132
|
popupsScrollableElement = _ref4.popupsScrollableElement,
|
|
@@ -123,28 +137,19 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
|
|
|
123
137
|
providers = _ref4.providers,
|
|
124
138
|
pluginInjectionApi = _ref4.pluginInjectionApi,
|
|
125
139
|
options = _ref4.options,
|
|
126
|
-
blockTypeState = _ref4.blockTypeState,
|
|
127
140
|
mediaState = _ref4.mediaState,
|
|
128
141
|
macroState = _ref4.macroState,
|
|
129
142
|
placeholderTextState = _ref4.placeholderTextState,
|
|
130
143
|
layoutState = _ref4.layoutState,
|
|
131
144
|
featureFlags = _ref4.featureFlags;
|
|
132
145
|
var buttons = toolbarSizeToButtons(toolbarSize);
|
|
133
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji']),
|
|
146
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType']),
|
|
134
147
|
dateState = _useSharedPluginState.dateState,
|
|
135
148
|
hyperlinkState = _useSharedPluginState.hyperlinkState,
|
|
136
149
|
imageUploadState = _useSharedPluginState.imageUploadState,
|
|
137
150
|
mentionState = _useSharedPluginState.mentionState,
|
|
138
|
-
emojiState = _useSharedPluginState.emojiState
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Wrapper over insertBlockTypeWithAnalytics to autobind toolbar input method
|
|
142
|
-
* @param name Block name
|
|
143
|
-
*/
|
|
144
|
-
var handleInsertBlockType = _react.default.useCallback(function (name) {
|
|
145
|
-
var _pluginInjectionApi$a;
|
|
146
|
-
return (0, _commands.insertBlockTypesWithAnalytics)(name, _analytics.INPUT_METHOD.TOOLBAR, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions);
|
|
147
|
-
}, [pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions]);
|
|
151
|
+
emojiState = _useSharedPluginState.emojiState,
|
|
152
|
+
blockTypeState = _useSharedPluginState.blockTypeState;
|
|
148
153
|
return /*#__PURE__*/_react.default.createElement(_ToolbarInsertBlock.default, {
|
|
149
154
|
pluginInjectionApi: pluginInjectionApi,
|
|
150
155
|
buttons: buttons,
|
|
@@ -174,7 +179,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
|
|
|
174
179
|
emojiProvider: providers.emojiProvider,
|
|
175
180
|
nativeStatusSupported: options.nativeStatusSupported,
|
|
176
181
|
horizontalRuleEnabled: options.horizontalRuleEnabled,
|
|
177
|
-
onInsertBlockType: handleInsertBlockType,
|
|
182
|
+
onInsertBlockType: handleInsertBlockType(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.codeBlock) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.insertCodeBlock, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$p = pluginInjectionApi.panel) === null || _pluginInjectionApi$p === void 0 ? void 0 : _pluginInjectionApi$p.actions.insertPanel, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$b = pluginInjectionApi.blockType) === null || _pluginInjectionApi$b === void 0 ? void 0 : _pluginInjectionApi$b.actions.insertBlockQuote),
|
|
178
183
|
onInsertMacroFromMacroBrowser: _macro.insertMacroFromMacroBrowser,
|
|
179
184
|
macroProvider: macroState.macroProvider,
|
|
180
185
|
popupsMountPoint: popupsMountPoint,
|
|
@@ -185,7 +190,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
|
|
|
185
190
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
186
191
|
replacePlusMenuWithElementBrowser: options.replacePlusMenuWithElementBrowser,
|
|
187
192
|
showElementBrowserLink: options.showElementBrowserLink,
|
|
188
|
-
showSeparator: !isLastItem && toolbarSize <=
|
|
193
|
+
showSeparator: !isLastItem && toolbarSize <= _types2.ToolbarSize.S,
|
|
189
194
|
featureFlags: featureFlags
|
|
190
195
|
});
|
|
191
196
|
}
|
|
@@ -78,7 +78,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
78
78
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calcNewSize", function (newWidth, stop) {
|
|
79
79
|
var _this$props2 = _this.props,
|
|
80
80
|
layout = _this$props2.layout,
|
|
81
|
-
state = _this$props2.view.state,
|
|
82
81
|
containerWidth = _this$props2.containerWidth,
|
|
83
82
|
lineLength = _this$props2.lineLength,
|
|
84
83
|
fullWidthMode = _this$props2.fullWidthMode;
|
|
@@ -86,29 +85,32 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
86
85
|
_this.setState({
|
|
87
86
|
resizedPctWidth: newPct
|
|
88
87
|
});
|
|
89
|
-
var newLayout =
|
|
88
|
+
var newLayout = _this.calcUnwrappedLayout(newWidth, containerWidth, lineLength, fullWidthMode, _this.isNestedNode());
|
|
90
89
|
if (newPct <= 100) {
|
|
91
90
|
if (_this.wrappedLayout && (stop ? newPct !== 100 : true)) {
|
|
92
91
|
newLayout = layout;
|
|
93
92
|
}
|
|
94
93
|
return {
|
|
95
|
-
width: newPct,
|
|
96
94
|
layout: newLayout
|
|
97
95
|
};
|
|
98
96
|
} else {
|
|
99
97
|
return {
|
|
100
|
-
width: _this.props.pctWidth || null,
|
|
101
98
|
layout: newLayout
|
|
102
99
|
};
|
|
103
100
|
}
|
|
104
101
|
});
|
|
105
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calcUnwrappedLayout", function (width, containerWidth, contentWidth, fullWidthMode) {
|
|
102
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calcUnwrappedLayout", function (width, containerWidth, contentWidth, fullWidthMode, isNestedNode) {
|
|
103
|
+
if (isNestedNode) {
|
|
104
|
+
return 'center';
|
|
105
|
+
}
|
|
106
106
|
if (fullWidthMode) {
|
|
107
107
|
if (width < contentWidth) {
|
|
108
108
|
return 'center';
|
|
109
109
|
}
|
|
110
110
|
return 'full-width';
|
|
111
111
|
}
|
|
112
|
+
|
|
113
|
+
// handle top-level node in fixed-width editor
|
|
112
114
|
if (width <= contentWidth) {
|
|
113
115
|
return 'center';
|
|
114
116
|
}
|
|
@@ -154,7 +156,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
154
156
|
return dispatch(tr);
|
|
155
157
|
}, _mediaSingle.MEDIA_SINGLE_RESIZE_THROTTLE_TIME));
|
|
156
158
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calcMaxWidth", (0, _memoizeOne.default)(function (contentWidth, containerWidth, fullWidthMode) {
|
|
157
|
-
if (fullWidthMode) {
|
|
159
|
+
if (_this.isNestedNode() || fullWidthMode) {
|
|
158
160
|
return contentWidth;
|
|
159
161
|
}
|
|
160
162
|
return (0, _mediaSingle.calcMediaSingleMaxWidth)(containerWidth);
|
|
@@ -269,14 +271,20 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
269
271
|
}
|
|
270
272
|
_this.setIsResizing(false);
|
|
271
273
|
_this.displayGuideline([]);
|
|
274
|
+
var newWidth = width;
|
|
275
|
+
if (calculatedWidthWithLayout.layout === 'full-width') {
|
|
276
|
+
// When a node reaches full width in current viewport,
|
|
277
|
+
// update its width with 1800 to align with pixel entry
|
|
278
|
+
newWidth = _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
279
|
+
}
|
|
272
280
|
_this.setState({
|
|
273
281
|
isResizing: false,
|
|
274
282
|
size: {
|
|
275
|
-
width:
|
|
283
|
+
width: newWidth,
|
|
276
284
|
height: height
|
|
277
285
|
}
|
|
278
286
|
}, function () {
|
|
279
|
-
updateSize(
|
|
287
|
+
updateSize(newWidth, calculatedWidthWithLayout.layout);
|
|
280
288
|
});
|
|
281
289
|
});
|
|
282
290
|
var initialWidth = props.mediaSingleWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH;
|
|
@@ -298,7 +306,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
298
306
|
(0, _createClass2.default)(ResizableMediaSingleNext, [{
|
|
299
307
|
key: "componentDidUpdate",
|
|
300
308
|
value: function componentDidUpdate(prevProps) {
|
|
301
|
-
var _this2 = this;
|
|
302
309
|
var offsetLeft = (0, _mediaSingle.calculateOffsetLeft)(this.insideInlineLike, this.insideLayout, this.props.view.dom, this.wrapper);
|
|
303
310
|
if (offsetLeft !== this.state.offsetLeft && offsetLeft >= 0) {
|
|
304
311
|
this.setState({
|
|
@@ -324,18 +331,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
324
331
|
}
|
|
325
332
|
});
|
|
326
333
|
}
|
|
327
|
-
if (this.props.layout === 'full-width' && !this.isNestedNode() && prevProps.containerWidth !== this.props.containerWidth) {
|
|
328
|
-
// To achieve edge-to-edge for full-width, we need to update its width according to containerWidth
|
|
329
|
-
// Update state to allow resizer to get most up-to-date width to avoid jumping when start resizing
|
|
330
|
-
this.setState(function (prevState) {
|
|
331
|
-
return {
|
|
332
|
-
size: {
|
|
333
|
-
width: (0, _mediaSingle.calcMediaSingleMaxWidth)(_this2.props.containerWidth),
|
|
334
|
-
height: prevState.size.height
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
334
|
return true;
|
|
340
335
|
}
|
|
341
336
|
}, {
|
|
@@ -503,7 +498,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
503
498
|
}, {
|
|
504
499
|
key: "render",
|
|
505
500
|
value: function render() {
|
|
506
|
-
var
|
|
501
|
+
var _this2 = this;
|
|
507
502
|
var _this$props8 = this.props,
|
|
508
503
|
origWidth = _this$props8.width,
|
|
509
504
|
layout = _this$props8.layout,
|
|
@@ -521,7 +516,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
521
516
|
_ui.handleSides.forEach(function (side) {
|
|
522
517
|
var oppositeSide = side === 'left' ? 'right' : 'left';
|
|
523
518
|
enable[side] = _utils2.nonWrappedLayouts.concat("wrap-".concat(oppositeSide)).concat("align-".concat(_ui.imageAlignmentMap[oppositeSide])).indexOf(layout) > -1;
|
|
524
|
-
if (side === 'left' &&
|
|
519
|
+
if (side === 'left' && _this2.insideInlineLike) {
|
|
525
520
|
enable[side] = false;
|
|
526
521
|
}
|
|
527
522
|
});
|
|
@@ -533,9 +528,23 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
533
528
|
'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
|
|
534
529
|
});
|
|
535
530
|
var resizerNextClassName = (0, _classnames.default)(className, _styles.resizerStyles);
|
|
536
|
-
var maxWidth = this.isNestedNode() ?
|
|
537
|
-
|
|
531
|
+
var maxWidth = !isResizing && this.isNestedNode() ?
|
|
532
|
+
// set undefined to fall back to 100%
|
|
533
|
+
undefined : this.calcMaxWidth(lineLength, containerWidth, fullWidthMode);
|
|
538
534
|
var minWidth = this.calcMinWidth(isVideoFile, lineLength);
|
|
535
|
+
var nestedHandleStyles = function nestedHandleStyles(isNestedNode) {
|
|
536
|
+
if (!isNestedNode) {
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
return {
|
|
540
|
+
left: {
|
|
541
|
+
left: "calc(".concat("var(--ds-space-075, 0.375em)", " * -1)")
|
|
542
|
+
},
|
|
543
|
+
right: {
|
|
544
|
+
right: "calc(".concat("var(--ds-space-075, 0.375em)", " * -1)")
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
};
|
|
539
548
|
return (0, _react2.jsx)("div", {
|
|
540
549
|
ref: this.saveWrapper,
|
|
541
550
|
css: (0, _styled.wrapperStyle)({
|
|
@@ -561,7 +570,8 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
561
570
|
resizeRatio: _utils2.nonWrappedLayouts.includes(layout) ? 2 : 1,
|
|
562
571
|
handleComponent: handleComponent,
|
|
563
572
|
"data-testid": resizerNextTestId,
|
|
564
|
-
isHandleVisible: selected
|
|
573
|
+
isHandleVisible: selected,
|
|
574
|
+
handleStyles: nestedHandleStyles(this.isNestedNode())
|
|
565
575
|
}, children));
|
|
566
576
|
}
|
|
567
577
|
}]);
|