@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
|
@@ -12,9 +12,11 @@ import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
|
12
12
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
13
13
|
import classnames from 'classnames';
|
|
14
14
|
import { richMediaClassName, resizerStyles } from '@atlaskit/editor-common/styles';
|
|
15
|
-
import { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, calculateOffsetLeft, DEFAULT_IMAGE_WIDTH, calcMediaSingleMaxWidth } from '@atlaskit/editor-common/media-single';
|
|
15
|
+
import { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, calculateOffsetLeft, DEFAULT_IMAGE_WIDTH, calcMediaSingleMaxWidth } from '@atlaskit/editor-common/media-single';
|
|
16
16
|
import { findClosestSnap, getGuidelinesWithHighlights, generateDefaultGuidelines, generateDynamicGuidelines, getGuidelineSnaps } from '@atlaskit/editor-common/guideline';
|
|
17
17
|
import memoizeOne from 'memoize-one';
|
|
18
|
+
import throttle from 'lodash/throttle';
|
|
19
|
+
import { MEDIA_PLUGIN_IS_RESIZING_KEY, MEDIA_PLUGIN_RESIZING_WIDTH_KEY } from '../../pm-plugins/main';
|
|
18
20
|
export const resizerNextTestId = 'mediaSingle.resizerNext.testid';
|
|
19
21
|
|
|
20
22
|
// TODO: Create new fixed image size event
|
|
@@ -122,7 +124,16 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
122
124
|
dispatch
|
|
123
125
|
} = this.props.view;
|
|
124
126
|
const tr = state.tr;
|
|
125
|
-
tr.setMeta(
|
|
127
|
+
tr.setMeta(MEDIA_PLUGIN_IS_RESIZING_KEY, isResizing);
|
|
128
|
+
return dispatch(tr);
|
|
129
|
+
});
|
|
130
|
+
_defineProperty(this, "updateSizeInPluginState", width => {
|
|
131
|
+
const {
|
|
132
|
+
state,
|
|
133
|
+
dispatch
|
|
134
|
+
} = this.props.view;
|
|
135
|
+
const tr = state.tr;
|
|
136
|
+
tr.setMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY, width);
|
|
126
137
|
return dispatch(tr);
|
|
127
138
|
});
|
|
128
139
|
_defineProperty(this, "calcMaxWidth", memoizeOne((contentWidth, containerWidth, fullWidthMode) => {
|
|
@@ -167,11 +178,12 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
167
178
|
});
|
|
168
179
|
this.selectCurrentMediaNode();
|
|
169
180
|
this.setIsResizing(true);
|
|
181
|
+
this.updateSizeInPluginState(this.state.size.width);
|
|
170
182
|
// re-calucate guidelines
|
|
171
183
|
this.guidelines = this.getAllGuidelines();
|
|
172
184
|
return 0;
|
|
173
185
|
});
|
|
174
|
-
_defineProperty(this, "handleResize", (size, delta) => {
|
|
186
|
+
_defineProperty(this, "handleResize", throttle((size, delta) => {
|
|
175
187
|
const {
|
|
176
188
|
width: originalWidth,
|
|
177
189
|
height: originalHeight,
|
|
@@ -193,10 +205,11 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
193
205
|
},
|
|
194
206
|
snaps: guidelineSnaps.snaps
|
|
195
207
|
});
|
|
208
|
+
this.updateSizeInPluginState(width);
|
|
196
209
|
if (calculatedWidthWithLayout.layout !== layout) {
|
|
197
210
|
updateSize(width, calculatedWidthWithLayout.layout);
|
|
198
211
|
}
|
|
199
|
-
});
|
|
212
|
+
}, MEDIA_SINGLE_RESIZE_THROTTLE_TIME));
|
|
200
213
|
_defineProperty(this, "handleResizeStop", (size, delta) => {
|
|
201
214
|
const {
|
|
202
215
|
width: originalWidth,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { toggleMark } from '@atlaskit/editor-common/mark';
|
|
2
2
|
import { ACTIONS, pluginKey } from '../pm-plugins/main';
|
|
3
3
|
import { getDisabledState } from '../utils/disabled';
|
|
4
|
+
import { pluginCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
4
5
|
export const toggleColor = color => (state, dispatch) => {
|
|
5
6
|
const {
|
|
6
7
|
textColor
|
|
@@ -21,9 +22,9 @@ export const toggleColor = color => (state, dispatch) => {
|
|
|
21
22
|
color
|
|
22
23
|
});
|
|
23
24
|
state.tr.scrollIntoView();
|
|
24
|
-
toggleMark(textColor, {
|
|
25
|
+
pluginCommandToPMCommand(toggleMark(textColor, {
|
|
25
26
|
color
|
|
26
|
-
})(state, dispatch);
|
|
27
|
+
}))(state, dispatch);
|
|
27
28
|
}
|
|
28
29
|
return true;
|
|
29
30
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { getBreakoutMode } from './node-width';
|
|
3
3
|
import { processRawValue, hasDocAsParent, getStepRange, isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
4
|
+
export { findFarthestParentNode } from '@atlaskit/editor-common/utils';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Checks if a node has any content. Ignores node that only contain empty block nodes.
|
|
@@ -46,26 +47,6 @@ export function processRawFragmentValue(schema, value, providerFactory, sanitize
|
|
|
46
47
|
}
|
|
47
48
|
return Fragment.from(adfEntities);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Find the farthest node given a condition
|
|
52
|
-
* @param predicate Function to check the node
|
|
53
|
-
*/
|
|
54
|
-
export const findFarthestParentNode = predicate => $pos => {
|
|
55
|
-
let candidate = null;
|
|
56
|
-
for (let i = $pos.depth; i > 0; i--) {
|
|
57
|
-
const node = $pos.node(i);
|
|
58
|
-
if (predicate(node)) {
|
|
59
|
-
candidate = {
|
|
60
|
-
pos: i > 0 ? $pos.before(i) : 0,
|
|
61
|
-
start: $pos.start(i),
|
|
62
|
-
depth: i,
|
|
63
|
-
node
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return candidate;
|
|
68
|
-
};
|
|
69
50
|
export const isSelectionEndOfParagraph = state => state.selection.$to.parent.type === state.schema.nodes.paragraph && state.selection.$to.pos === state.doc.resolve(state.selection.$to.pos).end();
|
|
70
51
|
export function getChangedNodesIn({
|
|
71
52
|
tr,
|
|
@@ -2,7 +2,7 @@ import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
|
|
|
2
2
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
3
3
|
import { FakeTextCursorSelection } from '../plugins/fake-text-cursor/cursor';
|
|
4
4
|
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
|
|
5
|
+
export { isEmptyNode, isSelectionInsideLastNodeInDocument, checkNodeDown, insideTableCell, isInListItem } from '@atlaskit/editor-common/utils';
|
|
6
6
|
export { insideTable } from '@atlaskit/editor-common/core-utils';
|
|
7
7
|
export { isNodeEmpty, findFarthestParentNode, isSelectionEndOfParagraph, nodesBetweenChanged, getNodesCount } from './document';
|
|
8
8
|
export { sanitiseMarksInSelection } from './mark';
|
|
@@ -15,11 +15,6 @@ function isMarkTypeCompatibleWithMark(markType, mark) {
|
|
|
15
15
|
function isMarkTypeAllowedInNode(markType, state) {
|
|
16
16
|
return toggleMark(markType)(state);
|
|
17
17
|
}
|
|
18
|
-
export function isSelectionInsideLastNodeInDocument(selection) {
|
|
19
|
-
const docNode = selection.$anchor.node(0);
|
|
20
|
-
const rootNode = selection.$anchor.node(1);
|
|
21
|
-
return docNode.lastChild === rootNode;
|
|
22
|
-
}
|
|
23
18
|
export function getCursor(selection) {
|
|
24
19
|
return selection.$cursor || undefined;
|
|
25
20
|
}
|
|
@@ -67,36 +62,6 @@ export function isMarkTypeAllowedInCurrentSelection(markType, state) {
|
|
|
67
62
|
return allowedInActiveMarks;
|
|
68
63
|
});
|
|
69
64
|
}
|
|
70
|
-
export function checkNodeDown(selection, doc, filter) {
|
|
71
|
-
const ancestorDepth = findAncestorPosition(doc, selection.$to).depth;
|
|
72
|
-
|
|
73
|
-
// Top level node
|
|
74
|
-
if (ancestorDepth === 0) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
const res = doc.resolve(selection.$to.after(ancestorDepth));
|
|
78
|
-
return res.nodeAfter ? filter(res.nodeAfter) : false;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Traverse the document until an "ancestor" is found. Any nestable block can be an ancestor.
|
|
83
|
-
*/
|
|
84
|
-
function findAncestorPosition(doc, pos) {
|
|
85
|
-
const nestableBlocks = ['blockquote', 'bulletList', 'orderedList'];
|
|
86
|
-
if (pos.depth === 1) {
|
|
87
|
-
return pos;
|
|
88
|
-
}
|
|
89
|
-
let node = pos.node(pos.depth);
|
|
90
|
-
let newPos = pos;
|
|
91
|
-
while (pos.depth >= 1) {
|
|
92
|
-
pos = doc.resolve(pos.before(pos.depth));
|
|
93
|
-
node = pos.node(pos.depth);
|
|
94
|
-
if (node && nestableBlocks.indexOf(node.type.name) !== -1) {
|
|
95
|
-
newPos = pos;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return newPos;
|
|
99
|
-
}
|
|
100
65
|
const transformer = new JSONTransformer();
|
|
101
66
|
export function toJSON(node) {
|
|
102
67
|
return transformer.encode(node);
|
|
@@ -142,69 +107,6 @@ export function whichTransitionEvent() {
|
|
|
142
107
|
export const isTemporary = id => {
|
|
143
108
|
return id.indexOf('temporary:') === 0;
|
|
144
109
|
};
|
|
145
|
-
export const isEmptyNode = schema => {
|
|
146
|
-
const {
|
|
147
|
-
doc,
|
|
148
|
-
paragraph,
|
|
149
|
-
codeBlock,
|
|
150
|
-
blockquote,
|
|
151
|
-
panel,
|
|
152
|
-
heading,
|
|
153
|
-
listItem,
|
|
154
|
-
bulletList,
|
|
155
|
-
orderedList,
|
|
156
|
-
taskList,
|
|
157
|
-
taskItem,
|
|
158
|
-
decisionList,
|
|
159
|
-
decisionItem,
|
|
160
|
-
media,
|
|
161
|
-
mediaGroup,
|
|
162
|
-
mediaSingle
|
|
163
|
-
} = schema.nodes;
|
|
164
|
-
const innerIsEmptyNode = node => {
|
|
165
|
-
switch (node.type) {
|
|
166
|
-
case media:
|
|
167
|
-
case mediaGroup:
|
|
168
|
-
case mediaSingle:
|
|
169
|
-
return false;
|
|
170
|
-
case paragraph:
|
|
171
|
-
case codeBlock:
|
|
172
|
-
case heading:
|
|
173
|
-
case taskItem:
|
|
174
|
-
case decisionItem:
|
|
175
|
-
return node.content.size === 0;
|
|
176
|
-
case blockquote:
|
|
177
|
-
case panel:
|
|
178
|
-
case listItem:
|
|
179
|
-
return node.content.size === 2 && innerIsEmptyNode(node.content.firstChild);
|
|
180
|
-
case bulletList:
|
|
181
|
-
case orderedList:
|
|
182
|
-
return node.content.size === 4 && innerIsEmptyNode(node.content.firstChild);
|
|
183
|
-
case taskList:
|
|
184
|
-
case decisionList:
|
|
185
|
-
return node.content.size === 2 && innerIsEmptyNode(node.content.firstChild);
|
|
186
|
-
case doc:
|
|
187
|
-
let isEmpty = true;
|
|
188
|
-
node.content.forEach(child => {
|
|
189
|
-
isEmpty = isEmpty && innerIsEmptyNode(child);
|
|
190
|
-
});
|
|
191
|
-
return isEmpty;
|
|
192
|
-
default:
|
|
193
|
-
return isNodeEmpty(node);
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
return innerIsEmptyNode;
|
|
197
|
-
};
|
|
198
|
-
export const insideTableCell = state => {
|
|
199
|
-
const {
|
|
200
|
-
tableCell,
|
|
201
|
-
tableHeader
|
|
202
|
-
} = state.schema.nodes;
|
|
203
|
-
return hasParentNodeOfType([tableCell, tableHeader])(state.selection);
|
|
204
|
-
};
|
|
205
|
-
export const isInListItem = state => {
|
|
206
|
-
return hasParentNodeOfType(state.schema.nodes.listItem)(state.selection);
|
|
207
|
-
};
|
|
208
110
|
export const hasOpenEnd = slice => {
|
|
209
111
|
return slice.openStart > 0 || slice.openEnd > 0;
|
|
210
112
|
};
|
|
@@ -1,51 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { GapCursorSelection } from '../../plugins/selection/gap-cursor/selection';
|
|
3
|
-
export function atTheEndOfDoc(state) {
|
|
4
|
-
const {
|
|
5
|
-
selection,
|
|
6
|
-
doc
|
|
7
|
-
} = state;
|
|
8
|
-
return doc.nodeSize - selection.$to.pos - 2 === selection.$to.depth;
|
|
9
|
-
}
|
|
10
|
-
export function atTheBeginningOfDoc(state) {
|
|
11
|
-
const {
|
|
12
|
-
selection
|
|
13
|
-
} = state;
|
|
14
|
-
return selection.$from.pos === selection.$from.depth;
|
|
15
|
-
}
|
|
16
|
-
export function atTheEndOfBlock(state) {
|
|
17
|
-
const {
|
|
18
|
-
selection
|
|
19
|
-
} = state;
|
|
20
|
-
const {
|
|
21
|
-
$to
|
|
22
|
-
} = selection;
|
|
23
|
-
if (selection instanceof GapCursorSelection) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
if (selection instanceof NodeSelection && selection.node.isBlock) {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
return endPositionOfParent($to) === $to.pos + 1;
|
|
30
|
-
}
|
|
31
|
-
export function atTheBeginningOfBlock(state) {
|
|
32
|
-
const {
|
|
33
|
-
selection
|
|
34
|
-
} = state;
|
|
35
|
-
const {
|
|
36
|
-
$from
|
|
37
|
-
} = selection;
|
|
38
|
-
if (selection instanceof GapCursorSelection) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
if (selection instanceof NodeSelection && selection.node.isBlock) {
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
return startPositionOfParent($from) === $from.pos;
|
|
45
|
-
}
|
|
46
|
-
export function startPositionOfParent(resolvedPos) {
|
|
47
|
-
return resolvedPos.start(resolvedPos.depth);
|
|
48
|
-
}
|
|
49
|
-
export function endPositionOfParent(resolvedPos) {
|
|
50
|
-
return resolvedPos.end(resolvedPos.depth) + 1;
|
|
51
|
-
}
|
|
1
|
+
export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, startPositionOfParent } from '@atlaskit/editor-common/selection';
|
package/dist/es2019/version.json
CHANGED
|
@@ -7,32 +7,33 @@ import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
|
7
7
|
import { EVENT_TYPE, ACTION_SUBJECT_ID, ACTION_SUBJECT, ACTION } from '@atlaskit/editor-common/analytics';
|
|
8
8
|
export var insertEmoji = function insertEmoji(editorAnalyticsAPI) {
|
|
9
9
|
return function (emojiId, inputMethod) {
|
|
10
|
-
return function (
|
|
11
|
-
var
|
|
10
|
+
return function (_ref) {
|
|
11
|
+
var tr = _ref.tr;
|
|
12
|
+
var doc = tr.doc,
|
|
13
|
+
selection = tr.selection;
|
|
14
|
+
var emoji = tr.doc.type.schema.nodes.emoji;
|
|
12
15
|
if (emoji && emojiId) {
|
|
13
16
|
var node = emoji.createChecked(_objectSpread(_objectSpread({}, emojiId), {}, {
|
|
14
17
|
text: emojiId.fallback || emojiId.shortName
|
|
15
18
|
}));
|
|
16
|
-
var textNode =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})(tr);
|
|
30
|
-
}
|
|
31
|
-
dispatch(tr.setSelection(Selection.near(tr.doc.resolve(state.selection.$from.pos + fragment.size))));
|
|
19
|
+
var textNode = doc.type.schema.text(' ');
|
|
20
|
+
var fragment = Fragment.fromArray([node, textNode]);
|
|
21
|
+
var newTr = safeInsert(fragment)(tr);
|
|
22
|
+
if (inputMethod) {
|
|
23
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
24
|
+
action: ACTION.INSERTED,
|
|
25
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
26
|
+
actionSubjectId: ACTION_SUBJECT_ID.EMOJI,
|
|
27
|
+
attributes: {
|
|
28
|
+
inputMethod: inputMethod
|
|
29
|
+
},
|
|
30
|
+
eventType: EVENT_TYPE.TRACK
|
|
31
|
+
})(newTr);
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
newTr.setSelection(Selection.near(newTr.doc.resolve(selection.$from.pos + fragment.size)));
|
|
34
|
+
return newTr;
|
|
34
35
|
}
|
|
35
|
-
return
|
|
36
|
+
return null;
|
|
36
37
|
};
|
|
37
38
|
};
|
|
38
39
|
};
|
|
@@ -15,6 +15,7 @@ import { IconEmoji } from '@atlaskit/editor-common/quick-insert';
|
|
|
15
15
|
import { EmojiNodeView } from './nodeviews/emoji';
|
|
16
16
|
import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
|
|
17
17
|
import { openTypeAheadAtCursor } from '../type-ahead/transforms/open-typeahead-at-cursor';
|
|
18
|
+
import { insertEmoji } from './commands/insert-emoji';
|
|
18
19
|
export var emojiToTypeaheadItem = function emojiToTypeaheadItem(emoji, emojiProvider) {
|
|
19
20
|
return {
|
|
20
21
|
title: emoji.shortName || '',
|
|
@@ -60,7 +61,8 @@ var isFullShortName = function isFullShortName(query) {
|
|
|
60
61
|
return query && query.length > 1 && query.charAt(0) === ':' && query.charAt(query.length - 1) === ':';
|
|
61
62
|
};
|
|
62
63
|
var TRIGGER = ':';
|
|
63
|
-
var emojiPlugin = function emojiPlugin(options, api) {
|
|
64
|
+
export var emojiPlugin = function emojiPlugin(options, api) {
|
|
65
|
+
var _api$dependencies$ana9;
|
|
64
66
|
var typeAhead = {
|
|
65
67
|
id: TypeAheadAvailableNodes.EMOJI,
|
|
66
68
|
trigger: TRIGGER,
|
|
@@ -182,6 +184,15 @@ var emojiPlugin = function emojiPlugin(options, api) {
|
|
|
182
184
|
}
|
|
183
185
|
}];
|
|
184
186
|
},
|
|
187
|
+
getSharedState: function getSharedState(editorState) {
|
|
188
|
+
if (!editorState) {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
return emojiPluginKey.getState(editorState);
|
|
192
|
+
},
|
|
193
|
+
commands: {
|
|
194
|
+
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)
|
|
195
|
+
},
|
|
185
196
|
pluginsOptions: {
|
|
186
197
|
quickInsert: function quickInsert(_ref7) {
|
|
187
198
|
var formatMessage = _ref7.formatMessage;
|
|
@@ -195,13 +206,13 @@ var emojiPlugin = function emojiPlugin(options, api) {
|
|
|
195
206
|
return /*#__PURE__*/React.createElement(IconEmoji, null);
|
|
196
207
|
},
|
|
197
208
|
action: function action(insert, state) {
|
|
198
|
-
var _api$dependencies$
|
|
209
|
+
var _api$dependencies$ana10;
|
|
199
210
|
var tr = insert(undefined);
|
|
200
211
|
openTypeAheadAtCursor({
|
|
201
212
|
triggerHandler: typeAhead,
|
|
202
213
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
203
214
|
})(tr);
|
|
204
|
-
api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
215
|
+
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({
|
|
205
216
|
action: ACTION.INVOKED,
|
|
206
217
|
actionSubject: ACTION_SUBJECT.TYPEAHEAD,
|
|
207
218
|
actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_EMOJI,
|
|
@@ -218,7 +229,6 @@ var emojiPlugin = function emojiPlugin(options, api) {
|
|
|
218
229
|
}
|
|
219
230
|
};
|
|
220
231
|
};
|
|
221
|
-
export default emojiPlugin;
|
|
222
232
|
|
|
223
233
|
/**
|
|
224
234
|
* Actions
|
|
@@ -6,7 +6,7 @@ export { default as clearMarksOnChangeToEmptyDocumentPlugin } from './clear-mark
|
|
|
6
6
|
export { default as codeBlockPlugin } from './code-block';
|
|
7
7
|
export { default as collabEditPlugin } from './collab-edit';
|
|
8
8
|
export { default as datePlugin } from './date';
|
|
9
|
-
export {
|
|
9
|
+
export { emojiPlugin } from './emoji';
|
|
10
10
|
export { default as extensionPlugin } from './extension';
|
|
11
11
|
export { default as fakeTextCursorPlugin } from './fake-text-cursor';
|
|
12
12
|
export { default as helpDialogPlugin } from './help-dialog';
|
|
@@ -5,7 +5,6 @@ import { stateKey as mediaStateKey } from '../media/pm-plugins/plugin-key';
|
|
|
5
5
|
import { isTypeAheadAllowed } from '../type-ahead/utils';
|
|
6
6
|
import { pluginKey as layoutStateKey } from '../layout';
|
|
7
7
|
import { insertMacroFromMacroBrowser } from '../macro';
|
|
8
|
-
import { emojiPluginKey } from '../emoji';
|
|
9
8
|
import WithPluginState from '../../ui/WithPluginState';
|
|
10
9
|
import ToolbarInsertBlock from './ui/ToolbarInsertBlock';
|
|
11
10
|
import { pluginKey as typeAheadPluginKey } from '../type-ahead/pm-plugins/key';
|
|
@@ -65,7 +64,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
|
|
|
65
64
|
blockTypeState: blockTypeStateKey,
|
|
66
65
|
mediaState: mediaStateKey,
|
|
67
66
|
macroState: macroStateKey,
|
|
68
|
-
emojiState: emojiPluginKey,
|
|
69
67
|
placeholderTextState: placeholderTextStateKey,
|
|
70
68
|
layoutState: layoutStateKey
|
|
71
69
|
},
|
|
@@ -74,7 +72,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
|
|
|
74
72
|
mediaState = _ref2.mediaState,
|
|
75
73
|
_ref2$macroState = _ref2.macroState,
|
|
76
74
|
macroState = _ref2$macroState === void 0 ? {} : _ref2$macroState,
|
|
77
|
-
emojiState = _ref2.emojiState,
|
|
78
75
|
placeholderTextState = _ref2.placeholderTextState,
|
|
79
76
|
layoutState = _ref2.layoutState;
|
|
80
77
|
return /*#__PURE__*/React.createElement(ToolbarInsertBlockWithInjectionApi, {
|
|
@@ -94,7 +91,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
|
|
|
94
91
|
blockTypeState: blockTypeState,
|
|
95
92
|
mediaState: mediaState,
|
|
96
93
|
macroState: macroState,
|
|
97
|
-
emojiState: emojiState,
|
|
98
94
|
placeholderTextState: placeholderTextState,
|
|
99
95
|
layoutState: layoutState,
|
|
100
96
|
providers: providers,
|
|
@@ -130,16 +126,16 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
|
|
|
130
126
|
blockTypeState = _ref3.blockTypeState,
|
|
131
127
|
mediaState = _ref3.mediaState,
|
|
132
128
|
macroState = _ref3.macroState,
|
|
133
|
-
emojiState = _ref3.emojiState,
|
|
134
129
|
placeholderTextState = _ref3.placeholderTextState,
|
|
135
130
|
layoutState = _ref3.layoutState,
|
|
136
131
|
featureFlags = _ref3.featureFlags;
|
|
137
132
|
var buttons = toolbarSizeToButtons(toolbarSize);
|
|
138
|
-
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention']),
|
|
133
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji']),
|
|
139
134
|
dateState = _useSharedPluginState.dateState,
|
|
140
135
|
hyperlinkState = _useSharedPluginState.hyperlinkState,
|
|
141
136
|
imageUploadState = _useSharedPluginState.imageUploadState,
|
|
142
|
-
mentionState = _useSharedPluginState.mentionState
|
|
137
|
+
mentionState = _useSharedPluginState.mentionState,
|
|
138
|
+
emojiState = _useSharedPluginState.emojiState;
|
|
143
139
|
return /*#__PURE__*/React.createElement(ToolbarInsertBlock, {
|
|
144
140
|
pluginInjectionApi: pluginInjectionApi,
|
|
145
141
|
buttons: buttons,
|
|
@@ -27,8 +27,7 @@ import { insertTaskDecisionCommand } from '../../../tasks-and-decisions/commands
|
|
|
27
27
|
import { insertExpand } from '../../../expand/commands';
|
|
28
28
|
import { createTypeAheadTools } from '../../../type-ahead/api';
|
|
29
29
|
import { updateStatusWithAnalytics } from '../../../status/actions';
|
|
30
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '
|
|
31
|
-
import { insertEmoji } from '../../../emoji/commands/insert-emoji';
|
|
30
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
32
31
|
import { messages } from './messages';
|
|
33
32
|
import { createItems } from './create-items';
|
|
34
33
|
import { BlockInsertMenu } from './block-insert-menu';
|
|
@@ -277,8 +276,10 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
277
276
|
};
|
|
278
277
|
});
|
|
279
278
|
_defineProperty(_assertThisInitialized(_this), "handleSelectedEmoji", function (emojiId) {
|
|
279
|
+
var _pluginInjectionApi$d8;
|
|
280
|
+
var pluginInjectionApi = _this.props.pluginInjectionApi;
|
|
280
281
|
_this.props.editorView.focus();
|
|
281
|
-
|
|
282
|
+
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, INPUT_METHOD.PICKER));
|
|
282
283
|
_this.toggleEmojiPicker();
|
|
283
284
|
return true;
|
|
284
285
|
});
|
|
@@ -36,6 +36,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
36
36
|
export { stateKey } from './plugin-key';
|
|
37
37
|
export var MEDIA_CONTENT_WRAP_CLASS_NAME = 'media-content-wrap';
|
|
38
38
|
export var MEDIA_PLUGIN_IS_RESIZING_KEY = 'mediaSinglePlugin.isResizing';
|
|
39
|
+
export var MEDIA_PLUGIN_RESIZING_WIDTH_KEY = 'mediaSinglePlugin.resizing-width';
|
|
39
40
|
var createDropPlaceholder = function createDropPlaceholder(intl, allowDropLine) {
|
|
40
41
|
var dropPlaceholder = document.createElement('div');
|
|
41
42
|
var createElement = React.createElement;
|
|
@@ -66,6 +67,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
66
67
|
_defineProperty(this, "layout", 'center');
|
|
67
68
|
_defineProperty(this, "mediaNodes", []);
|
|
68
69
|
_defineProperty(this, "isResizing", false);
|
|
70
|
+
_defineProperty(this, "resizingWidth", 0);
|
|
69
71
|
_defineProperty(this, "destroyed", false);
|
|
70
72
|
_defineProperty(this, "removeOnCloseListener", function () {});
|
|
71
73
|
_defineProperty(this, "onPopupToggleCallback", function () {});
|
|
@@ -485,6 +487,11 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
485
487
|
value: function setIsResizing(isResizing) {
|
|
486
488
|
this.isResizing = isResizing;
|
|
487
489
|
}
|
|
490
|
+
}, {
|
|
491
|
+
key: "setResizingWidth",
|
|
492
|
+
value: function setResizingWidth(width) {
|
|
493
|
+
this.resizingWidth = width;
|
|
494
|
+
}
|
|
488
495
|
}, {
|
|
489
496
|
key: "updateElement",
|
|
490
497
|
value: function updateElement() {
|
|
@@ -626,9 +633,13 @@ export var createPlugin = function createPlugin(_schema, options, reactContext,
|
|
|
626
633
|
},
|
|
627
634
|
apply: function apply(tr, pluginState) {
|
|
628
635
|
var isResizing = tr.getMeta(MEDIA_PLUGIN_IS_RESIZING_KEY);
|
|
636
|
+
var resizingWidth = tr.getMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY);
|
|
629
637
|
if (isResizing !== undefined) {
|
|
630
638
|
pluginState.setIsResizing(isResizing);
|
|
631
639
|
}
|
|
640
|
+
if (resizingWidth) {
|
|
641
|
+
pluginState.setResizingWidth(resizingWidth);
|
|
642
|
+
}
|
|
632
643
|
|
|
633
644
|
// remap editing media single position if we're in collab
|
|
634
645
|
if (typeof pluginState.editingMediaSinglePos === 'number') {
|
|
@@ -29,8 +29,8 @@ import ImageBorderItem from '../ui/ImageBorder';
|
|
|
29
29
|
import { currentMediaNodeBorderMark } from '../utils/current-media-node';
|
|
30
30
|
import { shouldShowImageBorder } from './imageBorder';
|
|
31
31
|
import { PixelEntry } from '../ui/PixelEntry';
|
|
32
|
-
import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
33
|
-
import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
32
|
+
import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_GUTTER_SIZE, calcMediaSinglePixelWidth } from '@atlaskit/editor-common/media-single';
|
|
33
|
+
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
34
34
|
var remove = function remove(state, dispatch) {
|
|
35
35
|
if (dispatch) {
|
|
36
36
|
dispatch(removeSelectedNode(state.tr));
|
|
@@ -258,12 +258,15 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
258
258
|
type: 'custom',
|
|
259
259
|
fallback: [],
|
|
260
260
|
render: function render(editorView) {
|
|
261
|
+
var _widthPlugin$sharedSt2, _widthPlugin$sharedSt3;
|
|
261
262
|
if (!editorView) {
|
|
262
263
|
return null;
|
|
263
264
|
}
|
|
264
265
|
var state = editorView.state,
|
|
265
266
|
dispatch = editorView.dispatch;
|
|
266
267
|
var selectedMediaSingleNode = getSelectedMediaSingle(state);
|
|
268
|
+
var contentWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || akEditorDefaultLayoutWidth;
|
|
269
|
+
var containerWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.width) || akEditorFullWidthLayoutWidth;
|
|
267
270
|
if (!selectedMediaSingleNode) {
|
|
268
271
|
return null;
|
|
269
272
|
}
|
|
@@ -271,13 +274,25 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
271
274
|
if (!selectedMediaNode) {
|
|
272
275
|
return null;
|
|
273
276
|
}
|
|
274
|
-
var
|
|
277
|
+
var _selectedMediaSingleN = selectedMediaSingleNode.node.attrs,
|
|
278
|
+
singleMediaWidth = _selectedMediaSingleN.width,
|
|
279
|
+
widthType = _selectedMediaSingleN.widthType,
|
|
280
|
+
layout = _selectedMediaSingleN.layout;
|
|
275
281
|
var _selectedMediaNode$at = selectedMediaNode.attrs,
|
|
276
282
|
mediaWidth = _selectedMediaNode$at.width,
|
|
277
283
|
mediaHeight = _selectedMediaNode$at.height;
|
|
284
|
+
var pixelWidth = calcMediaSinglePixelWidth({
|
|
285
|
+
width: singleMediaWidth,
|
|
286
|
+
widthType: widthType,
|
|
287
|
+
origWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
|
|
288
|
+
layout: layout,
|
|
289
|
+
contentWidth: contentWidth,
|
|
290
|
+
containerWidth: containerWidth,
|
|
291
|
+
gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
|
|
292
|
+
});
|
|
278
293
|
return /*#__PURE__*/React.createElement(PixelEntry, {
|
|
279
294
|
intl: intl,
|
|
280
|
-
width:
|
|
295
|
+
width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
|
|
281
296
|
mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
|
|
282
297
|
mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
|
|
283
298
|
validate: function validate(value) {
|
|
@@ -297,11 +312,9 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
297
312
|
});
|
|
298
313
|
}
|
|
299
314
|
});
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
});
|
|
304
|
-
}
|
|
315
|
+
toolbarButtons.push({
|
|
316
|
+
type: 'separator'
|
|
317
|
+
});
|
|
305
318
|
}
|
|
306
319
|
if (allowLinking && shouldShowMediaLinkToolbar(state)) {
|
|
307
320
|
toolbarButtons.push({
|
|
@@ -399,7 +412,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
399
412
|
var mediaLinkingState = getMediaLinkingState(state);
|
|
400
413
|
var _ref3 = (_pluginInjectionApi$d9 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d9 !== void 0 ? _pluginInjectionApi$d9 : {},
|
|
401
414
|
hoverDecoration = _ref3.hoverDecoration;
|
|
402
|
-
if (!mediaPluginState
|
|
415
|
+
if (!mediaPluginState) {
|
|
403
416
|
return;
|
|
404
417
|
}
|
|
405
418
|
var nodeType = allowMediaInline ? [mediaInline, mediaSingle, media] : [mediaSingle];
|