@atlaskit/editor-common 74.29.3 → 74.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/i18n/cs.js +19 -0
- package/dist/cjs/i18n/da.js +19 -0
- package/dist/cjs/i18n/de.js +19 -0
- package/dist/cjs/i18n/es.js +19 -0
- package/dist/cjs/i18n/fi.js +19 -0
- package/dist/cjs/i18n/fr.js +19 -0
- package/dist/cjs/i18n/hu.js +19 -0
- package/dist/cjs/i18n/it.js +19 -0
- package/dist/cjs/i18n/ja.js +19 -0
- package/dist/cjs/i18n/ko.js +19 -0
- package/dist/cjs/i18n/nb.js +19 -0
- package/dist/cjs/i18n/nl.js +19 -0
- package/dist/cjs/i18n/pl.js +19 -0
- package/dist/cjs/i18n/pt_BR.js +19 -0
- package/dist/cjs/i18n/ru.js +19 -0
- package/dist/cjs/i18n/sv.js +19 -0
- package/dist/cjs/i18n/th.js +19 -0
- package/dist/cjs/i18n/tr.js +19 -0
- package/dist/cjs/i18n/uk.js +19 -0
- package/dist/cjs/i18n/vi.js +19 -0
- package/dist/cjs/i18n/zh.js +19 -0
- package/dist/cjs/i18n/zh_TW.js +19 -0
- package/dist/cjs/lists/analytics.js +40 -0
- package/dist/cjs/lists/indentation.js +24 -0
- package/dist/cjs/lists/index.js +89 -0
- package/dist/cjs/lists/node.js +97 -0
- package/dist/cjs/lists/replace-content.js +24 -0
- package/dist/cjs/lists/selection.js +59 -0
- package/dist/cjs/mark/commands.js +201 -0
- package/dist/cjs/mark/index.js +30 -0
- package/dist/cjs/messages/full-page.js +25 -0
- package/dist/cjs/messages/index.js +7 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/node-width/index.js +10 -2
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/Toolbar/index.js +8 -0
- package/dist/cjs/ui/index.js +7 -0
- package/dist/cjs/ui-menu/DropdownMenu/index.js +16 -2
- package/dist/cjs/ui-menu/ToolbarArrowKeyNavigationProvider/index.js +219 -0
- package/dist/cjs/ui-menu/index.js +23 -4
- package/dist/cjs/utils/commands.js +110 -2
- package/dist/cjs/utils/document.js +26 -1
- package/dist/cjs/utils/index.js +51 -2
- package/dist/cjs/utils/prosemirror/autojoin.js +68 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/i18n/cs.js +19 -0
- package/dist/es2019/i18n/da.js +19 -0
- package/dist/es2019/i18n/de.js +19 -0
- package/dist/es2019/i18n/es.js +19 -0
- package/dist/es2019/i18n/fi.js +19 -0
- package/dist/es2019/i18n/fr.js +19 -0
- package/dist/es2019/i18n/hu.js +19 -0
- package/dist/es2019/i18n/it.js +19 -0
- package/dist/es2019/i18n/ja.js +19 -0
- package/dist/es2019/i18n/ko.js +19 -0
- package/dist/es2019/i18n/nb.js +19 -0
- package/dist/es2019/i18n/nl.js +19 -0
- package/dist/es2019/i18n/pl.js +19 -0
- package/dist/es2019/i18n/pt_BR.js +19 -0
- package/dist/es2019/i18n/ru.js +19 -0
- package/dist/es2019/i18n/sv.js +19 -0
- package/dist/es2019/i18n/th.js +19 -0
- package/dist/es2019/i18n/tr.js +19 -0
- package/dist/es2019/i18n/uk.js +19 -0
- package/dist/es2019/i18n/vi.js +19 -0
- package/dist/es2019/i18n/zh.js +19 -0
- package/dist/es2019/i18n/zh_TW.js +19 -0
- package/dist/es2019/lists/analytics.js +36 -0
- package/dist/es2019/lists/indentation.js +18 -0
- package/dist/es2019/lists/index.js +6 -0
- package/dist/es2019/lists/node.js +97 -0
- package/dist/es2019/lists/replace-content.js +18 -0
- package/dist/es2019/lists/selection.js +53 -0
- package/dist/es2019/mark/commands.js +205 -0
- package/dist/es2019/mark/index.js +1 -0
- package/dist/es2019/messages/full-page.js +18 -0
- package/dist/es2019/messages/index.js +1 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/node-width/index.js +7 -0
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/Toolbar/index.js +1 -0
- package/dist/es2019/ui/index.js +2 -1
- package/dist/es2019/ui-menu/DropdownMenu/index.js +16 -2
- package/dist/es2019/ui-menu/ToolbarArrowKeyNavigationProvider/index.js +209 -0
- package/dist/es2019/ui-menu/index.js +5 -4
- package/dist/es2019/utils/commands.js +106 -2
- package/dist/es2019/utils/document.js +25 -1
- package/dist/es2019/utils/index.js +3 -2
- package/dist/es2019/utils/prosemirror/autojoin.js +57 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/i18n/cs.js +19 -0
- package/dist/esm/i18n/da.js +19 -0
- package/dist/esm/i18n/de.js +19 -0
- package/dist/esm/i18n/es.js +19 -0
- package/dist/esm/i18n/fi.js +19 -0
- package/dist/esm/i18n/fr.js +19 -0
- package/dist/esm/i18n/hu.js +19 -0
- package/dist/esm/i18n/it.js +19 -0
- package/dist/esm/i18n/ja.js +19 -0
- package/dist/esm/i18n/ko.js +19 -0
- package/dist/esm/i18n/nb.js +19 -0
- package/dist/esm/i18n/nl.js +19 -0
- package/dist/esm/i18n/pl.js +19 -0
- package/dist/esm/i18n/pt_BR.js +19 -0
- package/dist/esm/i18n/ru.js +19 -0
- package/dist/esm/i18n/sv.js +19 -0
- package/dist/esm/i18n/th.js +19 -0
- package/dist/esm/i18n/tr.js +19 -0
- package/dist/esm/i18n/uk.js +19 -0
- package/dist/esm/i18n/vi.js +19 -0
- package/dist/esm/i18n/zh.js +19 -0
- package/dist/esm/i18n/zh_TW.js +19 -0
- package/dist/esm/lists/analytics.js +32 -0
- package/dist/esm/lists/indentation.js +17 -0
- package/dist/esm/lists/index.js +6 -0
- package/dist/esm/lists/node.js +87 -0
- package/dist/esm/lists/replace-content.js +17 -0
- package/dist/esm/lists/selection.js +50 -0
- package/dist/esm/mark/commands.js +190 -0
- package/dist/esm/mark/index.js +1 -0
- package/dist/esm/messages/full-page.js +18 -0
- package/dist/esm/messages/index.js +1 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/node-width/index.js +7 -0
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/Toolbar/index.js +1 -0
- package/dist/esm/ui/index.js +2 -1
- package/dist/esm/ui-menu/DropdownMenu/index.js +15 -2
- package/dist/esm/ui-menu/ToolbarArrowKeyNavigationProvider/index.js +207 -0
- package/dist/esm/ui-menu/index.js +5 -4
- package/dist/esm/utils/commands.js +104 -2
- package/dist/esm/utils/document.js +25 -1
- package/dist/esm/utils/index.js +3 -2
- package/dist/esm/utils/prosemirror/autojoin.js +63 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/i18n/cs.d.ts +19 -0
- package/dist/types/i18n/da.d.ts +19 -0
- package/dist/types/i18n/de.d.ts +19 -0
- package/dist/types/i18n/es.d.ts +19 -0
- package/dist/types/i18n/fi.d.ts +19 -0
- package/dist/types/i18n/fr.d.ts +19 -0
- package/dist/types/i18n/hu.d.ts +19 -0
- package/dist/types/i18n/it.d.ts +19 -0
- package/dist/types/i18n/ja.d.ts +19 -0
- package/dist/types/i18n/ko.d.ts +19 -0
- package/dist/types/i18n/nb.d.ts +19 -0
- package/dist/types/i18n/nl.d.ts +19 -0
- package/dist/types/i18n/pl.d.ts +19 -0
- package/dist/types/i18n/pt_BR.d.ts +19 -0
- package/dist/types/i18n/ru.d.ts +19 -0
- package/dist/types/i18n/sv.d.ts +19 -0
- package/dist/types/i18n/th.d.ts +19 -0
- package/dist/types/i18n/tr.d.ts +19 -0
- package/dist/types/i18n/uk.d.ts +19 -0
- package/dist/types/i18n/vi.d.ts +19 -0
- package/dist/types/i18n/zh.d.ts +19 -0
- package/dist/types/i18n/zh_TW.d.ts +19 -0
- package/dist/types/lists/analytics.d.ts +4 -0
- package/dist/types/lists/indentation.d.ts +5 -0
- package/dist/types/lists/index.d.ts +6 -0
- package/dist/types/lists/node.d.ts +18 -0
- package/dist/types/lists/replace-content.d.ts +8 -0
- package/dist/types/lists/selection.d.ts +13 -0
- package/dist/types/mark/commands.d.ts +18 -0
- package/dist/types/mark/index.d.ts +1 -0
- package/dist/types/messages/full-page.d.ts +17 -0
- package/dist/types/messages/index.d.ts +1 -0
- package/dist/types/node-width/index.d.ts +1 -0
- package/dist/types/ui/Toolbar/index.d.ts +5 -0
- package/dist/types/ui/index.d.ts +2 -0
- package/dist/types/ui-menu/DropdownMenu/index.d.ts +2 -1
- package/dist/types/ui-menu/ToolbarArrowKeyNavigationProvider/index.d.ts +30 -0
- package/dist/types/ui-menu/index.d.ts +7 -6
- package/dist/types/utils/commands.d.ts +36 -2
- package/dist/types/utils/document.d.ts +4 -0
- package/dist/types/utils/index.d.ts +4 -2
- package/dist/types/utils/prosemirror/autojoin.d.ts +13 -0
- package/dist/types-ts4.5/i18n/cs.d.ts +19 -0
- package/dist/types-ts4.5/i18n/da.d.ts +19 -0
- package/dist/types-ts4.5/i18n/de.d.ts +19 -0
- package/dist/types-ts4.5/i18n/es.d.ts +19 -0
- package/dist/types-ts4.5/i18n/fi.d.ts +19 -0
- package/dist/types-ts4.5/i18n/fr.d.ts +19 -0
- package/dist/types-ts4.5/i18n/hu.d.ts +19 -0
- package/dist/types-ts4.5/i18n/it.d.ts +19 -0
- package/dist/types-ts4.5/i18n/ja.d.ts +19 -0
- package/dist/types-ts4.5/i18n/ko.d.ts +19 -0
- package/dist/types-ts4.5/i18n/nb.d.ts +19 -0
- package/dist/types-ts4.5/i18n/nl.d.ts +19 -0
- package/dist/types-ts4.5/i18n/pl.d.ts +19 -0
- package/dist/types-ts4.5/i18n/pt_BR.d.ts +19 -0
- package/dist/types-ts4.5/i18n/ru.d.ts +19 -0
- package/dist/types-ts4.5/i18n/sv.d.ts +19 -0
- package/dist/types-ts4.5/i18n/th.d.ts +19 -0
- package/dist/types-ts4.5/i18n/tr.d.ts +19 -0
- package/dist/types-ts4.5/i18n/uk.d.ts +19 -0
- package/dist/types-ts4.5/i18n/vi.d.ts +19 -0
- package/dist/types-ts4.5/i18n/zh.d.ts +19 -0
- package/dist/types-ts4.5/i18n/zh_TW.d.ts +19 -0
- package/dist/types-ts4.5/lists/analytics.d.ts +4 -0
- package/dist/types-ts4.5/lists/indentation.d.ts +5 -0
- package/dist/types-ts4.5/lists/index.d.ts +6 -0
- package/dist/types-ts4.5/lists/node.d.ts +18 -0
- package/dist/types-ts4.5/lists/replace-content.d.ts +8 -0
- package/dist/types-ts4.5/lists/selection.d.ts +13 -0
- package/dist/types-ts4.5/mark/commands.d.ts +18 -0
- package/dist/types-ts4.5/mark/index.d.ts +1 -0
- package/dist/types-ts4.5/messages/full-page.d.ts +17 -0
- package/dist/types-ts4.5/messages/index.d.ts +1 -0
- package/dist/types-ts4.5/node-width/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/Toolbar/index.d.ts +5 -0
- package/dist/types-ts4.5/ui/index.d.ts +2 -0
- package/dist/types-ts4.5/ui-menu/DropdownMenu/index.d.ts +2 -1
- package/dist/types-ts4.5/ui-menu/ToolbarArrowKeyNavigationProvider/index.d.ts +30 -0
- package/dist/types-ts4.5/ui-menu/index.d.ts +7 -6
- package/dist/types-ts4.5/utils/commands.d.ts +42 -2
- package/dist/types-ts4.5/utils/document.d.ts +4 -0
- package/dist/types-ts4.5/utils/index.d.ts +4 -2
- package/dist/types-ts4.5/utils/prosemirror/autojoin.d.ts +13 -0
- package/lists/package.json +15 -0
- package/mark/package.json +15 -0
- package/package.json +6 -3
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ToolbarArrowKeyNavigationProvider = exports.KeyDownHandlerContext = void 0;
|
|
9
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _react2 = require("@emotion/react");
|
|
12
|
+
var _messages = require("../../messages");
|
|
13
|
+
var _ui = require("../../ui");
|
|
14
|
+
var _templateObject;
|
|
15
|
+
/** @jsx jsx */
|
|
16
|
+
/* eslint-disable no-console */
|
|
17
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
/*
|
|
20
|
+
** The context is used to handle the keydown events of submenus.
|
|
21
|
+
** Because the keyboard navigation is explicitly managed for main toolbar items
|
|
22
|
+
** Few key presses such as Tab,Arrow Right/Left need ot be handled here via context
|
|
23
|
+
*/
|
|
24
|
+
var KeyDownHandlerContext = /*#__PURE__*/_react.default.createContext({
|
|
25
|
+
handleArrowLeft: function handleArrowLeft() {},
|
|
26
|
+
handleArrowRight: function handleArrowRight() {},
|
|
27
|
+
handleTab: function handleTab() {}
|
|
28
|
+
});
|
|
29
|
+
exports.KeyDownHandlerContext = KeyDownHandlerContext;
|
|
30
|
+
var centeredToolbarContainer = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n width: 100%;\n align-items: center;\n"])));
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* This component is a wrapper of main toolbar which listens to keydown events of children
|
|
34
|
+
* and handles left/right arrow key navigation for all focusable elements
|
|
35
|
+
* @param
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
var ToolbarArrowKeyNavigationProvider = function ToolbarArrowKeyNavigationProvider(_ref) {
|
|
39
|
+
var children = _ref.children,
|
|
40
|
+
editorView = _ref.editorView,
|
|
41
|
+
childComponentSelector = _ref.childComponentSelector,
|
|
42
|
+
handleEscape = _ref.handleEscape,
|
|
43
|
+
disableArrowKeyNavigation = _ref.disableArrowKeyNavigation,
|
|
44
|
+
isShortcutToFocusToolbar = _ref.isShortcutToFocusToolbar,
|
|
45
|
+
editorAppearance = _ref.editorAppearance,
|
|
46
|
+
useStickyToolbar = _ref.useStickyToolbar,
|
|
47
|
+
intl = _ref.intl;
|
|
48
|
+
var wrapperRef = (0, _react.useRef)(null);
|
|
49
|
+
var selectedItemIndex = (0, _react.useRef)(0);
|
|
50
|
+
var incrementIndex = (0, _react.useCallback)(function (list) {
|
|
51
|
+
var index = 0;
|
|
52
|
+
if (document.activeElement) {
|
|
53
|
+
index = list.indexOf(document.activeElement);
|
|
54
|
+
index = (index + 1) % list.length;
|
|
55
|
+
}
|
|
56
|
+
selectedItemIndex.current = index;
|
|
57
|
+
}, []);
|
|
58
|
+
var decrementIndex = (0, _react.useCallback)(function (list) {
|
|
59
|
+
var index = 0;
|
|
60
|
+
if (document.activeElement) {
|
|
61
|
+
index = list.indexOf(document.activeElement);
|
|
62
|
+
index = (list.length + index - 1) % list.length;
|
|
63
|
+
}
|
|
64
|
+
selectedItemIndex.current = index;
|
|
65
|
+
}, []);
|
|
66
|
+
var handleArrowRight = function handleArrowRight() {
|
|
67
|
+
var _filteredFocusableEle;
|
|
68
|
+
var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
69
|
+
incrementIndex(filteredFocusableElements);
|
|
70
|
+
(_filteredFocusableEle = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle === void 0 ? void 0 : _filteredFocusableEle.focus();
|
|
71
|
+
};
|
|
72
|
+
var handleArrowLeft = function handleArrowLeft() {
|
|
73
|
+
var _filteredFocusableEle2;
|
|
74
|
+
var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
75
|
+
decrementIndex(filteredFocusableElements);
|
|
76
|
+
(_filteredFocusableEle2 = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle2 === void 0 ? void 0 : _filteredFocusableEle2.focus();
|
|
77
|
+
};
|
|
78
|
+
var handleTab = function handleTab() {
|
|
79
|
+
var _filteredFocusableEle3;
|
|
80
|
+
var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
81
|
+
(_filteredFocusableEle3 = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle3 === void 0 ? void 0 : _filteredFocusableEle3.focus();
|
|
82
|
+
};
|
|
83
|
+
var handleTabLocal = function handleTabLocal() {
|
|
84
|
+
var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
85
|
+
filteredFocusableElements.forEach(function (element) {
|
|
86
|
+
element.setAttribute('tabindex', '-1');
|
|
87
|
+
});
|
|
88
|
+
filteredFocusableElements[selectedItemIndex.current].setAttribute('tabindex', '0');
|
|
89
|
+
};
|
|
90
|
+
var focusAndScrollToElement = function focusAndScrollToElement(element) {
|
|
91
|
+
var scrollToElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
92
|
+
if (scrollToElement) {
|
|
93
|
+
element === null || element === void 0 ? void 0 : element.scrollIntoView({
|
|
94
|
+
behavior: 'smooth',
|
|
95
|
+
block: 'center',
|
|
96
|
+
inline: 'nearest'
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
element.focus();
|
|
100
|
+
};
|
|
101
|
+
var submenuKeydownHandleContext = {
|
|
102
|
+
handleArrowLeft: handleArrowLeft,
|
|
103
|
+
handleArrowRight: handleArrowRight,
|
|
104
|
+
handleTab: handleTab
|
|
105
|
+
};
|
|
106
|
+
(0, _react.useLayoutEffect)(function () {
|
|
107
|
+
if (!wrapperRef.current || disableArrowKeyNavigation) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
var element = wrapperRef.current;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* To handle the key events on the list
|
|
114
|
+
* @param event
|
|
115
|
+
*/
|
|
116
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
117
|
+
var _document$querySelect, _document$querySelect2, _wrapperRef$current;
|
|
118
|
+
//To trap the focus inside the horizontal toolbar for left and right arrow keys
|
|
119
|
+
var targetElement = event.target;
|
|
120
|
+
|
|
121
|
+
//To filter out the events outside the child component
|
|
122
|
+
if (!targetElement.closest("".concat(childComponentSelector))) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//The key events are from child components such as dropdown menus / popups are ignored
|
|
127
|
+
if ((_document$querySelect = document.querySelector('[data-role="droplistContent"], [data-test-id="color-picker-menu"], [data-emoji-picker-container="true"]')) !== null && _document$querySelect !== void 0 && _document$querySelect.contains(targetElement) || (_document$querySelect2 = document.querySelector('[data-test-id="color-picker-menu"]')) !== null && _document$querySelect2 !== void 0 && _document$querySelect2.contains(targetElement) || event.key === 'ArrowUp' || event.key === 'ArrowDown' || disableArrowKeyNavigation) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
var menuWrapper = document.querySelector('.menu-key-handler-wrapper');
|
|
131
|
+
if (menuWrapper) {
|
|
132
|
+
// if menu wrapper exists, then a menu is open and arrow keys will be handled by MenuArrowKeyNavigationProvider
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
136
|
+
if (!filteredFocusableElements || (filteredFocusableElements === null || filteredFocusableElements === void 0 ? void 0 : filteredFocusableElements.length) === 0) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//This is kind of hack to reset the current focused toolbar item
|
|
141
|
+
//to handle some use cases such as Tab in/out of main toolbar
|
|
142
|
+
if (!((_wrapperRef$current = wrapperRef.current) !== null && _wrapperRef$current !== void 0 && _wrapperRef$current.contains(targetElement))) {
|
|
143
|
+
selectedItemIndex.current = -1;
|
|
144
|
+
} else {
|
|
145
|
+
selectedItemIndex.current = filteredFocusableElements.indexOf(targetElement) > -1 ? filteredFocusableElements.indexOf(targetElement) : selectedItemIndex.current;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
//do not scroll to focused element for sticky toolbar when navigating with arrows to avoid unnesessary scroll jump
|
|
149
|
+
var allowScrollToElement = !(editorAppearance === 'comment' && !!useStickyToolbar);
|
|
150
|
+
switch (event.key) {
|
|
151
|
+
case 'ArrowRight':
|
|
152
|
+
incrementIndex(filteredFocusableElements);
|
|
153
|
+
focusAndScrollToElement(filteredFocusableElements[selectedItemIndex.current], allowScrollToElement);
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
break;
|
|
156
|
+
case 'ArrowLeft':
|
|
157
|
+
decrementIndex(filteredFocusableElements);
|
|
158
|
+
focusAndScrollToElement(filteredFocusableElements[selectedItemIndex.current], allowScrollToElement);
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
break;
|
|
161
|
+
case 'Tab':
|
|
162
|
+
handleTabLocal();
|
|
163
|
+
break;
|
|
164
|
+
case 'Escape':
|
|
165
|
+
handleEscape(event);
|
|
166
|
+
break;
|
|
167
|
+
default:
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
var globalKeyDownHandler = function globalKeyDownHandler(event) {
|
|
171
|
+
//To focus the first element in the toolbar
|
|
172
|
+
if (isShortcutToFocusToolbar(event)) {
|
|
173
|
+
var _filteredFocusableEle4, _filteredFocusableEle5;
|
|
174
|
+
var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
175
|
+
(_filteredFocusableEle4 = filteredFocusableElements[0]) === null || _filteredFocusableEle4 === void 0 ? void 0 : _filteredFocusableEle4.focus();
|
|
176
|
+
(_filteredFocusableEle5 = filteredFocusableElements[0]) === null || _filteredFocusableEle5 === void 0 ? void 0 : _filteredFocusableEle5.scrollIntoView({
|
|
177
|
+
behavior: 'smooth',
|
|
178
|
+
block: 'center',
|
|
179
|
+
inline: 'nearest'
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
element === null || element === void 0 ? void 0 : element.addEventListener('keydown', handleKeyDown);
|
|
184
|
+
var editorViewDom = editorView === null || editorView === void 0 ? void 0 : editorView.dom;
|
|
185
|
+
if (isShortcutToFocusToolbar) {
|
|
186
|
+
editorViewDom === null || editorViewDom === void 0 ? void 0 : editorViewDom.addEventListener('keydown', globalKeyDownHandler);
|
|
187
|
+
}
|
|
188
|
+
return function () {
|
|
189
|
+
element === null || element === void 0 ? void 0 : element.removeEventListener('keydown', handleKeyDown);
|
|
190
|
+
if (isShortcutToFocusToolbar) {
|
|
191
|
+
editorViewDom === null || editorViewDom === void 0 ? void 0 : editorViewDom.removeEventListener('keydown', globalKeyDownHandler);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}, [selectedItemIndex, wrapperRef, editorView, disableArrowKeyNavigation, handleEscape, childComponentSelector, incrementIndex, decrementIndex, isShortcutToFocusToolbar, editorAppearance, useStickyToolbar]);
|
|
195
|
+
return (0, _react2.jsx)("div", {
|
|
196
|
+
css: editorAppearance === 'comment' && centeredToolbarContainer,
|
|
197
|
+
className: "custom-key-handler-wrapper",
|
|
198
|
+
ref: wrapperRef,
|
|
199
|
+
role: "toolbar",
|
|
200
|
+
"aria-label": intl.formatMessage(_messages.fullPageMessages.toolbarLabel),
|
|
201
|
+
"aria-controls": _ui.EDIT_AREA_ID
|
|
202
|
+
}, (0, _react2.jsx)(KeyDownHandlerContext.Provider, {
|
|
203
|
+
value: submenuKeydownHandleContext
|
|
204
|
+
}, children));
|
|
205
|
+
};
|
|
206
|
+
exports.ToolbarArrowKeyNavigationProvider = ToolbarArrowKeyNavigationProvider;
|
|
207
|
+
function getFocusableElements(rootNode) {
|
|
208
|
+
if (!rootNode) {
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
var focusableModalElements = rootNode.querySelectorAll('a[href], button:not([disabled]), textarea, input, select, div[tabindex="-1"], div[tabindex="0"]') || [];
|
|
212
|
+
return Array.from(focusableModalElements);
|
|
213
|
+
}
|
|
214
|
+
function getFilteredFocusableElements(rootNode) {
|
|
215
|
+
//The focusable elements from child components such as dropdown menus / popups are ignored
|
|
216
|
+
return getFocusableElements(rootNode).filter(function (elm) {
|
|
217
|
+
return !elm.closest('[data-role="droplistContent"]') && !elm.closest('[data-emoji-picker-container="true"]') && !elm.closest('[data-test-id="color-picker-menu"]') && !elm.closest('.scroll-buttons');
|
|
218
|
+
});
|
|
219
|
+
}
|
|
@@ -35,22 +35,41 @@ Object.defineProperty(exports, "DropdownMenu", {
|
|
|
35
35
|
return _DropdownMenu.default;
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
+
Object.defineProperty(exports, "DropdownMenuWithKeyboardNavigation", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function get() {
|
|
41
|
+
return _DropdownMenu.DropdownMenuWithKeyboardNavigation;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, "KeyDownHandlerContext", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function get() {
|
|
47
|
+
return _ToolbarArrowKeyNavigationProvider.KeyDownHandlerContext;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
38
50
|
Object.defineProperty(exports, "TOOLBAR_BUTTON", {
|
|
39
51
|
enumerable: true,
|
|
40
52
|
get: function get() {
|
|
41
53
|
return _ToolbarButton.TOOLBAR_BUTTON;
|
|
42
54
|
}
|
|
43
55
|
});
|
|
56
|
+
Object.defineProperty(exports, "ToolbarArrowKeyNavigationProvider", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function get() {
|
|
59
|
+
return _ToolbarArrowKeyNavigationProvider.ToolbarArrowKeyNavigationProvider;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
44
62
|
Object.defineProperty(exports, "ToolbarButton", {
|
|
45
63
|
enumerable: true,
|
|
46
64
|
get: function get() {
|
|
47
65
|
return _ToolbarButton.default;
|
|
48
66
|
}
|
|
49
67
|
});
|
|
50
|
-
var _DropdownMenu =
|
|
51
|
-
var _ToolbarButton = _interopRequireWildcard(require("
|
|
52
|
-
var _ArrowKeyNavigationProvider = require("
|
|
53
|
-
var
|
|
68
|
+
var _DropdownMenu = _interopRequireWildcard(require("./DropdownMenu"));
|
|
69
|
+
var _ToolbarButton = _interopRequireWildcard(require("./ToolbarButton"));
|
|
70
|
+
var _ArrowKeyNavigationProvider = require("./ArrowKeyNavigationProvider");
|
|
71
|
+
var _ToolbarArrowKeyNavigationProvider = require("./ToolbarArrowKeyNavigationProvider");
|
|
72
|
+
var _types = require("./ArrowKeyNavigationProvider/types");
|
|
54
73
|
var _ColorPaletteArrowKeyNavigationProvider = require("./ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider");
|
|
55
74
|
var _Dropdown = _interopRequireDefault(require("./Dropdown"));
|
|
56
75
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.
|
|
7
|
+
exports.walkPrevNode = exports.walkNextNode = exports.isEmptySelectionAtStart = exports.isEmptySelectionAtEnd = exports.insertContentDeleteRange = exports.filterCommand = exports.deleteEmptyParagraphAndMoveBlockUp = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
|
+
var _selection = require("../selection");
|
|
11
|
+
var _editorCoreUtils = require("./editor-core-utils");
|
|
7
12
|
var filter = function filter(predicates, cmd) {
|
|
8
13
|
return function (state, dispatch, view) {
|
|
9
14
|
if (!Array.isArray(predicates)) {
|
|
@@ -17,4 +22,107 @@ var filter = function filter(predicates, cmd) {
|
|
|
17
22
|
return cmd(state, dispatch, view) || false;
|
|
18
23
|
};
|
|
19
24
|
};
|
|
20
|
-
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Walk forwards from a position until we encounter the (inside) start of
|
|
28
|
+
* the next node, or reach the end of the document.
|
|
29
|
+
*
|
|
30
|
+
* @param $startPos Position to start walking from.
|
|
31
|
+
*/
|
|
32
|
+
exports.filterCommand = filter;
|
|
33
|
+
var walkNextNode = function walkNextNode($startPos) {
|
|
34
|
+
var $pos = $startPos;
|
|
35
|
+
|
|
36
|
+
// invariant 1: don't walk past the end of the document
|
|
37
|
+
// invariant 2: we are at the beginning or
|
|
38
|
+
// we haven't walked to the start of *any* node
|
|
39
|
+
// parentOffset includes textOffset.
|
|
40
|
+
while ($pos.pos < $pos.doc.nodeSize - 2 && ($pos.pos === $startPos.pos || $pos.parentOffset > 0)) {
|
|
41
|
+
$pos = $pos.doc.resolve($pos.pos + 1);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
$pos: $pos,
|
|
45
|
+
foundNode: $pos.pos < $pos.doc.nodeSize - 2
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Walk backwards from a position until we encounter the (inside) end of
|
|
51
|
+
* the previous node, or reach the start of the document.
|
|
52
|
+
*
|
|
53
|
+
* @param $startPos Position to start walking from.
|
|
54
|
+
*/
|
|
55
|
+
exports.walkNextNode = walkNextNode;
|
|
56
|
+
var walkPrevNode = function walkPrevNode($startPos) {
|
|
57
|
+
var $pos = $startPos;
|
|
58
|
+
while ($pos.pos > 0 && ($pos.pos === $startPos.pos || $pos.parentOffset < $pos.parent.nodeSize - 2)) {
|
|
59
|
+
$pos = $pos.doc.resolve($pos.pos - 1);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
$pos: $pos,
|
|
63
|
+
foundNode: $pos.pos > 0
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* If the selection is empty, is inside a paragraph node and `canNextNodeMoveUp` is true then delete current paragraph
|
|
69
|
+
* and move the node below it up. The selection will be retained, to be placed in the moved node.
|
|
70
|
+
*
|
|
71
|
+
* @param canNextNodeMoveUp check if node directly after the selection is able to be brought up to selection
|
|
72
|
+
* @returns PM Command
|
|
73
|
+
*/
|
|
74
|
+
exports.walkPrevNode = walkPrevNode;
|
|
75
|
+
var deleteEmptyParagraphAndMoveBlockUp = function deleteEmptyParagraphAndMoveBlockUp(canNextNodeMoveUp) {
|
|
76
|
+
return function (state, dispatch, view) {
|
|
77
|
+
var _state$selection = state.selection,
|
|
78
|
+
_state$selection$$fro = _state$selection.$from,
|
|
79
|
+
pos = _state$selection$$fro.pos,
|
|
80
|
+
parent = _state$selection$$fro.parent,
|
|
81
|
+
$head = _state$selection.$head,
|
|
82
|
+
empty = _state$selection.empty,
|
|
83
|
+
tr = state.tr,
|
|
84
|
+
doc = state.doc;
|
|
85
|
+
var _walkNextNode = walkNextNode($head),
|
|
86
|
+
$pos = _walkNextNode.$pos;
|
|
87
|
+
var nextPMNode = doc.nodeAt($pos.pos - 1);
|
|
88
|
+
if (empty && nextPMNode && canNextNodeMoveUp(nextPMNode) && (0, _editorCoreUtils.isEmptyParagraph)(parent) && view !== null && view !== void 0 && view.endOfTextblock('right')) {
|
|
89
|
+
tr.deleteRange(pos - 1, pos + 1);
|
|
90
|
+
if (dispatch) {
|
|
91
|
+
dispatch(tr);
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
exports.deleteEmptyParagraphAndMoveBlockUp = deleteEmptyParagraphAndMoveBlockUp;
|
|
99
|
+
var insertContentDeleteRange = function insertContentDeleteRange(tr, getSelectionResolvedPos, insertions, deletions) {
|
|
100
|
+
insertions.forEach(function (contentInsert) {
|
|
101
|
+
var _contentInsert = (0, _slicedToArray2.default)(contentInsert, 2),
|
|
102
|
+
content = _contentInsert[0],
|
|
103
|
+
pos = _contentInsert[1];
|
|
104
|
+
tr.insert(tr.mapping.map(pos), content);
|
|
105
|
+
});
|
|
106
|
+
deletions.forEach(function (deleteRange) {
|
|
107
|
+
var _deleteRange = (0, _slicedToArray2.default)(deleteRange, 2),
|
|
108
|
+
firstPos = _deleteRange[0],
|
|
109
|
+
lastPos = _deleteRange[1];
|
|
110
|
+
tr.delete(tr.mapping.map(firstPos), tr.mapping.map(lastPos));
|
|
111
|
+
});
|
|
112
|
+
tr.setSelection(new _state.TextSelection(getSelectionResolvedPos(tr)));
|
|
113
|
+
};
|
|
114
|
+
exports.insertContentDeleteRange = insertContentDeleteRange;
|
|
115
|
+
var isEmptySelectionAtStart = function isEmptySelectionAtStart(state) {
|
|
116
|
+
var _state$selection2 = state.selection,
|
|
117
|
+
empty = _state$selection2.empty,
|
|
118
|
+
$from = _state$selection2.$from;
|
|
119
|
+
return empty && ($from.parentOffset === 0 || state.selection instanceof _selection.GapCursorSelection);
|
|
120
|
+
};
|
|
121
|
+
exports.isEmptySelectionAtStart = isEmptySelectionAtStart;
|
|
122
|
+
var isEmptySelectionAtEnd = function isEmptySelectionAtEnd(state) {
|
|
123
|
+
var _state$selection3 = state.selection,
|
|
124
|
+
empty = _state$selection3.empty,
|
|
125
|
+
$from = _state$selection3.$from;
|
|
126
|
+
return empty && ($from.end() === $from.pos || state.selection instanceof _selection.GapCursorSelection);
|
|
127
|
+
};
|
|
128
|
+
exports.isEmptySelectionAtEnd = isEmptySelectionAtEnd;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.bracketTyped = bracketTyped;
|
|
7
7
|
exports.getStepRange = void 0;
|
|
8
8
|
exports.hasDocAsParent = hasDocAsParent;
|
|
9
|
+
exports.hasVisibleContent = hasVisibleContent;
|
|
9
10
|
exports.isEmptyDocument = isEmptyDocument;
|
|
10
11
|
exports.nodesBetweenChanged = nodesBetweenChanged;
|
|
11
12
|
exports.processRawValue = processRawValue;
|
|
@@ -255,4 +256,28 @@ var maySanitizePrivateContent = function maySanitizePrivateContent(entity, provi
|
|
|
255
256
|
return (0, _privacyFilter.sanitizeNodeForPrivacy)(entity, providerFactory);
|
|
256
257
|
}
|
|
257
258
|
return entity;
|
|
258
|
-
};
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Returns false if node contains only empty inline nodes and hardBreaks.
|
|
263
|
+
*/
|
|
264
|
+
function hasVisibleContent(node) {
|
|
265
|
+
var isInlineNodeHasVisibleContent = function isInlineNodeHasVisibleContent(inlineNode) {
|
|
266
|
+
return inlineNode.isText ? !!inlineNode.textContent.trim() : inlineNode.type.name !== 'hardBreak';
|
|
267
|
+
};
|
|
268
|
+
if (node.isInline) {
|
|
269
|
+
return isInlineNodeHasVisibleContent(node);
|
|
270
|
+
} else if (node.isBlock && (node.isLeaf || node.isAtom)) {
|
|
271
|
+
return true;
|
|
272
|
+
} else if (!node.childCount) {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
for (var _index = 0; _index < node.childCount; _index++) {
|
|
276
|
+
var child = node.child(_index);
|
|
277
|
+
var invisibleNodeTypes = ['paragraph', 'text', 'hardBreak'];
|
|
278
|
+
if (!invisibleNodeTypes.includes(child.type.name) || hasVisibleContent(child)) {
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return false;
|
|
283
|
+
}
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -106,6 +106,12 @@ Object.defineProperty(exports, "analyticsEventKey", {
|
|
|
106
106
|
return _analytics.analyticsEventKey;
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
|
+
Object.defineProperty(exports, "autoJoinTr", {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function get() {
|
|
112
|
+
return _autojoin.autoJoinTr;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
109
115
|
Object.defineProperty(exports, "bracketTyped", {
|
|
110
116
|
enumerable: true,
|
|
111
117
|
get: function get() {
|
|
@@ -220,16 +226,22 @@ Object.defineProperty(exports, "createCompareNodes", {
|
|
|
220
226
|
return _compareNodes.createCompareNodes;
|
|
221
227
|
}
|
|
222
228
|
});
|
|
229
|
+
Object.defineProperty(exports, "deleteEmptyParagraphAndMoveBlockUp", {
|
|
230
|
+
enumerable: true,
|
|
231
|
+
get: function get() {
|
|
232
|
+
return _commands.deleteEmptyParagraphAndMoveBlockUp;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
223
235
|
Object.defineProperty(exports, "extractSliceFromStep", {
|
|
224
236
|
enumerable: true,
|
|
225
237
|
get: function get() {
|
|
226
238
|
return _editorCoreUtils.extractSliceFromStep;
|
|
227
239
|
}
|
|
228
240
|
});
|
|
229
|
-
Object.defineProperty(exports, "
|
|
241
|
+
Object.defineProperty(exports, "filterCommand", {
|
|
230
242
|
enumerable: true,
|
|
231
243
|
get: function get() {
|
|
232
|
-
return _commands.
|
|
244
|
+
return _commands.filterCommand;
|
|
233
245
|
}
|
|
234
246
|
});
|
|
235
247
|
Object.defineProperty(exports, "findAndTrackUnsupportedContentNodes", {
|
|
@@ -424,6 +436,18 @@ Object.defineProperty(exports, "hasMergedCell", {
|
|
|
424
436
|
return _table.hasMergedCell;
|
|
425
437
|
}
|
|
426
438
|
});
|
|
439
|
+
Object.defineProperty(exports, "hasVisibleContent", {
|
|
440
|
+
enumerable: true,
|
|
441
|
+
get: function get() {
|
|
442
|
+
return _document.hasVisibleContent;
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
Object.defineProperty(exports, "insertContentDeleteRange", {
|
|
446
|
+
enumerable: true,
|
|
447
|
+
get: function get() {
|
|
448
|
+
return _commands.insertContentDeleteRange;
|
|
449
|
+
}
|
|
450
|
+
});
|
|
427
451
|
Object.defineProperty(exports, "isBulletList", {
|
|
428
452
|
enumerable: true,
|
|
429
453
|
get: function get() {
|
|
@@ -448,6 +472,18 @@ Object.defineProperty(exports, "isEmptyParagraph", {
|
|
|
448
472
|
return _editorCoreUtils.isEmptyParagraph;
|
|
449
473
|
}
|
|
450
474
|
});
|
|
475
|
+
Object.defineProperty(exports, "isEmptySelectionAtEnd", {
|
|
476
|
+
enumerable: true,
|
|
477
|
+
get: function get() {
|
|
478
|
+
return _commands.isEmptySelectionAtEnd;
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
Object.defineProperty(exports, "isEmptySelectionAtStart", {
|
|
482
|
+
enumerable: true,
|
|
483
|
+
get: function get() {
|
|
484
|
+
return _commands.isEmptySelectionAtStart;
|
|
485
|
+
}
|
|
486
|
+
});
|
|
451
487
|
Object.defineProperty(exports, "isFromCurrentDomain", {
|
|
452
488
|
enumerable: true,
|
|
453
489
|
get: function get() {
|
|
@@ -828,6 +864,18 @@ Object.defineProperty(exports, "validationErrorHandler", {
|
|
|
828
864
|
return _validateUsingSpec.validationErrorHandler;
|
|
829
865
|
}
|
|
830
866
|
});
|
|
867
|
+
Object.defineProperty(exports, "walkNextNode", {
|
|
868
|
+
enumerable: true,
|
|
869
|
+
get: function get() {
|
|
870
|
+
return _commands.walkNextNode;
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
Object.defineProperty(exports, "walkPrevNode", {
|
|
874
|
+
enumerable: true,
|
|
875
|
+
get: function get() {
|
|
876
|
+
return _commands.walkPrevNode;
|
|
877
|
+
}
|
|
878
|
+
});
|
|
831
879
|
Object.defineProperty(exports, "walkUpTreeUntil", {
|
|
832
880
|
enumerable: true,
|
|
833
881
|
get: function get() {
|
|
@@ -875,6 +923,7 @@ var _validateUsingSpec = require("./validate-using-spec");
|
|
|
875
923
|
var _compareProps = require("./compare-props");
|
|
876
924
|
var _useComponentRenderTracking = require("./performance/hooks/use-component-render-tracking");
|
|
877
925
|
var _outdatedBrowsers = require("./outdated-browsers");
|
|
926
|
+
var _autojoin = require("./prosemirror/autojoin");
|
|
878
927
|
var _referentiality = require("./referentiality");
|
|
879
928
|
var _list = require("./list");
|
|
880
929
|
var _hyperlink = require("./hyperlink");
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.autoJoinTr = autoJoinTr;
|
|
7
|
+
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
8
|
+
/**
|
|
9
|
+
* Checks whether two adjacent nodes can be joined. If so, the document
|
|
10
|
+
* will be updated to join those nodes. If not, the original transaction
|
|
11
|
+
* remains untouched.
|
|
12
|
+
*
|
|
13
|
+
* Nodes are considered joinable if the `isJoinable` predicate returns true or,
|
|
14
|
+
* if an array of strings was passed, if their node type name is in that array.
|
|
15
|
+
*
|
|
16
|
+
* Adapted from https://github.com/ProseMirror/prosemirror-commands/blob/master/src/commands.js#L597-L610
|
|
17
|
+
*/
|
|
18
|
+
function autoJoinTr(tr, isJoinable) {
|
|
19
|
+
if (Array.isArray(isJoinable)) {
|
|
20
|
+
var types = isJoinable;
|
|
21
|
+
isJoinable = function isJoinable(node) {
|
|
22
|
+
return types.indexOf(node.type.name) > -1;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
var ranges = [];
|
|
26
|
+
for (var i = 0; i < tr.mapping.maps.length; i++) {
|
|
27
|
+
var map = tr.mapping.maps[i];
|
|
28
|
+
for (var j = 0; j < ranges.length; j++) {
|
|
29
|
+
ranges[j] = map.map(ranges[j]);
|
|
30
|
+
}
|
|
31
|
+
map.forEach(function (_s, _e, from, to) {
|
|
32
|
+
return ranges.push(from, to);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Figure out which joinable points exist inside those ranges,
|
|
37
|
+
// by checking all node boundaries in their parent nodes.
|
|
38
|
+
var joinable = [];
|
|
39
|
+
for (var _i = 0; _i < ranges.length; _i += 2) {
|
|
40
|
+
var from = ranges[_i];
|
|
41
|
+
var to = ranges[_i + 1];
|
|
42
|
+
var $from = tr.doc.resolve(from);
|
|
43
|
+
var depth = $from.sharedDepth(to);
|
|
44
|
+
var parent = $from.node(depth);
|
|
45
|
+
for (var index = $from.indexAfter(depth), pos = $from.after(depth + 1); pos <= to; ++index) {
|
|
46
|
+
var _after = parent.maybeChild(index);
|
|
47
|
+
if (!_after) {
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
if (index && joinable.indexOf(pos) === -1) {
|
|
51
|
+
var _before = parent.child(index - 1);
|
|
52
|
+
if (_before.type === _after.type && isJoinable(_before, _after)) {
|
|
53
|
+
joinable.push(pos);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
pos += _after.nodeSize;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Join the joinable points
|
|
60
|
+
joinable.sort(function (a, b) {
|
|
61
|
+
return a - b;
|
|
62
|
+
});
|
|
63
|
+
for (var _i2 = joinable.length - 1; _i2 >= 0; _i2--) {
|
|
64
|
+
if ((0, _transform.canJoin)(tr.doc, joinable[_i2])) {
|
|
65
|
+
tr.join(joinable[_i2]);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/i18n/cs.js
CHANGED
|
@@ -17,9 +17,12 @@ export default {
|
|
|
17
17
|
'fabric.editor.blockDescription': 'Zobrazit další informace o odkazu, včetně souhrnu a akcí',
|
|
18
18
|
'fabric.editor.blockTitle': 'Karta',
|
|
19
19
|
'fabric.editor.blockquote': 'citace',
|
|
20
|
+
'fabric.editor.bug': 'Chyba',
|
|
20
21
|
'fabric.editor.cancelButton': 'Zrušit',
|
|
21
22
|
'fabric.editor.captionPlaceholder': 'Přidejte popisek',
|
|
22
23
|
'fabric.editor.cardFloatingControls': 'Možnosti karty',
|
|
24
|
+
'fabric.editor.clearLink': 'Vymazat odkaz',
|
|
25
|
+
'fabric.editor.clearLinkText': 'Vymazat text',
|
|
23
26
|
'fabric.editor.codeBidiWarningLabel': 'Obousměrné znaky mění pořadí vykreslování textu. Může to být použito k zakrytí škodlivého kódu.',
|
|
24
27
|
'fabric.editor.codeBlockCopyButton.copiedToClipboard': 'Zkopírováno!',
|
|
25
28
|
'fabric.editor.codeBlockCopyButton.copyToClipboard': 'Kopírovat jako text',
|
|
@@ -34,11 +37,13 @@ export default {
|
|
|
34
37
|
'fabric.editor.date.description': 'Přidat datum pomocí kalendáře',
|
|
35
38
|
'fabric.editor.decision': 'Rozhodnutí',
|
|
36
39
|
'fabric.editor.decision.description': 'Zaznamenávejte rozhodnutí, aby se snadněji sledovala',
|
|
40
|
+
'fabric.editor.defaultAltText': 'Položka seznamu',
|
|
37
41
|
'fabric.editor.displayBlock': 'Zobrazit jako kartu',
|
|
38
42
|
'fabric.editor.displayEmbed': 'Zobrazit jako vložený objekt',
|
|
39
43
|
'fabric.editor.displayInline': 'Zobrazit v řádku',
|
|
40
44
|
'fabric.editor.displayLink': 'Zobrazit jako text',
|
|
41
45
|
'fabric.editor.displayOptionUnavailableInParentNode': 'Tato možnost zobrazení není v uzlu {node} dostupná',
|
|
46
|
+
'fabric.editor.displayText': 'Text k zobrazení',
|
|
42
47
|
'fabric.editor.ecombedDescription': 'Zobrazit interaktivní náhled odkazu',
|
|
43
48
|
'fabric.editor.edit.datasource': 'Upravit vyhledávací dotaz',
|
|
44
49
|
'fabric.editor.editLink': 'Upravit odkaz',
|
|
@@ -47,6 +52,7 @@ export default {
|
|
|
47
52
|
'fabric.editor.emoji': 'Emoji',
|
|
48
53
|
'fabric.editor.emoji.description': 'Používejte emoji k vyjádření nápadů 🎉 a emocí 😄',
|
|
49
54
|
'fabric.editor.emptyLink': 'Zadejte odkaz.',
|
|
55
|
+
'fabric.editor.epic': 'Epic',
|
|
50
56
|
'fabric.editor.expand': 'Rozbalení',
|
|
51
57
|
'fabric.editor.expand.description': 'Vložit rozbalení',
|
|
52
58
|
'fabric.editor.expandDefaultTitle': 'Klikněte sem pro rozbalení...',
|
|
@@ -54,12 +60,22 @@ export default {
|
|
|
54
60
|
'fabric.editor.expandPlaceholder': 'Dejte rozbalenému obsahu název...',
|
|
55
61
|
'fabric.editor.feedbackDialog': 'Poskytnout zpětnou vazbu',
|
|
56
62
|
'fabric.editor.feedbackDialog.description': 'Podělte se s námi o pocity z práce v novém editoru',
|
|
63
|
+
'fabric.editor.headingLink.hyperlinkIconBlogLabel': 'Blog',
|
|
64
|
+
'fabric.editor.headingLink.hyperlinkIconBugLabel': 'Chyba',
|
|
65
|
+
'fabric.editor.headingLink.hyperlinkIconIssueLabel': 'Požadavek',
|
|
66
|
+
'fabric.editor.headingLink.hyperlinkIconPageLabel': 'Stránka',
|
|
67
|
+
'fabric.editor.headingLink.hyperlinkIconStoryLabel': 'Story',
|
|
68
|
+
'fabric.editor.headingLink.hyperlinkIconTaskLabel': 'Úkol',
|
|
57
69
|
'fabric.editor.help': 'Nápověda',
|
|
58
70
|
'fabric.editor.help.description': 'Projděte si všechny klávesové zkratky a možnosti markdownu',
|
|
59
71
|
'fabric.editor.horizontalRule': 'Dílčí příčka',
|
|
60
72
|
'fabric.editor.horizontalRule.description': 'Rozdělit obsah horizontální čárou',
|
|
73
|
+
'fabric.editor.hyperlink.linkAriaLabel': 'Popisek odkazu',
|
|
74
|
+
'fabric.editor.hyperlink.searchLinkAriaDescription': 'Níže se objeví návrhy na základě vámi napsaného textu v poli',
|
|
75
|
+
'fabric.editor.hyperlink.searchLinkResults': '{count, plural, =0 {nebyly nalezeny žádné výsledky} one {{count,number} nalezený výsledek} few {{count,number} nalezené výsledky} many {{count,number} nalezeného výsledku} other {{count,number} nalezených výsledků}}',
|
|
61
76
|
'fabric.editor.hyperlinkToolbarPlaceholder': 'Vložit nebo vyhledat odkaz',
|
|
62
77
|
'fabric.editor.image': 'Obrázek',
|
|
78
|
+
'fabric.editor.improvement': 'Vylepšení',
|
|
63
79
|
'fabric.editor.inlineDescription': 'Zobrazit odkaz jako vložený text',
|
|
64
80
|
'fabric.editor.inlineTitle': 'Vložený',
|
|
65
81
|
'fabric.editor.insertMenu': 'Vložit',
|
|
@@ -85,8 +101,11 @@ export default {
|
|
|
85
101
|
'fabric.editor.settingsLinks': 'Přejít do předvoleb odkazů',
|
|
86
102
|
'fabric.editor.status': 'Stav',
|
|
87
103
|
'fabric.editor.status.description': 'Přidat vlastní štítek stavu',
|
|
104
|
+
'fabric.editor.story': 'Story',
|
|
105
|
+
'fabric.editor.subTask': 'Podúkol',
|
|
88
106
|
'fabric.editor.table': 'Tabulka',
|
|
89
107
|
'fabric.editor.table.description': 'Vložit tabulku',
|
|
108
|
+
'fabric.editor.task': 'Úkol',
|
|
90
109
|
'fabric.editor.time.ago': 'zpět',
|
|
91
110
|
'fabric.editor.time.updated': 'Aktualizováno',
|
|
92
111
|
'fabric.editor.time.viewed': 'Zobrazeno',
|