@atlaskit/editor-core 189.3.3 → 189.3.6
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 +15 -0
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/presets/default.js +2 -2
- package/dist/cjs/utils/deprecation-warnings.js +1 -3
- package/dist/cjs/utils/editorDeprecationWarnings.js +2 -4
- package/dist/cjs/version-wrapper.js +2 -5
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/presets/default.js +1 -1
- package/dist/es2019/utils/deprecation-warnings.js +1 -3
- package/dist/es2019/utils/editorDeprecationWarnings.js +2 -4
- package/dist/es2019/version-wrapper.js +1 -4
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/presets/default.js +1 -1
- package/dist/esm/utils/deprecation-warnings.js +1 -3
- package/dist/esm/utils/editorDeprecationWarnings.js +2 -4
- package/dist/esm/version-wrapper.js +1 -4
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/insert-block/types.d.ts +1 -1
- package/dist/types/presets/default.d.ts +1 -1
- package/dist/types/types/editor-props.d.ts +1 -1
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/version-wrapper.d.ts +0 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +1 -1
- package/dist/types-ts4.5/presets/default.d.ts +1 -1
- package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
- 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/version-wrapper.d.ts +0 -1
- package/package.json +4 -3
- package/report.api.md +1 -11
- package/tmp/api-report-tmp.d.ts +1 -11
- package/dist/cjs/plugins/code-block/actions.js +0 -201
- package/dist/cjs/plugins/code-block/ide-ux/bracket-handling.js +0 -35
- package/dist/cjs/plugins/code-block/ide-ux/commands.js +0 -115
- package/dist/cjs/plugins/code-block/ide-ux/line-handling.js +0 -81
- package/dist/cjs/plugins/code-block/ide-ux/paired-character-handling.js +0 -23
- package/dist/cjs/plugins/code-block/ide-ux/quote-handling.js +0 -40
- package/dist/cjs/plugins/code-block/index.js +0 -120
- package/dist/cjs/plugins/code-block/language-list.js +0 -62
- package/dist/cjs/plugins/code-block/nodeviews/code-block.js +0 -153
- package/dist/cjs/plugins/code-block/plugin-key.js +0 -8
- package/dist/cjs/plugins/code-block/pm-plugins/actions.js +0 -10
- package/dist/cjs/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +0 -113
- package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +0 -132
- package/dist/cjs/plugins/code-block/pm-plugins/input-rule.js +0 -68
- package/dist/cjs/plugins/code-block/pm-plugins/keymaps.js +0 -66
- package/dist/cjs/plugins/code-block/pm-plugins/main-state.js +0 -10
- package/dist/cjs/plugins/code-block/pm-plugins/main.js +0 -114
- package/dist/cjs/plugins/code-block/refresh-browser-selection.js +0 -29
- package/dist/cjs/plugins/code-block/toolbar.js +0 -131
- package/dist/cjs/plugins/code-block/transform-to-code-block.js +0 -84
- package/dist/cjs/plugins/code-block/types.js +0 -5
- package/dist/cjs/plugins/code-block/ui/class-names.js +0 -15
- package/dist/cjs/plugins/code-block/utils.js +0 -28
- package/dist/es2019/plugins/code-block/actions.js +0 -211
- package/dist/es2019/plugins/code-block/ide-ux/bracket-handling.js +0 -27
- package/dist/es2019/plugins/code-block/ide-ux/commands.js +0 -114
- package/dist/es2019/plugins/code-block/ide-ux/line-handling.js +0 -75
- package/dist/es2019/plugins/code-block/ide-ux/paired-character-handling.js +0 -12
- package/dist/es2019/plugins/code-block/ide-ux/quote-handling.js +0 -32
- package/dist/es2019/plugins/code-block/index.js +0 -104
- package/dist/es2019/plugins/code-block/language-list.js +0 -51
- package/dist/es2019/plugins/code-block/nodeviews/code-block.js +0 -126
- package/dist/es2019/plugins/code-block/plugin-key.js +0 -2
- package/dist/es2019/plugins/code-block/pm-plugins/actions.js +0 -4
- package/dist/es2019/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +0 -101
- package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +0 -135
- package/dist/es2019/plugins/code-block/pm-plugins/input-rule.js +0 -60
- package/dist/es2019/plugins/code-block/pm-plugins/keymaps.js +0 -58
- package/dist/es2019/plugins/code-block/pm-plugins/main-state.js +0 -2
- package/dist/es2019/plugins/code-block/pm-plugins/main.js +0 -102
- package/dist/es2019/plugins/code-block/refresh-browser-selection.js +0 -25
- package/dist/es2019/plugins/code-block/toolbar.js +0 -108
- package/dist/es2019/plugins/code-block/transform-to-code-block.js +0 -79
- package/dist/es2019/plugins/code-block/types.js +0 -1
- package/dist/es2019/plugins/code-block/ui/class-names.js +0 -9
- package/dist/es2019/plugins/code-block/utils.js +0 -4
- package/dist/esm/plugins/code-block/actions.js +0 -191
- package/dist/esm/plugins/code-block/ide-ux/bracket-handling.js +0 -29
- package/dist/esm/plugins/code-block/ide-ux/commands.js +0 -106
- package/dist/esm/plugins/code-block/ide-ux/line-handling.js +0 -73
- package/dist/esm/plugins/code-block/ide-ux/paired-character-handling.js +0 -16
- package/dist/esm/plugins/code-block/ide-ux/quote-handling.js +0 -34
- package/dist/esm/plugins/code-block/index.js +0 -113
- package/dist/esm/plugins/code-block/language-list.js +0 -52
- package/dist/esm/plugins/code-block/nodeviews/code-block.js +0 -146
- package/dist/esm/plugins/code-block/plugin-key.js +0 -2
- package/dist/esm/plugins/code-block/pm-plugins/actions.js +0 -4
- package/dist/esm/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +0 -103
- package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +0 -126
- package/dist/esm/plugins/code-block/pm-plugins/input-rule.js +0 -62
- package/dist/esm/plugins/code-block/pm-plugins/keymaps.js +0 -59
- package/dist/esm/plugins/code-block/pm-plugins/main-state.js +0 -4
- package/dist/esm/plugins/code-block/pm-plugins/main.js +0 -107
- package/dist/esm/plugins/code-block/refresh-browser-selection.js +0 -25
- package/dist/esm/plugins/code-block/toolbar.js +0 -121
- package/dist/esm/plugins/code-block/transform-to-code-block.js +0 -77
- package/dist/esm/plugins/code-block/types.js +0 -1
- package/dist/esm/plugins/code-block/ui/class-names.js +0 -9
- package/dist/esm/plugins/code-block/utils.js +0 -4
- package/dist/types/plugins/code-block/actions.d.ts +0 -18
- package/dist/types/plugins/code-block/ide-ux/bracket-handling.d.ts +0 -12
- package/dist/types/plugins/code-block/ide-ux/commands.d.ts +0 -7
- package/dist/types/plugins/code-block/ide-ux/line-handling.d.ts +0 -25
- package/dist/types/plugins/code-block/ide-ux/paired-character-handling.d.ts +0 -2
- package/dist/types/plugins/code-block/ide-ux/quote-handling.d.ts +0 -12
- package/dist/types/plugins/code-block/index.d.ts +0 -19
- package/dist/types/plugins/code-block/language-list.d.ts +0 -942
- package/dist/types/plugins/code-block/nodeviews/code-block.d.ts +0 -21
- package/dist/types/plugins/code-block/plugin-key.d.ts +0 -2
- package/dist/types/plugins/code-block/pm-plugins/actions.d.ts +0 -4
- package/dist/types/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.d.ts +0 -11
- package/dist/types/plugins/code-block/pm-plugins/ide-ux.d.ts +0 -5
- package/dist/types/plugins/code-block/pm-plugins/input-rule.d.ts +0 -3
- package/dist/types/plugins/code-block/pm-plugins/keymaps.d.ts +0 -4
- package/dist/types/plugins/code-block/pm-plugins/main-state.d.ts +0 -8
- package/dist/types/plugins/code-block/pm-plugins/main.d.ts +0 -10
- package/dist/types/plugins/code-block/refresh-browser-selection.d.ts +0 -5
- package/dist/types/plugins/code-block/toolbar.d.ts +0 -14
- package/dist/types/plugins/code-block/transform-to-code-block.d.ts +0 -3
- package/dist/types/plugins/code-block/types.d.ts +0 -6
- package/dist/types/plugins/code-block/ui/class-names.d.ts +0 -8
- package/dist/types/plugins/code-block/utils.d.ts +0 -4
- package/dist/types-ts4.5/plugins/code-block/actions.d.ts +0 -18
- package/dist/types-ts4.5/plugins/code-block/ide-ux/bracket-handling.d.ts +0 -12
- package/dist/types-ts4.5/plugins/code-block/ide-ux/commands.d.ts +0 -7
- package/dist/types-ts4.5/plugins/code-block/ide-ux/line-handling.d.ts +0 -25
- package/dist/types-ts4.5/plugins/code-block/ide-ux/paired-character-handling.d.ts +0 -2
- package/dist/types-ts4.5/plugins/code-block/ide-ux/quote-handling.d.ts +0 -12
- package/dist/types-ts4.5/plugins/code-block/index.d.ts +0 -19
- package/dist/types-ts4.5/plugins/code-block/language-list.d.ts +0 -1641
- package/dist/types-ts4.5/plugins/code-block/nodeviews/code-block.d.ts +0 -21
- package/dist/types-ts4.5/plugins/code-block/plugin-key.d.ts +0 -2
- package/dist/types-ts4.5/plugins/code-block/pm-plugins/actions.d.ts +0 -4
- package/dist/types-ts4.5/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.d.ts +0 -14
- package/dist/types-ts4.5/plugins/code-block/pm-plugins/ide-ux.d.ts +0 -5
- package/dist/types-ts4.5/plugins/code-block/pm-plugins/input-rule.d.ts +0 -3
- package/dist/types-ts4.5/plugins/code-block/pm-plugins/keymaps.d.ts +0 -4
- package/dist/types-ts4.5/plugins/code-block/pm-plugins/main-state.d.ts +0 -8
- package/dist/types-ts4.5/plugins/code-block/pm-plugins/main.d.ts +0 -10
- package/dist/types-ts4.5/plugins/code-block/refresh-browser-selection.d.ts +0 -5
- package/dist/types-ts4.5/plugins/code-block/toolbar.d.ts +0 -14
- package/dist/types-ts4.5/plugins/code-block/transform-to-code-block.d.ts +0 -3
- package/dist/types-ts4.5/plugins/code-block/types.d.ts +0 -6
- package/dist/types-ts4.5/plugins/code-block/ui/class-names.d.ts +0 -8
- package/dist/types-ts4.5/plugins/code-block/utils.d.ts +0 -4
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import rafSchedule from 'raf-schd';
|
|
3
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
4
|
-
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
import { codeBlockClassNames } from '../ui/class-names';
|
|
6
|
-
import { resetShouldIgnoreFollowingMutations } from '../actions';
|
|
7
|
-
import { getPluginState } from '../pm-plugins/main-state';
|
|
8
|
-
const MATCH_NEWLINES = new RegExp('\n', 'g');
|
|
9
|
-
const toDOM = node => ['div', {
|
|
10
|
-
class: 'code-block'
|
|
11
|
-
}, ['div', {
|
|
12
|
-
class: codeBlockClassNames.start,
|
|
13
|
-
contenteditable: 'false'
|
|
14
|
-
}], ['div', {
|
|
15
|
-
class: codeBlockClassNames.contentWrapper
|
|
16
|
-
}, ['div', {
|
|
17
|
-
class: codeBlockClassNames.gutter,
|
|
18
|
-
contenteditable: 'false'
|
|
19
|
-
}], ['div', {
|
|
20
|
-
class: codeBlockClassNames.content
|
|
21
|
-
}, ['code', {
|
|
22
|
-
'data-language': node.attrs.language || '',
|
|
23
|
-
spellcheck: 'false',
|
|
24
|
-
contenteditable: 'true',
|
|
25
|
-
'data-testid': 'code-block--code'
|
|
26
|
-
}, 0]]], ['div', {
|
|
27
|
-
class: codeBlockClassNames.end,
|
|
28
|
-
contenteditable: 'false'
|
|
29
|
-
}]];
|
|
30
|
-
export class CodeBlockView {
|
|
31
|
-
constructor(_node, view, getPos) {
|
|
32
|
-
_defineProperty(this, "ensureLineNumbers", rafSchedule(() => {
|
|
33
|
-
let lines = 1;
|
|
34
|
-
this.node.forEach(node => {
|
|
35
|
-
const text = node.text;
|
|
36
|
-
if (text) {
|
|
37
|
-
lines += (node.text.match(MATCH_NEWLINES) || []).length;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
while (this.lineNumberGutter.childElementCount < lines) {
|
|
41
|
-
this.lineNumberGutter.appendChild(document.createElement('span'));
|
|
42
|
-
}
|
|
43
|
-
while (this.lineNumberGutter.childElementCount > lines) {
|
|
44
|
-
this.lineNumberGutter.removeChild(this.lineNumberGutter.lastChild);
|
|
45
|
-
}
|
|
46
|
-
}));
|
|
47
|
-
const {
|
|
48
|
-
dom,
|
|
49
|
-
contentDOM
|
|
50
|
-
} = DOMSerializer.renderSpec(document, toDOM(_node));
|
|
51
|
-
this.getPos = getPos;
|
|
52
|
-
this.view = view;
|
|
53
|
-
this.node = _node;
|
|
54
|
-
this.dom = dom;
|
|
55
|
-
this.contentDOM = contentDOM;
|
|
56
|
-
this.lineNumberGutter = this.dom.querySelector(`.${codeBlockClassNames.gutter}`);
|
|
57
|
-
this.ensureLineNumbers();
|
|
58
|
-
}
|
|
59
|
-
updateDOMAndSelection(savedInnerHTML, newCursorPosition) {
|
|
60
|
-
var _this$dom;
|
|
61
|
-
if ((_this$dom = this.dom) !== null && _this$dom !== void 0 && _this$dom.childNodes && this.dom.childNodes.length > 1) {
|
|
62
|
-
var _contentView$childNod;
|
|
63
|
-
const contentWrapper = this.dom.childNodes[1];
|
|
64
|
-
const contentView = contentWrapper === null || contentWrapper === void 0 ? void 0 : contentWrapper.childNodes[1];
|
|
65
|
-
if ((contentView === null || contentView === void 0 ? void 0 : (_contentView$childNod = contentView.childNodes) === null || _contentView$childNod === void 0 ? void 0 : _contentView$childNod.length) > 0) {
|
|
66
|
-
const codeElement = contentView.firstChild;
|
|
67
|
-
codeElement.innerHTML = savedInnerHTML;
|
|
68
|
-
|
|
69
|
-
// We need to set cursor for the DOM update
|
|
70
|
-
const textElement = [...codeElement.childNodes].find(child => child.nodeName === '#text');
|
|
71
|
-
const sel = window.getSelection();
|
|
72
|
-
const range = document.createRange();
|
|
73
|
-
range.setStart(textElement, newCursorPosition);
|
|
74
|
-
range.collapse(true);
|
|
75
|
-
sel === null || sel === void 0 ? void 0 : sel.removeAllRanges();
|
|
76
|
-
sel === null || sel === void 0 ? void 0 : sel.addRange(range);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
coalesceDOMElements() {
|
|
81
|
-
var _this$dom2;
|
|
82
|
-
if ((_this$dom2 = this.dom) !== null && _this$dom2 !== void 0 && _this$dom2.childNodes && this.dom.childNodes.length > 1) {
|
|
83
|
-
const contentWrapper = this.dom.childNodes[1];
|
|
84
|
-
const contentView = contentWrapper === null || contentWrapper === void 0 ? void 0 : contentWrapper.childNodes[1];
|
|
85
|
-
if (contentView !== null && contentView !== void 0 && contentView.childNodes && contentView.childNodes.length > 1) {
|
|
86
|
-
let savedInnerHTML = '';
|
|
87
|
-
while (contentView.childNodes.length > 1) {
|
|
88
|
-
const lastChild = contentView.lastChild;
|
|
89
|
-
savedInnerHTML = lastChild.innerHTML + savedInnerHTML;
|
|
90
|
-
contentView.removeChild(lastChild);
|
|
91
|
-
}
|
|
92
|
-
const firstChild = contentView.firstChild;
|
|
93
|
-
savedInnerHTML = firstChild.innerHTML + '\n' + savedInnerHTML;
|
|
94
|
-
const newCursorPosition = firstChild.innerHTML.length + 1;
|
|
95
|
-
setTimeout(this.updateDOMAndSelection.bind(this, savedInnerHTML, newCursorPosition), 20);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
update(node) {
|
|
100
|
-
if (node.type !== this.node.type) {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
if (node !== this.node) {
|
|
104
|
-
if (node.attrs.language !== this.node.attrs.language) {
|
|
105
|
-
this.contentDOM.setAttribute('data-language', node.attrs.language || '');
|
|
106
|
-
}
|
|
107
|
-
this.node = node;
|
|
108
|
-
this.ensureLineNumbers();
|
|
109
|
-
if (browser.android) {
|
|
110
|
-
this.coalesceDOMElements();
|
|
111
|
-
resetShouldIgnoreFollowingMutations(this.view.state, this.view.dispatch);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
ignoreMutation(record) {
|
|
117
|
-
const pluginState = getPluginState(this.view.state);
|
|
118
|
-
if (pluginState !== null && pluginState !== void 0 && pluginState.shouldIgnoreFollowingMutations) {
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Ensure updating the line-number gutter doesn't trigger reparsing the codeblock
|
|
123
|
-
return record.target === this.lineNumberGutter || record.target.parentNode === this.lineNumberGutter;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
export const codeBlockNodeView = (node, view, getPos) => new CodeBlockView(node, view, getPos);
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
import { getSelectedNodeOrNodeParentByNodeType } from '@atlaskit/editor-common/copy-button';
|
|
5
|
-
export const copySelectionPluginKey = new PluginKey('codeBlockCopySelectionPlugin');
|
|
6
|
-
function getSelectionDecorationStartAndEnd({
|
|
7
|
-
state,
|
|
8
|
-
transaction
|
|
9
|
-
}) {
|
|
10
|
-
const codeBlockNode = getSelectedNodeOrNodeParentByNodeType({
|
|
11
|
-
nodeType: state.schema.nodes.codeBlock,
|
|
12
|
-
selection: transaction.selection
|
|
13
|
-
});
|
|
14
|
-
if (!codeBlockNode) {
|
|
15
|
-
return {
|
|
16
|
-
decorationStartAndEnd: undefined
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
const decorationStartAndEnd = [codeBlockNode.start, codeBlockNode.start + codeBlockNode.node.nodeSize];
|
|
20
|
-
return {
|
|
21
|
-
decorationStartAndEnd
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export function codeBlockCopySelectionPlugin() {
|
|
25
|
-
return new SafePlugin({
|
|
26
|
-
key: copySelectionPluginKey,
|
|
27
|
-
state: {
|
|
28
|
-
init() {
|
|
29
|
-
return {
|
|
30
|
-
decorationStartAndEnd: undefined
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
apply(transaction, currentCodeBlockCopySelectionPluginState, _oldState, newState) {
|
|
34
|
-
switch (transaction.getMeta(copySelectionPluginKey)) {
|
|
35
|
-
case 'show-selection':
|
|
36
|
-
{
|
|
37
|
-
return getSelectionDecorationStartAndEnd({
|
|
38
|
-
state: newState,
|
|
39
|
-
transaction
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
case 'remove-selection':
|
|
43
|
-
return {
|
|
44
|
-
decorationStartAndEnd: undefined
|
|
45
|
-
};
|
|
46
|
-
default:
|
|
47
|
-
// The contents of the code block can change while the selection is being shown
|
|
48
|
-
// (either from collab edits -- or from the user continuing to type while hovering
|
|
49
|
-
// the mouse over the copy button).
|
|
50
|
-
// This ensures the selection is updated in these cases.
|
|
51
|
-
if (currentCodeBlockCopySelectionPluginState.decorationStartAndEnd !== undefined) {
|
|
52
|
-
return getSelectionDecorationStartAndEnd({
|
|
53
|
-
state: newState,
|
|
54
|
-
transaction
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return currentCodeBlockCopySelectionPluginState;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
props: {
|
|
62
|
-
decorations(state) {
|
|
63
|
-
if (copySelectionPluginKey.getState(state).decorationStartAndEnd) {
|
|
64
|
-
const [start, end] = copySelectionPluginKey.getState(state).decorationStartAndEnd;
|
|
65
|
-
return DecorationSet.create(state.doc, [Decoration.inline(start, end, {
|
|
66
|
-
class: 'ProseMirror-fake-text-selection'
|
|
67
|
-
})]);
|
|
68
|
-
}
|
|
69
|
-
return DecorationSet.empty;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
export function provideVisualFeedbackForCopyButton(state, dispatch) {
|
|
75
|
-
const tr = state.tr;
|
|
76
|
-
tr.setMeta(copySelectionPluginKey, 'show-selection');
|
|
77
|
-
|
|
78
|
-
// note: dispatch should always be defined when called from the
|
|
79
|
-
// floating toolbar. Howver the Command type which the floating toolbar
|
|
80
|
-
// uses suggests it's optional.
|
|
81
|
-
// Using the type here to protect against future refactors of the
|
|
82
|
-
// floating toolbar
|
|
83
|
-
if (dispatch) {
|
|
84
|
-
dispatch(tr);
|
|
85
|
-
}
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
export function removeVisualFeedbackForCopyButton(state, dispatch) {
|
|
89
|
-
const tr = state.tr;
|
|
90
|
-
tr.setMeta(copySelectionPluginKey, 'remove-selection');
|
|
91
|
-
|
|
92
|
-
// note: dispatch should always be defined when called from the
|
|
93
|
-
// floating toolbar. Howver the Command type which the floating toolbar
|
|
94
|
-
// uses suggests it's optional.
|
|
95
|
-
// Using the type here to protect against future refactors of the
|
|
96
|
-
// floating toolbar
|
|
97
|
-
if (dispatch) {
|
|
98
|
-
dispatch(tr);
|
|
99
|
-
}
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
4
|
-
import { setTextSelection } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { getCursor } from '../utils';
|
|
6
|
-
import { filterCommand as filter } from '@atlaskit/editor-common/utils';
|
|
7
|
-
import { isCursorBeforeClosingCharacter, isClosingCharacter } from '../ide-ux/paired-character-handling';
|
|
8
|
-
import { getAutoClosingBracketInfo, shouldAutoCloseBracket } from '../ide-ux/bracket-handling';
|
|
9
|
-
import { getAutoClosingQuoteInfo, shouldAutoCloseQuote } from '../ide-ux/quote-handling';
|
|
10
|
-
import { getEndOfCurrentLine, getStartOfCurrentLine, isCursorInsideCodeBlock, isSelectionEntirelyInsideCodeBlock, getLineInfo } from '../ide-ux/line-handling';
|
|
11
|
-
import { insertIndent, outdent, indent, insertNewlineWithIndent } from '../ide-ux/commands';
|
|
12
|
-
const ideUX = pluginInjectionApi => {
|
|
13
|
-
var _pluginInjectionApi$a;
|
|
14
|
-
const editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
15
|
-
return new SafePlugin({
|
|
16
|
-
props: {
|
|
17
|
-
handleTextInput(view, from, to, text) {
|
|
18
|
-
var _pluginInjectionApi$c;
|
|
19
|
-
const {
|
|
20
|
-
state,
|
|
21
|
-
dispatch
|
|
22
|
-
} = view;
|
|
23
|
-
const compositionPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.composition) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.sharedState.currentState();
|
|
24
|
-
if (isCursorInsideCodeBlock(state) && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing)) {
|
|
25
|
-
const beforeText = getStartOfCurrentLine(state).text;
|
|
26
|
-
const afterText = getEndOfCurrentLine(state).text;
|
|
27
|
-
|
|
28
|
-
// If text is a closing bracket/quote and we've already inserted it, move the selection after
|
|
29
|
-
if (isCursorBeforeClosingCharacter(afterText) && isClosingCharacter(text) && afterText.startsWith(text)) {
|
|
30
|
-
dispatch(setTextSelection(to + text.length)(state.tr));
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Automatically add right-hand side bracket when user types the left bracket
|
|
35
|
-
if (shouldAutoCloseBracket(beforeText, afterText)) {
|
|
36
|
-
const {
|
|
37
|
-
left,
|
|
38
|
-
right
|
|
39
|
-
} = getAutoClosingBracketInfo(beforeText + text, afterText);
|
|
40
|
-
if (left && right) {
|
|
41
|
-
const bracketPair = state.schema.text(text + right);
|
|
42
|
-
let tr = state.tr.replaceWith(from, to, bracketPair);
|
|
43
|
-
dispatch(setTextSelection(from + text.length)(tr));
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Automatically add closing quote when user types a starting quote
|
|
49
|
-
if (shouldAutoCloseQuote(beforeText, afterText)) {
|
|
50
|
-
const {
|
|
51
|
-
left: leftQuote,
|
|
52
|
-
right: rightQuote
|
|
53
|
-
} = getAutoClosingQuoteInfo(beforeText + text, afterText);
|
|
54
|
-
if (leftQuote && rightQuote) {
|
|
55
|
-
const quotePair = state.schema.text(text + rightQuote);
|
|
56
|
-
let tr = state.tr.replaceWith(from, to, quotePair);
|
|
57
|
-
dispatch(setTextSelection(from + text.length)(tr));
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return false;
|
|
63
|
-
},
|
|
64
|
-
handleKeyDown: keydownHandler({
|
|
65
|
-
Backspace: (state, dispatch) => {
|
|
66
|
-
if (isCursorInsideCodeBlock(state)) {
|
|
67
|
-
const $cursor = getCursor(state.selection);
|
|
68
|
-
const beforeText = getStartOfCurrentLine(state).text;
|
|
69
|
-
const afterText = getEndOfCurrentLine(state).text;
|
|
70
|
-
const {
|
|
71
|
-
left: leftBracket,
|
|
72
|
-
right: rightBracket,
|
|
73
|
-
hasTrailingMatchingBracket
|
|
74
|
-
} = getAutoClosingBracketInfo(beforeText, afterText);
|
|
75
|
-
if (leftBracket && rightBracket && hasTrailingMatchingBracket && dispatch) {
|
|
76
|
-
dispatch(state.tr.delete($cursor.pos - leftBracket.length, $cursor.pos + rightBracket.length));
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
const {
|
|
80
|
-
left: leftQuote,
|
|
81
|
-
right: rightQuote,
|
|
82
|
-
hasTrailingMatchingQuote
|
|
83
|
-
} = getAutoClosingQuoteInfo(beforeText, afterText);
|
|
84
|
-
if (leftQuote && rightQuote && hasTrailingMatchingQuote && dispatch) {
|
|
85
|
-
dispatch(state.tr.delete($cursor.pos - leftQuote.length, $cursor.pos + rightQuote.length));
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
const {
|
|
89
|
-
indentToken: {
|
|
90
|
-
size,
|
|
91
|
-
token
|
|
92
|
-
},
|
|
93
|
-
indentText
|
|
94
|
-
} = getLineInfo(beforeText);
|
|
95
|
-
if (beforeText === indentText) {
|
|
96
|
-
if (indentText.endsWith(token.repeat(size)) && dispatch) {
|
|
97
|
-
dispatch(state.tr.delete($cursor.pos - (size - indentText.length % size || size), $cursor.pos));
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return false;
|
|
103
|
-
},
|
|
104
|
-
Enter: filter(isSelectionEntirelyInsideCodeBlock, insertNewlineWithIndent),
|
|
105
|
-
'Mod-]': filter(isSelectionEntirelyInsideCodeBlock, indent(editorAnalyticsAPI)),
|
|
106
|
-
'Mod-[': filter(isSelectionEntirelyInsideCodeBlock, outdent(editorAnalyticsAPI)),
|
|
107
|
-
Tab: filter(isSelectionEntirelyInsideCodeBlock, (state, dispatch) => {
|
|
108
|
-
if (!dispatch) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
if (isCursorInsideCodeBlock(state)) {
|
|
112
|
-
return insertIndent(state, dispatch);
|
|
113
|
-
}
|
|
114
|
-
return indent(editorAnalyticsAPI)(state, dispatch);
|
|
115
|
-
}),
|
|
116
|
-
'Shift-Tab': filter(isSelectionEntirelyInsideCodeBlock, outdent(editorAnalyticsAPI)),
|
|
117
|
-
'Mod-a': (state, dispatch) => {
|
|
118
|
-
if (isSelectionEntirelyInsideCodeBlock(state)) {
|
|
119
|
-
const {
|
|
120
|
-
$from,
|
|
121
|
-
$to
|
|
122
|
-
} = state.selection;
|
|
123
|
-
const isFullCodeBlockSelection = $from.parentOffset === 0 && $to.parentOffset === $to.parent.nodeSize - 2;
|
|
124
|
-
if (!isFullCodeBlockSelection && dispatch) {
|
|
125
|
-
dispatch(state.tr.setSelection(TextSelection.create(state.doc, $from.start(), $to.end())));
|
|
126
|
-
return true;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
})
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
export default ideUX;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
2
|
-
import { createRule, createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
3
|
-
import { INPUT_METHOD, ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { inputRuleWithAnalytics } from '@atlaskit/editor-common/utils';
|
|
5
|
-
import { isConvertableToCodeBlock, transformToCodeBlockAction } from '../transform-to-code-block';
|
|
6
|
-
import { insertBlock } from '@atlaskit/editor-common/commands';
|
|
7
|
-
export function createCodeBlockInputRule(schema, editorAnalyticsAPI) {
|
|
8
|
-
const rules = getCodeBlockRules(editorAnalyticsAPI, schema);
|
|
9
|
-
return createPlugin('code-block-input-rule', rules, {
|
|
10
|
-
isBlockNodeRule: true
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Get all code block input rules
|
|
16
|
-
*
|
|
17
|
-
* @param {Schema} schema
|
|
18
|
-
* @returns {InputRuleWithHandler[]}
|
|
19
|
-
*/
|
|
20
|
-
function getCodeBlockRules(editorAnalyticsAPI, schema) {
|
|
21
|
-
const ruleAnalytics = inputRuleWithAnalytics({
|
|
22
|
-
action: ACTION.INSERTED,
|
|
23
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
24
|
-
actionSubjectId: ACTION_SUBJECT_ID.CODE_BLOCK,
|
|
25
|
-
attributes: {
|
|
26
|
-
inputMethod: INPUT_METHOD.FORMATTING
|
|
27
|
-
},
|
|
28
|
-
eventType: EVENT_TYPE.TRACK
|
|
29
|
-
}, editorAnalyticsAPI);
|
|
30
|
-
const validMatchLength = match => match.length > 0 && match[0].length === 3;
|
|
31
|
-
const threeTildeRule = createRule(/(?!\s)(`{3,})$/, (state, match, start, end) => {
|
|
32
|
-
if (!validMatchLength(match)) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
const attributes = {};
|
|
36
|
-
if (match[4]) {
|
|
37
|
-
attributes.language = match[4];
|
|
38
|
-
}
|
|
39
|
-
if (isConvertableToCodeBlock(state)) {
|
|
40
|
-
return transformToCodeBlockAction(state, start, attributes);
|
|
41
|
-
}
|
|
42
|
-
const tr = state.tr;
|
|
43
|
-
tr.delete(start, end);
|
|
44
|
-
const codeBlock = tr.doc.type.schema.nodes.codeBlock.createChecked();
|
|
45
|
-
safeInsert(codeBlock)(tr);
|
|
46
|
-
return tr;
|
|
47
|
-
});
|
|
48
|
-
const leftNodeReplacementThreeTildeRule = createRule(new RegExp(`((${leafNodeReplacementCharacter}\`{3,})|^\\s(\`{3,}))(\\S*)$`), (state, match, start, end) => {
|
|
49
|
-
if (!validMatchLength(match)) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
const attributes = {};
|
|
53
|
-
if (match[4]) {
|
|
54
|
-
attributes.language = match[4];
|
|
55
|
-
}
|
|
56
|
-
const inlineStart = Math.max(match.index + state.selection.$from.start(), 1);
|
|
57
|
-
return insertBlock(state, schema.nodes.codeBlock, inlineStart, end, attributes);
|
|
58
|
-
});
|
|
59
|
-
return [ruleAnalytics(threeTildeRule), ruleAnalytics(leftNodeReplacementThreeTildeRule)];
|
|
60
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
-
import { getCursor } from '../utils';
|
|
5
|
-
import { isEmptyNode } from '@atlaskit/editor-common/utils';
|
|
6
|
-
const deleteCurrentItem = $from => tr => {
|
|
7
|
-
return tr.delete($from.before($from.depth), $from.after($from.depth));
|
|
8
|
-
};
|
|
9
|
-
const setTextSelection = pos => tr => {
|
|
10
|
-
const newSelection = Selection.findFrom(tr.doc.resolve(pos), -1, true);
|
|
11
|
-
if (newSelection) {
|
|
12
|
-
tr.setSelection(newSelection);
|
|
13
|
-
}
|
|
14
|
-
return tr;
|
|
15
|
-
};
|
|
16
|
-
export function keymapPlugin(schema) {
|
|
17
|
-
return keymap({
|
|
18
|
-
Backspace: (state, dispatch) => {
|
|
19
|
-
const $cursor = getCursor(state.selection);
|
|
20
|
-
const {
|
|
21
|
-
paragraph,
|
|
22
|
-
codeBlock,
|
|
23
|
-
listItem,
|
|
24
|
-
table,
|
|
25
|
-
layoutColumn
|
|
26
|
-
} = state.schema.nodes;
|
|
27
|
-
if (!$cursor || $cursor.parent.type !== codeBlock || !dispatch) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
if ($cursor.pos === 1 || hasParentNodeOfType(listItem)(state.selection) && $cursor.parentOffset === 0) {
|
|
31
|
-
const node = findParentNodeOfTypeClosestToPos($cursor, codeBlock);
|
|
32
|
-
if (!node) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
dispatch(state.tr.setNodeMarkup(node.pos, node.node.type, node.node.attrs, []).setBlockType($cursor.pos, $cursor.pos, paragraph));
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
if ($cursor.node && isEmptyNode(schema)($cursor.node()) && (hasParentNodeOfType(layoutColumn)(state.selection) || hasParentNodeOfType(table)(state.selection))) {
|
|
39
|
-
const {
|
|
40
|
-
tr
|
|
41
|
-
} = state;
|
|
42
|
-
const insertPos = $cursor.pos;
|
|
43
|
-
deleteCurrentItem($cursor)(tr);
|
|
44
|
-
setTextSelection(insertPos)(tr);
|
|
45
|
-
dispatch(tr.scrollIntoView());
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Handle not nested empty code block
|
|
50
|
-
if (isEmptyNode(schema)($cursor.node())) {
|
|
51
|
-
dispatch(deleteCurrentItem($cursor)(state === null || state === void 0 ? void 0 : state.tr));
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
export default keymapPlugin;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
3
|
-
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { codeBlockNodeView } from '../nodeviews/code-block';
|
|
5
|
-
import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
6
|
-
import { pluginKey } from '../plugin-key';
|
|
7
|
-
import { ACTIONS } from './actions';
|
|
8
|
-
import { ignoreFollowingMutations, resetShouldIgnoreFollowingMutations } from '../actions';
|
|
9
|
-
import { findCodeBlock } from '../utils';
|
|
10
|
-
import { codeBlockClassNames } from '../ui/class-names';
|
|
11
|
-
export const createPlugin = ({
|
|
12
|
-
useLongPressSelection = false,
|
|
13
|
-
getIntl,
|
|
14
|
-
appearance,
|
|
15
|
-
allowCompositionInputOverride = false
|
|
16
|
-
}) => {
|
|
17
|
-
const handleDOMEvents = {};
|
|
18
|
-
|
|
19
|
-
// ME-1599: Composition on mobile was causing the DOM observer to mutate the code block
|
|
20
|
-
// incorrecly and lose content when pressing enter in the middle of a code block line.
|
|
21
|
-
if (allowCompositionInputOverride) {
|
|
22
|
-
handleDOMEvents.beforeinput = (view, event) => {
|
|
23
|
-
const keyEvent = event;
|
|
24
|
-
const eventInputType = keyEvent.inputType;
|
|
25
|
-
const eventText = keyEvent.data;
|
|
26
|
-
if (browser.ios && event.composed &&
|
|
27
|
-
// insertParagraph will be the input type when the enter key is pressed.
|
|
28
|
-
eventInputType === 'insertParagraph' && findCodeBlock(view.state, view.state.selection)) {
|
|
29
|
-
event.preventDefault();
|
|
30
|
-
return true;
|
|
31
|
-
} else if (browser.android && event.composed && eventInputType === 'insertCompositionText' && eventText[(eventText === null || eventText === void 0 ? void 0 : eventText.length) - 1] === '\n' && findCodeBlock(view.state, view.state.selection)) {
|
|
32
|
-
const resultingText = event.target.outerText + '\n';
|
|
33
|
-
if (resultingText.endsWith(eventText)) {
|
|
34
|
-
// End of paragraph
|
|
35
|
-
setTimeout(() => {
|
|
36
|
-
view.someProp('handleKeyDown', f => f(view, new KeyboardEvent('keydown', {
|
|
37
|
-
bubbles: true,
|
|
38
|
-
cancelable: true,
|
|
39
|
-
key: 'Enter',
|
|
40
|
-
code: 'Enter'
|
|
41
|
-
})));
|
|
42
|
-
}, 0);
|
|
43
|
-
} else {
|
|
44
|
-
// Middle of paragraph, end of line
|
|
45
|
-
ignoreFollowingMutations(view.state, view.dispatch);
|
|
46
|
-
}
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
if (browser.android) {
|
|
50
|
-
resetShouldIgnoreFollowingMutations(view.state, view.dispatch);
|
|
51
|
-
}
|
|
52
|
-
return false;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
return new SafePlugin({
|
|
56
|
-
state: {
|
|
57
|
-
init(_, state) {
|
|
58
|
-
const node = findCodeBlock(state, state.selection);
|
|
59
|
-
return {
|
|
60
|
-
pos: node ? node.pos : null,
|
|
61
|
-
contentCopied: false,
|
|
62
|
-
isNodeSelected: false,
|
|
63
|
-
shouldIgnoreFollowingMutations: false
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
apply(tr, pluginState, _oldState, newState) {
|
|
67
|
-
if (tr.docChanged || tr.selectionSet) {
|
|
68
|
-
const node = findCodeBlock(newState, tr.selection);
|
|
69
|
-
const newPluginState = {
|
|
70
|
-
...pluginState,
|
|
71
|
-
pos: node ? node.pos : null,
|
|
72
|
-
isNodeSelected: tr.selection instanceof NodeSelection
|
|
73
|
-
};
|
|
74
|
-
return newPluginState;
|
|
75
|
-
}
|
|
76
|
-
const meta = tr.getMeta(pluginKey);
|
|
77
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.type) === ACTIONS.SET_COPIED_TO_CLIPBOARD) {
|
|
78
|
-
return {
|
|
79
|
-
...pluginState,
|
|
80
|
-
contentCopied: meta.data
|
|
81
|
-
};
|
|
82
|
-
} else if ((meta === null || meta === void 0 ? void 0 : meta.type) === ACTIONS.SET_SHOULD_IGNORE_FOLLOWING_MUTATIONS) {
|
|
83
|
-
return {
|
|
84
|
-
...pluginState,
|
|
85
|
-
shouldIgnoreFollowingMutations: meta.data
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
return pluginState;
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
key: pluginKey,
|
|
92
|
-
props: {
|
|
93
|
-
nodeViews: {
|
|
94
|
-
codeBlock: codeBlockNodeView
|
|
95
|
-
},
|
|
96
|
-
handleClickOn: createSelectionClickHandler(['codeBlock'], target => !!(target.closest(`.${codeBlockClassNames.gutter}`) || target.classList.contains(codeBlockClassNames.content)), {
|
|
97
|
-
useLongPressSelection
|
|
98
|
-
}),
|
|
99
|
-
handleDOMEvents
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
2
|
-
import { pluginKey } from './plugin-key';
|
|
3
|
-
|
|
4
|
-
// Workaround for a firefox issue where dom selection is off sync
|
|
5
|
-
// https://product-fabric.atlassian.net/browse/ED-12442
|
|
6
|
-
const refreshBrowserSelection = () => {
|
|
7
|
-
const domSelection = window.getSelection();
|
|
8
|
-
if (domSelection) {
|
|
9
|
-
const domRange = domSelection && domSelection.rangeCount === 1 && domSelection.getRangeAt(0).cloneRange();
|
|
10
|
-
if (domRange) {
|
|
11
|
-
domSelection.removeAllRanges();
|
|
12
|
-
domSelection.addRange(domRange);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
const refreshBrowserSelectionOnChange = (transaction, editorState) => {
|
|
17
|
-
var _pluginKey$getState;
|
|
18
|
-
if (browser.gecko && transaction.docChanged &&
|
|
19
|
-
// codeblockState.pos should be set if current selection is in a codeblock.
|
|
20
|
-
typeof ((_pluginKey$getState = pluginKey.getState(editorState)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.pos) === 'number') {
|
|
21
|
-
refreshBrowserSelection();
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
export default refreshBrowserSelectionOnChange;
|
|
25
|
-
export { refreshBrowserSelection };
|