@manuscripts/body-editor 3.7.4 → 3.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,7 +55,7 @@ const reservedCharacters = new Set([
55
55
  const generateCharacters = (start, end) => Array.from({ length: end - start + 1 }, (_, i) => start + i)
56
56
  .filter((c) => !reservedCharacters.has(c))
57
57
  .map((c) => String.fromCharCode(c));
58
- const InsertSpecialCharacterDialog = ({ view, }) => {
58
+ const InsertSpecialCharacterDialog = ({ view }) => {
59
59
  const [isOpen, setOpen] = (0, react_1.useState)(true);
60
60
  const [range, setRange] = (0, react_1.useState)(unicodeRanges[0].value);
61
61
  const handleRangeChange = (range) => range && setRange(range.value);
package/dist/cjs/menus.js CHANGED
@@ -28,7 +28,7 @@ const template_1 = require("./lib/template");
28
28
  const utils_1 = require("./lib/utils");
29
29
  const editor_props_1 = require("./plugins/editor-props");
30
30
  const getEditorMenus = (editor) => {
31
- const { isCommandValid, state } = editor;
31
+ const { isCommandValid, state, view } = editor;
32
32
  const doCommand = (command) => () => editor.doCommand(command);
33
33
  const props = (0, editor_props_1.getEditorProps)(state);
34
34
  const insertBackmatterSectionMenu = (category) => {
@@ -409,7 +409,7 @@ const getEditorMenus = (editor) => {
409
409
  id: 'insert-special-character',
410
410
  label: 'Special Characters',
411
411
  isEnabled: (0, utils_1.isEditAllowed)(state) && isCommandValid((0, commands_1.canInsert)(transform_1.schema.nodes.text)),
412
- run: () => (0, InsertSpecialCharacter_1.openInsertSpecialCharacterDialog)(editor.view),
412
+ run: () => (0, InsertSpecialCharacter_1.openInsertSpecialCharacterDialog)(view),
413
413
  isHidden: !(0, template_1.templateAllows)(state, transform_1.schema.nodes.text),
414
414
  },
415
415
  {
@@ -26,6 +26,7 @@ const react_1 = __importDefault(require("react"));
26
26
  const commands_1 = require("./commands");
27
27
  const helpers_1 = require("./components/toolbar/helpers");
28
28
  const InsertTableDialog_1 = require("./components/toolbar/InsertTableDialog");
29
+ const InsertSpecialCharacter_1 = require("./components/views/InsertSpecialCharacter");
29
30
  const utils_1 = require("./lib/utils");
30
31
  const isEnabled = (isCommandEnabled) => (state) => {
31
32
  return (0, utils_1.isEditAllowed)(state) && isCommandEnabled(state);
@@ -112,17 +113,31 @@ exports.toolbar = {
112
113
  },
113
114
  },
114
115
  inline: {
116
+ comment: {
117
+ title: 'Insert comment',
118
+ content: react_1.default.createElement(style_guide_1.AddCommentIcon, null),
119
+ isEnabled: isEnabled((0, commands_1.canInsert)(transform_1.schema.nodes.highlight_marker)),
120
+ run: commands_1.addInlineComment,
121
+ },
115
122
  citation: {
116
123
  title: 'Insert citation',
117
124
  content: react_1.default.createElement(style_guide_1.ToolbarCitationIcon, null),
118
125
  isEnabled: isEnabled((0, commands_1.canInsert)(transform_1.schema.nodes.citation)),
119
126
  run: commands_1.insertInlineCitation,
120
127
  },
121
- comment: {
122
- title: 'Insert comment',
123
- content: react_1.default.createElement(style_guide_1.AddCommentIcon, null),
124
- isEnabled: isEnabled((0, commands_1.canInsert)(transform_1.schema.nodes.highlight_marker)),
125
- run: commands_1.addInlineComment,
128
+ },
129
+ quote: {
130
+ blockquote: {
131
+ title: 'Insert blockquote',
132
+ content: react_1.default.createElement(style_guide_1.OutlineBlockQuoteIcon, null),
133
+ isEnabled: isEnabled((0, commands_1.canInsert)(transform_1.schema.nodes.blockquote_element)),
134
+ run: (0, commands_1.insertBlock)(transform_1.schema.nodes.blockquote_element),
135
+ },
136
+ pullquote: {
137
+ title: 'Insert pullquote',
138
+ content: react_1.default.createElement(style_guide_1.OutlinePullQuoteIcon, null),
139
+ isEnabled: isEnabled((0, commands_1.canInsert)(transform_1.schema.nodes.pullquote_element)),
140
+ run: (0, commands_1.insertBlock)(transform_1.schema.nodes.pullquote_element),
126
141
  },
127
142
  },
128
143
  element: {
@@ -132,12 +147,24 @@ exports.toolbar = {
132
147
  isEnabled: isEnabled((0, commands_1.canInsert)(transform_1.schema.nodes.figure_element)),
133
148
  run: (0, commands_1.insertBlock)(transform_1.schema.nodes.figure_element),
134
149
  },
150
+ image_element: {
151
+ title: 'Insert image',
152
+ content: react_1.default.createElement(style_guide_1.FileImageIcon, { width: "19", height: "16" }),
153
+ isEnabled: isEnabled((0, commands_1.canInsert)(transform_1.schema.nodes.image_element)),
154
+ run: (0, commands_1.insertBlock)(transform_1.schema.nodes.image_element),
155
+ },
135
156
  table_element: {
136
157
  title: 'Insert table',
137
158
  content: react_1.default.createElement(style_guide_1.ToolbarTableIcon, null),
138
159
  isEnabled: isEnabled((0, commands_1.canInsert)(transform_1.schema.nodes.table_element)),
139
160
  run: InsertTableDialog_1.openInsertTableDialog,
140
161
  },
162
+ box_element: {
163
+ title: 'Insert boxed text',
164
+ content: react_1.default.createElement(style_guide_1.ToolbarBoxedTextIcon, null),
165
+ isEnabled: isEnabled((0, commands_1.canInsert)(transform_1.schema.nodes.box_element)),
166
+ run: commands_1.insertBoxElement,
167
+ },
141
168
  equation_element: {
142
169
  title: 'Insert equation',
143
170
  content: react_1.default.createElement(style_guide_1.ToolbarEquationIcon, null),
@@ -145,4 +172,28 @@ exports.toolbar = {
145
172
  run: (0, commands_1.insertBlock)(transform_1.schema.nodes.equation_element),
146
173
  },
147
174
  },
175
+ media: {
176
+ embed: {
177
+ title: 'Insert media',
178
+ content: react_1.default.createElement(style_guide_1.OutlineEmbedIcon, null),
179
+ isEnabled: isEnabled((0, commands_1.canInsert)(transform_1.schema.nodes.embed)),
180
+ run: commands_1.insertEmbed,
181
+ },
182
+ link: {
183
+ title: 'Insert link',
184
+ content: react_1.default.createElement(style_guide_1.LinkIcon, null),
185
+ isEnabled: isEnabled((0, commands_1.canInsert)(transform_1.schema.nodes.link)),
186
+ run: commands_1.insertLink,
187
+ },
188
+ },
189
+ special: {
190
+ special_characters: {
191
+ title: 'Insert special characters',
192
+ content: react_1.default.createElement(style_guide_1.ToolbarSpecialCharactersIcon, null),
193
+ isEnabled: isEnabled((0, commands_1.canInsert)(transform_1.schema.nodes.text)),
194
+ run: (state, dispatch, view) => {
195
+ (0, InsertSpecialCharacter_1.openInsertSpecialCharacterDialog)(view);
196
+ },
197
+ },
198
+ },
148
199
  };
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MATHJAX_VERSION = exports.VERSION = void 0;
4
- exports.VERSION = '3.7.4';
4
+ exports.VERSION = '3.7.6';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -53,6 +53,7 @@ const EditableBlock = (Base) => {
53
53
  const button = document.createElement('a');
54
54
  button.classList.add('add-block', context_menu_1.contextMenuBtnClass);
55
55
  button.classList.add('add-block-after');
56
+ button.setAttribute('role', 'button');
56
57
  button.setAttribute('aria-label', `Add an element below`);
57
58
  button.setAttribute('data-balloon-pos', 'down-left');
58
59
  button.addEventListener('mousedown', (event) => {
@@ -68,6 +69,7 @@ const EditableBlock = (Base) => {
68
69
  }
69
70
  const button = document.createElement('a');
70
71
  button.classList.add('edit-block', context_menu_1.contextMenuBtnClass);
72
+ button.setAttribute('role', 'button');
71
73
  button.setAttribute('aria-label', 'Open menu');
72
74
  button.setAttribute('data-balloon-pos', 'down-left');
73
75
  button.addEventListener('mousedown', (event) => {
@@ -16,7 +16,7 @@ const reservedCharacters = new Set([
16
16
  const generateCharacters = (start, end) => Array.from({ length: end - start + 1 }, (_, i) => start + i)
17
17
  .filter((c) => !reservedCharacters.has(c))
18
18
  .map((c) => String.fromCharCode(c));
19
- const InsertSpecialCharacterDialog = ({ view, }) => {
19
+ const InsertSpecialCharacterDialog = ({ view }) => {
20
20
  const [isOpen, setOpen] = useState(true);
21
21
  const [range, setRange] = useState(unicodeRanges[0].value);
22
22
  const handleRangeChange = (range) => range && setRange(range.value);
package/dist/es/menus.js CHANGED
@@ -25,7 +25,7 @@ import { templateAllows } from './lib/template';
25
25
  import { isEditAllowed } from './lib/utils';
26
26
  import { getEditorProps } from './plugins/editor-props';
27
27
  export const getEditorMenus = (editor) => {
28
- const { isCommandValid, state } = editor;
28
+ const { isCommandValid, state, view } = editor;
29
29
  const doCommand = (command) => () => editor.doCommand(command);
30
30
  const props = getEditorProps(state);
31
31
  const insertBackmatterSectionMenu = (category) => {
@@ -406,7 +406,7 @@ export const getEditorMenus = (editor) => {
406
406
  id: 'insert-special-character',
407
407
  label: 'Special Characters',
408
408
  isEnabled: isEditAllowed(state) && isCommandValid(canInsert(schema.nodes.text)),
409
- run: () => openInsertSpecialCharacterDialog(editor.view),
409
+ run: () => openInsertSpecialCharacterDialog(view),
410
410
  isHidden: !templateAllows(state, schema.nodes.text),
411
411
  },
412
412
  {
@@ -13,13 +13,14 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { AddCommentIcon, ToolbarBoldIcon, ToolbarCitationIcon, ToolbarEquationIcon, ToolbarFigureIcon, ToolbarIndentIcon, ToolbarItalicIcon, ToolbarOrderedListIcon, ToolbarSubscriptIcon, ToolbarSuperscriptIcon, ToolbarTableIcon, ToolbarUnderlineIcon, ToolbarUnindentIcon, ToolbarUnorderedListIcon, } from '@manuscripts/style-guide';
16
+ import { AddCommentIcon, FileImageIcon, LinkIcon, OutlineBlockQuoteIcon, OutlineEmbedIcon, OutlinePullQuoteIcon, ToolbarBoldIcon, ToolbarBoxedTextIcon, ToolbarCitationIcon, ToolbarEquationIcon, ToolbarFigureIcon, ToolbarIndentIcon, ToolbarItalicIcon, ToolbarOrderedListIcon, ToolbarSpecialCharactersIcon, ToolbarSubscriptIcon, ToolbarSuperscriptIcon, ToolbarTableIcon, ToolbarUnderlineIcon, ToolbarUnindentIcon, ToolbarUnorderedListIcon, } from '@manuscripts/style-guide';
17
17
  import { schema } from '@manuscripts/transform';
18
18
  import { toggleMark } from 'prosemirror-commands';
19
19
  import React from 'react';
20
- import { addInlineComment, blockActive, canInsert, insertBlock, insertInlineCitation, insertList, markActive, } from './commands';
20
+ import { addInlineComment, blockActive, canInsert, insertBlock, insertBoxElement, insertEmbed, insertInlineCitation, insertLink, insertList, markActive, } from './commands';
21
21
  import { changeIndentation, isIndentationAllowed, } from './components/toolbar/helpers';
22
22
  import { openInsertTableDialog } from './components/toolbar/InsertTableDialog';
23
+ import { openInsertSpecialCharacterDialog } from './components/views/InsertSpecialCharacter';
23
24
  import { isEditAllowed } from './lib/utils';
24
25
  const isEnabled = (isCommandEnabled) => (state) => {
25
26
  return isEditAllowed(state) && isCommandEnabled(state);
@@ -106,17 +107,31 @@ export const toolbar = {
106
107
  },
107
108
  },
108
109
  inline: {
110
+ comment: {
111
+ title: 'Insert comment',
112
+ content: React.createElement(AddCommentIcon, null),
113
+ isEnabled: isEnabled(canInsert(schema.nodes.highlight_marker)),
114
+ run: addInlineComment,
115
+ },
109
116
  citation: {
110
117
  title: 'Insert citation',
111
118
  content: React.createElement(ToolbarCitationIcon, null),
112
119
  isEnabled: isEnabled(canInsert(schema.nodes.citation)),
113
120
  run: insertInlineCitation,
114
121
  },
115
- comment: {
116
- title: 'Insert comment',
117
- content: React.createElement(AddCommentIcon, null),
118
- isEnabled: isEnabled(canInsert(schema.nodes.highlight_marker)),
119
- run: addInlineComment,
122
+ },
123
+ quote: {
124
+ blockquote: {
125
+ title: 'Insert blockquote',
126
+ content: React.createElement(OutlineBlockQuoteIcon, null),
127
+ isEnabled: isEnabled(canInsert(schema.nodes.blockquote_element)),
128
+ run: insertBlock(schema.nodes.blockquote_element),
129
+ },
130
+ pullquote: {
131
+ title: 'Insert pullquote',
132
+ content: React.createElement(OutlinePullQuoteIcon, null),
133
+ isEnabled: isEnabled(canInsert(schema.nodes.pullquote_element)),
134
+ run: insertBlock(schema.nodes.pullquote_element),
120
135
  },
121
136
  },
122
137
  element: {
@@ -126,12 +141,24 @@ export const toolbar = {
126
141
  isEnabled: isEnabled(canInsert(schema.nodes.figure_element)),
127
142
  run: insertBlock(schema.nodes.figure_element),
128
143
  },
144
+ image_element: {
145
+ title: 'Insert image',
146
+ content: React.createElement(FileImageIcon, { width: "19", height: "16" }),
147
+ isEnabled: isEnabled(canInsert(schema.nodes.image_element)),
148
+ run: insertBlock(schema.nodes.image_element),
149
+ },
129
150
  table_element: {
130
151
  title: 'Insert table',
131
152
  content: React.createElement(ToolbarTableIcon, null),
132
153
  isEnabled: isEnabled(canInsert(schema.nodes.table_element)),
133
154
  run: openInsertTableDialog,
134
155
  },
156
+ box_element: {
157
+ title: 'Insert boxed text',
158
+ content: React.createElement(ToolbarBoxedTextIcon, null),
159
+ isEnabled: isEnabled(canInsert(schema.nodes.box_element)),
160
+ run: insertBoxElement,
161
+ },
135
162
  equation_element: {
136
163
  title: 'Insert equation',
137
164
  content: React.createElement(ToolbarEquationIcon, null),
@@ -139,4 +166,28 @@ export const toolbar = {
139
166
  run: insertBlock(schema.nodes.equation_element),
140
167
  },
141
168
  },
169
+ media: {
170
+ embed: {
171
+ title: 'Insert media',
172
+ content: React.createElement(OutlineEmbedIcon, null),
173
+ isEnabled: isEnabled(canInsert(schema.nodes.embed)),
174
+ run: insertEmbed,
175
+ },
176
+ link: {
177
+ title: 'Insert link',
178
+ content: React.createElement(LinkIcon, null),
179
+ isEnabled: isEnabled(canInsert(schema.nodes.link)),
180
+ run: insertLink,
181
+ },
182
+ },
183
+ special: {
184
+ special_characters: {
185
+ title: 'Insert special characters',
186
+ content: React.createElement(ToolbarSpecialCharactersIcon, null),
187
+ isEnabled: isEnabled(canInsert(schema.nodes.text)),
188
+ run: (state, dispatch, view) => {
189
+ openInsertSpecialCharacterDialog(view);
190
+ },
191
+ },
192
+ },
142
193
  };
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.7.4';
1
+ export const VERSION = '3.7.6';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -50,6 +50,7 @@ export const EditableBlock = (Base) => {
50
50
  const button = document.createElement('a');
51
51
  button.classList.add('add-block', contextMenuBtnClass);
52
52
  button.classList.add('add-block-after');
53
+ button.setAttribute('role', 'button');
53
54
  button.setAttribute('aria-label', `Add an element below`);
54
55
  button.setAttribute('data-balloon-pos', 'down-left');
55
56
  button.addEventListener('mousedown', (event) => {
@@ -65,6 +66,7 @@ export const EditableBlock = (Base) => {
65
66
  }
66
67
  const button = document.createElement('a');
67
68
  button.classList.add('edit-block', contextMenuBtnClass);
69
+ button.setAttribute('role', 'button');
68
70
  button.setAttribute('aria-label', 'Open menu');
69
71
  button.setAttribute('data-balloon-pos', 'down-left');
70
72
  button.addEventListener('mousedown', (event) => {
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.7.4";
1
+ export declare const VERSION = "3.7.6";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/body-editor",
3
3
  "description": "Prosemirror components for editing and viewing manuscripts",
4
- "version": "3.7.4",
4
+ "version": "3.7.6",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -38,7 +38,7 @@
38
38
  "@citation-js/plugin-ris": "0.7.18",
39
39
  "@iarna/word-count": "1.1.2",
40
40
  "@manuscripts/json-schema": "2.2.12",
41
- "@manuscripts/style-guide": "3.3.6",
41
+ "@manuscripts/style-guide": "3.3.7",
42
42
  "@manuscripts/track-changes-plugin": "2.2.1",
43
43
  "@manuscripts/transform": "4.3.10",
44
44
  "@popperjs/core": "2.11.8",