@atlaskit/editor-plugin-media 1.31.1 → 1.31.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/cjs/plugin.js +2 -2
- package/dist/cjs/pm-plugins/{keymap-media-single.js → keymap-media.js} +34 -16
- package/dist/es2019/plugin.js +1 -1
- package/dist/es2019/pm-plugins/{keymap-media-single.js → keymap-media.js} +34 -16
- package/dist/esm/plugin.js +1 -1
- package/dist/esm/pm-plugins/{keymap-media-single.js → keymap-media.js} +34 -16
- package/package.json +1 -1
- /package/dist/types/pm-plugins/{keymap-media-single.d.ts → keymap-media.d.ts} +0 -0
- /package/dist/types-ts4.5/pm-plugins/{keymap-media-single.d.ts → keymap-media.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 1.31.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#139335](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/139335)
|
|
8
|
+
[`ac5e66fc71394`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ac5e66fc71394) -
|
|
9
|
+
ED-24798 bug-fix: pressing Backspace before media that is nested in a quote should move your
|
|
10
|
+
selection to the media
|
|
11
|
+
|
|
3
12
|
## 1.31.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -21,7 +21,7 @@ var _lazyMediaSingle = require("./nodeviews/lazy-media-single");
|
|
|
21
21
|
var _altText = require("./pm-plugins/alt-text");
|
|
22
22
|
var _keymap = _interopRequireDefault(require("./pm-plugins/alt-text/keymap"));
|
|
23
23
|
var _keymap2 = _interopRequireDefault(require("./pm-plugins/keymap"));
|
|
24
|
-
var
|
|
24
|
+
var _keymapMedia = _interopRequireDefault(require("./pm-plugins/keymap-media"));
|
|
25
25
|
var _linking = _interopRequireDefault(require("./pm-plugins/linking"));
|
|
26
26
|
var _keymap3 = _interopRequireDefault(require("./pm-plugins/linking/keymap"));
|
|
27
27
|
var _main = require("./pm-plugins/main");
|
|
@@ -164,7 +164,7 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
164
164
|
name: 'mediaSingleKeymap',
|
|
165
165
|
plugin: function plugin(_ref7) {
|
|
166
166
|
var schema = _ref7.schema;
|
|
167
|
-
return (0,
|
|
167
|
+
return (0, _keymapMedia.default)(schema);
|
|
168
168
|
}
|
|
169
169
|
});
|
|
170
170
|
}
|
|
@@ -9,6 +9,7 @@ var _selection = require("@atlaskit/editor-common/selection");
|
|
|
9
9
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
10
|
var _commands = require("@atlaskit/editor-prosemirror/commands");
|
|
11
11
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
12
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
13
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
13
14
|
/**
|
|
14
15
|
* Check if is an empty selection at the start of the node
|
|
@@ -121,11 +122,12 @@ function handleSelectionAfterWrapRight(isEmptyNode) {
|
|
|
121
122
|
return true;
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
|
-
var
|
|
125
|
+
var backspaceAfterMediaNode = function backspaceAfterMediaNode(schema) {
|
|
125
126
|
var isEmptyNodeInSchema = (0, _utils.isEmptyNode)(schema);
|
|
126
127
|
return function (state, dispatch) {
|
|
127
128
|
var selection = state.selection,
|
|
128
|
-
schema = state.schema
|
|
129
|
+
schema = state.schema,
|
|
130
|
+
tr = state.tr;
|
|
129
131
|
var $from = selection.$from;
|
|
130
132
|
if (!isEmptySelectionAtStart(state.selection)) {
|
|
131
133
|
return false;
|
|
@@ -134,29 +136,45 @@ var maybeRemoveMediaSingleNode = function maybeRemoveMediaSingleNode(schema) {
|
|
|
134
136
|
return false;
|
|
135
137
|
}
|
|
136
138
|
var previousSibling = -1;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
+
|
|
140
|
+
// no media single or media group
|
|
141
|
+
if (!isSiblingOfType(state.selection, schema.nodes.mediaSingle, previousSibling) && !isSiblingOfType(state.selection, schema.nodes.mediaGroup, previousSibling)) {
|
|
139
142
|
return false;
|
|
140
143
|
}
|
|
141
|
-
var
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
var media = getSibling(state.selection, previousSibling);
|
|
145
|
+
|
|
146
|
+
// if media single
|
|
147
|
+
if (media.type === schema.nodes.mediaSingle) {
|
|
148
|
+
if (media.attrs.layout === 'wrap-right') {
|
|
149
|
+
return handleSelectionAfterWrapRight(isEmptyNodeInSchema)(state, dispatch);
|
|
150
|
+
}
|
|
151
|
+
if (dispatch) {
|
|
152
|
+
// Select media single, and remove paragraph if it's empty.
|
|
153
|
+
(0, _commands.selectNodeBackward)(state, function (tr) {
|
|
154
|
+
if (isEmptyNodeInSchema($from.parent) && !(0, _selection.atTheEndOfDoc)(state)) {
|
|
155
|
+
tr.replace($from.pos - 1, $from.pos + $from.parent.nodeSize - 1); // Remove node
|
|
156
|
+
}
|
|
157
|
+
dispatch(tr);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return true;
|
|
144
161
|
}
|
|
162
|
+
|
|
163
|
+
// if media group
|
|
145
164
|
if (dispatch) {
|
|
146
|
-
//
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
165
|
+
// select media group, and remove paragraph if it's empty.
|
|
166
|
+
if (isEmptyNodeInSchema($from.parent)) {
|
|
167
|
+
tr.replace($from.pos - 1, $from.pos + $from.parent.nodeSize - 1); // remove node
|
|
168
|
+
tr.setSelection(new _state.NodeSelection(tr.doc.resolve($from.pos - media.nodeSize))).scrollIntoView(); // select media
|
|
169
|
+
}
|
|
170
|
+
dispatch(tr);
|
|
153
171
|
}
|
|
154
172
|
return true;
|
|
155
173
|
};
|
|
156
174
|
};
|
|
157
175
|
function keymapPlugin(schema) {
|
|
158
176
|
var list = {};
|
|
159
|
-
var
|
|
160
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.backspace.common,
|
|
177
|
+
var backspaceAfterMediaCommand = backspaceAfterMediaNode(schema);
|
|
178
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.backspace.common, backspaceAfterMediaCommand, list);
|
|
161
179
|
return (0, _keymap.keymap)(list);
|
|
162
180
|
}
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -14,7 +14,7 @@ import { lazyMediaSingleView } from './nodeviews/lazy-media-single';
|
|
|
14
14
|
import { createPlugin as createMediaAltTextPlugin } from './pm-plugins/alt-text';
|
|
15
15
|
import keymapMediaAltTextPlugin from './pm-plugins/alt-text/keymap';
|
|
16
16
|
import keymapPlugin from './pm-plugins/keymap';
|
|
17
|
-
import keymapMediaSinglePlugin from './pm-plugins/keymap-media
|
|
17
|
+
import keymapMediaSinglePlugin from './pm-plugins/keymap-media';
|
|
18
18
|
import linkingPlugin from './pm-plugins/linking';
|
|
19
19
|
import keymapLinkingPlugin from './pm-plugins/linking/keymap';
|
|
20
20
|
import { createPlugin, stateKey } from './pm-plugins/main';
|
|
@@ -3,6 +3,7 @@ import { atTheEndOfDoc } from '@atlaskit/editor-common/selection';
|
|
|
3
3
|
import { isEmptyNode, isSelectionInsideLastNodeInDocument } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { selectNodeBackward } from '@atlaskit/editor-prosemirror/commands';
|
|
5
5
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
6
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
7
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -126,12 +127,13 @@ function handleSelectionAfterWrapRight(isEmptyNode) {
|
|
|
126
127
|
return true;
|
|
127
128
|
};
|
|
128
129
|
}
|
|
129
|
-
const
|
|
130
|
+
const backspaceAfterMediaNode = schema => {
|
|
130
131
|
const isEmptyNodeInSchema = isEmptyNode(schema);
|
|
131
132
|
return (state, dispatch) => {
|
|
132
133
|
const {
|
|
133
134
|
selection,
|
|
134
|
-
schema
|
|
135
|
+
schema,
|
|
136
|
+
tr
|
|
135
137
|
} = state;
|
|
136
138
|
const {
|
|
137
139
|
$from
|
|
@@ -143,29 +145,45 @@ const maybeRemoveMediaSingleNode = schema => {
|
|
|
143
145
|
return false;
|
|
144
146
|
}
|
|
145
147
|
const previousSibling = -1;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
|
|
149
|
+
// no media single or media group
|
|
150
|
+
if (!isSiblingOfType(state.selection, schema.nodes.mediaSingle, previousSibling) && !isSiblingOfType(state.selection, schema.nodes.mediaGroup, previousSibling)) {
|
|
148
151
|
return false;
|
|
149
152
|
}
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
const media = getSibling(state.selection, previousSibling);
|
|
154
|
+
|
|
155
|
+
// if media single
|
|
156
|
+
if (media.type === schema.nodes.mediaSingle) {
|
|
157
|
+
if (media.attrs.layout === 'wrap-right') {
|
|
158
|
+
return handleSelectionAfterWrapRight(isEmptyNodeInSchema)(state, dispatch);
|
|
159
|
+
}
|
|
160
|
+
if (dispatch) {
|
|
161
|
+
// Select media single, and remove paragraph if it's empty.
|
|
162
|
+
selectNodeBackward(state, tr => {
|
|
163
|
+
if (isEmptyNodeInSchema($from.parent) && !atTheEndOfDoc(state)) {
|
|
164
|
+
tr.replace($from.pos - 1, $from.pos + $from.parent.nodeSize - 1); // Remove node
|
|
165
|
+
}
|
|
166
|
+
dispatch(tr);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return true;
|
|
153
170
|
}
|
|
171
|
+
|
|
172
|
+
// if media group
|
|
154
173
|
if (dispatch) {
|
|
155
|
-
//
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
});
|
|
174
|
+
// select media group, and remove paragraph if it's empty.
|
|
175
|
+
if (isEmptyNodeInSchema($from.parent)) {
|
|
176
|
+
tr.replace($from.pos - 1, $from.pos + $from.parent.nodeSize - 1); // remove node
|
|
177
|
+
tr.setSelection(new NodeSelection(tr.doc.resolve($from.pos - media.nodeSize))).scrollIntoView(); // select media
|
|
178
|
+
}
|
|
179
|
+
dispatch(tr);
|
|
162
180
|
}
|
|
163
181
|
return true;
|
|
164
182
|
};
|
|
165
183
|
};
|
|
166
184
|
export default function keymapPlugin(schema) {
|
|
167
185
|
const list = {};
|
|
168
|
-
const
|
|
169
|
-
bindKeymapWithCommand(backspace.common,
|
|
186
|
+
const backspaceAfterMediaCommand = backspaceAfterMediaNode(schema);
|
|
187
|
+
bindKeymapWithCommand(backspace.common, backspaceAfterMediaCommand, list);
|
|
170
188
|
return keymap(list);
|
|
171
189
|
}
|
package/dist/esm/plugin.js
CHANGED
|
@@ -14,7 +14,7 @@ import { lazyMediaSingleView } from './nodeviews/lazy-media-single';
|
|
|
14
14
|
import { createPlugin as createMediaAltTextPlugin } from './pm-plugins/alt-text';
|
|
15
15
|
import keymapMediaAltTextPlugin from './pm-plugins/alt-text/keymap';
|
|
16
16
|
import keymapPlugin from './pm-plugins/keymap';
|
|
17
|
-
import keymapMediaSinglePlugin from './pm-plugins/keymap-media
|
|
17
|
+
import keymapMediaSinglePlugin from './pm-plugins/keymap-media';
|
|
18
18
|
import linkingPlugin from './pm-plugins/linking';
|
|
19
19
|
import keymapLinkingPlugin from './pm-plugins/linking/keymap';
|
|
20
20
|
import { createPlugin, stateKey } from './pm-plugins/main';
|
|
@@ -3,6 +3,7 @@ import { atTheEndOfDoc } from '@atlaskit/editor-common/selection';
|
|
|
3
3
|
import { isEmptyNode, isSelectionInsideLastNodeInDocument } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { selectNodeBackward } from '@atlaskit/editor-prosemirror/commands';
|
|
5
5
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
6
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
7
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -116,11 +117,12 @@ function handleSelectionAfterWrapRight(isEmptyNode) {
|
|
|
116
117
|
return true;
|
|
117
118
|
};
|
|
118
119
|
}
|
|
119
|
-
var
|
|
120
|
+
var backspaceAfterMediaNode = function backspaceAfterMediaNode(schema) {
|
|
120
121
|
var isEmptyNodeInSchema = isEmptyNode(schema);
|
|
121
122
|
return function (state, dispatch) {
|
|
122
123
|
var selection = state.selection,
|
|
123
|
-
schema = state.schema
|
|
124
|
+
schema = state.schema,
|
|
125
|
+
tr = state.tr;
|
|
124
126
|
var $from = selection.$from;
|
|
125
127
|
if (!isEmptySelectionAtStart(state.selection)) {
|
|
126
128
|
return false;
|
|
@@ -129,29 +131,45 @@ var maybeRemoveMediaSingleNode = function maybeRemoveMediaSingleNode(schema) {
|
|
|
129
131
|
return false;
|
|
130
132
|
}
|
|
131
133
|
var previousSibling = -1;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
+
|
|
135
|
+
// no media single or media group
|
|
136
|
+
if (!isSiblingOfType(state.selection, schema.nodes.mediaSingle, previousSibling) && !isSiblingOfType(state.selection, schema.nodes.mediaGroup, previousSibling)) {
|
|
134
137
|
return false;
|
|
135
138
|
}
|
|
136
|
-
var
|
|
137
|
-
|
|
138
|
-
|
|
139
|
+
var media = getSibling(state.selection, previousSibling);
|
|
140
|
+
|
|
141
|
+
// if media single
|
|
142
|
+
if (media.type === schema.nodes.mediaSingle) {
|
|
143
|
+
if (media.attrs.layout === 'wrap-right') {
|
|
144
|
+
return handleSelectionAfterWrapRight(isEmptyNodeInSchema)(state, dispatch);
|
|
145
|
+
}
|
|
146
|
+
if (dispatch) {
|
|
147
|
+
// Select media single, and remove paragraph if it's empty.
|
|
148
|
+
selectNodeBackward(state, function (tr) {
|
|
149
|
+
if (isEmptyNodeInSchema($from.parent) && !atTheEndOfDoc(state)) {
|
|
150
|
+
tr.replace($from.pos - 1, $from.pos + $from.parent.nodeSize - 1); // Remove node
|
|
151
|
+
}
|
|
152
|
+
dispatch(tr);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return true;
|
|
139
156
|
}
|
|
157
|
+
|
|
158
|
+
// if media group
|
|
140
159
|
if (dispatch) {
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
});
|
|
160
|
+
// select media group, and remove paragraph if it's empty.
|
|
161
|
+
if (isEmptyNodeInSchema($from.parent)) {
|
|
162
|
+
tr.replace($from.pos - 1, $from.pos + $from.parent.nodeSize - 1); // remove node
|
|
163
|
+
tr.setSelection(new NodeSelection(tr.doc.resolve($from.pos - media.nodeSize))).scrollIntoView(); // select media
|
|
164
|
+
}
|
|
165
|
+
dispatch(tr);
|
|
148
166
|
}
|
|
149
167
|
return true;
|
|
150
168
|
};
|
|
151
169
|
};
|
|
152
170
|
export default function keymapPlugin(schema) {
|
|
153
171
|
var list = {};
|
|
154
|
-
var
|
|
155
|
-
bindKeymapWithCommand(backspace.common,
|
|
172
|
+
var backspaceAfterMediaCommand = backspaceAfterMediaNode(schema);
|
|
173
|
+
bindKeymapWithCommand(backspace.common, backspaceAfterMediaCommand, list);
|
|
156
174
|
return keymap(list);
|
|
157
175
|
}
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|