@manuscripts/body-editor 1.6.10 → 1.6.12

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.
Files changed (95) hide show
  1. package/dist/cjs/commands.js +57 -1
  2. package/dist/cjs/components/toolbar/LevelSelector.js +2 -2
  3. package/dist/cjs/index.js +4 -9
  4. package/dist/cjs/keys/list.js +9 -9
  5. package/dist/cjs/lib/context-menu.js +81 -163
  6. package/dist/cjs/menus.js +353 -405
  7. package/dist/cjs/toolbar.js +30 -34
  8. package/dist/cjs/views/editable_block.js +12 -4
  9. package/dist/es/commands.js +57 -2
  10. package/dist/es/components/toolbar/LevelSelector.js +2 -2
  11. package/dist/es/index.js +2 -4
  12. package/dist/es/keys/list.js +7 -7
  13. package/dist/es/lib/context-menu.js +81 -163
  14. package/dist/es/menus.js +353 -405
  15. package/dist/es/toolbar.js +31 -35
  16. package/dist/es/views/editable_block.js +13 -5
  17. package/dist/types/commands.d.ts +1 -0
  18. package/dist/types/components/toolbar/LevelSelector.d.ts +2 -2
  19. package/dist/types/configs/editor-views.d.ts +14 -14
  20. package/dist/types/index.d.ts +2 -4
  21. package/dist/types/keys/list.d.ts +1 -1
  22. package/dist/types/lib/context-menu.d.ts +0 -7
  23. package/dist/types/menus.d.ts +2 -3
  24. package/dist/types/toolbar.d.ts +18 -1
  25. package/dist/types/views/bibliography_element_editable.d.ts +1 -1
  26. package/dist/types/views/blockquote_element_editable.d.ts +1 -1
  27. package/dist/types/views/bullet_list_editable.d.ts +1 -1
  28. package/dist/types/views/editable_block.d.ts +1 -1
  29. package/dist/types/views/equation_element_editable.d.ts +1 -1
  30. package/dist/types/views/figure_element_editable.d.ts +1 -1
  31. package/dist/types/views/footnote_editable.d.ts +1 -1
  32. package/dist/types/views/footnotes_element_editable.d.ts +1 -1
  33. package/dist/types/views/listing_element_editable.d.ts +1 -1
  34. package/dist/types/views/ordered_list_editable.d.ts +1 -1
  35. package/dist/types/views/paragraph_editable.d.ts +1 -1
  36. package/dist/types/views/placeholder_element_editable.d.ts +1 -1
  37. package/dist/types/views/pullquote_element_editable.d.ts +1 -1
  38. package/dist/types/views/section_title_editable.d.ts +1 -1
  39. package/dist/types/views/table_element_editable.d.ts +1 -1
  40. package/dist/types/views/toc_element_editable.d.ts +1 -1
  41. package/package.json +3 -5
  42. package/dist/cjs/components/application-menu/ApplicationMenu.js +0 -63
  43. package/dist/cjs/components/application-menu/MenuItemContainer.js +0 -127
  44. package/dist/cjs/components/application-menu/Shortcut.js +0 -63
  45. package/dist/cjs/components/application-menu/index.js +0 -22
  46. package/dist/cjs/components/application-menu/menuState.js +0 -49
  47. package/dist/cjs/components/application-menu/types.js +0 -17
  48. package/dist/cjs/components/application-menu/useApplicationMenus.js +0 -154
  49. package/dist/cjs/components/dialog/TableCellBorderOptions.js +0 -64
  50. package/dist/cjs/components/dialog/TableCellOptions.js +0 -50
  51. package/dist/cjs/components/dialog/TableOptions.js +0 -31
  52. package/dist/cjs/components/dialog/commands.js +0 -185
  53. package/dist/cjs/components/dialog/index.js +0 -26
  54. package/dist/cjs/components/dialog/shared.js +0 -48
  55. package/dist/cjs/components/dialog/types.js +0 -9
  56. package/dist/cjs/components/toolbar/ListStyleSelector.js +0 -150
  57. package/dist/cjs/components/toolbar/ManuscriptToolbar.js +0 -104
  58. package/dist/cjs/components/toolbar/OrderListSelector.js +0 -103
  59. package/dist/cjs/views/EditableBlock.js +0 -37
  60. package/dist/es/components/application-menu/ApplicationMenu.js +0 -56
  61. package/dist/es/components/application-menu/MenuItemContainer.js +0 -120
  62. package/dist/es/components/application-menu/Shortcut.js +0 -56
  63. package/dist/es/components/application-menu/index.js +0 -17
  64. package/dist/es/components/application-menu/menuState.js +0 -44
  65. package/dist/es/components/application-menu/types.js +0 -16
  66. package/dist/es/components/application-menu/useApplicationMenus.js +0 -148
  67. package/dist/es/components/dialog/TableCellBorderOptions.js +0 -36
  68. package/dist/es/components/dialog/TableCellOptions.js +0 -22
  69. package/dist/es/components/dialog/TableOptions.js +0 -26
  70. package/dist/es/components/dialog/commands.js +0 -177
  71. package/dist/es/components/dialog/index.js +0 -18
  72. package/dist/es/components/dialog/shared.js +0 -21
  73. package/dist/es/components/dialog/types.js +0 -6
  74. package/dist/es/components/toolbar/ListStyleSelector.js +0 -120
  75. package/dist/es/components/toolbar/ManuscriptToolbar.js +0 -97
  76. package/dist/es/components/toolbar/OrderListSelector.js +0 -72
  77. package/dist/es/views/EditableBlock.js +0 -29
  78. package/dist/types/components/application-menu/ApplicationMenu.d.ts +0 -24
  79. package/dist/types/components/application-menu/MenuItemContainer.d.ts +0 -27
  80. package/dist/types/components/application-menu/Shortcut.d.ts +0 -26
  81. package/dist/types/components/application-menu/index.d.ts +0 -18
  82. package/dist/types/components/application-menu/menuState.d.ts +0 -18
  83. package/dist/types/components/application-menu/types.d.ts +0 -47
  84. package/dist/types/components/application-menu/useApplicationMenus.d.ts +0 -12
  85. package/dist/types/components/dialog/TableCellBorderOptions.d.ts +0 -9
  86. package/dist/types/components/dialog/TableCellOptions.d.ts +0 -4
  87. package/dist/types/components/dialog/TableOptions.d.ts +0 -4
  88. package/dist/types/components/dialog/commands.d.ts +0 -28
  89. package/dist/types/components/dialog/index.d.ts +0 -4
  90. package/dist/types/components/dialog/shared.d.ts +0 -16
  91. package/dist/types/components/dialog/types.d.ts +0 -16
  92. package/dist/types/components/toolbar/ListStyleSelector.d.ts +0 -36
  93. package/dist/types/components/toolbar/ManuscriptToolbar.d.ts +0 -50
  94. package/dist/types/components/toolbar/OrderListSelector.d.ts +0 -14
  95. package/dist/types/views/EditableBlock.d.ts +0 -19
@@ -1,63 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.ApplicationMenus = void 0;
22
- const react_1 = __importDefault(require("react"));
23
- const react_modal_1 = __importDefault(require("react-modal"));
24
- const styled_components_1 = __importDefault(require("styled-components"));
25
- const MenuItemContainer_1 = require("./MenuItemContainer");
26
- react_modal_1.default.setAppElement('#root');
27
- const ApplicationMenuContainer = styled_components_1.default.div `
28
- display: flex;
29
- font-size: 14px;
30
- `;
31
- const MenuHeading = styled_components_1.default.div `
32
- padding: 4px 8px;
33
- cursor: pointer;
34
- border: 1px solid transparent;
35
- border-bottom: none;
36
- `;
37
- const MenuContainer = styled_components_1.default.div `
38
- position: relative;
39
-
40
- & ${MenuHeading} {
41
- background-color: #fff;
42
- color: ${(props) => (props.isEnabled ? '#353535' : '#e2e2e2')};
43
-
44
- &:hover {
45
- background-color: ${(props) => (props.isEnabled ? '#f2fbfc' : '#fff')};
46
- }
47
- }
48
- `;
49
- const ApplicationMenus = ({ menuState, wrapperRef, handleItemClick, }) => {
50
- return (react_1.default.createElement(ApplicationMenuContainer, { ref: wrapperRef }, menuState.map((menu, index) => {
51
- return (react_1.default.createElement(MenuContainer, { key: `menu-${index}`, isEnabled: menu.enable },
52
- react_1.default.createElement(MenuHeading, { onMouseDown: (e) => {
53
- e.preventDefault();
54
- handleItemClick([index]);
55
- }, isOpen: menu.isOpen },
56
- react_1.default.createElement(MenuItemContainer_1.Text, null, menu.label)),
57
- menu.enable && menu.isOpen && (react_1.default.createElement(MenuItemContainer_1.MenuList, null, menu.submenu &&
58
- menu.submenu.map((submenu, menuIndex) => {
59
- return (react_1.default.createElement(MenuItemContainer_1.MenuItemContainer, { key: `menu-${menuIndex}`, item: submenu, depth: 1, handleMenuItemClick: () => handleItemClick([index, menuIndex]), handleSubmenuItemClick: (submenuIndex) => handleItemClick([index, menuIndex, submenuIndex]) }));
60
- })))));
61
- })));
62
- };
63
- exports.ApplicationMenus = ApplicationMenus;
@@ -1,127 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.MenuItemContainer = exports.MenuList = exports.Text = void 0;
22
- const TriangleCollapsed_1 = __importDefault(require("@manuscripts/assets/react/TriangleCollapsed"));
23
- const react_1 = __importDefault(require("react"));
24
- const styled_components_1 = __importDefault(require("styled-components"));
25
- const Shortcut_1 = require("./Shortcut");
26
- exports.Text = styled_components_1.default.div `
27
- flex: 1 0 auto;
28
- `;
29
- exports.MenuList = styled_components_1.default.div `
30
- background: #fff;
31
- border: 1px solid #e2e2e2;
32
- border-radius: 4px;
33
- box-shadow: 0 4px 9px 0 rgba(84, 83, 83, 0.3);
34
- color: #353535;
35
- min-width: 150px;
36
- max-height: 70vh;
37
- overflow-y: auto;
38
- padding: 4px 0;
39
- white-space: nowrap;
40
- width: auto;
41
- z-index: 10;
42
-
43
- position: absolute;
44
-
45
- &[data-placement='bottom-start'] {
46
- border-top-left-radius: 0;
47
- border-top-right-radius: 0;
48
- }
49
- closeMenu={closeMenu}
50
-
51
- &[data-placement='right-start'] {
52
- top: 8px;
53
- }
54
- `;
55
- const SubmenuContainer = styled_components_1.default.div `
56
- position: relative;
57
- `;
58
- const SubmenuList = (0, styled_components_1.default)(exports.MenuList) `
59
- top: 0;
60
- left: 100%;
61
- `;
62
- const Separator = styled_components_1.default.div `
63
- height: 0;
64
- border-bottom: 1px solid #e2e2e2;
65
- margin: 4px 0;
66
- `;
67
- const Active = styled_components_1.default.div `
68
- width: 16px;
69
- display: inline-flex;
70
- flex-shrink: 0;
71
- justify-content: center;
72
- align-items: center;
73
- `;
74
- const Arrow = (0, styled_components_1.default)(TriangleCollapsed_1.default) `
75
- margin-left: 8px;
76
- `;
77
- const Container = styled_components_1.default.div `
78
- align-items: center;
79
- cursor: pointer;
80
- display: flex;
81
- padding: 8px 16px 8px 4px;
82
- position: relative;
83
- ${(props) => props.isOpen && 'background: #f2fbfc;'}
84
-
85
- &:hover {
86
- background: #f2fbfc;
87
- }
88
-
89
- &.disabled {
90
- cursor: default;
91
- opacity: 0.4;
92
- }
93
- `;
94
- const classNameFromState = (item) => (item.enable ? '' : 'disabled');
95
- const activeContent = (item) => (item.active ? '✓' : '');
96
- const isSeparator = (item) => item.role === 'separator';
97
- const MenuItemContainer = ({ item, handleMenuItemClick, handleSubmenuItemClick, depth, }) => {
98
- if (isSeparator(item)) {
99
- return react_1.default.createElement(Separator, null);
100
- }
101
- if (!item.submenu) {
102
- return (react_1.default.createElement(Container, { isOpen: item.isOpen, className: classNameFromState(item), onMouseDown: (e) => {
103
- e.preventDefault();
104
- handleMenuItemClick();
105
- } },
106
- react_1.default.createElement(Active, null, activeContent(item)),
107
- react_1.default.createElement(exports.Text, null, item.label),
108
- item.accelerator && react_1.default.createElement(Shortcut_1.Shortcut, { accelerator: item.accelerator })));
109
- }
110
- return (react_1.default.createElement(SubmenuContainer, null,
111
- react_1.default.createElement(Container, { onMouseDown: (e) => {
112
- e.preventDefault();
113
- handleMenuItemClick();
114
- }, isOpen: item.isOpen, className: classNameFromState(item) },
115
- react_1.default.createElement(Active, null, activeContent(item)),
116
- react_1.default.createElement(exports.Text, null, item.label),
117
- item.submenu && react_1.default.createElement(Arrow, null),
118
- item.accelerator && react_1.default.createElement(Shortcut_1.Shortcut, { accelerator: item.accelerator })),
119
- item.isOpen && (react_1.default.createElement(SubmenuList, null, item.submenu &&
120
- item.submenu.map((menu, index) => (react_1.default.createElement(exports.MenuItemContainer, { key: `menu-${index}`, item: menu, handleMenuItemClick: () => {
121
- if (!handleSubmenuItemClick) {
122
- return;
123
- }
124
- handleSubmenuItemClick(index);
125
- }, depth: depth + 1 })))))));
126
- };
127
- exports.MenuItemContainer = MenuItemContainer;
@@ -1,63 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.Shortcut = exports.ShortcutContainer = void 0;
22
- const react_1 = __importDefault(require("react"));
23
- const styled_components_1 = __importDefault(require("styled-components"));
24
- const platform_1 = require("../../lib/platform");
25
- exports.ShortcutContainer = styled_components_1.default.div `
26
- display: inline-flex;
27
- color: #6e6e6e;
28
- margin-left: 16px;
29
- flex-shrink: 0;
30
- justify-content: flex-end;
31
- `;
32
- const modifiers = platform_1.isMac
33
- ? {
34
- Option: '⌥',
35
- CommandOrControl: '⌘',
36
- Shift: '⇧',
37
- }
38
- : {
39
- Option: 'Alt',
40
- CommandOrControl: 'Ctrl',
41
- Shift: 'Shift',
42
- };
43
- const system = platform_1.isMac ? 'mac' : 'pc';
44
- const separator = platform_1.isMac ? '' : '-';
45
- const Character = styled_components_1.default.span `
46
- display: inline-block;
47
- min-width: 1ch;
48
- `;
49
- const acceleratorParts = (accelerator) => {
50
- const parts = [];
51
- for (const part of accelerator[system].split('+')) {
52
- if (part in modifiers) {
53
- parts.push(modifiers[part]);
54
- parts.push(separator);
55
- }
56
- else {
57
- parts.push(react_1.default.createElement(Character, { key: part }, part));
58
- }
59
- }
60
- return parts;
61
- };
62
- const Shortcut = ({ accelerator, }) => react_1.default.createElement(exports.ShortcutContainer, null, acceleratorParts(accelerator));
63
- exports.Shortcut = Shortcut;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.useApplicationMenus = exports.ApplicationMenus = void 0;
19
- var ApplicationMenu_1 = require("./ApplicationMenu");
20
- Object.defineProperty(exports, "ApplicationMenus", { enumerable: true, get: function () { return ApplicationMenu_1.ApplicationMenus; } });
21
- var useApplicationMenus_1 = require("./useApplicationMenus");
22
- Object.defineProperty(exports, "useApplicationMenus", { enumerable: true, get: function () { return useApplicationMenus_1.useApplicationMenus; } });
@@ -1,49 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.getMenuItem = exports.getMenuState = void 0;
19
- const getMenuState = (spec, pointer, depth = 0) => {
20
- const pointerPart = pointer[depth];
21
- return spec.map((itemSpec, index) => {
22
- return {
23
- id: itemSpec.id || '',
24
- role: itemSpec.role || '',
25
- accelerator: itemSpec.accelerator || null,
26
- label: itemSpec.label || '',
27
- active: itemSpec.active || false,
28
- enable: typeof itemSpec.enable === 'boolean' ? itemSpec.enable : true,
29
- run: itemSpec.run || null,
30
- submenu: itemSpec.submenu
31
- ? (0, exports.getMenuState)(itemSpec.submenu, pointer, depth + 1)
32
- : null,
33
- isOpen: index === pointerPart,
34
- };
35
- });
36
- };
37
- exports.getMenuState = getMenuState;
38
- const getMenuItem = (menuState, indices) => {
39
- const [head, ...tail] = indices.filter((item) => item !== -1);
40
- const item = menuState[head];
41
- if (!tail.length) {
42
- return item;
43
- }
44
- else if (item.submenu) {
45
- return (0, exports.getMenuItem)(item.submenu, tail);
46
- }
47
- return null;
48
- };
49
- exports.getMenuItem = getMenuItem;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,154 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useApplicationMenus = exports.nextValidItem = exports.prevValidItem = void 0;
4
- const react_1 = require("react");
5
- const menuState_1 = require("./menuState");
6
- const initialPointer = [-1, -1, -1];
7
- const transformPointer = (depth, index) => (pointer) => pointer.map((pointerPart, i) => {
8
- if (i === depth) {
9
- return index;
10
- }
11
- if (i > depth) {
12
- return -1;
13
- }
14
- return pointerPart;
15
- });
16
- const prevValidItem = (menu, current) => {
17
- const prevIndex = current - 1;
18
- if (prevIndex <= -1) {
19
- return -1;
20
- }
21
- const prevItem = menu[prevIndex];
22
- if (prevItem.role !== 'separator' && prevItem.enable) {
23
- return prevIndex;
24
- }
25
- return (0, exports.prevValidItem)(menu, prevIndex);
26
- };
27
- exports.prevValidItem = prevValidItem;
28
- const nextValidItem = (menu, current) => {
29
- const nextIndex = current + 1;
30
- if (nextIndex >= menu.length) {
31
- return 0;
32
- }
33
- const nextItem = menu[nextIndex];
34
- if (nextItem.role !== 'separator' && nextItem.enable) {
35
- return nextIndex;
36
- }
37
- return (0, exports.nextValidItem)(menu, nextIndex);
38
- };
39
- exports.nextValidItem = nextValidItem;
40
- const useApplicationMenus = (menuSpec) => {
41
- const [pointer, setPointer] = (0, react_1.useState)(initialPointer);
42
- const menuState = (0, menuState_1.getMenuState)(menuSpec, pointer);
43
- const toggleMenus = (0, react_1.useCallback)(() => {
44
- setPointer(pointer[0] === -1 ? [0, -1, -1] : [-1, -1, -1]);
45
- }, [pointer]);
46
- const handleItemClick = (0, react_1.useCallback)((indices) => {
47
- const item = (0, menuState_1.getMenuItem)(menuState, indices);
48
- if (!item || !item.enable) {
49
- return;
50
- }
51
- if (item.run) {
52
- item.run();
53
- setPointer([-1, -1, -1]);
54
- }
55
- else if (item.submenu) {
56
- const depth = indices.length - 1;
57
- const index = indices[depth];
58
- setPointer(transformPointer(depth, index));
59
- }
60
- }, [menuState]);
61
- const wrapperRef = (0, react_1.useRef)(null);
62
- const handleKeydown = (0, react_1.useCallback)((e) => {
63
- const { key } = e;
64
- const [menuI, itemI, submenuItemI] = pointer;
65
- if (key === 'Escape') {
66
- toggleMenus();
67
- return false;
68
- }
69
- else if (menuI === -1) {
70
- return true;
71
- }
72
- e.preventDefault();
73
- let menuItem;
74
- let items;
75
- switch (key) {
76
- case 'ArrowLeft':
77
- if (submenuItemI !== -1) {
78
- setPointer([menuI, itemI, -1]);
79
- return false;
80
- }
81
- setPointer(transformPointer(0, (0, exports.prevValidItem)(menuState, menuI)));
82
- return false;
83
- case 'ArrowRight':
84
- if (itemI !== -1 && submenuItemI === -1) {
85
- menuItem = (0, menuState_1.getMenuItem)(menuState, pointer);
86
- if (!menuItem || !menuItem.submenu) {
87
- return false;
88
- }
89
- setPointer(transformPointer(2, (0, exports.nextValidItem)(menuItem.submenu, -1)));
90
- return false;
91
- }
92
- setPointer(transformPointer(0, (0, exports.nextValidItem)(menuState, menuI)));
93
- return false;
94
- case 'ArrowUp':
95
- if (submenuItemI !== -1) {
96
- menuItem = (0, menuState_1.getMenuItem)(menuState, [menuI, itemI]);
97
- items = menuItem && menuItem.submenu;
98
- if (!items) {
99
- return false;
100
- }
101
- setPointer(transformPointer(2, (0, exports.prevValidItem)(items, submenuItemI)));
102
- return false;
103
- }
104
- items = menuState[menuI].submenu;
105
- if (!items) {
106
- return false;
107
- }
108
- setPointer(transformPointer(1, (0, exports.prevValidItem)(items, itemI)));
109
- return false;
110
- case 'ArrowDown':
111
- if (submenuItemI !== -1) {
112
- menuItem = (0, menuState_1.getMenuItem)(menuState, [menuI, itemI]);
113
- items = menuItem && menuItem.submenu;
114
- if (!items) {
115
- return false;
116
- }
117
- setPointer(transformPointer(2, (0, exports.nextValidItem)(items, submenuItemI)));
118
- return false;
119
- }
120
- items = menuState[menuI].submenu;
121
- if (!items) {
122
- return false;
123
- }
124
- setPointer(transformPointer(1, (0, exports.nextValidItem)(items, itemI)));
125
- return false;
126
- case 'Enter':
127
- case 'Space':
128
- handleItemClick(pointer);
129
- return false;
130
- }
131
- return false;
132
- }, [menuState, handleItemClick, pointer, toggleMenus]);
133
- (0, react_1.useEffect)(() => {
134
- const handleClickOutside = (event) => {
135
- if (wrapperRef.current &&
136
- !wrapperRef.current.contains(event.target)) {
137
- setPointer([-1, -1, -1]);
138
- }
139
- };
140
- document.addEventListener('click', handleClickOutside);
141
- return () => {
142
- document.removeEventListener('click', handleClickOutside);
143
- };
144
- }, []);
145
- return {
146
- handleKeydown,
147
- toggleMenus,
148
- menuState,
149
- handleItemClick,
150
- isMenuOpen: pointer[0] > -1,
151
- wrapperRef,
152
- };
153
- };
154
- exports.useApplicationMenus = useApplicationMenus;
@@ -1,64 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const style_guide_1 = require("@manuscripts/style-guide");
30
- const react_1 = __importStar(require("react"));
31
- const styled_components_1 = __importDefault(require("styled-components"));
32
- const commands_1 = require("./commands");
33
- const shared_1 = require("./shared");
34
- const LabelStyled = styled_components_1.default.label `
35
- font-weight: bold;
36
- display: block;
37
- `;
38
- const initialState = () => ({
39
- direction: 'all',
40
- width: 1,
41
- color: '#000',
42
- });
43
- const TableCellBorderOptions = ({ editorState, handleCloseDialog, dispatch, colors, handleAddColor, }) => {
44
- const setColors = colors.filter((color) => color.value);
45
- const colorExists = (0, react_1.useCallback)((hex) => setColors.find((color) => color.value === hex), [setColors]);
46
- return (react_1.default.createElement(shared_1.Modal, { handleCloseDialog: handleCloseDialog, selector: initialState, command: commands_1.setTableCellBorderStyles, editorState: editorState, dispatch: dispatch, header: "Configure the Cell Borders" }, ({ state, handleChange }) => (react_1.default.createElement("form", null,
47
- react_1.default.createElement(LabelStyled, { htmlFor: "direction" }, "Apply to"),
48
- react_1.default.createElement("select", { id: "direction", value: state.direction, onChange: (e) => handleChange('direction', e.target.value) },
49
- react_1.default.createElement("option", { value: "all" }, "All"),
50
- react_1.default.createElement("option", { value: "top" }, "Top"),
51
- react_1.default.createElement("option", { value: "bottom" }, "Bottom"),
52
- react_1.default.createElement("option", { value: "left" }, "Left"),
53
- react_1.default.createElement("option", { value: "right" }, "Right")),
54
- react_1.default.createElement(LabelStyled, { htmlFor: "width" }, "Width (px)"),
55
- react_1.default.createElement("input", { id: "width", type: "number", min: "0", max: "5", value: state.width, onChange: (e) => handleChange('width', e.target.value) }),
56
- react_1.default.createElement(LabelStyled, { htmlFor: "backgroundColor" }, "Border Color"),
57
- react_1.default.createElement(style_guide_1.ColorField, { options: setColors, value: state.color, handleChange: (hex) => {
58
- handleChange('color', hex || '');
59
- if (hex && !colorExists(hex)) {
60
- handleAddColor(hex);
61
- }
62
- } })))));
63
- };
64
- exports.default = TableCellBorderOptions;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const style_guide_1 = require("@manuscripts/style-guide");
30
- const react_1 = __importStar(require("react"));
31
- const styled_components_1 = __importDefault(require("styled-components"));
32
- const commands_1 = require("./commands");
33
- const shared_1 = require("./shared");
34
- const LabelStyled = styled_components_1.default.label `
35
- font-weight: bold;
36
- display: block;
37
- `;
38
- const TableCellOptions = ({ editorState, handleCloseDialog, dispatch, colors, handleAddColor, }) => {
39
- const setColors = colors.filter((color) => color.value);
40
- const colorExists = (0, react_1.useCallback)((hex) => setColors.find((color) => color.value === hex), [setColors]);
41
- return (react_1.default.createElement(shared_1.Modal, { handleCloseDialog: handleCloseDialog, selector: commands_1.getSelectedTableCellStyles, command: commands_1.setTableCellStyles, editorState: editorState, dispatch: dispatch, header: "Configure the Selected Table Cells" }, ({ state, handleChange }) => (react_1.default.createElement("form", null,
42
- react_1.default.createElement(LabelStyled, { htmlFor: "backgroundColor" }, "Background Color"),
43
- react_1.default.createElement(style_guide_1.ColorField, { options: setColors, value: state.backgroundColor || '', handleChange: (hex) => {
44
- handleChange('backgroundColor', hex || '');
45
- if (hex && !colorExists(hex)) {
46
- handleAddColor(hex);
47
- }
48
- } })))));
49
- };
50
- exports.default = TableCellOptions;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
7
- const styled_components_1 = __importDefault(require("styled-components"));
8
- const commands_1 = require("./commands");
9
- const shared_1 = require("./shared");
10
- const FormStyled = styled_components_1.default.form `
11
- display: flex;
12
- flex-direction: row;
13
- `;
14
- const Field = styled_components_1.default.div `
15
- flex: 1 0 auto;
16
- width: 50%;
17
- `;
18
- const LabelStyled = styled_components_1.default.label `
19
- font-weight: bold;
20
- display: block;
21
- `;
22
- const TableOptions = ({ editorState, handleCloseDialog, dispatch, }) => {
23
- return (react_1.default.createElement(shared_1.Modal, { handleCloseDialog: handleCloseDialog, editorState: editorState, dispatch: dispatch, selector: commands_1.getSelectedTableAttr, command: commands_1.setTableAttrs, header: "Configure the Selected Table" }, ({ state, handleChange }) => (react_1.default.createElement(FormStyled, null,
24
- react_1.default.createElement(Field, null,
25
- react_1.default.createElement(LabelStyled, { htmlFor: "headerRows" }, "Num Header Rows"),
26
- react_1.default.createElement("input", { id: "headerRows", type: "number", min: "0", max: "5", value: state.headerRows, onChange: (e) => handleChange('headerRows', e.target.value) })),
27
- react_1.default.createElement(Field, null,
28
- react_1.default.createElement(LabelStyled, { htmlFor: "footerRows" }, "Num Footer Rows"),
29
- react_1.default.createElement("input", { id: "footerRows", type: "number", min: "0", max: "5", value: state.footerRows, onChange: (e) => handleChange('footerRows', e.target.value) }))))));
30
- };
31
- exports.default = TableOptions;