@atlaskit/editor-core 187.18.1 → 187.19.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/labs/next/presets/default.js +2 -1
- package/dist/cjs/labs/next/presets/universal.js +2 -1
- package/dist/cjs/plugins/base/index.js +0 -7
- package/dist/cjs/plugins/code-block/index.js +1 -1
- package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +98 -95
- package/dist/cjs/plugins/composition/index.js +33 -0
- package/dist/cjs/plugins/{base/pm-plugins/composition.js → composition/pm-plugins/main.js} +8 -14
- package/dist/cjs/plugins/{image-upload → composition}/pm-plugins/plugin-key.js +3 -3
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/paste/pm-plugins/main.js +2 -6
- package/dist/cjs/plugins/placeholder/index.js +2 -2
- package/dist/cjs/utils/clipboard.js +5 -27
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/labs/next/presets/default.js +2 -1
- package/dist/es2019/labs/next/presets/universal.js +2 -1
- package/dist/es2019/plugins/base/index.js +0 -5
- package/dist/es2019/plugins/code-block/index.js +1 -1
- package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +107 -104
- package/dist/es2019/plugins/composition/index.js +23 -0
- package/dist/es2019/plugins/{base/pm-plugins/composition.js → composition/pm-plugins/main.js} +7 -12
- package/dist/es2019/plugins/{image-upload → composition}/pm-plugins/plugin-key.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/paste/pm-plugins/main.js +2 -2
- package/dist/es2019/plugins/placeholder/index.js +2 -2
- package/dist/es2019/utils/clipboard.js +0 -16
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/labs/next/presets/default.js +2 -1
- package/dist/esm/labs/next/presets/universal.js +2 -1
- package/dist/esm/plugins/base/index.js +0 -7
- package/dist/esm/plugins/code-block/index.js +1 -1
- package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +98 -95
- package/dist/esm/plugins/composition/index.js +25 -0
- package/dist/esm/plugins/{base/pm-plugins/composition.js → composition/pm-plugins/main.js} +7 -12
- package/dist/esm/plugins/{image-upload → composition}/pm-plugins/plugin-key.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/paste/pm-plugins/main.js +2 -2
- package/dist/esm/plugins/placeholder/index.js +2 -2
- package/dist/esm/utils/clipboard.js +4 -23
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/labs/next/presets/default.d.ts +16 -0
- package/dist/types/plugins/code-block/index.d.ts +6 -4
- package/dist/types/plugins/code-block/pm-plugins/ide-ux.d.ts +4 -2
- package/dist/types/plugins/composition/index.d.ts +8 -0
- package/dist/types/plugins/composition/pm-plugins/main.d.ts +4 -0
- package/dist/types/plugins/composition/pm-plugins/plugin-key.d.ts +6 -0
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/insert-block/index.d.ts +1 -1
- package/dist/types/plugins/placeholder/index.d.ts +2 -1
- package/dist/types/utils/clipboard.d.ts +0 -3
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +20 -0
- package/dist/types-ts4.5/plugins/code-block/index.d.ts +6 -4
- package/dist/types-ts4.5/plugins/code-block/pm-plugins/ide-ux.d.ts +4 -2
- package/dist/types-ts4.5/plugins/composition/index.d.ts +8 -0
- package/dist/types-ts4.5/plugins/composition/pm-plugins/main.d.ts +4 -0
- package/dist/types-ts4.5/plugins/composition/pm-plugins/plugin-key.d.ts +6 -0
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/insert-block/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/placeholder/index.d.ts +3 -1
- package/dist/types-ts4.5/utils/clipboard.d.ts +0 -3
- package/package.json +4 -3
- package/dist/cjs/plugins/image-upload/index.js +0 -45
- package/dist/cjs/plugins/image-upload/pm-plugins/actions.js +0 -19
- package/dist/cjs/plugins/image-upload/pm-plugins/commands-toolbar.js +0 -19
- package/dist/cjs/plugins/image-upload/pm-plugins/commands.js +0 -40
- package/dist/cjs/plugins/image-upload/pm-plugins/input-rule.js +0 -31
- package/dist/cjs/plugins/image-upload/pm-plugins/main.js +0 -194
- package/dist/cjs/plugins/image-upload/types.js +0 -5
- package/dist/cjs/plugins/image-upload/utils.js +0 -40
- package/dist/cjs/utils/drag-drop.js +0 -19
- package/dist/es2019/plugins/image-upload/index.js +0 -34
- package/dist/es2019/plugins/image-upload/pm-plugins/actions.js +0 -8
- package/dist/es2019/plugins/image-upload/pm-plugins/commands-toolbar.js +0 -12
- package/dist/es2019/plugins/image-upload/pm-plugins/commands.js +0 -28
- package/dist/es2019/plugins/image-upload/pm-plugins/input-rule.js +0 -25
- package/dist/es2019/plugins/image-upload/pm-plugins/main.js +0 -159
- package/dist/es2019/plugins/image-upload/types.js +0 -1
- package/dist/es2019/plugins/image-upload/utils.js +0 -38
- package/dist/es2019/utils/drag-drop.js +0 -9
- package/dist/esm/plugins/image-upload/index.js +0 -37
- package/dist/esm/plugins/image-upload/pm-plugins/actions.js +0 -12
- package/dist/esm/plugins/image-upload/pm-plugins/commands-toolbar.js +0 -12
- package/dist/esm/plugins/image-upload/pm-plugins/commands.js +0 -32
- package/dist/esm/plugins/image-upload/pm-plugins/input-rule.js +0 -23
- package/dist/esm/plugins/image-upload/pm-plugins/main.js +0 -186
- package/dist/esm/plugins/image-upload/types.js +0 -1
- package/dist/esm/plugins/image-upload/utils.js +0 -31
- package/dist/esm/utils/drag-drop.js +0 -11
- package/dist/types/plugins/base/pm-plugins/composition.d.ts +0 -9
- package/dist/types/plugins/image-upload/index.d.ts +0 -16
- package/dist/types/plugins/image-upload/pm-plugins/actions.d.ts +0 -3
- package/dist/types/plugins/image-upload/pm-plugins/commands-toolbar.d.ts +0 -3
- package/dist/types/plugins/image-upload/pm-plugins/commands.d.ts +0 -5
- package/dist/types/plugins/image-upload/pm-plugins/input-rule.d.ts +0 -5
- package/dist/types/plugins/image-upload/pm-plugins/main.d.ts +0 -4
- package/dist/types/plugins/image-upload/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types/plugins/image-upload/types.d.ts +0 -18
- package/dist/types/plugins/image-upload/utils.d.ts +0 -5
- package/dist/types/utils/drag-drop.d.ts +0 -2
- package/dist/types-ts4.5/plugins/base/pm-plugins/composition.d.ts +0 -9
- package/dist/types-ts4.5/plugins/image-upload/index.d.ts +0 -16
- package/dist/types-ts4.5/plugins/image-upload/pm-plugins/actions.d.ts +0 -3
- package/dist/types-ts4.5/plugins/image-upload/pm-plugins/commands-toolbar.d.ts +0 -3
- package/dist/types-ts4.5/plugins/image-upload/pm-plugins/commands.d.ts +0 -5
- package/dist/types-ts4.5/plugins/image-upload/pm-plugins/input-rule.d.ts +0 -5
- package/dist/types-ts4.5/plugins/image-upload/pm-plugins/main.d.ts +0 -4
- package/dist/types-ts4.5/plugins/image-upload/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/image-upload/types.d.ts +0 -18
- package/dist/types-ts4.5/plugins/image-upload/utils.d.ts +0 -5
- package/dist/types-ts4.5/utils/drag-drop.d.ts +0 -2
|
@@ -9,121 +9,124 @@ import { getAutoClosingBracketInfo, shouldAutoCloseBracket } from '../ide-ux/bra
|
|
|
9
9
|
import { getAutoClosingQuoteInfo, shouldAutoCloseQuote } from '../ide-ux/quote-handling';
|
|
10
10
|
import { getEndOfCurrentLine, getStartOfCurrentLine, isCursorInsideCodeBlock, isSelectionEntirelyInsideCodeBlock, getLineInfo } from '../ide-ux/line-handling';
|
|
11
11
|
import { insertIndent, outdent, indent, insertNewlineWithIndent } from '../ide-ux/commands';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const afterText = getEndOfCurrentLine(state).text;
|
|
23
|
-
|
|
24
|
-
// If text is a closing bracket/quote and we've already inserted it, move the selection after
|
|
25
|
-
if (isCursorBeforeClosingCharacter(afterText) && isClosingCharacter(text) && afterText.startsWith(text)) {
|
|
26
|
-
dispatch(setTextSelection(to + text.length)(state.tr));
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Automatically add right-hand side bracket when user types the left bracket
|
|
31
|
-
if (shouldAutoCloseBracket(beforeText, afterText)) {
|
|
32
|
-
const {
|
|
33
|
-
left,
|
|
34
|
-
right
|
|
35
|
-
} = getAutoClosingBracketInfo(beforeText + text, afterText);
|
|
36
|
-
if (left && right) {
|
|
37
|
-
const bracketPair = state.schema.text(text + right);
|
|
38
|
-
let tr = state.tr.replaceWith(from, to, bracketPair);
|
|
39
|
-
dispatch(setTextSelection(from + text.length)(tr));
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Automatically add closing quote when user types a starting quote
|
|
45
|
-
if (shouldAutoCloseQuote(beforeText, afterText)) {
|
|
46
|
-
const {
|
|
47
|
-
left: leftQuote,
|
|
48
|
-
right: rightQuote
|
|
49
|
-
} = getAutoClosingQuoteInfo(beforeText + text, afterText);
|
|
50
|
-
if (leftQuote && rightQuote) {
|
|
51
|
-
const quotePair = state.schema.text(text + rightQuote);
|
|
52
|
-
let tr = state.tr.replaceWith(from, to, quotePair);
|
|
53
|
-
dispatch(setTextSelection(from + text.length)(tr));
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
59
|
-
},
|
|
60
|
-
handleKeyDown: keydownHandler({
|
|
61
|
-
Backspace: (state, dispatch) => {
|
|
62
|
-
if (isCursorInsideCodeBlock(state)) {
|
|
63
|
-
const $cursor = getCursor(state.selection);
|
|
12
|
+
const ideUX = pluginInjectionApi => {
|
|
13
|
+
return new SafePlugin({
|
|
14
|
+
props: {
|
|
15
|
+
handleTextInput(view, from, to, text) {
|
|
16
|
+
const {
|
|
17
|
+
state,
|
|
18
|
+
dispatch
|
|
19
|
+
} = view;
|
|
20
|
+
const compositionPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.composition.sharedState.currentState();
|
|
21
|
+
if (isCursorInsideCodeBlock(state) && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing)) {
|
|
64
22
|
const beforeText = getStartOfCurrentLine(state).text;
|
|
65
23
|
const afterText = getEndOfCurrentLine(state).text;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
} = getAutoClosingBracketInfo(beforeText, afterText);
|
|
71
|
-
if (leftBracket && rightBracket && hasTrailingMatchingBracket && dispatch) {
|
|
72
|
-
dispatch(state.tr.delete($cursor.pos - leftBracket.length, $cursor.pos + rightBracket.length));
|
|
24
|
+
|
|
25
|
+
// If text is a closing bracket/quote and we've already inserted it, move the selection after
|
|
26
|
+
if (isCursorBeforeClosingCharacter(afterText) && isClosingCharacter(text) && afterText.startsWith(text)) {
|
|
27
|
+
dispatch(setTextSelection(to + text.length)(state.tr));
|
|
73
28
|
return true;
|
|
74
29
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
30
|
+
|
|
31
|
+
// Automatically add right-hand side bracket when user types the left bracket
|
|
32
|
+
if (shouldAutoCloseBracket(beforeText, afterText)) {
|
|
33
|
+
const {
|
|
34
|
+
left,
|
|
35
|
+
right
|
|
36
|
+
} = getAutoClosingBracketInfo(beforeText + text, afterText);
|
|
37
|
+
if (left && right) {
|
|
38
|
+
const bracketPair = state.schema.text(text + right);
|
|
39
|
+
let tr = state.tr.replaceWith(from, to, bracketPair);
|
|
40
|
+
dispatch(setTextSelection(from + text.length)(tr));
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
83
43
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
44
|
+
|
|
45
|
+
// Automatically add closing quote when user types a starting quote
|
|
46
|
+
if (shouldAutoCloseQuote(beforeText, afterText)) {
|
|
47
|
+
const {
|
|
48
|
+
left: leftQuote,
|
|
49
|
+
right: rightQuote
|
|
50
|
+
} = getAutoClosingQuoteInfo(beforeText + text, afterText);
|
|
51
|
+
if (leftQuote && rightQuote) {
|
|
52
|
+
const quotePair = state.schema.text(text + rightQuote);
|
|
53
|
+
let tr = state.tr.replaceWith(from, to, quotePair);
|
|
54
|
+
dispatch(setTextSelection(from + text.length)(tr));
|
|
94
55
|
return true;
|
|
95
56
|
}
|
|
96
57
|
}
|
|
97
58
|
}
|
|
98
59
|
return false;
|
|
99
60
|
},
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
61
|
+
handleKeyDown: keydownHandler({
|
|
62
|
+
Backspace: (state, dispatch) => {
|
|
63
|
+
if (isCursorInsideCodeBlock(state)) {
|
|
64
|
+
const $cursor = getCursor(state.selection);
|
|
65
|
+
const beforeText = getStartOfCurrentLine(state).text;
|
|
66
|
+
const afterText = getEndOfCurrentLine(state).text;
|
|
67
|
+
const {
|
|
68
|
+
left: leftBracket,
|
|
69
|
+
right: rightBracket,
|
|
70
|
+
hasTrailingMatchingBracket
|
|
71
|
+
} = getAutoClosingBracketInfo(beforeText, afterText);
|
|
72
|
+
if (leftBracket && rightBracket && hasTrailingMatchingBracket && dispatch) {
|
|
73
|
+
dispatch(state.tr.delete($cursor.pos - leftBracket.length, $cursor.pos + rightBracket.length));
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
const {
|
|
77
|
+
left: leftQuote,
|
|
78
|
+
right: rightQuote,
|
|
79
|
+
hasTrailingMatchingQuote
|
|
80
|
+
} = getAutoClosingQuoteInfo(beforeText, afterText);
|
|
81
|
+
if (leftQuote && rightQuote && hasTrailingMatchingQuote && dispatch) {
|
|
82
|
+
dispatch(state.tr.delete($cursor.pos - leftQuote.length, $cursor.pos + rightQuote.length));
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
const {
|
|
86
|
+
indentToken: {
|
|
87
|
+
size,
|
|
88
|
+
token
|
|
89
|
+
},
|
|
90
|
+
indentText
|
|
91
|
+
} = getLineInfo(beforeText);
|
|
92
|
+
if (beforeText === indentText) {
|
|
93
|
+
if (indentText.endsWith(token.repeat(size)) && dispatch) {
|
|
94
|
+
dispatch(state.tr.delete($cursor.pos - (size - indentText.length % size || size), $cursor.pos));
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
105
99
|
return false;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
$from,
|
|
117
|
-
$to
|
|
118
|
-
} = state.selection;
|
|
119
|
-
const isFullCodeBlockSelection = $from.parentOffset === 0 && $to.parentOffset === $to.parent.nodeSize - 2;
|
|
120
|
-
if (!isFullCodeBlockSelection && dispatch) {
|
|
121
|
-
dispatch(state.tr.setSelection(TextSelection.create(state.doc, $from.start(), $to.end())));
|
|
122
|
-
return true;
|
|
100
|
+
},
|
|
101
|
+
Enter: filter(isSelectionEntirelyInsideCodeBlock, insertNewlineWithIndent),
|
|
102
|
+
'Mod-]': filter(isSelectionEntirelyInsideCodeBlock, indent),
|
|
103
|
+
'Mod-[': filter(isSelectionEntirelyInsideCodeBlock, outdent),
|
|
104
|
+
Tab: filter(isSelectionEntirelyInsideCodeBlock, (state, dispatch) => {
|
|
105
|
+
if (!dispatch) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
if (isCursorInsideCodeBlock(state)) {
|
|
109
|
+
return insertIndent(state, dispatch);
|
|
123
110
|
}
|
|
111
|
+
return indent(state, dispatch);
|
|
112
|
+
}),
|
|
113
|
+
'Shift-Tab': filter(isSelectionEntirelyInsideCodeBlock, outdent),
|
|
114
|
+
'Mod-a': (state, dispatch) => {
|
|
115
|
+
if (isSelectionEntirelyInsideCodeBlock(state)) {
|
|
116
|
+
const {
|
|
117
|
+
$from,
|
|
118
|
+
$to
|
|
119
|
+
} = state.selection;
|
|
120
|
+
const isFullCodeBlockSelection = $from.parentOffset === 0 && $to.parentOffset === $to.parent.nodeSize - 2;
|
|
121
|
+
if (!isFullCodeBlockSelection && dispatch) {
|
|
122
|
+
dispatch(state.tr.setSelection(TextSelection.create(state.doc, $from.start(), $to.end())));
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return false;
|
|
124
127
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
export default ideUX;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import createPlugin from './pm-plugins/main';
|
|
2
|
+
import { pluginKey } from './pm-plugins/plugin-key';
|
|
3
|
+
const composition = () => {
|
|
4
|
+
return {
|
|
5
|
+
name: 'composition',
|
|
6
|
+
getSharedState(editorState) {
|
|
7
|
+
var _pluginKey$getState;
|
|
8
|
+
if (!editorState) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
isComposing: !!((_pluginKey$getState = pluginKey.getState(editorState)) !== null && _pluginKey$getState !== void 0 && _pluginKey$getState.isComposing)
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
pmPlugins() {
|
|
16
|
+
return [{
|
|
17
|
+
name: 'composition',
|
|
18
|
+
plugin: () => createPlugin()
|
|
19
|
+
}];
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export default composition;
|
package/dist/es2019/plugins/{base/pm-plugins/composition.js → composition/pm-plugins/main.js}
RENAMED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
2
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
|
|
4
|
-
|
|
5
|
-
export const isComposing = state => {
|
|
6
|
-
var _compositionPluginKey;
|
|
7
|
-
return !!((_compositionPluginKey = compositionPluginKey.getState(state)) !== null && _compositionPluginKey !== void 0 && _compositionPluginKey.isComposing);
|
|
8
|
-
};
|
|
3
|
+
import { pluginKey } from './plugin-key';
|
|
9
4
|
const isLinux = () => navigator.userAgent.indexOf('Linux') >= 0;
|
|
10
5
|
export default (() => new SafePlugin({
|
|
11
|
-
key:
|
|
6
|
+
key: pluginKey,
|
|
12
7
|
state: {
|
|
13
8
|
init: () => ({
|
|
14
9
|
isComposing: false,
|
|
15
10
|
zeroWidthSpacePos: undefined
|
|
16
11
|
}),
|
|
17
12
|
apply: (tr, value) => {
|
|
18
|
-
const isComposing = tr.getMeta(
|
|
13
|
+
const isComposing = tr.getMeta(pluginKey);
|
|
19
14
|
const zeroWidthSpacePos = tr.getMeta('zeroWidthSpacePos');
|
|
20
15
|
if (typeof isComposing === 'undefined') {
|
|
21
16
|
return value;
|
|
@@ -32,7 +27,7 @@ export default (() => new SafePlugin({
|
|
|
32
27
|
const {
|
|
33
28
|
tr
|
|
34
29
|
} = view.state;
|
|
35
|
-
tr.setMeta(
|
|
30
|
+
tr.setMeta(pluginKey, true);
|
|
36
31
|
|
|
37
32
|
// only apply for linux and cursor is at start of line
|
|
38
33
|
if (isLinux() && view.state.selection.$from.parentOffset === 0) {
|
|
@@ -48,10 +43,10 @@ export default (() => new SafePlugin({
|
|
|
48
43
|
const {
|
|
49
44
|
tr
|
|
50
45
|
} = view.state;
|
|
51
|
-
tr.setMeta(
|
|
46
|
+
tr.setMeta(pluginKey, false);
|
|
52
47
|
if (isLinux()) {
|
|
53
|
-
var
|
|
54
|
-
const zeroWidthSpacePos = (
|
|
48
|
+
var _pluginKey$getState;
|
|
49
|
+
const zeroWidthSpacePos = (_pluginKey$getState = pluginKey.getState(view.state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.zeroWidthSpacePos;
|
|
55
50
|
if (typeof zeroWidthSpacePos !== 'undefined') {
|
|
56
51
|
tr.deleteRange(zeroWidthSpacePos, zeroWidthSpacePos + 1);
|
|
57
52
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
export const
|
|
2
|
+
export const pluginKey = new PluginKey('compositionPlugin');
|
|
@@ -10,7 +10,6 @@ export { default as 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';
|
|
13
|
-
export { default as imageUploadPlugin } from './image-upload';
|
|
14
13
|
export { default as insertBlockPlugin } from './insert-block';
|
|
15
14
|
export { default as jiraIssuePlugin } from './jira-issue';
|
|
16
15
|
export { default as layoutPlugin } from './layout';
|
|
@@ -5,7 +5,7 @@ import { MarkdownTransformer } from '@atlaskit/editor-markdown-transformer';
|
|
|
5
5
|
import { addLinkMetadata } from '@atlaskit/editor-common/card';
|
|
6
6
|
import { mapChildren } from '../../../utils/slice';
|
|
7
7
|
import { getExtensionAutoConvertersFromProvider } from '@atlaskit/editor-common/extensions';
|
|
8
|
-
import
|
|
8
|
+
import { isPastedFile as isPastedFileFromEvent } from '@atlaskit/editor-common/paste';
|
|
9
9
|
import { transformSliceForMedia } from '../../media/utils/media-single';
|
|
10
10
|
import { escapeLinks, htmlContainsSingleFile, isPastedFromWord, isPastedFromExcel, htmlHasInvalidLinkTags, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from '../util';
|
|
11
11
|
import { linkifyContent } from '@atlaskit/editor-common/utils';
|
|
@@ -95,7 +95,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
95
95
|
if ((_text = text) !== null && _text !== void 0 && _text.includes('\r')) {
|
|
96
96
|
text = text.replace(/\r/g, '');
|
|
97
97
|
}
|
|
98
|
-
const isPastedFile =
|
|
98
|
+
const isPastedFile = isPastedFileFromEvent(event);
|
|
99
99
|
const isPlainText = text && !html;
|
|
100
100
|
const isRichText = !!html;
|
|
101
101
|
|
|
@@ -4,7 +4,6 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
|
4
4
|
import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
export const pluginKey = new PluginKey('placeholderPlugin');
|
|
6
6
|
import { isTypeAheadOpen } from '../type-ahead/utils';
|
|
7
|
-
import { isComposing } from '../base/pm-plugins/composition';
|
|
8
7
|
function getPlaceholderState(editorState) {
|
|
9
8
|
return pluginKey.getState(editorState);
|
|
10
9
|
}
|
|
@@ -100,7 +99,8 @@ export function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api
|
|
|
100
99
|
placeholderText,
|
|
101
100
|
pos
|
|
102
101
|
} = getPlaceholderState(editorState);
|
|
103
|
-
|
|
102
|
+
const compositionPluginState = api === null || api === void 0 ? void 0 : api.dependencies.composition.sharedState.currentState();
|
|
103
|
+
if (hasPlaceholder && placeholderText && pos !== undefined && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing)) {
|
|
104
104
|
return createPlaceholderDecoration(editorState, placeholderText, pos);
|
|
105
105
|
}
|
|
106
106
|
return;
|
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
import * as clipboard from 'clipboard-polyfill';
|
|
2
|
-
export function checkClipboardTypes(type, item) {
|
|
3
|
-
const isDOMStringList = t => !t.indexOf && !!t.contains;
|
|
4
|
-
return isDOMStringList(type) ? type.contains(item) : type.indexOf(item) > -1;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
// Typeguard Function
|
|
8
|
-
export const isClipboardEvent = event => 'clipboardData' in event;
|
|
9
|
-
export function isPastedFile(rawEvent) {
|
|
10
|
-
const {
|
|
11
|
-
clipboardData
|
|
12
|
-
} = rawEvent;
|
|
13
|
-
if (!clipboardData) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
return checkClipboardTypes(clipboardData.types, 'Files');
|
|
17
|
-
}
|
|
18
2
|
const isClipboardApiSupported = () => !!navigator.clipboard && typeof navigator.clipboard.writeText === 'function';
|
|
19
3
|
const isIEClipboardApiSupported = () => window.clipboardData && typeof window.clipboardData.setData === 'function';
|
|
20
4
|
export const copyToClipboard = async textToCopy => {
|
package/dist/es2019/version.json
CHANGED
|
@@ -20,6 +20,7 @@ import { analyticsPlugin as deprecatedAnalyticsPlugin } from '../../../plugins';
|
|
|
20
20
|
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
21
21
|
import placeholderPlugin from '../../../plugins/placeholder';
|
|
22
22
|
import annotationPlugin from '../../../plugins/annotation';
|
|
23
|
+
import compositionPlugin from '../../../plugins/composition';
|
|
23
24
|
import quickInsertPlugin from '../../../plugins/quick-insert';
|
|
24
25
|
import selectionPlugin from '../../../plugins/selection';
|
|
25
26
|
import codeBlockPlugin from '../../../plugins/code-block';
|
|
@@ -53,7 +54,7 @@ export function createDefaultPreset(options) {
|
|
|
53
54
|
}]);
|
|
54
55
|
}
|
|
55
56
|
return builder;
|
|
56
|
-
}).add([pastePlugin, options.paste]).add(clipboardPlugin).add(focusPlugin).add([basePlugin, options.base]).add(decorationsPlugin).maybeAdd(undoRedoPlugin, function (p, builder) {
|
|
57
|
+
}).add([pastePlugin, options.paste]).add(clipboardPlugin).add(focusPlugin).add(compositionPlugin).add([basePlugin, options.base]).add(decorationsPlugin).maybeAdd(undoRedoPlugin, function (p, builder) {
|
|
57
58
|
var _options$featureFlags;
|
|
58
59
|
// The undo redo plugin needs to be add before the blockTypePlugin
|
|
59
60
|
if ((_options$featureFlags = options.featureFlags) !== null && _options$featureFlags !== void 0 && _options$featureFlags.undoRedoButtons) {
|
|
@@ -3,7 +3,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
5
|
import { createEditorSelectionAPI } from '../../../selection-api/api';
|
|
6
|
-
import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, datePlugin, emojiPlugin, extensionPlugin, fragmentMarkPlugin, helpDialogPlugin,
|
|
6
|
+
import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, datePlugin, emojiPlugin, extensionPlugin, fragmentMarkPlugin, helpDialogPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, listPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, mediaPlugin, mentionsPlugin, panelPlugin, placeholderTextPlugin, rulePlugin, saveOnEnterPlugin, tasksAndDecisionsPlugin, textColorPlugin, statusPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, scrollIntoViewPlugin, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, captionPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin, copyButtonPlugin, borderPlugin } from '../../../plugins';
|
|
7
|
+
import { imageUploadPlugin } from '@atlaskit/editor-plugin-image-upload';
|
|
7
8
|
import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
|
|
8
9
|
import { contextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
|
|
9
10
|
import { gridPlugin } from '@atlaskit/editor-plugin-grid';
|
|
@@ -14,7 +14,6 @@ import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
|
|
|
14
14
|
import scrollGutter from './pm-plugins/scroll-gutter';
|
|
15
15
|
import { keymap } from '@atlaskit/editor-common/keymaps';
|
|
16
16
|
import frozenEditor from './pm-plugins/frozen-editor';
|
|
17
|
-
import compositionPlugin from './pm-plugins/composition';
|
|
18
17
|
// Chrome >= 88
|
|
19
18
|
export var isChromeWithSelectionBug = browser.chrome && browser.chrome_version >= 88;
|
|
20
19
|
var basePlugin = function basePlugin(options, api) {
|
|
@@ -104,12 +103,6 @@ var basePlugin = function basePlugin(options, api) {
|
|
|
104
103
|
return disableSpellcheckingPlugin(featureFlags);
|
|
105
104
|
}
|
|
106
105
|
});
|
|
107
|
-
plugins.push({
|
|
108
|
-
name: 'compositionPlugin',
|
|
109
|
-
plugin: function plugin() {
|
|
110
|
-
return compositionPlugin();
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
106
|
return plugins;
|
|
114
107
|
},
|
|
115
108
|
nodes: function nodes() {
|