@atlaskit/editor-core 187.14.8 → 187.14.11
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/commands/index.js +35 -120
- package/dist/cjs/plugins/media/commands/captions.js +29 -27
- package/dist/cjs/plugins/media/commands/linking.js +21 -17
- package/dist/cjs/plugins/media/index.js +4 -3
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +4 -2
- package/dist/cjs/plugins/media/pm-plugins/keymap.js +17 -15
- package/dist/cjs/plugins/media/pm-plugins/main.js +7 -5
- package/dist/cjs/plugins/media/toolbar/commands.js +149 -141
- package/dist/cjs/plugins/media/toolbar/index.js +20 -16
- package/dist/cjs/plugins/media/toolbar/linking.js +4 -3
- package/dist/cjs/plugins/media/utils/media-files.js +78 -75
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/commands/index.js +1 -115
- package/dist/es2019/plugins/media/commands/captions.js +4 -4
- package/dist/es2019/plugins/media/commands/linking.js +12 -11
- package/dist/es2019/plugins/media/index.js +6 -3
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +4 -2
- package/dist/es2019/plugins/media/pm-plugins/keymap.js +5 -5
- package/dist/es2019/plugins/media/pm-plugins/main.js +7 -5
- package/dist/es2019/plugins/media/toolbar/commands.js +15 -15
- package/dist/es2019/plugins/media/toolbar/index.js +20 -16
- package/dist/es2019/plugins/media/toolbar/linking.js +6 -3
- package/dist/es2019/plugins/media/utils/media-files.js +5 -6
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/commands/index.js +1 -113
- package/dist/esm/plugins/media/commands/captions.js +29 -27
- package/dist/esm/plugins/media/commands/linking.js +21 -17
- package/dist/esm/plugins/media/index.js +4 -3
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +4 -2
- package/dist/esm/plugins/media/pm-plugins/keymap.js +17 -15
- package/dist/esm/plugins/media/pm-plugins/main.js +7 -5
- package/dist/esm/plugins/media/toolbar/commands.js +148 -140
- package/dist/esm/plugins/media/toolbar/index.js +20 -16
- package/dist/esm/plugins/media/toolbar/linking.js +4 -3
- package/dist/esm/plugins/media/utils/media-files.js +78 -75
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/commands/index.d.ts +1 -17
- package/dist/types/plugins/media/commands/captions.d.ts +2 -1
- package/dist/types/plugins/media/commands/linking.d.ts +3 -3
- package/dist/types/plugins/media/pm-plugins/keymap.d.ts +2 -1
- package/dist/types/plugins/media/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/media/toolbar/commands.d.ts +5 -4
- package/dist/types/plugins/media/utils/media-files.d.ts +3 -2
- package/dist/types-ts4.5/commands/index.d.ts +1 -17
- package/dist/types-ts4.5/plugins/media/commands/captions.d.ts +2 -1
- package/dist/types-ts4.5/plugins/media/commands/linking.d.ts +3 -3
- package/dist/types-ts4.5/plugins/media/pm-plugins/keymap.d.ts +2 -1
- package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/toolbar/commands.d.ts +5 -4
- package/dist/types-ts4.5/plugins/media/utils/media-files.d.ts +3 -2
- package/package.json +4 -4
- package/report.api.md +2 -2
- package/tmp/api-report-tmp.d.ts +2 -2
|
@@ -7,85 +7,89 @@ exports.toggleBorderMark = exports.setBorderMark = exports.removeInlineCard = ex
|
|
|
7
7
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
8
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
9
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
10
|
-
var _analytics = require("
|
|
10
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
11
|
var _utils2 = require("./utils");
|
|
12
12
|
var _currentMediaNode = require("../utils/current-media-node");
|
|
13
13
|
var DEFAULT_BORDER_COLOR = '#091e4224';
|
|
14
14
|
exports.DEFAULT_BORDER_COLOR = DEFAULT_BORDER_COLOR;
|
|
15
15
|
var DEFAULT_BORDER_SIZE = 2;
|
|
16
16
|
exports.DEFAULT_BORDER_SIZE = DEFAULT_BORDER_SIZE;
|
|
17
|
-
var changeInlineToMediaCard = function changeInlineToMediaCard(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var group = mediaGroup.createChecked({}, mediaNode);
|
|
36
|
-
var nodePos = state.tr.doc.resolve(state.selection.from).end();
|
|
37
|
-
var tr = state.tr;
|
|
38
|
-
tr = (0, _utils.removeSelectedNode)(tr);
|
|
39
|
-
tr = (0, _utils.safeInsert)(group, nodePos, true)(tr);
|
|
40
|
-
if (dispatch) {
|
|
41
|
-
(0, _analytics.addAnalytics)(state, tr, {
|
|
42
|
-
action: _analytics.ACTION.CHANGED_TYPE,
|
|
43
|
-
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
44
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
45
|
-
attributes: {
|
|
46
|
-
newType: _analytics.ACTION_SUBJECT_ID.MEDIA_GROUP,
|
|
47
|
-
previousType: _analytics.ACTION_SUBJECT_ID.MEDIA_INLINE
|
|
48
|
-
}
|
|
17
|
+
var changeInlineToMediaCard = function changeInlineToMediaCard(editorAnalyticsAPI) {
|
|
18
|
+
return function (state, dispatch) {
|
|
19
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
20
|
+
media = _state$schema$nodes.media,
|
|
21
|
+
mediaInline = _state$schema$nodes.mediaInline,
|
|
22
|
+
mediaGroup = _state$schema$nodes.mediaGroup;
|
|
23
|
+
var selectedNode = state.selection instanceof _state.NodeSelection && state.selection.node.type === mediaInline && state.selection.node;
|
|
24
|
+
if (!selectedNode) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
var _selectedNode$attrs = selectedNode.attrs,
|
|
28
|
+
id = _selectedNode$attrs.id,
|
|
29
|
+
type = _selectedNode$attrs.type,
|
|
30
|
+
collection = _selectedNode$attrs.collection;
|
|
31
|
+
var mediaNode = media.createChecked({
|
|
32
|
+
id: id,
|
|
33
|
+
type: type,
|
|
34
|
+
collection: collection
|
|
49
35
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
36
|
+
var group = mediaGroup.createChecked({}, mediaNode);
|
|
37
|
+
var nodePos = state.tr.doc.resolve(state.selection.from).end();
|
|
38
|
+
var tr = state.tr;
|
|
39
|
+
tr = (0, _utils.removeSelectedNode)(tr);
|
|
40
|
+
tr = (0, _utils.safeInsert)(group, nodePos, true)(tr);
|
|
41
|
+
if (dispatch) {
|
|
42
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
43
|
+
action: _analytics.ACTION.CHANGED_TYPE,
|
|
44
|
+
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
45
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
46
|
+
attributes: {
|
|
47
|
+
newType: _analytics.ACTION_SUBJECT_ID.MEDIA_GROUP,
|
|
48
|
+
previousType: _analytics.ACTION_SUBJECT_ID.MEDIA_INLINE
|
|
49
|
+
}
|
|
50
|
+
})(tr);
|
|
51
|
+
dispatch(tr);
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
};
|
|
53
55
|
};
|
|
54
56
|
exports.changeInlineToMediaCard = changeInlineToMediaCard;
|
|
55
|
-
var changeMediaCardToInline = function changeMediaCardToInline(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
var changeMediaCardToInline = function changeMediaCardToInline(editorAnalyticsAPI) {
|
|
58
|
+
return function (state, dispatch) {
|
|
59
|
+
var _state$schema$nodes2 = state.schema.nodes,
|
|
60
|
+
media = _state$schema$nodes2.media,
|
|
61
|
+
mediaInline = _state$schema$nodes2.mediaInline,
|
|
62
|
+
paragraph = _state$schema$nodes2.paragraph;
|
|
63
|
+
var selectedNode = state.selection instanceof _state.NodeSelection && state.selection.node;
|
|
61
64
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
});
|
|
70
|
-
var space = state.schema.text(' ');
|
|
71
|
-
var content = _model.Fragment.from([mediaInlineNode, space]);
|
|
72
|
-
var node = paragraph.createChecked({}, content);
|
|
73
|
-
var nodePos = state.tr.doc.resolve(state.selection.from).start() - 1;
|
|
74
|
-
var tr = (0, _utils2.removeMediaGroupNode)(state);
|
|
75
|
-
tr = (0, _utils.safeInsert)(node, nodePos, true)(tr);
|
|
76
|
-
if (dispatch) {
|
|
77
|
-
(0, _analytics.addAnalytics)(state, tr, {
|
|
78
|
-
action: _analytics.ACTION.CHANGED_TYPE,
|
|
79
|
-
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
80
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
81
|
-
attributes: {
|
|
82
|
-
newType: _analytics.ACTION_SUBJECT_ID.MEDIA_INLINE,
|
|
83
|
-
previousType: _analytics.ACTION_SUBJECT_ID.MEDIA_GROUP
|
|
84
|
-
}
|
|
65
|
+
// @ts-ignore - [unblock prosemirror bump] redundant check comparing boolean to media
|
|
66
|
+
if (!selectedNode || !selectedNode.type === media) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
var mediaInlineNode = mediaInline.create({
|
|
70
|
+
id: selectedNode.attrs.id,
|
|
71
|
+
collection: selectedNode.attrs.collection
|
|
85
72
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
73
|
+
var space = state.schema.text(' ');
|
|
74
|
+
var content = _model.Fragment.from([mediaInlineNode, space]);
|
|
75
|
+
var node = paragraph.createChecked({}, content);
|
|
76
|
+
var nodePos = state.tr.doc.resolve(state.selection.from).start() - 1;
|
|
77
|
+
var tr = (0, _utils2.removeMediaGroupNode)(state);
|
|
78
|
+
tr = (0, _utils.safeInsert)(node, nodePos, true)(tr);
|
|
79
|
+
if (dispatch) {
|
|
80
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
81
|
+
action: _analytics.ACTION.CHANGED_TYPE,
|
|
82
|
+
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
83
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
84
|
+
attributes: {
|
|
85
|
+
newType: _analytics.ACTION_SUBJECT_ID.MEDIA_INLINE,
|
|
86
|
+
previousType: _analytics.ACTION_SUBJECT_ID.MEDIA_GROUP
|
|
87
|
+
}
|
|
88
|
+
})(tr);
|
|
89
|
+
dispatch(tr);
|
|
90
|
+
}
|
|
91
|
+
return true;
|
|
92
|
+
};
|
|
89
93
|
};
|
|
90
94
|
exports.changeMediaCardToInline = changeMediaCardToInline;
|
|
91
95
|
var removeInlineCard = function removeInlineCard(state, dispatch) {
|
|
@@ -98,77 +102,22 @@ var removeInlineCard = function removeInlineCard(state, dispatch) {
|
|
|
98
102
|
return false;
|
|
99
103
|
};
|
|
100
104
|
exports.removeInlineCard = removeInlineCard;
|
|
101
|
-
var toggleBorderMark = function toggleBorderMark(
|
|
102
|
-
var nodeWithPos = (0, _currentMediaNode.currentMediaNodeWithPos)(state);
|
|
103
|
-
if (!nodeWithPos) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
var node = nodeWithPos.node,
|
|
107
|
-
pos = nodeWithPos.pos;
|
|
108
|
-
var borderMark = node.marks.find(function (m) {
|
|
109
|
-
return m.type.name === 'border';
|
|
110
|
-
});
|
|
111
|
-
var marks = node.marks.filter(function (m) {
|
|
112
|
-
return m.type.name !== 'border';
|
|
113
|
-
}).concat(borderMark ? [] : state.schema.marks.border.create({
|
|
114
|
-
color: DEFAULT_BORDER_COLOR,
|
|
115
|
-
size: DEFAULT_BORDER_SIZE
|
|
116
|
-
}));
|
|
117
|
-
var tr = state.tr.setNodeMarkup(pos, node.type, node.attrs, marks);
|
|
118
|
-
tr.setMeta('scrollIntoView', false);
|
|
119
|
-
if (state.selection instanceof _state.NodeSelection) {
|
|
120
|
-
if (state.selection.$anchor.pos === state.selection.from) {
|
|
121
|
-
tr.setSelection(_state.NodeSelection.create(tr.doc, state.selection.from));
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (dispatch) {
|
|
125
|
-
if (borderMark !== null && borderMark !== void 0 && borderMark.attrs) {
|
|
126
|
-
(0, _analytics.addAnalytics)(state, tr, {
|
|
127
|
-
action: _analytics.ACTION.DELETED,
|
|
128
|
-
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
129
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.BORDER,
|
|
130
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
131
|
-
attributes: {
|
|
132
|
-
previousColor: borderMark.attrs.color,
|
|
133
|
-
previousSize: borderMark.attrs.size
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
} else {
|
|
137
|
-
(0, _analytics.addAnalytics)(state, tr, {
|
|
138
|
-
action: _analytics.ACTION.ADDED,
|
|
139
|
-
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
140
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.BORDER,
|
|
141
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
142
|
-
attributes: {
|
|
143
|
-
color: DEFAULT_BORDER_COLOR,
|
|
144
|
-
size: DEFAULT_BORDER_SIZE
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
dispatch(tr);
|
|
149
|
-
}
|
|
150
|
-
return true;
|
|
151
|
-
};
|
|
152
|
-
exports.toggleBorderMark = toggleBorderMark;
|
|
153
|
-
var setBorderMark = function setBorderMark(attrs) {
|
|
105
|
+
var toggleBorderMark = function toggleBorderMark(editorAnalyticsAPI) {
|
|
154
106
|
return function (state, dispatch) {
|
|
155
|
-
var _node$marks$find, _ref, _attrs$color, _ref2, _attrs$size;
|
|
156
107
|
var nodeWithPos = (0, _currentMediaNode.currentMediaNodeWithPos)(state);
|
|
157
108
|
if (!nodeWithPos) {
|
|
158
109
|
return false;
|
|
159
110
|
}
|
|
160
111
|
var node = nodeWithPos.node,
|
|
161
112
|
pos = nodeWithPos.pos;
|
|
162
|
-
var borderMark =
|
|
113
|
+
var borderMark = node.marks.find(function (m) {
|
|
163
114
|
return m.type.name === 'border';
|
|
164
|
-
})
|
|
165
|
-
var color = (_ref = (_attrs$color = attrs.color) !== null && _attrs$color !== void 0 ? _attrs$color : borderMark === null || borderMark === void 0 ? void 0 : borderMark.color) !== null && _ref !== void 0 ? _ref : DEFAULT_BORDER_COLOR;
|
|
166
|
-
var size = (_ref2 = (_attrs$size = attrs.size) !== null && _attrs$size !== void 0 ? _attrs$size : borderMark === null || borderMark === void 0 ? void 0 : borderMark.size) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_BORDER_SIZE;
|
|
115
|
+
});
|
|
167
116
|
var marks = node.marks.filter(function (m) {
|
|
168
117
|
return m.type.name !== 'border';
|
|
169
|
-
}).concat(state.schema.marks.border.create({
|
|
170
|
-
color:
|
|
171
|
-
size:
|
|
118
|
+
}).concat(borderMark ? [] : state.schema.marks.border.create({
|
|
119
|
+
color: DEFAULT_BORDER_COLOR,
|
|
120
|
+
size: DEFAULT_BORDER_SIZE
|
|
172
121
|
}));
|
|
173
122
|
var tr = state.tr.setNodeMarkup(pos, node.type, node.attrs, marks);
|
|
174
123
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -178,21 +127,80 @@ var setBorderMark = function setBorderMark(attrs) {
|
|
|
178
127
|
}
|
|
179
128
|
}
|
|
180
129
|
if (dispatch) {
|
|
181
|
-
(0
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
}
|
|
130
|
+
if (borderMark !== null && borderMark !== void 0 && borderMark.attrs) {
|
|
131
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
132
|
+
action: _analytics.ACTION.DELETED,
|
|
133
|
+
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
134
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.BORDER,
|
|
135
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
136
|
+
attributes: {
|
|
137
|
+
previousColor: borderMark.attrs.color,
|
|
138
|
+
previousSize: borderMark.attrs.size
|
|
139
|
+
}
|
|
140
|
+
})(tr);
|
|
141
|
+
} else {
|
|
142
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
143
|
+
action: _analytics.ACTION.ADDED,
|
|
144
|
+
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
145
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.BORDER,
|
|
146
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
147
|
+
attributes: {
|
|
148
|
+
color: DEFAULT_BORDER_COLOR,
|
|
149
|
+
size: DEFAULT_BORDER_SIZE
|
|
150
|
+
}
|
|
151
|
+
})(tr);
|
|
152
|
+
}
|
|
193
153
|
dispatch(tr);
|
|
194
154
|
}
|
|
195
155
|
return true;
|
|
196
156
|
};
|
|
197
157
|
};
|
|
158
|
+
exports.toggleBorderMark = toggleBorderMark;
|
|
159
|
+
var setBorderMark = function setBorderMark(editorAnalyticsAPI) {
|
|
160
|
+
return function (attrs) {
|
|
161
|
+
return function (state, dispatch) {
|
|
162
|
+
var _node$marks$find, _ref, _attrs$color, _ref2, _attrs$size;
|
|
163
|
+
var nodeWithPos = (0, _currentMediaNode.currentMediaNodeWithPos)(state);
|
|
164
|
+
if (!nodeWithPos) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
var node = nodeWithPos.node,
|
|
168
|
+
pos = nodeWithPos.pos;
|
|
169
|
+
var borderMark = (_node$marks$find = node.marks.find(function (m) {
|
|
170
|
+
return m.type.name === 'border';
|
|
171
|
+
})) === null || _node$marks$find === void 0 ? void 0 : _node$marks$find.attrs;
|
|
172
|
+
var color = (_ref = (_attrs$color = attrs.color) !== null && _attrs$color !== void 0 ? _attrs$color : borderMark === null || borderMark === void 0 ? void 0 : borderMark.color) !== null && _ref !== void 0 ? _ref : DEFAULT_BORDER_COLOR;
|
|
173
|
+
var size = (_ref2 = (_attrs$size = attrs.size) !== null && _attrs$size !== void 0 ? _attrs$size : borderMark === null || borderMark === void 0 ? void 0 : borderMark.size) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_BORDER_SIZE;
|
|
174
|
+
var marks = node.marks.filter(function (m) {
|
|
175
|
+
return m.type.name !== 'border';
|
|
176
|
+
}).concat(state.schema.marks.border.create({
|
|
177
|
+
color: color,
|
|
178
|
+
size: size
|
|
179
|
+
}));
|
|
180
|
+
var tr = state.tr.setNodeMarkup(pos, node.type, node.attrs, marks);
|
|
181
|
+
tr.setMeta('scrollIntoView', false);
|
|
182
|
+
if (state.selection instanceof _state.NodeSelection) {
|
|
183
|
+
if (state.selection.$anchor.pos === state.selection.from) {
|
|
184
|
+
tr.setSelection(_state.NodeSelection.create(tr.doc, state.selection.from));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (dispatch) {
|
|
188
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
189
|
+
action: _analytics.ACTION.UPDATED,
|
|
190
|
+
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
191
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.BORDER,
|
|
192
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
193
|
+
attributes: {
|
|
194
|
+
previousColor: borderMark === null || borderMark === void 0 ? void 0 : borderMark.color,
|
|
195
|
+
previousSize: borderMark === null || borderMark === void 0 ? void 0 : borderMark.size,
|
|
196
|
+
newColor: color,
|
|
197
|
+
newSize: size
|
|
198
|
+
}
|
|
199
|
+
})(tr);
|
|
200
|
+
dispatch(tr);
|
|
201
|
+
}
|
|
202
|
+
return true;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
};
|
|
198
206
|
exports.setBorderMark = setBorderMark;
|
|
@@ -48,7 +48,7 @@ var handleRemoveMediaGroup = function handleRemoveMediaGroup(state, dispatch) {
|
|
|
48
48
|
}
|
|
49
49
|
return true;
|
|
50
50
|
};
|
|
51
|
-
var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration) {
|
|
51
|
+
var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) {
|
|
52
52
|
var mediaGroup = state.schema.nodes.mediaGroup;
|
|
53
53
|
var items = [{
|
|
54
54
|
id: 'editor.media.view.switcher',
|
|
@@ -59,7 +59,7 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
59
59
|
title: intl.formatMessage(_messages2.cardMessages.inline),
|
|
60
60
|
selected: false,
|
|
61
61
|
disabled: false,
|
|
62
|
-
onClick: _commands.changeMediaCardToInline,
|
|
62
|
+
onClick: (0, _commands.changeMediaCardToInline)(editorAnalyticsAPI),
|
|
63
63
|
testId: 'inline-appearance'
|
|
64
64
|
}, {
|
|
65
65
|
id: 'editor.media.view.switcher.thumbnail',
|
|
@@ -121,7 +121,7 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
121
121
|
}];
|
|
122
122
|
return items;
|
|
123
123
|
};
|
|
124
|
-
var generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration) {
|
|
124
|
+
var generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) {
|
|
125
125
|
var mediaInline = state.schema.nodes.mediaInline;
|
|
126
126
|
var items = [{
|
|
127
127
|
id: 'editor.media.view.switcher',
|
|
@@ -141,7 +141,7 @@ var generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToo
|
|
|
141
141
|
title: intl.formatMessage(_mediaUi.messages.displayThumbnail),
|
|
142
142
|
selected: false,
|
|
143
143
|
disabled: false,
|
|
144
|
-
onClick: _commands.changeInlineToMediaCard,
|
|
144
|
+
onClick: (0, _commands.changeInlineToMediaCard)(editorAnalyticsAPI),
|
|
145
145
|
testId: 'thumbnail-appearance'
|
|
146
146
|
}]
|
|
147
147
|
}, {
|
|
@@ -195,7 +195,7 @@ var generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToo
|
|
|
195
195
|
return items;
|
|
196
196
|
};
|
|
197
197
|
var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToolbar(state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) {
|
|
198
|
-
var _pluginInjectionApi$
|
|
198
|
+
var _pluginInjectionApi$d7;
|
|
199
199
|
var mediaSingle = state.schema.nodes.mediaSingle;
|
|
200
200
|
var allowResizing = options.allowResizing,
|
|
201
201
|
allowLinking = options.allowLinking,
|
|
@@ -216,10 +216,12 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
216
216
|
var borderMark = (0, _currentMediaNode.currentMediaNodeBorderMark)(state);
|
|
217
217
|
return /*#__PURE__*/_react.default.createElement(_ImageBorder.default, {
|
|
218
218
|
toggleBorder: function toggleBorder() {
|
|
219
|
-
|
|
219
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
220
|
+
(0, _commands.toggleBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions)(state, dispatch);
|
|
220
221
|
},
|
|
221
222
|
setBorder: function setBorder(attrs) {
|
|
222
|
-
|
|
223
|
+
var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
224
|
+
(0, _commands.setBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : (_pluginInjectionApi$d4 = _pluginInjectionApi$d3.analytics) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions)(attrs)(state, dispatch);
|
|
223
225
|
},
|
|
224
226
|
showSomewhatSemanticTooltips: getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags().useSomewhatSemanticTextColorNames,
|
|
225
227
|
borderMark: borderMark,
|
|
@@ -232,7 +234,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
232
234
|
});
|
|
233
235
|
}
|
|
234
236
|
if (allowAdvancedToolBarOptions) {
|
|
235
|
-
var _pluginInjectionApi$
|
|
237
|
+
var _pluginInjectionApi$d5;
|
|
236
238
|
var widthPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.width;
|
|
237
239
|
var isChangingLayoutDisabled = false;
|
|
238
240
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience')) {
|
|
@@ -246,7 +248,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
246
248
|
}
|
|
247
249
|
}
|
|
248
250
|
}
|
|
249
|
-
var layoutButtons = (0, _card.buildLayoutButtons)(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
251
|
+
var layoutButtons = (0, _card.buildLayoutButtons)(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d5 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
|
|
250
252
|
toolbarButtons = [].concat((0, _toConsumableArray2.default)(toolbarButtons), (0, _toConsumableArray2.default)(layoutButtons));
|
|
251
253
|
if (layoutButtons.length) {
|
|
252
254
|
toolbarButtons.push({
|
|
@@ -268,10 +270,10 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
268
270
|
};
|
|
269
271
|
var openLink = function openLink() {
|
|
270
272
|
if (editorView) {
|
|
271
|
-
var _pluginInjectionApi$
|
|
273
|
+
var _pluginInjectionApi$d6;
|
|
272
274
|
var tr = editorView.state.tr,
|
|
273
275
|
dispatch = editorView.dispatch;
|
|
274
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
276
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d6 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : _pluginInjectionApi$d6.actions.attachAnalyticsEvent({
|
|
275
277
|
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
276
278
|
action: _analytics.ACTION.VISITED,
|
|
277
279
|
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
@@ -301,7 +303,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
301
303
|
type: 'separator'
|
|
302
304
|
});
|
|
303
305
|
}
|
|
304
|
-
var _ref = (_pluginInjectionApi$
|
|
306
|
+
var _ref = (_pluginInjectionApi$d7 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d7 !== void 0 ? _pluginInjectionApi$d7 : {},
|
|
305
307
|
hoverDecoration = _ref.hoverDecoration;
|
|
306
308
|
var removeButton = {
|
|
307
309
|
id: 'editor.media.delete',
|
|
@@ -330,7 +332,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
330
332
|
return items;
|
|
331
333
|
};
|
|
332
334
|
var floatingToolbar = function floatingToolbar(state, intl) {
|
|
333
|
-
var _pluginInjectionApi$
|
|
335
|
+
var _pluginInjectionApi$d8;
|
|
334
336
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
335
337
|
var pluginInjectionApi = arguments.length > 3 ? arguments[3] : undefined;
|
|
336
338
|
var _state$schema$nodes = state.schema.nodes,
|
|
@@ -346,7 +348,7 @@ var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
346
348
|
getEditorFeatureFlags = options.getEditorFeatureFlags;
|
|
347
349
|
var mediaPluginState = _pluginKey.stateKey.getState(state);
|
|
348
350
|
var mediaLinkingState = (0, _linking2.getMediaLinkingState)(state);
|
|
349
|
-
var _ref2 = (_pluginInjectionApi$
|
|
351
|
+
var _ref2 = (_pluginInjectionApi$d8 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d8 !== void 0 ? _pluginInjectionApi$d8 : {},
|
|
350
352
|
hoverDecoration = _ref2.hoverDecoration;
|
|
351
353
|
if (!mediaPluginState || mediaPluginState.isResizing) {
|
|
352
354
|
return;
|
|
@@ -380,20 +382,22 @@ var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
380
382
|
selectedNodeType = state.selection.node.type;
|
|
381
383
|
}
|
|
382
384
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
385
|
+
var _pluginInjectionApi$d9, _pluginInjectionApi$d10;
|
|
383
386
|
var mediaOffset = state.selection.$from.parentOffset + 1;
|
|
384
387
|
baseToolbar.getDomRef = function () {
|
|
385
388
|
var _mediaPluginState$ele;
|
|
386
389
|
var selector = (0, _mediaFilmstrip.mediaFilmstripItemDOMSelector)(mediaOffset);
|
|
387
390
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
388
391
|
};
|
|
389
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration);
|
|
392
|
+
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d9 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d9 === void 0 ? void 0 : (_pluginInjectionApi$d10 = _pluginInjectionApi$d9.analytics) === null || _pluginInjectionApi$d10 === void 0 ? void 0 : _pluginInjectionApi$d10.actions);
|
|
390
393
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
394
|
+
var _pluginInjectionApi$d11, _pluginInjectionApi$d12;
|
|
391
395
|
baseToolbar.getDomRef = function () {
|
|
392
396
|
var _mediaPluginState$ele2;
|
|
393
397
|
var element = (_mediaPluginState$ele2 = mediaPluginState.element) === null || _mediaPluginState$ele2 === void 0 ? void 0 : _mediaPluginState$ele2.querySelector(".".concat(_styles.MediaInlineNodeSelector));
|
|
394
398
|
return element || mediaPluginState.element;
|
|
395
399
|
};
|
|
396
|
-
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration);
|
|
400
|
+
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d11 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d11 === void 0 ? void 0 : (_pluginInjectionApi$d12 = _pluginInjectionApi$d11.analytics) === null || _pluginInjectionApi$d12 === void 0 ? void 0 : _pluginInjectionApi$d12.actions);
|
|
397
401
|
} else {
|
|
398
402
|
baseToolbar.getDomRef = function () {
|
|
399
403
|
var _mediaPluginState$ele3;
|
|
@@ -58,7 +58,8 @@ var getLinkingToolbar = function getLinkingToolbar(toolbarBaseConfig, mediaLinki
|
|
|
58
58
|
intl: intl,
|
|
59
59
|
editing: editing,
|
|
60
60
|
onUnlink: function onUnlink() {
|
|
61
|
-
|
|
61
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
62
|
+
return (0, _linking.unlink)(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions)(view.state, view.dispatch, view);
|
|
62
63
|
},
|
|
63
64
|
onBack: function onBack(href, meta) {
|
|
64
65
|
if (href.trim() && meta.inputMethod) {
|
|
@@ -67,14 +68,14 @@ var getLinkingToolbar = function getLinkingToolbar(toolbarBaseConfig, mediaLinki
|
|
|
67
68
|
(0, _linking.hideLinkingToolbar)(view.state, view.dispatch, view);
|
|
68
69
|
},
|
|
69
70
|
onCancel: function onCancel() {
|
|
70
|
-
var _pluginInjectionApi$
|
|
71
|
+
var _pluginInjectionApi$d3;
|
|
71
72
|
(0, _linking.hideLinkingToolbar)(view.state, view.dispatch, view, true);
|
|
72
73
|
/** Focus should move to the 'Add link' button when the toolbar closes
|
|
73
74
|
* and not close the floating toolbar.
|
|
74
75
|
*/
|
|
75
76
|
var tr = view.state.tr,
|
|
76
77
|
dispatch = view.dispatch;
|
|
77
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
78
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies.floatingToolbar.actions) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : _pluginInjectionApi$d3.forceFocusSelector(FORCE_FOCUS_SELECTOR)(tr);
|
|
78
79
|
dispatch(tr);
|
|
79
80
|
},
|
|
80
81
|
onSubmit: function onSubmit(href, meta) {
|