@atlaskit/editor-core 150.0.2 → 151.1.1
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 +69 -0
- package/dist/cjs/actions/index.js +5 -23
- package/dist/cjs/create-editor/ErrorBoundary.js +113 -79
- package/dist/cjs/create-editor/ReactEditorView.js +145 -31
- package/dist/cjs/create-editor/create-plugins-list.js +8 -2
- package/dist/cjs/editor.js +101 -40
- package/dist/cjs/labs/next/presets/cxhtml.js +2 -1
- package/dist/cjs/plugins/analytics/types/enums.js +3 -1
- package/dist/cjs/plugins/base/index.js +4 -3
- package/dist/cjs/plugins/base/pm-plugins/frozen-editor.js +66 -36
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +3 -1
- package/dist/cjs/plugins/card/index.js +13 -2
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/cjs/plugins/card/pm-plugins/main.js +7 -2
- package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +10 -3
- package/dist/cjs/plugins/code-bidi-warning/index.js +25 -0
- package/dist/cjs/plugins/code-bidi-warning/plugin-key.js +11 -0
- package/dist/cjs/plugins/code-bidi-warning/pm-plugins/main.js +43 -0
- package/dist/cjs/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +118 -0
- package/dist/cjs/plugins/code-bidi-warning/pm-plugins/reducer.js +12 -0
- package/dist/cjs/plugins/code-bidi-warning/pm-plugins/types.js +5 -0
- package/dist/cjs/plugins/code-block/index.js +10 -6
- package/dist/cjs/plugins/code-block/nodeviews/highlighting-code-block.js +16 -5
- package/dist/cjs/plugins/code-block/pm-plugins/main.js +12 -3
- package/dist/cjs/plugins/code-block/toolbar.js +1 -1
- package/dist/cjs/plugins/emoji/styles.js +1 -1
- package/dist/cjs/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/cjs/plugins/extension/toolbar.js +28 -23
- package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +9 -3
- package/dist/cjs/plugins/find-replace/ui/Find.js +27 -7
- package/dist/cjs/plugins/hyperlink/HyperlinkToolbarAppearance.js +2 -2
- package/dist/cjs/plugins/hyperlink/pm-plugins/keymap.js +3 -3
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/cjs/plugins/hyperlink/utils.js +6 -69
- package/dist/cjs/plugins/index.js +8 -0
- package/dist/cjs/plugins/media/index.js +14 -3
- package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +24 -10
- package/dist/cjs/plugins/media/nodeviews/mediaInline.js +179 -0
- package/dist/cjs/plugins/media/pm-plugins/main.js +18 -9
- package/dist/cjs/plugins/media/toolbar/index.js +49 -17
- package/dist/cjs/plugins/media/toolbar/utils.js +20 -2
- package/dist/cjs/plugins/media/utils/media-files.js +67 -1
- package/dist/cjs/plugins/mentions/type-ahead/index.js +39 -3
- package/dist/cjs/plugins/panel/index.js +2 -3
- package/dist/cjs/plugins/panel/message.js +47 -0
- package/dist/cjs/plugins/panel/toolbar.js +64 -84
- package/dist/cjs/plugins/panel/utils.js +2 -2
- package/dist/cjs/plugins/paste/linkify-md-plugin.js +3 -3
- package/dist/cjs/plugins/rank.js +1 -1
- package/dist/cjs/plugins/status/styles.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/cjs/profiler/render-count.js +82 -0
- package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -5
- package/dist/cjs/utils/react-hooks/use-component-renderer-tracking/index.js +55 -19
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/actions/index.js +6 -28
- package/dist/es2019/create-editor/ErrorBoundary.js +73 -60
- package/dist/es2019/create-editor/ReactEditorView.js +130 -23
- package/dist/es2019/create-editor/create-plugins-list.js +9 -3
- package/dist/es2019/editor.js +74 -35
- package/dist/es2019/labs/next/presets/cxhtml.js +2 -1
- package/dist/es2019/plugins/analytics/types/enums.js +3 -1
- package/dist/es2019/plugins/base/index.js +4 -3
- package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +63 -35
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +2 -1
- package/dist/es2019/plugins/card/index.js +7 -2
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/es2019/plugins/card/pm-plugins/main.js +9 -2
- package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +12 -5
- package/dist/es2019/plugins/code-bidi-warning/index.js +15 -0
- package/dist/es2019/plugins/code-bidi-warning/plugin-key.js +2 -0
- package/dist/es2019/plugins/code-bidi-warning/pm-plugins/main.js +31 -0
- package/dist/es2019/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +88 -0
- package/dist/es2019/plugins/code-bidi-warning/pm-plugins/reducer.js +3 -0
- package/dist/es2019/plugins/code-bidi-warning/pm-plugins/types.js +1 -0
- package/dist/es2019/plugins/code-block/index.js +6 -1
- package/dist/es2019/plugins/code-block/nodeviews/highlighting-code-block.js +16 -4
- package/dist/es2019/plugins/code-block/pm-plugins/main.js +50 -39
- package/dist/es2019/plugins/code-block/toolbar.js +1 -1
- package/dist/es2019/plugins/emoji/styles.js +2 -0
- package/dist/es2019/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/es2019/plugins/extension/toolbar.js +30 -25
- package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +9 -4
- package/dist/es2019/plugins/find-replace/ui/Find.js +27 -6
- package/dist/es2019/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -1
- package/dist/es2019/plugins/hyperlink/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/es2019/plugins/hyperlink/utils.js +3 -59
- package/dist/es2019/plugins/index.js +2 -1
- package/dist/es2019/plugins/media/index.js +13 -4
- package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +16 -7
- package/dist/es2019/plugins/media/nodeviews/mediaInline.js +88 -0
- package/dist/es2019/plugins/media/pm-plugins/main.js +20 -11
- package/dist/es2019/plugins/media/toolbar/index.js +44 -15
- package/dist/es2019/plugins/media/toolbar/utils.js +16 -0
- package/dist/es2019/plugins/media/utils/media-files.js +68 -2
- package/dist/es2019/plugins/mentions/type-ahead/index.js +21 -2
- package/dist/es2019/plugins/panel/index.js +3 -4
- package/dist/es2019/plugins/panel/message.js +38 -0
- package/dist/es2019/plugins/panel/toolbar.js +52 -71
- package/dist/es2019/plugins/panel/utils.js +2 -2
- package/dist/es2019/plugins/paste/linkify-md-plugin.js +2 -2
- package/dist/es2019/plugins/rank.js +1 -1
- package/dist/es2019/plugins/status/styles.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/es2019/profiler/render-count.js +60 -0
- package/dist/es2019/ui/Appearance/Comment/Comment.js +4 -2
- package/dist/es2019/utils/react-hooks/use-component-renderer-tracking/index.js +51 -18
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions/index.js +6 -24
- package/dist/esm/create-editor/ErrorBoundary.js +113 -78
- package/dist/esm/create-editor/ReactEditorView.js +146 -31
- package/dist/esm/create-editor/create-plugins-list.js +9 -3
- package/dist/esm/editor.js +100 -40
- package/dist/esm/labs/next/presets/cxhtml.js +2 -1
- package/dist/esm/plugins/analytics/types/enums.js +3 -1
- package/dist/esm/plugins/base/index.js +4 -3
- package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +64 -36
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +3 -1
- package/dist/esm/plugins/card/index.js +13 -2
- package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/esm/plugins/card/pm-plugins/main.js +7 -2
- package/dist/esm/plugins/card/pm-plugins/util/resolve.js +12 -5
- package/dist/esm/plugins/code-bidi-warning/index.js +17 -0
- package/dist/esm/plugins/code-bidi-warning/plugin-key.js +2 -0
- package/dist/esm/plugins/code-bidi-warning/pm-plugins/main.js +30 -0
- package/dist/esm/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +96 -0
- package/dist/esm/plugins/code-bidi-warning/pm-plugins/reducer.js +3 -0
- package/dist/esm/plugins/code-bidi-warning/pm-plugins/types.js +1 -0
- package/dist/esm/plugins/code-block/index.js +10 -6
- package/dist/esm/plugins/code-block/nodeviews/highlighting-code-block.js +16 -5
- package/dist/esm/plugins/code-block/pm-plugins/main.js +11 -3
- package/dist/esm/plugins/code-block/toolbar.js +1 -1
- package/dist/esm/plugins/emoji/styles.js +1 -1
- package/dist/esm/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/esm/plugins/extension/toolbar.js +28 -23
- package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +9 -4
- package/dist/esm/plugins/find-replace/ui/Find.js +27 -7
- package/dist/esm/plugins/hyperlink/HyperlinkToolbarAppearance.js +2 -2
- package/dist/esm/plugins/hyperlink/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/esm/plugins/hyperlink/utils.js +3 -59
- package/dist/esm/plugins/index.js +2 -1
- package/dist/esm/plugins/media/index.js +14 -4
- package/dist/esm/plugins/media/nodeviews/mediaGroup.js +24 -10
- package/dist/esm/plugins/media/nodeviews/mediaInline.js +147 -0
- package/dist/esm/plugins/media/pm-plugins/main.js +19 -11
- package/dist/esm/plugins/media/toolbar/index.js +47 -19
- package/dist/esm/plugins/media/toolbar/utils.js +15 -1
- package/dist/esm/plugins/media/utils/media-files.js +60 -2
- package/dist/esm/plugins/mentions/type-ahead/index.js +39 -3
- package/dist/esm/plugins/panel/index.js +3 -4
- package/dist/esm/plugins/panel/message.js +38 -0
- package/dist/esm/plugins/panel/toolbar.js +57 -77
- package/dist/esm/plugins/panel/utils.js +2 -2
- package/dist/esm/plugins/paste/linkify-md-plugin.js +2 -2
- package/dist/esm/plugins/rank.js +1 -1
- package/dist/esm/plugins/status/styles.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/esm/profiler/render-count.js +57 -0
- package/dist/esm/ui/Appearance/Comment/Comment.js +6 -5
- package/dist/esm/utils/react-hooks/use-component-renderer-tracking/index.js +53 -20
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/create-editor/ErrorBoundary.d.ts +6 -6
- package/dist/types/create-editor/ReactEditorView.d.ts +15 -3
- package/dist/types/editor.d.ts +2 -0
- package/dist/types/plugins/analytics/index.d.ts +1 -1
- package/dist/types/plugins/analytics/types/enums.d.ts +4 -2
- package/dist/types/plugins/analytics/types/events.d.ts +7 -2
- package/dist/types/plugins/analytics/types/general-events.d.ts +4 -1
- package/dist/types/plugins/analytics/types/index.d.ts +1 -1
- package/dist/types/plugins/analytics/types/insert-events.d.ts +6 -1
- package/dist/types/plugins/analytics/types/link-tool-bar-events.d.ts +1 -0
- package/dist/types/plugins/base/index.d.ts +1 -0
- package/dist/types/plugins/base/pm-plugins/frozen-editor.d.ts +3 -2
- package/dist/types/plugins/card/pm-plugins/main.d.ts +2 -3
- package/dist/types/plugins/card/pm-plugins/util/resolve.d.ts +2 -1
- package/dist/types/plugins/card/types.d.ts +6 -0
- package/dist/types/plugins/code-bidi-warning/index.d.ts +3 -0
- package/dist/types/plugins/code-bidi-warning/plugin-key.d.ts +2 -0
- package/dist/types/plugins/code-bidi-warning/pm-plugins/main.d.ts +3 -0
- package/dist/types/plugins/code-bidi-warning/pm-plugins/plugin-factory.d.ts +7 -0
- package/dist/types/plugins/code-bidi-warning/pm-plugins/reducer.d.ts +3 -0
- package/dist/types/plugins/code-bidi-warning/pm-plugins/types.d.ts +5 -0
- package/dist/types/plugins/code-block/nodeviews/highlighting-code-block.d.ts +11 -2
- package/dist/types/plugins/code-block/pm-plugins/main.d.ts +5 -1
- package/dist/types/plugins/extension/types.d.ts +0 -2
- package/dist/types/plugins/feature-flags-context/get-enabled-feature-flag-keys.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/types.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +1 -1
- package/dist/types/plugins/hyperlink/HyperlinkToolbarAppearance.d.ts +1 -1
- package/dist/types/plugins/hyperlink/utils.d.ts +0 -21
- package/dist/types/plugins/index.d.ts +1 -0
- package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +27 -0
- package/dist/types/plugins/media/pm-plugins/main.d.ts +2 -2
- package/dist/types/plugins/media/toolbar/utils.d.ts +2 -0
- package/dist/types/plugins/media/utils/media-files.d.ts +8 -0
- package/dist/types/plugins/panel/message.d.ts +37 -0
- package/dist/types/plugins/panel/toolbar.d.ts +4 -37
- package/dist/types/plugins/panel/types.d.ts +1 -0
- package/dist/types/profiler/render-count.d.ts +14 -0
- package/dist/types/types/feature-flags.d.ts +17 -0
- package/dist/types/ui/LinkSearch/types.d.ts +1 -0
- package/dist/types/utils/react-hooks/use-component-renderer-tracking/index.d.ts +17 -1
- package/package.json +21 -18
- package/dist/cjs/plugins/caption/nodeviews/index.test.js +0 -135
- package/dist/cjs/plugins/caption/pm-plugins/keymap.test.js +0 -203
- package/dist/cjs/plugins/caption/pm-plugins/main.test.js +0 -141
- package/dist/cjs/plugins/code-block/language-list.test.js +0 -74
- package/dist/cjs/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -101
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -98
- package/dist/cjs/plugins/media/commands/captions.test.js +0 -149
- package/dist/cjs/plugins/media/commands/linking.test.js +0 -296
- package/dist/cjs/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -50
- package/dist/cjs/plugins/panel/toolbar.test.js +0 -250
- package/dist/cjs/ui/ColorPickerButton/index.test.js +0 -123
- package/dist/cjs/ui/PortalProvider/index.test.js +0 -139
- package/dist/es2019/plugins/caption/nodeviews/index.test.js +0 -122
- package/dist/es2019/plugins/caption/pm-plugins/keymap.test.js +0 -193
- package/dist/es2019/plugins/caption/pm-plugins/main.test.js +0 -132
- package/dist/es2019/plugins/code-block/language-list.test.js +0 -69
- package/dist/es2019/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -83
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
- package/dist/es2019/plugins/media/commands/captions.test.js +0 -126
- package/dist/es2019/plugins/media/commands/linking.test.js +0 -208
- package/dist/es2019/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
- package/dist/es2019/plugins/panel/toolbar.test.js +0 -200
- package/dist/es2019/ui/ColorPickerButton/index.test.js +0 -88
- package/dist/es2019/ui/PortalProvider/index.test.js +0 -115
- package/dist/esm/plugins/caption/nodeviews/index.test.js +0 -125
- package/dist/esm/plugins/caption/pm-plugins/keymap.test.js +0 -195
- package/dist/esm/plugins/caption/pm-plugins/main.test.js +0 -124
- package/dist/esm/plugins/code-block/language-list.test.js +0 -71
- package/dist/esm/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -92
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
- package/dist/esm/plugins/media/commands/captions.test.js +0 -135
- package/dist/esm/plugins/media/commands/linking.test.js +0 -268
- package/dist/esm/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
- package/dist/esm/plugins/panel/toolbar.test.js +0 -230
- package/dist/esm/ui/ColorPickerButton/index.test.js +0 -107
- package/dist/esm/ui/PortalProvider/index.test.js +0 -129
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
4
|
+
import CodeBidiWarning from '@atlaskit/code/bidi-warning';
|
|
5
|
+
import codeBidiWarningDecorator from '@atlaskit/code/bidi-warning-decorator';
|
|
6
|
+
import { pluginFactory } from '../../../utils/plugin-state-factory';
|
|
7
|
+
import { stepHasSlice } from '../../../utils/step';
|
|
8
|
+
import { codeBidiWarningPluginKey } from '../plugin-key';
|
|
9
|
+
import reducer from './reducer';
|
|
10
|
+
export const {
|
|
11
|
+
createPluginState,
|
|
12
|
+
getPluginState
|
|
13
|
+
} = pluginFactory(codeBidiWarningPluginKey, reducer, {
|
|
14
|
+
onDocChanged: (tr, pluginState) => {
|
|
15
|
+
if (!tr.steps.find(stepHasSlice)) {
|
|
16
|
+
return pluginState;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const newBidiWarningsDecorationSet = createBidiWarningsDecorationSetFromDoc({
|
|
20
|
+
doc: tr.doc,
|
|
21
|
+
codeBidiWarningLabel: pluginState.codeBidiWarningLabel
|
|
22
|
+
});
|
|
23
|
+
return { ...pluginState,
|
|
24
|
+
decorationSet: newBidiWarningsDecorationSet
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
export function createBidiWarningsDecorationSetFromDoc({
|
|
29
|
+
doc,
|
|
30
|
+
codeBidiWarningLabel
|
|
31
|
+
}) {
|
|
32
|
+
const bidiCharactersAndTheirPositions = [];
|
|
33
|
+
doc.descendants((node, pos) => {
|
|
34
|
+
const isTextWithCodeMark = node.type.name === 'text' && node.marks && node.marks.some(mark => mark.type.name === 'code');
|
|
35
|
+
|
|
36
|
+
if (isTextWithCodeMark) {
|
|
37
|
+
codeBidiWarningDecorator(node.textContent, ({
|
|
38
|
+
bidiCharacter,
|
|
39
|
+
index
|
|
40
|
+
}) => {
|
|
41
|
+
bidiCharactersAndTheirPositions.push({
|
|
42
|
+
position: pos + index,
|
|
43
|
+
bidiCharacter
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const isCodeBlock = node.type.name === 'codeBlock';
|
|
50
|
+
|
|
51
|
+
if (isCodeBlock) {
|
|
52
|
+
codeBidiWarningDecorator(node.textContent, ({
|
|
53
|
+
bidiCharacter,
|
|
54
|
+
index
|
|
55
|
+
}) => {
|
|
56
|
+
bidiCharactersAndTheirPositions.push({
|
|
57
|
+
position: pos + index + 1,
|
|
58
|
+
bidiCharacter
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}); // Bidi characters are not expected to commonly appear in code snippets, so recreating the decoration set
|
|
63
|
+
// for documents rather than reusing existing decorations seems a reasonable performance/complexity tradeoff.
|
|
64
|
+
|
|
65
|
+
if (bidiCharactersAndTheirPositions.length === 0) {
|
|
66
|
+
return DecorationSet.empty;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const newBidiWarningsDecorationSet = DecorationSet.create(doc, bidiCharactersAndTheirPositions.map(({
|
|
70
|
+
position,
|
|
71
|
+
bidiCharacter
|
|
72
|
+
}) => {
|
|
73
|
+
return Decoration.widget(position, () => renderDOM(bidiCharacter, codeBidiWarningLabel));
|
|
74
|
+
}));
|
|
75
|
+
return newBidiWarningsDecorationSet;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function renderDOM(bidiCharacter, codeBidiWarningLabel) {
|
|
79
|
+
const element = document.createElement('span'); // Note: we use this pattern elsewhere (see highlighting code block, and drop cursor widget decoration)
|
|
80
|
+
// we should investigate if there is a memory leak with such usage.
|
|
81
|
+
|
|
82
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(CodeBidiWarning, {
|
|
83
|
+
bidiCharacter: bidiCharacter,
|
|
84
|
+
skipChildren: true,
|
|
85
|
+
label: codeBidiWarningLabel
|
|
86
|
+
}), element);
|
|
87
|
+
return element;
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -22,7 +22,12 @@ const codeBlockPlugin = (options = {}) => ({
|
|
|
22
22
|
pmPlugins() {
|
|
23
23
|
return [{
|
|
24
24
|
name: 'codeBlock',
|
|
25
|
-
plugin: (
|
|
25
|
+
plugin: ({
|
|
26
|
+
reactContext
|
|
27
|
+
}) => createPlugin({
|
|
28
|
+
useLongPressSelection: options.useLongPressSelection,
|
|
29
|
+
reactContext
|
|
30
|
+
})
|
|
26
31
|
}, {
|
|
27
32
|
name: 'codeBlockIDEKeyBindings',
|
|
28
33
|
plugin: () => ideUX
|
|
@@ -28,7 +28,7 @@ const toDOM = node => ['div', {
|
|
|
28
28
|
}]]];
|
|
29
29
|
|
|
30
30
|
export class CodeBlockView {
|
|
31
|
-
constructor(_node, view, getPos) {
|
|
31
|
+
constructor(_node, view, getPos, codeBidiWarningOptions) {
|
|
32
32
|
_defineProperty(this, "highlighting", null);
|
|
33
33
|
|
|
34
34
|
_defineProperty(this, "highlighter", null);
|
|
@@ -57,6 +57,7 @@ export class CodeBlockView {
|
|
|
57
57
|
dom,
|
|
58
58
|
contentDOM
|
|
59
59
|
} = DOMSerializer.renderSpec(document, toDOM(_node));
|
|
60
|
+
this.codeBidiWarningOptions = codeBidiWarningOptions;
|
|
60
61
|
this.getPos = getPos;
|
|
61
62
|
this.view = view;
|
|
62
63
|
this.node = _node;
|
|
@@ -99,7 +100,9 @@ export class CodeBlockView {
|
|
|
99
100
|
ReactDOM.render( /*#__PURE__*/React.createElement(CodeBlock, {
|
|
100
101
|
text: node.textContent,
|
|
101
102
|
language: node.attrs.language,
|
|
102
|
-
showLineNumbers: false
|
|
103
|
+
showLineNumbers: false,
|
|
104
|
+
codeBidiWarnings: this.codeBidiWarningOptions.enabled,
|
|
105
|
+
codeBidiWarningLabel: this.codeBidiWarningOptions.label
|
|
103
106
|
}), highlighting);
|
|
104
107
|
this.measure(performance.now() - start);
|
|
105
108
|
content === null || content === void 0 ? void 0 : content.setAttribute('data-debounce', 'false');
|
|
@@ -130,8 +133,17 @@ export class CodeBlockView {
|
|
|
130
133
|
ignoreMutation(record) {
|
|
131
134
|
var _this$highlighting$co, _this$highlighting;
|
|
132
135
|
|
|
133
|
-
|
|
136
|
+
const lineNumberChanges = record.target === this.lineNumberGutter || record.target.parentNode === this.lineNumberGutter;
|
|
137
|
+
const outsideTheCodeBlockChanges = (_this$highlighting$co = (_this$highlighting = this.highlighting) === null || _this$highlighting === void 0 ? void 0 : _this$highlighting.contains(record.target)) !== null && _this$highlighting$co !== void 0 ? _this$highlighting$co : false;
|
|
138
|
+
const codeBidiWarningDecorationChanges = record.type === 'attributes' && record.attributeName === 'aria-describedby';
|
|
139
|
+
return lineNumberChanges || outsideTheCodeBlockChanges || codeBidiWarningDecorationChanges;
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
}
|
|
137
|
-
export const highlightingCodeBlockNodeView = (
|
|
143
|
+
export const highlightingCodeBlockNodeView = ({
|
|
144
|
+
codeBidiWarnings,
|
|
145
|
+
codeBidiWarningLabel
|
|
146
|
+
}) => (node, view, getPos) => new CodeBlockView(node, view, getPos, {
|
|
147
|
+
enabled: codeBidiWarnings,
|
|
148
|
+
label: codeBidiWarningLabel
|
|
149
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Plugin, NodeSelection } from 'prosemirror-state';
|
|
2
|
+
import { codeBidiWarningMessages } from '@atlaskit/editor-common/messages';
|
|
2
3
|
import { codeBlockNodeView } from '../nodeviews/code-block';
|
|
3
4
|
import { highlightingCodeBlockNodeView } from '../nodeviews/highlighting-code-block';
|
|
4
5
|
import { createSelectionClickHandler } from '../../selection/utils';
|
|
@@ -7,51 +8,61 @@ import { ACTIONS } from './actions';
|
|
|
7
8
|
import { findCodeBlock } from '../utils';
|
|
8
9
|
import { codeBlockClassNames } from '../ui/class-names';
|
|
9
10
|
import { getFeatureFlags } from '../../feature-flags-context';
|
|
10
|
-
export const createPlugin = (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
apply(tr, pluginState, _oldState, newState) {
|
|
22
|
-
if (tr.docChanged || tr.selectionSet) {
|
|
23
|
-
const node = findCodeBlock(newState, tr.selection);
|
|
24
|
-
const newPluginState = { ...pluginState,
|
|
11
|
+
export const createPlugin = ({
|
|
12
|
+
useLongPressSelection = false,
|
|
13
|
+
reactContext
|
|
14
|
+
}) => {
|
|
15
|
+
const intl = reactContext().intl;
|
|
16
|
+
const codeBidiWarningLabel = intl.formatMessage(codeBidiWarningMessages.label);
|
|
17
|
+
return new Plugin({
|
|
18
|
+
state: {
|
|
19
|
+
init(_, state) {
|
|
20
|
+
const node = findCodeBlock(state, state.selection);
|
|
21
|
+
return {
|
|
25
22
|
pos: node ? node.pos : null,
|
|
26
|
-
|
|
23
|
+
contentCopied: false,
|
|
24
|
+
isNodeSelected: false
|
|
27
25
|
};
|
|
28
|
-
|
|
29
|
-
}
|
|
26
|
+
},
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
apply(tr, pluginState, _oldState, newState) {
|
|
29
|
+
if (tr.docChanged || tr.selectionSet) {
|
|
30
|
+
const node = findCodeBlock(newState, tr.selection);
|
|
31
|
+
const newPluginState = { ...pluginState,
|
|
32
|
+
pos: node ? node.pos : null,
|
|
33
|
+
isNodeSelected: tr.selection instanceof NodeSelection
|
|
34
|
+
};
|
|
35
|
+
return newPluginState;
|
|
36
|
+
}
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
return { ...pluginState,
|
|
35
|
-
contentCopied: meta.data
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
+
const meta = tr.getMeta(pluginKey);
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.type) === ACTIONS.SET_COPIED_TO_CLIPBOARD) {
|
|
41
|
+
return { ...pluginState,
|
|
42
|
+
contentCopied: meta.data
|
|
43
|
+
};
|
|
44
|
+
}
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
key: pluginKey,
|
|
44
|
-
props: {
|
|
45
|
-
nodeViews: {
|
|
46
|
-
codeBlock(node, view, getPos) {
|
|
47
|
-
const featureFlags = getFeatureFlags(view.state);
|
|
48
|
-
const createCodeBlockNodeView = featureFlags !== null && featureFlags !== void 0 && featureFlags.codeBlockSyntaxHighlighting ? highlightingCodeBlockNodeView() : codeBlockNodeView();
|
|
49
|
-
return createCodeBlockNodeView(node, view, getPos);
|
|
46
|
+
return pluginState;
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
key: pluginKey,
|
|
51
|
+
props: {
|
|
52
|
+
nodeViews: {
|
|
53
|
+
codeBlock(node, view, getPos) {
|
|
54
|
+
const featureFlags = getFeatureFlags(view.state);
|
|
55
|
+
const createCodeBlockNodeView = featureFlags !== null && featureFlags !== void 0 && featureFlags.codeBlockSyntaxHighlighting ? highlightingCodeBlockNodeView({
|
|
56
|
+
codeBidiWarnings: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.codeBidiWarnings,
|
|
57
|
+
codeBidiWarningLabel
|
|
58
|
+
}) : codeBlockNodeView();
|
|
59
|
+
return createCodeBlockNodeView(node, view, getPos);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
},
|
|
63
|
+
handleClickOn: createSelectionClickHandler(['codeBlock'], target => !!(target.closest(`.${codeBlockClassNames.gutter}`) || target.classList.contains(codeBlockClassNames.content)), {
|
|
64
|
+
useLongPressSelection
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
};
|
|
@@ -41,7 +41,7 @@ export const getToolbarConfig = (allowCopyToClipboard = false) => (state, {
|
|
|
41
41
|
alias: lang.alias
|
|
42
42
|
})); // If language is not undefined search for it in the value and then search in the aliases
|
|
43
43
|
|
|
44
|
-
const defaultValue = language ? options.find(option => option.value === language) || options.find(option => option.alias.includes(language)) :
|
|
44
|
+
const defaultValue = language ? options.find(option => option.value === language) || options.find(option => option.alias.includes(language)) : null;
|
|
45
45
|
const languageSelect = {
|
|
46
46
|
id: 'editor.codeBlock.languageOptions',
|
|
47
47
|
type: 'select',
|
|
@@ -5,6 +5,8 @@ import { EmojiSharedCssClassName } from '@atlaskit/editor-common';
|
|
|
5
5
|
import { SelectionStyle, getSelectionStyles, akEditorSelectedNodeClassName, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
6
6
|
export const emojiStyles = css`
|
|
7
7
|
.${EmojiSharedCssClassName.EMOJI_CONTAINER} {
|
|
8
|
+
display: inline-block;
|
|
9
|
+
|
|
8
10
|
.${EmojiSharedCssClassName.EMOJI_NODE} {
|
|
9
11
|
cursor: pointer;
|
|
10
12
|
|
|
@@ -97,7 +97,6 @@ export const createContextIdentifierProviderHandler = view => async (name, provi
|
|
|
97
97
|
|
|
98
98
|
const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProviderAPI, eventDispatcher, useLongPressSelection = false, options = {}) => {
|
|
99
99
|
const state = createPluginState(dispatch, {
|
|
100
|
-
layout: 'default',
|
|
101
100
|
showEditButton: false,
|
|
102
101
|
showContextPanel: false
|
|
103
102
|
});
|
|
@@ -155,14 +154,12 @@ const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProvid
|
|
|
155
154
|
const showEditButton = shouldShowEditButton(extensionHandler, extensionProvider);
|
|
156
155
|
const updateExtension = getUpdateExtensionPromise(view, extensionHandler, extensionProvider).catch(() => {// do nothing;
|
|
157
156
|
});
|
|
158
|
-
const layout = selectedExtension ? node.attrs.layout : 'default';
|
|
159
157
|
updateState({
|
|
160
158
|
localId: node.attrs.localId,
|
|
161
159
|
showContextPanel: false,
|
|
162
160
|
element: newElement,
|
|
163
161
|
showEditButton,
|
|
164
|
-
updateExtension
|
|
165
|
-
layout
|
|
162
|
+
updateExtension
|
|
166
163
|
})(state, dispatch);
|
|
167
164
|
} // New DOM element doesn't necessarily mean it's a new Node
|
|
168
165
|
else if (element !== newElement) {
|
|
@@ -41,30 +41,35 @@ const isLayoutSupported = (state, selectedExtNode) => {
|
|
|
41
41
|
return !!((selectedExtNode.node.type === bodiedExtension || selectedExtNode.node.type === extension && !hasParentNodeOfType([bodiedExtension, table, expand].filter(Boolean))(selection)) && !hasParentNodeOfType([layoutSection])(selection));
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const breakoutOptions = (state, formatMessage,
|
|
45
|
-
const nodeWithPos = getSelectedExtension(state, true);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
44
|
+
const breakoutOptions = (state, formatMessage, breakoutEnabled) => {
|
|
45
|
+
const nodeWithPos = getSelectedExtension(state, true); // we should only return breakout options when breakouts are enabled and the node supports them
|
|
46
|
+
|
|
47
|
+
if (nodeWithPos && breakoutEnabled && isLayoutSupported(state, nodeWithPos)) {
|
|
48
|
+
const {
|
|
49
|
+
layout
|
|
50
|
+
} = nodeWithPos.node.attrs;
|
|
51
|
+
return [{
|
|
52
|
+
type: 'button',
|
|
53
|
+
icon: CenterIcon,
|
|
54
|
+
onClick: updateExtensionLayout('default'),
|
|
55
|
+
selected: layout === 'default',
|
|
56
|
+
title: formatMessage(commonMessages.layoutFixedWidth)
|
|
57
|
+
}, {
|
|
58
|
+
type: 'button',
|
|
59
|
+
icon: WideIcon,
|
|
60
|
+
onClick: updateExtensionLayout('wide'),
|
|
61
|
+
selected: layout === 'wide',
|
|
62
|
+
title: formatMessage(commonMessages.layoutWide)
|
|
63
|
+
}, {
|
|
64
|
+
type: 'button',
|
|
65
|
+
icon: FullWidthIcon,
|
|
66
|
+
onClick: updateExtensionLayout('full-width'),
|
|
67
|
+
selected: layout === 'full-width',
|
|
68
|
+
title: formatMessage(commonMessages.layoutFullWidth)
|
|
69
|
+
}];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return [];
|
|
68
73
|
};
|
|
69
74
|
|
|
70
75
|
const editButton = (formatMessage, extensionState) => {
|
|
@@ -99,7 +104,7 @@ export const getToolbarConfig = (breakoutEnabled = true) => (state, intl) => {
|
|
|
99
104
|
if (extensionState && !extensionState.showContextPanel && extensionState.element) {
|
|
100
105
|
const nodeType = [state.schema.nodes.extension, state.schema.nodes.inlineExtension, state.schema.nodes.bodiedExtension];
|
|
101
106
|
const editButtonArray = editButton(formatMessage, extensionState);
|
|
102
|
-
const breakoutButtonArray = breakoutOptions(state, formatMessage,
|
|
107
|
+
const breakoutButtonArray = breakoutOptions(state, formatMessage, breakoutEnabled);
|
|
103
108
|
return {
|
|
104
109
|
title: 'Extension floating controls',
|
|
105
110
|
getDomRef: () => extensionState.element.parentElement || undefined,
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { normalizeFeatureFlags } from '@atlaskit/editor-common/normalize-feature-flags';
|
|
2
|
-
|
|
2
|
+
import { browser } from '@atlaskit/editor-common';
|
|
3
3
|
/**
|
|
4
4
|
* Transforms EditorProps to an FeatureFlags object,
|
|
5
5
|
* which is used by both current and archv3 editors.
|
|
6
6
|
*/
|
|
7
|
+
|
|
7
8
|
export function createFeatureFlagsFromProps(props) {
|
|
8
|
-
var _props$allowTextColor, _props$performanceTra, _props$performanceTra2, _props$featureFlags, _props$featureFlags2, _props$featureFlags3, _props$allowTables, _props$featureFlags4, _props$featureFlags5, _props$allowTables2, _props$featureFlags6, _props$featureFlags7, _props$allowTables3, _props$featureFlags8, _props$featureFlags9, _props$allowTables4, _props$featureFlags10, _props$featureFlags11, _props$allowTables5, _props$allowExtension, _props$featureFlags12, _props$featureFlags13, _props$featureFlags14, _props$featureFlags15, _props$featureFlags16, _props$featureFlags17, _props$featureFlags18, _props$featureFlags19, _props$featureFlags20, _props$featureFlags21, _props$featureFlags22, _props$featureFlags23, _props$featureFlags24, _props$featureFlags25;
|
|
9
|
+
var _props$allowTextColor, _props$performanceTra, _props$performanceTra2, _props$featureFlags, _props$featureFlags2, _props$featureFlags3, _props$allowTables, _props$featureFlags4, _props$featureFlags5, _props$allowTables2, _props$featureFlags6, _props$featureFlags7, _props$allowTables3, _props$featureFlags8, _props$featureFlags9, _props$allowTables4, _props$featureFlags10, _props$featureFlags11, _props$allowTables5, _props$allowExtension, _props$featureFlags12, _props$featureFlags13, _props$featureFlags14, _props$featureFlags15, _props$featureFlags16, _props$featureFlags17, _props$featureFlags18, _props$featureFlags19, _props$featureFlags20, _props$featureFlags21, _props$featureFlags22, _props$featureFlags23, _props$featureFlags24, _props$featureFlags25, _props$featureFlags26, _props$featureFlags27, _props$featureFlags28, _props$featureFlags29;
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
const normalizedFeatureFlags = normalizeFeatureFlags(props.featureFlags);
|
|
12
|
+
return { ...normalizedFeatureFlags,
|
|
11
13
|
newInsertionBehaviour: props.allowNewInsertionBehaviour,
|
|
12
14
|
interactiveExpand: typeof props.allowExpand === 'boolean' ? props.allowExpand : Boolean(props.allowExpand && props.allowExpand.allowInteractiveExpand !== false),
|
|
13
15
|
placeholderBracketHint: !!props.placeholderBracketHint,
|
|
@@ -32,6 +34,9 @@ export function createFeatureFlagsFromProps(props) {
|
|
|
32
34
|
errorBoundaryDocStructure: Boolean(typeof ((_props$featureFlags18 = props.featureFlags) === null || _props$featureFlags18 === void 0 ? void 0 : _props$featureFlags18.useErrorBoundaryDocStructure) === 'boolean' ? !!((_props$featureFlags19 = props.featureFlags) !== null && _props$featureFlags19 !== void 0 && _props$featureFlags19.useErrorBoundaryDocStructure) : false),
|
|
33
35
|
synchronyErrorDocStructure: Boolean(typeof ((_props$featureFlags20 = props.featureFlags) === null || _props$featureFlags20 === void 0 ? void 0 : _props$featureFlags20.synchronyErrorDocStructure) === 'boolean' ? !!((_props$featureFlags21 = props.featureFlags) !== null && _props$featureFlags21 !== void 0 && _props$featureFlags21.synchronyErrorDocStructure) : false),
|
|
34
36
|
enableViewUpdateSubscription: Boolean(typeof ((_props$featureFlags22 = props.featureFlags) === null || _props$featureFlags22 === void 0 ? void 0 : _props$featureFlags22.enableViewUpdateSubscription) === 'boolean' ? !!((_props$featureFlags23 = props.featureFlags) !== null && _props$featureFlags23 !== void 0 && _props$featureFlags23.enableViewUpdateSubscription) : false),
|
|
35
|
-
collabAvatarScroll: Boolean(typeof ((_props$featureFlags24 = props.featureFlags) === null || _props$featureFlags24 === void 0 ? void 0 : _props$featureFlags24.collabAvatarScroll) === 'boolean' ? !!((_props$featureFlags25 = props.featureFlags) !== null && _props$featureFlags25 !== void 0 && _props$featureFlags25.collabAvatarScroll) : false)
|
|
37
|
+
collabAvatarScroll: Boolean(typeof ((_props$featureFlags24 = props.featureFlags) === null || _props$featureFlags24 === void 0 ? void 0 : _props$featureFlags24.collabAvatarScroll) === 'boolean' ? !!((_props$featureFlags25 = props.featureFlags) !== null && _props$featureFlags25 !== void 0 && _props$featureFlags25.collabAvatarScroll) : false),
|
|
38
|
+
ufo: Boolean(typeof ((_props$featureFlags26 = props.featureFlags) === null || _props$featureFlags26 === void 0 ? void 0 : _props$featureFlags26.ufo) === 'boolean' ? !!((_props$featureFlags27 = props.featureFlags) !== null && _props$featureFlags27 !== void 0 && _props$featureFlags27.ufo) : false),
|
|
39
|
+
codeBlockSyntaxHighlighting: Boolean(typeof normalizedFeatureFlags.codeBlockSyntaxHighlighting === 'boolean' ? !!normalizedFeatureFlags.codeBlockSyntaxHighlighting && !browser.safari : false),
|
|
40
|
+
codeBidiWarnings: Boolean(typeof ((_props$featureFlags28 = props.featureFlags) === null || _props$featureFlags28 === void 0 ? void 0 : _props$featureFlags28.codeBidiWarnings) === 'boolean' ? !!((_props$featureFlags29 = props.featureFlags) !== null && _props$featureFlags29 !== void 0 && _props$featureFlags29.codeBidiWarnings) : true)
|
|
36
41
|
};
|
|
37
42
|
}
|
|
@@ -71,12 +71,17 @@ class Find extends React.Component {
|
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
_defineProperty(this, "handleFindChange", event =>
|
|
74
|
+
_defineProperty(this, "handleFindChange", event => {
|
|
75
75
|
this.updateFindValue(event.target.value);
|
|
76
|
-
})
|
|
76
|
+
});
|
|
77
77
|
|
|
78
78
|
_defineProperty(this, "updateFindValue", value => {
|
|
79
|
-
this.
|
|
79
|
+
this.setState({
|
|
80
|
+
localFindText: value
|
|
81
|
+
});
|
|
82
|
+
this.skipWhileComposing(() => {
|
|
83
|
+
this.props.onFind(value);
|
|
84
|
+
});
|
|
80
85
|
});
|
|
81
86
|
|
|
82
87
|
_defineProperty(this, "handleFindKeyDown", event => this.skipWhileComposing(() => {
|
|
@@ -153,7 +158,13 @@ class Find extends React.Component {
|
|
|
153
158
|
});
|
|
154
159
|
this.closeIcon = /*#__PURE__*/React.createElement(EditorCloseIcon, {
|
|
155
160
|
label: this.closeFindReplaceDialog
|
|
156
|
-
});
|
|
161
|
+
}); // We locally manage the value of the input inside this component in order to support compositions.
|
|
162
|
+
// This requires some additional work inside componentDidUpdate to ensure we support changes that
|
|
163
|
+
// occur to this value which do not originate from this component.
|
|
164
|
+
|
|
165
|
+
this.state = {
|
|
166
|
+
localFindText: this.props.findText || ''
|
|
167
|
+
};
|
|
157
168
|
}
|
|
158
169
|
|
|
159
170
|
componentDidMount() {
|
|
@@ -162,7 +173,17 @@ class Find extends React.Component {
|
|
|
162
173
|
}
|
|
163
174
|
|
|
164
175
|
componentDidUpdate() {
|
|
165
|
-
this.focusFindTextfield();
|
|
176
|
+
this.focusFindTextfield(); // If the external prop findText changes and we aren't in a composition we should update to the
|
|
177
|
+
// use the external prop value.
|
|
178
|
+
//
|
|
179
|
+
// An example of where this may happen is when a find occurs through the user selecting some text
|
|
180
|
+
// and pressing Mod-f.
|
|
181
|
+
|
|
182
|
+
if (!this.isComposing && this.props.findText !== this.state.localFindText) {
|
|
183
|
+
this.setState({
|
|
184
|
+
localFindText: this.props.findText || ''
|
|
185
|
+
});
|
|
186
|
+
}
|
|
166
187
|
}
|
|
167
188
|
|
|
168
189
|
render() {
|
|
@@ -183,7 +204,7 @@ class Find extends React.Component {
|
|
|
183
204
|
name: "find",
|
|
184
205
|
appearance: "none",
|
|
185
206
|
placeholder: this.find,
|
|
186
|
-
value:
|
|
207
|
+
value: this.state.localFindText,
|
|
187
208
|
ref: this.findTextfieldRef,
|
|
188
209
|
autoComplete: "off",
|
|
189
210
|
onChange: this.handleFindChange,
|
|
@@ -59,7 +59,7 @@ export class HyperlinkToolbarAppearance extends Component {
|
|
|
59
59
|
|
|
60
60
|
// needed so we display the right state on the Toolbar while the same Toolbar
|
|
61
61
|
// instance is visible and we click other link
|
|
62
|
-
|
|
62
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
63
63
|
if (nextProps.url !== this.props.url) {
|
|
64
64
|
this.resolveUrl(nextProps.url);
|
|
65
65
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { keymap } from 'prosemirror-keymap';
|
|
2
|
+
import { getLinkMatch } from '@atlaskit/adf-schema';
|
|
2
3
|
import * as keymaps from '../../../keymaps';
|
|
3
|
-
import { getLinkMatch } from '../utils';
|
|
4
4
|
import { stateKey } from '../pm-plugins/main';
|
|
5
5
|
import { showLinkToolbar, hideLinkToolbar } from '../commands';
|
|
6
6
|
import { queueCards } from '../../card/pm-plugins/actions';
|
|
@@ -83,7 +83,8 @@ const mapActivityProviderResultToLinkSearchItemData = ({
|
|
|
83
83
|
container,
|
|
84
84
|
iconUrl,
|
|
85
85
|
url,
|
|
86
|
-
lastViewedDate: viewedTimestamp ? new Date(viewedTimestamp) : undefined
|
|
86
|
+
lastViewedDate: viewedTimestamp ? new Date(viewedTimestamp) : undefined,
|
|
87
|
+
prefetch: true
|
|
87
88
|
});
|
|
88
89
|
|
|
89
90
|
const mapSearchProviderResultToLinkSearchItemData = ({
|
|
@@ -99,7 +100,8 @@ const mapSearchProviderResultToLinkSearchItemData = ({
|
|
|
99
100
|
name: title,
|
|
100
101
|
url,
|
|
101
102
|
lastUpdatedDate: updatedTimestamp ? new Date(updatedTimestamp) : undefined,
|
|
102
|
-
icon: contentType && mapContentTypeToIcon[contentType] || defaultIcon
|
|
103
|
+
icon: contentType && mapContentTypeToIcon[contentType] || defaultIcon,
|
|
104
|
+
prefetch: false
|
|
103
105
|
});
|
|
104
106
|
|
|
105
107
|
export class HyperlinkLinkAddToolbar extends PureComponent {
|
|
@@ -344,7 +346,7 @@ export class HyperlinkLinkAddToolbar extends PureComponent {
|
|
|
344
346
|
}
|
|
345
347
|
|
|
346
348
|
if (interaction === 'click' || this.isUrlPopulatedWithSelectedItem()) {
|
|
347
|
-
var _pluginState$searchSe3;
|
|
349
|
+
var _pluginState$searchSe3, _selectedItem$prefetc;
|
|
348
350
|
|
|
349
351
|
/**
|
|
350
352
|
* When it's a mouse click even or the selectedItem.url matches displayUrl, we think
|
|
@@ -361,7 +363,8 @@ export class HyperlinkLinkAddToolbar extends PureComponent {
|
|
|
361
363
|
trigger: interaction,
|
|
362
364
|
resultCount: items.length,
|
|
363
365
|
selectedResultId: selectedItem.objectId,
|
|
364
|
-
selectedRelativePosition: selectedIndex
|
|
366
|
+
selectedRelativePosition: selectedIndex,
|
|
367
|
+
prefetch: (_selectedItem$prefetc = selectedItem.prefetch) !== null && _selectedItem$prefetc !== void 0 ? _selectedItem$prefetc : false
|
|
365
368
|
},
|
|
366
369
|
eventType: EVENT_TYPE.UI
|
|
367
370
|
});
|
|
@@ -1,26 +1,5 @@
|
|
|
1
|
-
import LinkifyIt from 'linkify-it';
|
|
2
1
|
import { mapSlice } from '../../utils/slice';
|
|
3
|
-
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
4
|
-
export const LINK_REGEXP = /(https?|ftp):\/\/[^\s]+/;
|
|
5
|
-
const linkify = LinkifyIt();
|
|
6
|
-
linkify.add('sourcetree:', 'http:');
|
|
7
|
-
const tlds = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
|
|
8
|
-
const tlds2Char = 'a[cdefgilmnoqrtuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrtuvwxyz]|n[acefgilopruz]|om|p[aefghkmnrtw]|qa|r[eosuw]|s[abcdegijklmnrtuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]';
|
|
9
|
-
tlds.push(tlds2Char);
|
|
10
|
-
linkify.tlds(tlds, false);
|
|
11
|
-
export function getLinkMatch(str) {
|
|
12
|
-
if (!str) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
let match = linkifyMatch(str);
|
|
17
|
-
|
|
18
|
-
if (!match.length) {
|
|
19
|
-
match = linkify.match(str);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return match && match[0];
|
|
23
|
-
}
|
|
2
|
+
import { isSafeUrl, linkify, normalizeUrl as normaliseLinkHref } from '@atlaskit/adf-schema';
|
|
24
3
|
/**
|
|
25
4
|
* Instance of class LinkMatcher are used in autoformatting in place of Regex.
|
|
26
5
|
* Hence it has been made similar to regex with an exec method.
|
|
@@ -81,8 +60,7 @@ export function normalizeUrl(url) {
|
|
|
81
60
|
return url;
|
|
82
61
|
}
|
|
83
62
|
|
|
84
|
-
|
|
85
|
-
return match && match.url || '';
|
|
63
|
+
return normaliseLinkHref(url);
|
|
86
64
|
}
|
|
87
65
|
export function linkifyContent(schema) {
|
|
88
66
|
return slice => mapSlice(slice, (node, parent) => {
|
|
@@ -148,38 +126,4 @@ function findLinkMatches(text) {
|
|
|
148
126
|
}
|
|
149
127
|
|
|
150
128
|
return matches;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export const linkifyMatch = text => {
|
|
154
|
-
const matches = [];
|
|
155
|
-
|
|
156
|
-
if (!LINK_REGEXP.test(text)) {
|
|
157
|
-
return matches;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
let startpos = 0;
|
|
161
|
-
let substr;
|
|
162
|
-
|
|
163
|
-
while (substr = text.substr(startpos)) {
|
|
164
|
-
const link = (substr.match(LINK_REGEXP) || [''])[0];
|
|
165
|
-
|
|
166
|
-
if (link) {
|
|
167
|
-
const index = substr.search(LINK_REGEXP);
|
|
168
|
-
const start = index >= 0 ? index + startpos : index;
|
|
169
|
-
const end = start + link.length;
|
|
170
|
-
matches.push({
|
|
171
|
-
index: start,
|
|
172
|
-
lastIndex: end,
|
|
173
|
-
raw: link,
|
|
174
|
-
url: link,
|
|
175
|
-
text: link,
|
|
176
|
-
schema: ''
|
|
177
|
-
});
|
|
178
|
-
startpos += end;
|
|
179
|
-
} else {
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return matches;
|
|
185
|
-
};
|
|
129
|
+
}
|
|
@@ -60,4 +60,5 @@ export { default as mobileSelectionPlugin } from './mobile-selection';
|
|
|
60
60
|
export { default as clipboardPlugin } from './clipboard';
|
|
61
61
|
export { default as undoRedoPlugin } from './undo-redo';
|
|
62
62
|
export { default as avatarGroupPlugin } from './avatar-group';
|
|
63
|
-
export { default as viewUpdateSubscriptionPlugin } from './view-update-subscription';
|
|
63
|
+
export { default as viewUpdateSubscriptionPlugin } from './view-update-subscription';
|
|
64
|
+
export { default as codeBidiWarningPlugin } from './code-bidi-warning';
|