@atlaskit/editor-core 178.0.2 → 178.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 +40 -0
- package/dist/cjs/create-editor/create-plugins-list.js +3 -1
- package/dist/cjs/plugins/alignment/ui/ToolbarAlignment/index.js +26 -13
- package/dist/cjs/plugins/annotation/index.js +4 -2
- package/dist/cjs/plugins/annotation/ui/InlineCommentView.js +6 -2
- package/dist/cjs/plugins/base/pm-plugins/react-nodeview.js +8 -1
- package/dist/cjs/plugins/block-type/commands/delete-block-content.js +53 -0
- package/dist/cjs/plugins/block-type/commands/index.js +9 -1
- package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +2 -2
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +8 -4
- package/dist/cjs/plugins/card/nodeviews/blockCard.js +1 -1
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +1 -3
- package/dist/cjs/plugins/card/pm-plugins/doc.js +21 -4
- package/dist/cjs/plugins/card/toolbar.js +4 -2
- package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +4 -1
- package/dist/cjs/plugins/card/ui/LinkToolbarAppearance.js +16 -9
- package/dist/cjs/plugins/collab-edit/actions.js +1 -1
- package/dist/cjs/plugins/collab-edit/index.js +1 -1
- package/dist/cjs/plugins/collab-edit/provider/channel.js +1 -1
- package/dist/cjs/plugins/expand/pm-plugins/keymap.js +5 -0
- package/dist/cjs/plugins/floating-toolbar/ui/Select.js +2 -1
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +18 -9
- package/dist/cjs/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -0
- package/dist/cjs/plugins/hyperlink/index.js +2 -1
- package/dist/cjs/plugins/hyperlink/ui/EditorLinkPicker/index.js +15 -2
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +27 -22
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +6 -2
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +2 -1
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +2 -1
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +2 -1
- package/dist/cjs/plugins/media/commands/helpers.js +24 -2
- package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +14 -16
- package/dist/cjs/plugins/media/nodeviews/mediaNodeUpdater.js +232 -183
- package/dist/cjs/plugins/media/nodeviews/mediaNodeView/index.js +1 -3
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/cjs/plugins/media/pm-plugins/keymap.js +46 -0
- package/dist/cjs/plugins/rank.js +3 -2
- package/dist/cjs/plugins/selection/pm-plugins/events/create-selection-between.js +86 -0
- package/dist/cjs/plugins/selection/pm-plugins/events/keydown.js +84 -0
- package/dist/cjs/plugins/selection/pm-plugins/selection-main.js +6 -56
- package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +1 -1
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +7 -2
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +4 -2
- package/dist/cjs/ui/Addon/ClickAreaBlock/index.js +22 -61
- package/dist/cjs/ui/Addon/ClickAreaInline/index.js +22 -56
- package/dist/cjs/ui/Addon/click-area-helper.js +28 -6
- package/dist/cjs/ui/Alignment/AlignmentButton/index.js +4 -2
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +2 -1
- package/dist/cjs/ui/ToolbarArrowKeyNavigationProvider/index.js +22 -9
- package/dist/cjs/utils/document.js +11 -2
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/create-editor/create-plugins-list.js +3 -1
- package/dist/es2019/plugins/alignment/ui/ToolbarAlignment/index.js +28 -13
- package/dist/es2019/plugins/annotation/index.js +4 -2
- package/dist/es2019/plugins/annotation/ui/InlineCommentView.js +6 -2
- package/dist/es2019/plugins/base/pm-plugins/react-nodeview.js +8 -1
- package/dist/es2019/plugins/block-type/commands/delete-block-content.js +49 -0
- package/dist/es2019/plugins/block-type/commands/index.js +2 -1
- package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +3 -3
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +8 -4
- package/dist/es2019/plugins/card/nodeviews/blockCard.js +1 -1
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -2
- package/dist/es2019/plugins/card/pm-plugins/doc.js +19 -3
- package/dist/es2019/plugins/card/toolbar.js +4 -2
- package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +5 -2
- package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +15 -9
- package/dist/es2019/plugins/collab-edit/actions.js +1 -1
- package/dist/es2019/plugins/collab-edit/index.js +1 -1
- package/dist/es2019/plugins/collab-edit/provider/channel.js +1 -1
- package/dist/es2019/plugins/expand/pm-plugins/keymap.js +5 -0
- package/dist/es2019/plugins/floating-toolbar/ui/Select.js +2 -1
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +18 -9
- package/dist/es2019/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -0
- package/dist/es2019/plugins/hyperlink/index.js +2 -1
- package/dist/es2019/plugins/hyperlink/ui/EditorLinkPicker/index.js +11 -2
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +1 -5
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +6 -2
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +2 -1
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +2 -1
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +2 -1
- package/dist/es2019/plugins/media/commands/helpers.js +18 -1
- package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +14 -16
- package/dist/es2019/plugins/media/nodeviews/mediaNodeUpdater.js +37 -13
- package/dist/es2019/plugins/media/nodeviews/mediaNodeView/index.js +1 -2
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/es2019/plugins/media/pm-plugins/keymap.js +45 -0
- package/dist/es2019/plugins/rank.js +3 -2
- package/dist/es2019/plugins/selection/pm-plugins/events/create-selection-between.js +79 -0
- package/dist/es2019/plugins/selection/pm-plugins/events/keydown.js +77 -0
- package/dist/es2019/plugins/selection/pm-plugins/selection-main.js +5 -55
- package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +1 -1
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +6 -2
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +3 -2
- package/dist/es2019/ui/Addon/ClickAreaBlock/index.js +20 -31
- package/dist/es2019/ui/Addon/ClickAreaInline/index.js +20 -27
- package/dist/es2019/ui/Addon/click-area-helper.js +28 -6
- package/dist/es2019/ui/Alignment/AlignmentButton/index.js +4 -2
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +2 -1
- package/dist/es2019/ui/ToolbarArrowKeyNavigationProvider/index.js +22 -9
- package/dist/es2019/utils/document.js +9 -2
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/create-editor/create-plugins-list.js +3 -1
- package/dist/esm/plugins/alignment/ui/ToolbarAlignment/index.js +26 -13
- package/dist/esm/plugins/annotation/index.js +4 -2
- package/dist/esm/plugins/annotation/ui/InlineCommentView.js +6 -2
- package/dist/esm/plugins/base/pm-plugins/react-nodeview.js +8 -1
- package/dist/esm/plugins/block-type/commands/delete-block-content.js +46 -0
- package/dist/esm/plugins/block-type/commands/index.js +2 -1
- package/dist/esm/plugins/block-type/pm-plugins/keymap.js +3 -3
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +8 -4
- package/dist/esm/plugins/card/nodeviews/blockCard.js +1 -1
- package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -2
- package/dist/esm/plugins/card/pm-plugins/doc.js +20 -3
- package/dist/esm/plugins/card/toolbar.js +4 -2
- package/dist/esm/plugins/card/ui/EditLinkToolbar.js +5 -2
- package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +16 -9
- package/dist/esm/plugins/collab-edit/actions.js +1 -1
- package/dist/esm/plugins/collab-edit/index.js +1 -1
- package/dist/esm/plugins/collab-edit/provider/channel.js +1 -1
- package/dist/esm/plugins/expand/pm-plugins/keymap.js +5 -0
- package/dist/esm/plugins/floating-toolbar/ui/Select.js +2 -1
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +18 -9
- package/dist/esm/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -0
- package/dist/esm/plugins/hyperlink/index.js +2 -1
- package/dist/esm/plugins/hyperlink/ui/EditorLinkPicker/index.js +15 -3
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +27 -22
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +6 -2
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +2 -1
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +2 -1
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +2 -1
- package/dist/esm/plugins/media/commands/helpers.js +20 -1
- package/dist/esm/plugins/media/nodeviews/mediaGroup.js +14 -16
- package/dist/esm/plugins/media/nodeviews/mediaNodeUpdater.js +235 -184
- package/dist/esm/plugins/media/nodeviews/mediaNodeView/index.js +1 -2
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/esm/plugins/media/pm-plugins/keymap.js +45 -0
- package/dist/esm/plugins/rank.js +3 -2
- package/dist/esm/plugins/selection/pm-plugins/events/create-selection-between.js +76 -0
- package/dist/esm/plugins/selection/pm-plugins/events/keydown.js +74 -0
- package/dist/esm/plugins/selection/pm-plugins/selection-main.js +4 -57
- package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +1 -1
- package/dist/esm/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +7 -2
- package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +4 -2
- package/dist/esm/ui/Addon/ClickAreaBlock/index.js +17 -58
- package/dist/esm/ui/Addon/ClickAreaInline/index.js +17 -53
- package/dist/esm/ui/Addon/click-area-helper.js +28 -6
- package/dist/esm/ui/Alignment/AlignmentButton/index.js +4 -2
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +2 -1
- package/dist/esm/ui/ToolbarArrowKeyNavigationProvider/index.js +22 -9
- package/dist/esm/utils/document.js +11 -2
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/alignment/ui/ToolbarAlignment/index.d.ts +1 -1
- package/dist/types/plugins/block-type/commands/delete-block-content.d.ts +10 -0
- package/dist/types/plugins/block-type/commands/index.d.ts +1 -0
- package/dist/types/plugins/card/pm-plugins/doc.d.ts +1 -1
- package/dist/types/plugins/card/ui/LinkToolbarAppearance.d.ts +1 -0
- package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +1 -0
- package/dist/types/plugins/hyperlink/ui/EditorLinkPicker/index.d.ts +6 -1
- package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +1 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +1 -0
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +1 -0
- package/dist/types/plugins/media/commands/helpers.d.ts +1 -0
- package/dist/types/plugins/media/nodeviews/__mocks__/mediaNodeUpdater.d.ts +1 -0
- package/dist/types/plugins/media/nodeviews/mediaNodeUpdater.d.ts +3 -1
- package/dist/types/plugins/media/types.d.ts +2 -0
- package/dist/types/plugins/selection/pm-plugins/events/create-selection-between.d.ts +4 -0
- package/dist/types/plugins/selection/pm-plugins/events/keydown.d.ts +2 -0
- package/dist/types/ui/Addon/ClickAreaBlock/index.d.ts +2 -5
- package/dist/types/ui/Addon/ClickAreaInline/index.d.ts +2 -5
- package/dist/types/ui/Addon/click-area-helper.d.ts +1 -1
- package/dist/types/ui/Alignment/AlignmentButton/index.d.ts +1 -1
- package/dist/types/ui/ElementBrowser/InsertMenu.d.ts +1 -1
- package/dist/types/ui/ElementBrowser/types.d.ts +1 -0
- package/docs/0-intro.tsx +9 -0
- package/package.json +14 -16
- package/report.api.md +4 -1
|
@@ -23,6 +23,10 @@ var insideContentArea = function insideContentArea(ref) {
|
|
|
23
23
|
|
|
24
24
|
return false;
|
|
25
25
|
};
|
|
26
|
+
|
|
27
|
+
var insideProseMirrorEditableArea = function insideProseMirrorEditableArea(ref) {
|
|
28
|
+
return Boolean(ref === null || ref === void 0 ? void 0 : ref.closest('.ProseMirror'));
|
|
29
|
+
};
|
|
26
30
|
/**
|
|
27
31
|
* @see ED-14699 - check if editor is inside a modal to continue to bring cursor to input when
|
|
28
32
|
* any part of the editor container is clicked
|
|
@@ -49,11 +53,19 @@ var checkForModal = function checkForModal(target) {
|
|
|
49
53
|
exports.checkForModal = checkForModal;
|
|
50
54
|
|
|
51
55
|
var clickAreaClickHandler = function clickAreaClickHandler(view, event) {
|
|
52
|
-
var _view$hasFocus;
|
|
56
|
+
var _view$hasFocus, _event$currentTarget;
|
|
53
57
|
|
|
54
|
-
var isTargetContentArea = event.currentTarget.querySelector('.ak-editor-content-area');
|
|
55
58
|
var isEditorFocused = !!(view !== null && view !== void 0 && (_view$hasFocus = view.hasFocus) !== null && _view$hasFocus !== void 0 && _view$hasFocus.call(view));
|
|
56
|
-
var target = event.target;
|
|
59
|
+
var target = event.target;
|
|
60
|
+
var isTargetContentArea = target.classList.contains('ak-editor-content-area');
|
|
61
|
+
var isTargetChildOfContentArea = insideContentArea(target.parentNode);
|
|
62
|
+
var isTargetInsideEditableArea = insideProseMirrorEditableArea(target); // Any click inside ProseMirror should be managed by ProseMirror
|
|
63
|
+
|
|
64
|
+
if (isTargetInsideEditableArea) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var isEventComingFromContentArea = Boolean(event.currentTarget.querySelector('.ak-editor-content-area')); // @see https://product-fabric.atlassian.net/browse/ED-4287
|
|
57
69
|
// click event gets triggered twice on a checkbox (on <label> first and then on <input>)
|
|
58
70
|
// by the time it gets triggered on input, PM already re-renders nodeView and detaches it from DOM
|
|
59
71
|
// which doesn't pass the check !contentArea.contains(event.target)
|
|
@@ -64,10 +76,20 @@ var clickAreaClickHandler = function clickAreaClickHandler(view, event) {
|
|
|
64
76
|
|
|
65
77
|
var isTextAreaClicked = target.nodeName === 'TEXTAREA';
|
|
66
78
|
var isBreadcrumbClicked = !!(0, _dom.closestElement)(target, 'nav[aria-label="Breadcrumbs"]');
|
|
67
|
-
var isTargetChildOfContentArea = insideContentArea(target.parentNode);
|
|
68
79
|
var selection = window.getSelection();
|
|
69
|
-
var isEditorPopupTextSelected = (selection === null || selection === void 0 ? void 0 : selection.type) === 'Range' && (0, _dom.closestElement)(selection === null || selection === void 0 ? void 0 : selection.anchorNode, '[data-editor-popup]');
|
|
70
|
-
|
|
80
|
+
var isEditorPopupTextSelected = (selection === null || selection === void 0 ? void 0 : selection.type) === 'Range' && (0, _dom.closestElement)(selection === null || selection === void 0 ? void 0 : selection.anchorNode, '[data-editor-popup]'); // This is a super workaround to find when events are coming from Confluence InlineComment modal
|
|
81
|
+
// We don't own those components, so we can't change them
|
|
82
|
+
|
|
83
|
+
var isEventComingFromInlineCommentPopup = Boolean((0, _dom.closestElement)(event.currentTarget, 'div[offset]')) || Boolean((0, _dom.closestElement)(target, 'div[offset]'));
|
|
84
|
+
var isButtonClicked = Boolean((0, _dom.closestElement)(event.currentTarget, 'button')) || Boolean((0, _dom.closestElement)(target, 'button')) || ((_event$currentTarget = event.currentTarget) === null || _event$currentTarget === void 0 ? void 0 : _event$currentTarget.nodeName) === 'BUTTON' || target.nodeName === 'BUTTON';
|
|
85
|
+
var isTargetInsideContentArea = Boolean(isTargetChildOfContentArea);
|
|
86
|
+
var isBetweenContentAreaAndEditableContent = isTargetInsideContentArea && !isTargetInsideEditableArea;
|
|
87
|
+
var edgeCaseScenario1 = (isBetweenContentAreaAndEditableContent || !isEventComingFromContentArea) && !isEditorFocused;
|
|
88
|
+
var edgeCaseScenario2 = !isTargetInsideContentArea && isEditorFocused;
|
|
89
|
+
var edgeCaseScenario3 = isTargetContentArea && !isTargetInsideContentArea && !isEditorFocused;
|
|
90
|
+
var edgeCaseScenario4 = isEventComingFromContentArea && !isTargetContentArea && !isTargetInsideContentArea && !isEditorFocused;
|
|
91
|
+
var edgeCases = edgeCaseScenario1 || edgeCaseScenario2 || edgeCaseScenario3 || edgeCaseScenario4;
|
|
92
|
+
var isClickOutsideEditor = edgeCases && !isEventComingFromInlineCommentPopup && !isButtonClicked && !isInputClicked && !isTextAreaClicked && !isPopupClicked && !isBreadcrumbClicked && !isEditorPopupTextSelected && checkForModal(target); // click was within editor container and focus should be brought to input
|
|
71
93
|
|
|
72
94
|
if (isClickOutsideEditor && view) {
|
|
73
95
|
outsideProsemirrorEditorClickHandler(view, event);
|
|
@@ -57,9 +57,11 @@ var AlignmentButton = /*#__PURE__*/function (_PureComponent) {
|
|
|
57
57
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClick", function (e) {
|
|
58
58
|
var _this$props = _this.props,
|
|
59
59
|
onClick = _this$props.onClick,
|
|
60
|
-
value = _this$props.value;
|
|
60
|
+
value = _this$props.value; // detect if the click event comes from keyboard where screenX and screenY are 0
|
|
61
|
+
|
|
62
|
+
var isMouseEvent = e instanceof MouseEvent;
|
|
61
63
|
e.preventDefault();
|
|
62
|
-
onClick(value);
|
|
64
|
+
onClick(value, isMouseEvent);
|
|
63
65
|
});
|
|
64
66
|
return _this;
|
|
65
67
|
}
|
|
@@ -50,6 +50,7 @@ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
|
50
50
|
var InsertMenu = function InsertMenu(_ref) {
|
|
51
51
|
var editorView = _ref.editorView,
|
|
52
52
|
dropdownItems = _ref.dropdownItems,
|
|
53
|
+
showElementBrowserLink = _ref.showElementBrowserLink,
|
|
53
54
|
onInsert = _ref.onInsert,
|
|
54
55
|
toggleVisiblity = _ref.toggleVisiblity;
|
|
55
56
|
|
|
@@ -79,7 +80,7 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
79
80
|
};
|
|
80
81
|
}, [onInsert]);
|
|
81
82
|
var quickInsertDropdownItems = dropdownItems.map(transform);
|
|
82
|
-
var viewMoreItem = quickInsertDropdownItems.pop();
|
|
83
|
+
var viewMoreItem = showElementBrowserLink && quickInsertDropdownItems.pop();
|
|
83
84
|
var onInsertItem = (0, _react.useCallback)(function (item) {
|
|
84
85
|
toggleVisiblity();
|
|
85
86
|
|
|
@@ -45,18 +45,24 @@ var ToolbarArrowKeyNavigationProvider = function ToolbarArrowKeyNavigationProvid
|
|
|
45
45
|
var wrapperRef = (0, _react.useRef)(null);
|
|
46
46
|
var selectedItemIndex = (0, _react.useRef)(0);
|
|
47
47
|
var incrementIndex = (0, _react.useCallback)(function (list) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
var index = 0;
|
|
49
|
+
|
|
50
|
+
if (document.activeElement) {
|
|
51
|
+
index = list.indexOf(document.activeElement);
|
|
52
|
+
index = (index + 1) % list.length;
|
|
52
53
|
}
|
|
54
|
+
|
|
55
|
+
selectedItemIndex.current = index;
|
|
53
56
|
}, []);
|
|
54
57
|
var decrementIndex = (0, _react.useCallback)(function (list) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
var index = 0;
|
|
59
|
+
|
|
60
|
+
if (document.activeElement) {
|
|
61
|
+
index = list.indexOf(document.activeElement);
|
|
62
|
+
index = (list.length + index - 1) % list.length;
|
|
59
63
|
}
|
|
64
|
+
|
|
65
|
+
selectedItemIndex.current = index;
|
|
60
66
|
}, []);
|
|
61
67
|
|
|
62
68
|
var handleArrowRight = function handleArrowRight() {
|
|
@@ -122,12 +128,19 @@ var ToolbarArrowKeyNavigationProvider = function ToolbarArrowKeyNavigationProvid
|
|
|
122
128
|
return;
|
|
123
129
|
}
|
|
124
130
|
|
|
131
|
+
var menuWrapper = document.querySelector('.menu-key-handler-wrapper');
|
|
132
|
+
|
|
133
|
+
if (menuWrapper) {
|
|
134
|
+
// if menu wrapper exists, then a menu is open and arrow keys will be handled by MenuArrowKeyNavigationProvider
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
125
138
|
var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
126
139
|
|
|
127
140
|
if (!filteredFocusableElements || (filteredFocusableElements === null || filteredFocusableElements === void 0 ? void 0 : filteredFocusableElements.length) === 0) {
|
|
128
141
|
return;
|
|
129
142
|
} //This is kind of hack to reset the current focused toolbar item
|
|
130
|
-
//to handle some
|
|
143
|
+
//to handle some use cases such as Tab in/out of main toolbar
|
|
131
144
|
|
|
132
145
|
|
|
133
146
|
if (!((_wrapperRef$current = wrapperRef.current) !== null && _wrapperRef$current !== void 0 && _wrapperRef$current.contains(targetElement))) {
|
|
@@ -253,11 +253,20 @@ function processRawValue(schema, value, providerFactory, sanitizePrivateContent,
|
|
|
253
253
|
|
|
254
254
|
if (isTransformed && dispatchAnalyticsEvent) {
|
|
255
255
|
dispatchAnalyticsEvent({
|
|
256
|
-
action: _enums.ACTION.
|
|
256
|
+
action: _enums.ACTION.DEDUPE_MARKS_TRANSFORMED_V2,
|
|
257
257
|
actionSubject: _enums.ACTION_SUBJECT.EDITOR,
|
|
258
258
|
eventType: _enums.EVENT_TYPE.OPERATIONAL,
|
|
259
259
|
attributes: {
|
|
260
|
-
|
|
260
|
+
/** UGC WARNING
|
|
261
|
+
*
|
|
262
|
+
* DO NOT include the `mark` attributes inside, we map here to only
|
|
263
|
+
* extract the mark type as that is the only non-UGC safe information
|
|
264
|
+
* that we can add to event-attributes
|
|
265
|
+
*
|
|
266
|
+
*/
|
|
267
|
+
discardedMarkTypes: discardedMarks.map(function (mark) {
|
|
268
|
+
return mark.type;
|
|
269
|
+
})
|
|
261
270
|
}
|
|
262
271
|
});
|
|
263
272
|
}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/editor-core";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "178.
|
|
9
|
+
var version = "178.1.1";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
|
|
12
12
|
var nextMajorVersion = function nextMajorVersion() {
|
package/dist/cjs/version.json
CHANGED
|
@@ -176,6 +176,7 @@ export default function createPluginsList(props, prevProps, createAnalyticsEvent
|
|
|
176
176
|
allowDropzoneDropLine: isFullPage,
|
|
177
177
|
allowMediaSingleEditable: !isMobile,
|
|
178
178
|
allowRemoteDimensionsFetch: !isMobile,
|
|
179
|
+
editorSelectionAPI,
|
|
179
180
|
// This is a wild one. I didnt quite understand what the code was doing
|
|
180
181
|
// so a bit of guess for now.
|
|
181
182
|
allowMarkingUploadsAsIncomplete: isMobile,
|
|
@@ -252,7 +253,8 @@ export default function createPluginsList(props, prevProps, createAnalyticsEvent
|
|
|
252
253
|
disableLayout: true
|
|
253
254
|
},
|
|
254
255
|
allowMediaGroup: false,
|
|
255
|
-
isCopyPasteEnabled: true
|
|
256
|
+
isCopyPasteEnabled: true,
|
|
257
|
+
editorSelectionAPI
|
|
256
258
|
}]);
|
|
257
259
|
}
|
|
258
260
|
}
|
|
@@ -21,8 +21,11 @@ export class AlignmentToolbar extends React.Component {
|
|
|
21
21
|
isOpen: false
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
_defineProperty(this, "changeAlignment", align => {
|
|
25
|
-
|
|
24
|
+
_defineProperty(this, "changeAlignment", (align, togglePopup) => {
|
|
25
|
+
if (togglePopup) {
|
|
26
|
+
this.toggleOpen();
|
|
27
|
+
}
|
|
28
|
+
|
|
26
29
|
return this.props.changeAlignment(align);
|
|
27
30
|
});
|
|
28
31
|
|
|
@@ -54,11 +57,10 @@ export class AlignmentToolbar extends React.Component {
|
|
|
54
57
|
}
|
|
55
58
|
});
|
|
56
59
|
|
|
57
|
-
_defineProperty(this, "
|
|
60
|
+
_defineProperty(this, "hideOnEscape", () => {
|
|
58
61
|
var _this$toolbarItemRef2, _this$toolbarItemRef3;
|
|
59
62
|
|
|
60
|
-
this.hide();
|
|
61
|
-
|
|
63
|
+
this.hide();
|
|
62
64
|
(_this$toolbarItemRef2 = this.toolbarItemRef) === null || _this$toolbarItemRef2 === void 0 ? void 0 : (_this$toolbarItemRef3 = _this$toolbarItemRef2.current) === null || _this$toolbarItemRef3 === void 0 ? void 0 : _this$toolbarItemRef3.focus();
|
|
63
65
|
});
|
|
64
66
|
}
|
|
@@ -84,15 +86,28 @@ export class AlignmentToolbar extends React.Component {
|
|
|
84
86
|
boundariesElement: popupsBoundariesElement,
|
|
85
87
|
scrollableElement: popupsScrollableElement,
|
|
86
88
|
isOpen: isOpen,
|
|
87
|
-
|
|
88
|
-
isOpen
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
onOpenChange: ({
|
|
90
|
+
isOpen
|
|
91
|
+
}) => {
|
|
92
|
+
var _this$toolbarItemRef4, _this$toolbarItemRef5;
|
|
93
|
+
|
|
94
|
+
this.setState({
|
|
95
|
+
isOpen
|
|
96
|
+
});
|
|
97
|
+
(_this$toolbarItemRef4 = this.toolbarItemRef) === null || _this$toolbarItemRef4 === void 0 ? void 0 : (_this$toolbarItemRef5 = _this$toolbarItemRef4.current) === null || _this$toolbarItemRef5 === void 0 ? void 0 : _this$toolbarItemRef5.focus();
|
|
98
|
+
},
|
|
99
|
+
handleClickOutside: event => {
|
|
100
|
+
if (event instanceof MouseEvent) {
|
|
101
|
+
this.hide({
|
|
102
|
+
isOpen: false,
|
|
103
|
+
event
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
handleEscapeKeydown: this.hideOnEscape,
|
|
93
108
|
fitWidth: 112,
|
|
94
109
|
fitHeight: 80,
|
|
95
|
-
|
|
110
|
+
closeOnTab: true,
|
|
96
111
|
trigger: jsx(ToolbarButton, {
|
|
97
112
|
spacing: isReducedSpacing ? 'none' : 'default',
|
|
98
113
|
disabled: disabled,
|
|
@@ -115,7 +130,7 @@ export class AlignmentToolbar extends React.Component {
|
|
|
115
130
|
ref: this.toolbarItemRef
|
|
116
131
|
})
|
|
117
132
|
}, jsx(Alignment, {
|
|
118
|
-
onClick: align => this.changeAlignment(align),
|
|
133
|
+
onClick: align => this.changeAlignment(align, false),
|
|
119
134
|
selectedAlignment: pluginState.align
|
|
120
135
|
})), jsx("span", {
|
|
121
136
|
css: separator
|
|
@@ -86,11 +86,13 @@ const annotationPlugin = annotationProviders => {
|
|
|
86
86
|
return null;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
return /*#__PURE__*/React.createElement(
|
|
89
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
"data-editor-popup": "true"
|
|
91
|
+
}, /*#__PURE__*/React.createElement(InlineCommentView, {
|
|
90
92
|
providers: annotationProviders,
|
|
91
93
|
editorView: editorView,
|
|
92
94
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
93
|
-
});
|
|
95
|
+
}));
|
|
94
96
|
}
|
|
95
97
|
});
|
|
96
98
|
}
|
|
@@ -67,7 +67,9 @@ export function InlineCommentView({
|
|
|
67
67
|
selection: selection.toJSON(),
|
|
68
68
|
position,
|
|
69
69
|
docSize: editorView.state.doc.nodeSize,
|
|
70
|
-
error: error.toString()
|
|
70
|
+
error: error.toString()
|
|
71
|
+
},
|
|
72
|
+
nonPrivacySafeAttributes: {
|
|
71
73
|
errorStack: error.stack || undefined
|
|
72
74
|
}
|
|
73
75
|
};
|
|
@@ -88,7 +90,8 @@ export function InlineCommentView({
|
|
|
88
90
|
|
|
89
91
|
const textSelection = state.doc.textBetween(selection.from, selection.to);
|
|
90
92
|
return /*#__PURE__*/React.createElement("div", {
|
|
91
|
-
"data-testid": AnnotationTestIds.floatingComponent
|
|
93
|
+
"data-testid": AnnotationTestIds.floatingComponent,
|
|
94
|
+
"data-editor-popup": "true"
|
|
92
95
|
}, /*#__PURE__*/React.createElement(CreateComponent, {
|
|
93
96
|
dom: dom,
|
|
94
97
|
textSelection: textSelection,
|
|
@@ -133,6 +136,7 @@ export function InlineCommentView({
|
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
return /*#__PURE__*/React.createElement(AnnotationViewWrapper, {
|
|
139
|
+
"data-editor-popup": "true",
|
|
136
140
|
"data-testid": AnnotationTestIds.floatingComponent,
|
|
137
141
|
key: getAnnotationViewKey(activeAnnotations),
|
|
138
142
|
onViewed: onAnnotationViewed
|
|
@@ -36,13 +36,20 @@ export const plugin = new SafePlugin({
|
|
|
36
36
|
key: stateKey,
|
|
37
37
|
view: view => {
|
|
38
38
|
const pluginState = stateKey.getState(view.state);
|
|
39
|
+
let prevFrom = -1;
|
|
40
|
+
let prevTo = -1;
|
|
39
41
|
return {
|
|
40
42
|
update: view => {
|
|
41
43
|
const {
|
|
42
44
|
from,
|
|
43
45
|
to
|
|
44
46
|
} = view.state.selection;
|
|
45
|
-
|
|
47
|
+
|
|
48
|
+
if (from !== prevFrom || to !== prevTo) {
|
|
49
|
+
pluginState.notifyNewSelection(from, to);
|
|
50
|
+
prevFrom = from;
|
|
51
|
+
prevTo = to;
|
|
52
|
+
}
|
|
46
53
|
}
|
|
47
54
|
};
|
|
48
55
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prevent removing the block when deleting block content
|
|
3
|
+
*
|
|
4
|
+
* @param state EditorState<any>
|
|
5
|
+
* @param dispatch CommandDispatch
|
|
6
|
+
* @returns boolean
|
|
7
|
+
*/
|
|
8
|
+
export function deleteBlockContent(isNodeAWrappingBlockNode) {
|
|
9
|
+
return (state, dispatch) => {
|
|
10
|
+
const {
|
|
11
|
+
tr,
|
|
12
|
+
selection: {
|
|
13
|
+
$from,
|
|
14
|
+
$to
|
|
15
|
+
},
|
|
16
|
+
doc
|
|
17
|
+
} = state;
|
|
18
|
+
|
|
19
|
+
if ($from.pos === $to.pos) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let selectionCrossesWrappingBlockNode = false;
|
|
24
|
+
doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
|
|
25
|
+
// Optimisation. If selection crosses wrapping block node
|
|
26
|
+
// short circuit the loop by returning false
|
|
27
|
+
if (selectionCrossesWrappingBlockNode) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (isNodeAWrappingBlockNode(node)) {
|
|
32
|
+
selectionCrossesWrappingBlockNode = true;
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (!selectionCrossesWrappingBlockNode) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
tr.delete($from.pos, $to.pos);
|
|
42
|
+
|
|
43
|
+
if (dispatch) {
|
|
44
|
+
dispatch(tr);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { cleanUpAtTheStartOfDocument, insertBlockType, insertBlockTypesWithAnalytics, setBlockType, setBlockTypeWithAnalytics, setHeading, setHeadingWithAnalytics, setNormalText, setNormalTextWithAnalytics } from './block-type';
|
|
2
2
|
export { insertBlock } from './insert-block';
|
|
3
3
|
export { isConvertableToCodeBlock, transformToCodeBlockAction } from './transform-to-code-block';
|
|
4
|
-
export { deleteAndMoveCursor } from './delete-and-move-cursor';
|
|
4
|
+
export { deleteAndMoveCursor } from './delete-and-move-cursor';
|
|
5
|
+
export { deleteBlockContent } from './delete-block-content';
|
|
@@ -4,12 +4,12 @@ import * as keymaps from '../../../keymaps';
|
|
|
4
4
|
import * as commands from '../../../commands';
|
|
5
5
|
import * as blockTypes from '../types';
|
|
6
6
|
import { keymap } from '../../../utils/keymap';
|
|
7
|
-
import { cleanUpAtTheStartOfDocument, deleteAndMoveCursor, insertBlockTypesWithAnalytics } from '../commands';
|
|
7
|
+
import { cleanUpAtTheStartOfDocument, deleteAndMoveCursor, deleteBlockContent, insertBlockTypesWithAnalytics } from '../commands';
|
|
8
8
|
import { deleteEmptyParagraphAndMoveBlockUp } from '../../../utils/commands';
|
|
9
9
|
import { INPUT_METHOD } from '../../analytics';
|
|
10
10
|
import { isNodeAWrappingBlockNode } from '../utils';
|
|
11
|
-
const backspace = chainCommands(cleanUpAtTheStartOfDocument, deleteAndMoveCursor);
|
|
12
|
-
const del = chainCommands(deleteEmptyParagraphAndMoveBlockUp(isNodeAWrappingBlockNode), deleteAndMoveCursor);
|
|
11
|
+
const backspace = chainCommands(cleanUpAtTheStartOfDocument, deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
|
|
12
|
+
const del = chainCommands(deleteEmptyParagraphAndMoveBlockUp(isNodeAWrappingBlockNode), deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
|
|
13
13
|
export default function keymapPlugin(schema, featureFlags) {
|
|
14
14
|
const list = {};
|
|
15
15
|
keymaps.bindKeymapWithCommand(keymaps.insertNewLine.common, commands.insertNewLineWithAnalytics, list);
|
|
@@ -69,13 +69,17 @@ class ToolbarBlockType extends React.PureComponent {
|
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
_defineProperty(this, "handleSelectBlockType", ({
|
|
72
|
-
item
|
|
72
|
+
item,
|
|
73
|
+
shouldCloseMenu = true
|
|
73
74
|
}) => {
|
|
74
75
|
const blockType = item.value;
|
|
75
76
|
this.props.setBlockType(blockType.name);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
|
|
78
|
+
if (shouldCloseMenu) {
|
|
79
|
+
this.setState({
|
|
80
|
+
active: false
|
|
81
|
+
});
|
|
82
|
+
}
|
|
79
83
|
});
|
|
80
84
|
}
|
|
81
85
|
|
|
@@ -100,7 +100,7 @@ export class BlockCard extends ReactNodeView {
|
|
|
100
100
|
createDomRef() {
|
|
101
101
|
const domRef = document.createElement('div');
|
|
102
102
|
|
|
103
|
-
if (
|
|
103
|
+
if (this.reactComponentProps.platform !== 'mobile') {
|
|
104
104
|
// workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
|
|
105
105
|
// see also: https://github.com/ProseMirror/prosemirror/issues/884
|
|
106
106
|
domRef.contentEditable = 'true';
|
|
@@ -6,7 +6,6 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import rafSchedule from 'raf-schd';
|
|
7
7
|
import { Card } from './genericCard';
|
|
8
8
|
import { UnsupportedBlock, MediaSingle as RichMediaWrapper, findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
9
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
10
9
|
import { DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
11
10
|
import { SelectionBasedNodeView } from '../../../nodeviews/';
|
|
12
11
|
import { registerCard } from '../pm-plugins/actions';
|
|
@@ -320,7 +319,7 @@ export class EmbedCard extends SelectionBasedNodeView {
|
|
|
320
319
|
createDomRef() {
|
|
321
320
|
const domRef = document.createElement('div');
|
|
322
321
|
|
|
323
|
-
if (
|
|
322
|
+
if (this.reactComponentProps.platform !== 'mobile') {
|
|
324
323
|
// workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
|
|
325
324
|
// see also: https://github.com/ProseMirror/prosemirror/issues/884
|
|
326
325
|
domRef.contentEditable = 'true';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { NodeSelection, TextSelection } from 'prosemirror-state';
|
|
1
2
|
import { closeHistory } from 'prosemirror-history';
|
|
2
|
-
import { NodeSelection } from 'prosemirror-state';
|
|
3
3
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE, INPUT_METHOD } from '../../../plugins/analytics';
|
|
5
5
|
import { SMART_LINK_TYPE } from '../../../plugins/analytics/types/node-events';
|
|
@@ -301,6 +301,8 @@ export const changeSelectedCardToText = text => (state, dispatch) => {
|
|
|
301
301
|
return true;
|
|
302
302
|
};
|
|
303
303
|
export const setSelectedCardAppearance = appearance => (state, dispatch) => {
|
|
304
|
+
var _previousNode$type;
|
|
305
|
+
|
|
304
306
|
const selectedNode = state.selection instanceof NodeSelection && state.selection.node;
|
|
305
307
|
|
|
306
308
|
if (!selectedNode) {
|
|
@@ -324,10 +326,24 @@ export const setSelectedCardAppearance = appearance => (state, dispatch) => {
|
|
|
324
326
|
layout: 'center'
|
|
325
327
|
} : selectedNode.attrs;
|
|
326
328
|
const {
|
|
327
|
-
from
|
|
329
|
+
from,
|
|
330
|
+
to
|
|
328
331
|
} = state.selection;
|
|
329
332
|
const nodeType = getLinkNodeType(appearance, state.schema.nodes);
|
|
330
|
-
const tr = state.tr.setNodeMarkup(from, nodeType, attrs, selectedNode.marks);
|
|
333
|
+
const tr = state.tr.setNodeMarkup(from, nodeType, attrs, selectedNode.marks); // When the selected card is the last element in the doc we add a new paragraph after it for consistent replacement
|
|
334
|
+
|
|
335
|
+
if (tr.doc.nodeSize - 2 === to) {
|
|
336
|
+
tr.insertText(' ', to);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
tr.setSelection(TextSelection.create(tr.doc, to + 1));
|
|
340
|
+
const previousNodePos = from - 1 > 0 ? from - 1 : 0;
|
|
341
|
+
const previousNode = tr.doc.nodeAt(previousNodePos);
|
|
342
|
+
|
|
343
|
+
if ((previousNode === null || previousNode === void 0 ? void 0 : (_previousNode$type = previousNode.type) === null || _previousNode$type === void 0 ? void 0 : _previousNode$type.name) === 'paragraph') {
|
|
344
|
+
tr.delete(previousNodePos, from);
|
|
345
|
+
}
|
|
346
|
+
|
|
331
347
|
addAnalytics(state, tr, {
|
|
332
348
|
action: ACTION.CHANGED_TYPE,
|
|
333
349
|
actionSubject: ACTION_SUBJECT.SMART_LINK,
|
|
@@ -255,9 +255,10 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, platfor
|
|
|
255
255
|
const {
|
|
256
256
|
allowBlockCards,
|
|
257
257
|
allowEmbeds
|
|
258
|
-
} = cardOptions;
|
|
258
|
+
} = cardOptions; // This code will be executed only for appearances such as "inline", "block" & "embed"
|
|
259
|
+
// For url appearance, please see HyperlinkToolbarAppearanceProps
|
|
259
260
|
|
|
260
|
-
if (
|
|
261
|
+
if (currentAppearance) {
|
|
261
262
|
toolbarItems.unshift({
|
|
262
263
|
type: 'custom',
|
|
263
264
|
fallback: [],
|
|
@@ -269,6 +270,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, platfor
|
|
|
269
270
|
editorView: editorView,
|
|
270
271
|
editorState: state,
|
|
271
272
|
allowEmbeds: allowEmbeds,
|
|
273
|
+
allowBlockCards: allowBlockCards,
|
|
272
274
|
platform: platform
|
|
273
275
|
})
|
|
274
276
|
}, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import HyperlinkToolbar from '../../hyperlink/ui/HyperlinkAddToolbar';
|
|
3
3
|
import { showLinkToolbar, hideLinkToolbar } from '../pm-plugins/actions';
|
|
4
|
-
import { addAnalytics } from '../../analytics';
|
|
4
|
+
import { addAnalytics, INPUT_METHOD } from '../../analytics';
|
|
5
5
|
import { LINKPICKER_HEIGHT_IN_PX, RECENT_SEARCH_HEIGHT_IN_PX, RECENT_SEARCH_WIDTH_IN_PX } from '../../../ui/LinkSearch/ToolbarComponents';
|
|
6
6
|
import { changeSelectedCardToLink, updateCard } from '../pm-plugins/doc';
|
|
7
7
|
import { findCardInfo, displayInfoForCard } from '../utils';
|
|
@@ -39,7 +39,10 @@ export class EditLinkToolbar extends React.Component {
|
|
|
39
39
|
linkPickerOptions: linkPickerOptions,
|
|
40
40
|
providerFactory: providerFactory,
|
|
41
41
|
displayUrl: url,
|
|
42
|
-
displayText: text
|
|
42
|
+
displayText: text // Assumes that the smart card link picker can only ever be invoked by clicking "edit"
|
|
43
|
+
// via the floating toolbar
|
|
44
|
+
,
|
|
45
|
+
invokeMethod: INPUT_METHOD.FLOATING_TB,
|
|
43
46
|
onSubmit: (href, title, displayText) => {
|
|
44
47
|
this.hideLinkToolbar();
|
|
45
48
|
|
|
@@ -19,6 +19,7 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
19
19
|
currentAppearance,
|
|
20
20
|
editorState,
|
|
21
21
|
allowEmbeds,
|
|
22
|
+
allowBlockCards = true,
|
|
22
23
|
platform
|
|
23
24
|
} = this.props;
|
|
24
25
|
const preview = allowEmbeds && cardContext && url && cardContext.extractors.getPreview(url, platform);
|
|
@@ -33,7 +34,7 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
const isBlockCardLinkSupportedInParent = isSupportedInParent(editorState, Fragment.from(editorState.schema.nodes.blockCard.createChecked({})), currentAppearance);
|
|
37
|
+
const isBlockCardLinkSupportedInParent = allowBlockCards ? isSupportedInParent(editorState, Fragment.from(editorState.schema.nodes.blockCard.createChecked({})), currentAppearance) : false;
|
|
37
38
|
const isEmbedCardLinkSupportedInParent = allowEmbeds ? isSupportedInParent(editorState, Fragment.from(editorState.schema.nodes.embedCard.createChecked({})), currentAppearance) : false;
|
|
38
39
|
const embedOption = allowEmbeds && preview && {
|
|
39
40
|
appearance: 'embed',
|
|
@@ -45,6 +46,15 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
45
46
|
disabled: !isEmbedCardLinkSupportedInParent,
|
|
46
47
|
tooltip: isEmbedCardLinkSupportedInParent ? undefined : getUnavailableMessage(editorState, intl)
|
|
47
48
|
};
|
|
49
|
+
const blockCardOption = allowBlockCards && {
|
|
50
|
+
appearance: 'block',
|
|
51
|
+
title: intl.formatMessage(messages.block),
|
|
52
|
+
onClick: setSelectedCardAppearance('block'),
|
|
53
|
+
selected: currentAppearance === 'block',
|
|
54
|
+
testId: 'block-appearance',
|
|
55
|
+
disabled: !isBlockCardLinkSupportedInParent,
|
|
56
|
+
tooltip: isBlockCardLinkSupportedInParent ? undefined : getUnavailableMessage(editorState, intl)
|
|
57
|
+
};
|
|
48
58
|
const options = [{
|
|
49
59
|
title: intl.formatMessage(messages.url),
|
|
50
60
|
onClick: () => changeSelectedCardToLink(url, url, true)(editorState, view === null || view === void 0 ? void 0 : view.dispatch),
|
|
@@ -56,14 +66,6 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
56
66
|
onClick: setSelectedCardAppearance('inline'),
|
|
57
67
|
selected: currentAppearance === 'inline',
|
|
58
68
|
testId: 'inline-appearance'
|
|
59
|
-
}, {
|
|
60
|
-
appearance: 'block',
|
|
61
|
-
title: intl.formatMessage(messages.block),
|
|
62
|
-
onClick: setSelectedCardAppearance('block'),
|
|
63
|
-
selected: currentAppearance === 'block',
|
|
64
|
-
testId: 'block-appearance',
|
|
65
|
-
disabled: !isBlockCardLinkSupportedInParent,
|
|
66
|
-
tooltip: isBlockCardLinkSupportedInParent ? undefined : getUnavailableMessage(editorState, intl)
|
|
67
69
|
}];
|
|
68
70
|
|
|
69
71
|
const dispatchCommand = fn => {
|
|
@@ -74,6 +76,10 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
74
76
|
}
|
|
75
77
|
};
|
|
76
78
|
|
|
79
|
+
if (blockCardOption) {
|
|
80
|
+
options.push(blockCardOption);
|
|
81
|
+
}
|
|
82
|
+
|
|
77
83
|
if (embedOption) {
|
|
78
84
|
options.push(embedOption);
|
|
79
85
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { receiveTransaction } from 'prosemirror-collab';
|
|
1
|
+
import { receiveTransaction } from '@atlaskit/prosemirror-collab';
|
|
2
2
|
import { Step } from 'prosemirror-transform';
|
|
3
3
|
import { AllSelection, NodeSelection } from 'prosemirror-state';
|
|
4
4
|
import { replaceDocument } from './utils';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { collab } from 'prosemirror-collab';
|
|
1
|
+
import { collab } from '@atlaskit/prosemirror-collab';
|
|
2
2
|
import { createPlugin, pluginKey } from './plugin';
|
|
3
3
|
import { sendTransaction } from './events/send-transaction';
|
|
4
4
|
import { addSynchronyErrorAnalytics } from './analytics';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { utils } from '@atlaskit/util-service-support';
|
|
3
3
|
import { EventEmitter2 } from 'eventemitter2';
|
|
4
|
-
import { getVersion, sendableSteps } from 'prosemirror-collab';
|
|
4
|
+
import { getVersion, sendableSteps } from '@atlaskit/prosemirror-collab';
|
|
5
5
|
import { logger } from './logger';
|
|
6
6
|
export class Channel {
|
|
7
7
|
constructor(config, pubSubClient) {
|