@manuscripts/body-editor 3.7.2 → 3.7.3

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.
@@ -16,7 +16,7 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.addHeaderRow = exports.addRows = exports.addInlineComment = exports.addNodeComment = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreMetaNodeBackspaceCommand = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertKeywords = exports.insertAward = exports.insertAffiliation = exports.insertContributors = exports.insertGraphicalAbstract = exports.insertBackmatterSection = exports.insertAbstractSection = exports.insertSection = exports.insertBoxElement = exports.insertInlineFootnote = exports.insertFootnotesElement = exports.insertTableElementFooter = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.findPosBeforeFirstSubsection = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertAttachment = exports.insertSupplement = exports.insertTable = exports.insertEmbed = exports.insertFigure = exports.insertGeneralTableFootnote = exports.insertInlineTableFootnote = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = exports.addToStart = void 0;
19
- exports.ignoreEnterInSubtitles = exports.insertHeroImage = exports.activateSearchReplace = exports.activateSearch = exports.autoComplete = exports.addColumns = void 0;
19
+ exports.paste = exports.copySelection = exports.ignoreEnterInSubtitles = exports.insertHeroImage = exports.activateSearchReplace = exports.activateSearch = exports.autoComplete = exports.addColumns = void 0;
20
20
  const json_schema_1 = require("@manuscripts/json-schema");
21
21
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
22
22
  const transform_1 = require("@manuscripts/transform");
@@ -1296,3 +1296,54 @@ const ignoreEnterInSubtitles = (state) => {
1296
1296
  return false;
1297
1297
  };
1298
1298
  exports.ignoreEnterInSubtitles = ignoreEnterInSubtitles;
1299
+ const copySelection = (state, dispatch, view) => {
1300
+ const { selection } = state;
1301
+ const clipboard = navigator?.clipboard;
1302
+ if (selection.content().size && clipboard) {
1303
+ view &&
1304
+ (async () => {
1305
+ try {
1306
+ const { dom, text } = view.serializeForClipboard(selection.content());
1307
+ await clipboard.write([
1308
+ new ClipboardItem({
1309
+ 'text/plain': new Blob([text], { type: 'text/plain' }),
1310
+ 'text/html': new Blob([dom.innerHTML], { type: 'text/html' }),
1311
+ }),
1312
+ ]);
1313
+ }
1314
+ catch (e) {
1315
+ console.error('clipboard writer error:', e);
1316
+ }
1317
+ })();
1318
+ return true;
1319
+ }
1320
+ return false;
1321
+ };
1322
+ exports.copySelection = copySelection;
1323
+ const paste = (format) => (state, dispatch, view) => {
1324
+ const clipboard = navigator?.clipboard;
1325
+ if (clipboard) {
1326
+ view &&
1327
+ (async () => {
1328
+ try {
1329
+ const items = await clipboard.read();
1330
+ const htmlItem = await items.find(({ types }) => types.includes('text/html'));
1331
+ if (format === 'html' && htmlItem) {
1332
+ const htmlBlob = await htmlItem.getType('text/html');
1333
+ const html = await htmlBlob.text();
1334
+ view.pasteHTML(html);
1335
+ }
1336
+ else {
1337
+ const text = await clipboard.readText();
1338
+ view.pasteText(text);
1339
+ }
1340
+ }
1341
+ catch (e) {
1342
+ console.error('clipboard reader error:', e);
1343
+ }
1344
+ })();
1345
+ return true;
1346
+ }
1347
+ return false;
1348
+ };
1349
+ exports.paste = paste;
package/dist/cjs/menus.js CHANGED
@@ -81,6 +81,30 @@ const getEditorMenus = (editor) => {
81
81
  {
82
82
  role: 'separator',
83
83
  },
84
+ {
85
+ id: 'edit-copy',
86
+ role: 'copy',
87
+ label: 'Copy',
88
+ isEnabled: (0, utils_1.isEditAllowed)(state) && isCommandValid(commands_1.copySelection),
89
+ run: doCommand(commands_1.copySelection),
90
+ },
91
+ {
92
+ id: 'edit-paste',
93
+ role: 'paste',
94
+ label: 'Paste',
95
+ isEnabled: (0, utils_1.isEditAllowed)(state) && isCommandValid((0, commands_1.paste)('html')),
96
+ run: doCommand((0, commands_1.paste)('html')),
97
+ },
98
+ {
99
+ id: 'edit-paste-text',
100
+ role: 'paste-text',
101
+ label: 'Paste without formatting',
102
+ isEnabled: (0, utils_1.isEditAllowed)(state) && isCommandValid((0, commands_1.paste)('text')),
103
+ run: doCommand((0, commands_1.paste)('text')),
104
+ },
105
+ {
106
+ role: 'separator',
107
+ },
84
108
  {
85
109
  id: 'edit-delete',
86
110
  role: 'delete',
@@ -119,6 +143,16 @@ const getEditorMenus = (editor) => {
119
143
  label: 'Insert',
120
144
  isEnabled: true,
121
145
  submenu: [
146
+ {
147
+ id: 'insert-comment',
148
+ label: 'Comment',
149
+ isEnabled: (0, utils_1.isEditAllowed)(state) && isCommandValid(commands_1.addInlineComment),
150
+ run: doCommand(commands_1.addInlineComment),
151
+ isHidden: !(0, template_1.templateAllows)(state, transform_1.schema.nodes.comment),
152
+ },
153
+ {
154
+ role: 'separator',
155
+ },
122
156
  {
123
157
  id: 'front-matter',
124
158
  label: 'Article Metadata',
@@ -202,6 +236,23 @@ const getEditorMenus = (editor) => {
202
236
  {
203
237
  role: 'separator',
204
238
  },
239
+ {
240
+ id: 'insert-bullet-list',
241
+ label: 'Bullet List',
242
+ isEnabled: (0, utils_1.isEditAllowed)(state) && isCommandValid((0, commands_1.canInsert)(transform_1.schema.nodes.list)),
243
+ run: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'bullet')),
244
+ isHidden: !(0, template_1.templateAllows)(state, transform_1.schema.nodes.list),
245
+ },
246
+ {
247
+ id: 'insert-order-list',
248
+ label: 'Ordered List',
249
+ isEnabled: (0, utils_1.isEditAllowed)(state) && isCommandValid((0, commands_1.canInsert)(transform_1.schema.nodes.list)),
250
+ run: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'order')),
251
+ isHidden: !(0, template_1.templateAllows)(state, transform_1.schema.nodes.list),
252
+ },
253
+ {
254
+ role: 'separator',
255
+ },
205
256
  {
206
257
  id: 'insert-blockquote',
207
258
  label: 'Block Quote',
@@ -221,18 +272,6 @@ const getEditorMenus = (editor) => {
221
272
  {
222
273
  role: 'separator',
223
274
  },
224
- {
225
- id: 'insert-boxed-text',
226
- label: 'Boxed Text',
227
- shortcut: {
228
- mac: 'Option+CommandOrControl+B',
229
- pc: 'CommandOrControl+Option+B',
230
- },
231
- isEnabled: (0, utils_1.isEditAllowed)(state) &&
232
- isCommandValid((0, commands_1.canInsert)(transform_1.schema.nodes.box_element)),
233
- run: doCommand(commands_1.insertBoxElement),
234
- isHidden: !(0, template_1.templateAllows)(state, transform_1.schema.nodes.box_element),
235
- },
236
275
  {
237
276
  id: 'insert-figure-element',
238
277
  label: 'Figure Panel',
@@ -247,20 +286,12 @@ const getEditorMenus = (editor) => {
247
286
  },
248
287
  {
249
288
  id: 'insert-image-element',
250
- label: 'Simple Image',
289
+ label: 'Image',
251
290
  isEnabled: (0, utils_1.isEditAllowed)(state) &&
252
291
  isCommandValid((0, commands_1.canInsert)(transform_1.schema.nodes.image_element)),
253
292
  run: doCommand((0, commands_1.insertBlock)(transform_1.schema.nodes.image_element)),
254
293
  isHidden: !(0, template_1.templateAllows)(state, transform_1.schema.nodes.image_element),
255
294
  },
256
- {
257
- id: 'insert-hero-image',
258
- label: 'Hero Image',
259
- isEnabled: (0, utils_1.isEditAllowed)(state) &&
260
- isCommandValid((0, commands_1.canInsert)(transform_1.schema.nodes.hero_image)),
261
- run: doCommand((0, commands_1.insertHeroImage)()),
262
- isHidden: !(0, template_1.templateAllows)(state, transform_1.schema.nodes.hero_image),
263
- },
264
295
  {
265
296
  id: 'insert-table-element',
266
297
  label: 'Table',
@@ -273,12 +304,24 @@ const getEditorMenus = (editor) => {
273
304
  run: () => (0, InsertTableDialog_1.openInsertTableDialog)(editor.state, editor.dispatch),
274
305
  isHidden: !(0, template_1.templateAllows)(state, transform_1.schema.nodes.table_element),
275
306
  },
307
+ {
308
+ id: 'insert-boxed-text',
309
+ label: 'Boxed Text',
310
+ shortcut: {
311
+ mac: 'Option+CommandOrControl+B',
312
+ pc: 'CommandOrControl+Option+B',
313
+ },
314
+ isEnabled: (0, utils_1.isEditAllowed)(state) &&
315
+ isCommandValid((0, commands_1.canInsert)(transform_1.schema.nodes.box_element)),
316
+ run: doCommand(commands_1.insertBoxElement),
317
+ isHidden: !(0, template_1.templateAllows)(state, transform_1.schema.nodes.box_element),
318
+ },
276
319
  {
277
320
  role: 'separator',
278
321
  },
279
322
  {
280
323
  id: 'insert-embed-media',
281
- label: 'Embedded Media',
324
+ label: 'Media',
282
325
  isActive: (0, commands_1.blockActive)(transform_1.schema.nodes.embed)(state),
283
326
  isEnabled: (0, utils_1.isEditAllowed)(state) && isCommandValid((0, commands_1.canInsert)(transform_1.schema.nodes.embed)),
284
327
  run: doCommand(commands_1.insertEmbed),
@@ -370,11 +413,12 @@ const getEditorMenus = (editor) => {
370
413
  isHidden: !(0, template_1.templateAllows)(state, transform_1.schema.nodes.text),
371
414
  },
372
415
  {
373
- id: 'insert-comment',
374
- label: 'Comment',
375
- isEnabled: (0, utils_1.isEditAllowed)(state) && isCommandValid(commands_1.addInlineComment),
376
- run: doCommand(commands_1.addInlineComment),
377
- isHidden: !(0, template_1.templateAllows)(state, transform_1.schema.nodes.comment),
416
+ id: 'insert-hero-image',
417
+ label: 'Hero Image',
418
+ isEnabled: (0, utils_1.isEditAllowed)(state) &&
419
+ isCommandValid((0, commands_1.canInsert)(transform_1.schema.nodes.hero_image)),
420
+ run: doCommand((0, commands_1.insertHeroImage)()),
421
+ isHidden: !(0, template_1.templateAllows)(state, transform_1.schema.nodes.hero_image),
378
422
  },
379
423
  ],
380
424
  };
@@ -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.2';
4
+ exports.VERSION = '3.7.3';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -1236,3 +1236,52 @@ export const ignoreEnterInSubtitles = (state) => {
1236
1236
  }
1237
1237
  return false;
1238
1238
  };
1239
+ export const copySelection = (state, dispatch, view) => {
1240
+ const { selection } = state;
1241
+ const clipboard = navigator?.clipboard;
1242
+ if (selection.content().size && clipboard) {
1243
+ view &&
1244
+ (async () => {
1245
+ try {
1246
+ const { dom, text } = view.serializeForClipboard(selection.content());
1247
+ await clipboard.write([
1248
+ new ClipboardItem({
1249
+ 'text/plain': new Blob([text], { type: 'text/plain' }),
1250
+ 'text/html': new Blob([dom.innerHTML], { type: 'text/html' }),
1251
+ }),
1252
+ ]);
1253
+ }
1254
+ catch (e) {
1255
+ console.error('clipboard writer error:', e);
1256
+ }
1257
+ })();
1258
+ return true;
1259
+ }
1260
+ return false;
1261
+ };
1262
+ export const paste = (format) => (state, dispatch, view) => {
1263
+ const clipboard = navigator?.clipboard;
1264
+ if (clipboard) {
1265
+ view &&
1266
+ (async () => {
1267
+ try {
1268
+ const items = await clipboard.read();
1269
+ const htmlItem = await items.find(({ types }) => types.includes('text/html'));
1270
+ if (format === 'html' && htmlItem) {
1271
+ const htmlBlob = await htmlItem.getType('text/html');
1272
+ const html = await htmlBlob.text();
1273
+ view.pasteHTML(html);
1274
+ }
1275
+ else {
1276
+ const text = await clipboard.readText();
1277
+ view.pasteText(text);
1278
+ }
1279
+ }
1280
+ catch (e) {
1281
+ console.error('clipboard reader error:', e);
1282
+ }
1283
+ })();
1284
+ return true;
1285
+ }
1286
+ return false;
1287
+ };
package/dist/es/menus.js CHANGED
@@ -16,7 +16,7 @@
16
16
  import { getGroupCategories, schema, } from '@manuscripts/transform';
17
17
  import { toggleMark } from 'prosemirror-commands';
18
18
  import { redo, undo } from 'prosemirror-history';
19
- import { activateSearchReplace, addInlineComment, blockActive, canInsert, insertAbstractSection, insertAffiliation, insertAward, insertBackmatterSection, insertBlock, insertBoxElement, insertContributors, insertCrossReference, insertEmbed, insertGraphicalAbstract, insertHeroImage, insertInlineCitation, insertInlineEquation, insertInlineFootnote, insertKeywords, insertLink, insertList, insertSection, markActive, } from './commands';
19
+ import { activateSearchReplace, addInlineComment, blockActive, canInsert, copySelection, insertAbstractSection, insertAffiliation, insertAward, insertBackmatterSection, insertBlock, insertBoxElement, insertContributors, insertCrossReference, insertEmbed, insertGraphicalAbstract, insertHeroImage, insertInlineCitation, insertInlineEquation, insertInlineFootnote, insertKeywords, insertLink, insertList, insertSection, markActive, paste, } from './commands';
20
20
  import { openInsertTableDialog } from './components/toolbar/InsertTableDialog';
21
21
  import { ListMenuItem } from './components/toolbar/ListMenuItem';
22
22
  import { openInsertSpecialCharacterDialog } from './components/views/InsertSpecialCharacter';
@@ -78,6 +78,30 @@ export const getEditorMenus = (editor) => {
78
78
  {
79
79
  role: 'separator',
80
80
  },
81
+ {
82
+ id: 'edit-copy',
83
+ role: 'copy',
84
+ label: 'Copy',
85
+ isEnabled: isEditAllowed(state) && isCommandValid(copySelection),
86
+ run: doCommand(copySelection),
87
+ },
88
+ {
89
+ id: 'edit-paste',
90
+ role: 'paste',
91
+ label: 'Paste',
92
+ isEnabled: isEditAllowed(state) && isCommandValid(paste('html')),
93
+ run: doCommand(paste('html')),
94
+ },
95
+ {
96
+ id: 'edit-paste-text',
97
+ role: 'paste-text',
98
+ label: 'Paste without formatting',
99
+ isEnabled: isEditAllowed(state) && isCommandValid(paste('text')),
100
+ run: doCommand(paste('text')),
101
+ },
102
+ {
103
+ role: 'separator',
104
+ },
81
105
  {
82
106
  id: 'edit-delete',
83
107
  role: 'delete',
@@ -116,6 +140,16 @@ export const getEditorMenus = (editor) => {
116
140
  label: 'Insert',
117
141
  isEnabled: true,
118
142
  submenu: [
143
+ {
144
+ id: 'insert-comment',
145
+ label: 'Comment',
146
+ isEnabled: isEditAllowed(state) && isCommandValid(addInlineComment),
147
+ run: doCommand(addInlineComment),
148
+ isHidden: !templateAllows(state, schema.nodes.comment),
149
+ },
150
+ {
151
+ role: 'separator',
152
+ },
119
153
  {
120
154
  id: 'front-matter',
121
155
  label: 'Article Metadata',
@@ -199,6 +233,23 @@ export const getEditorMenus = (editor) => {
199
233
  {
200
234
  role: 'separator',
201
235
  },
236
+ {
237
+ id: 'insert-bullet-list',
238
+ label: 'Bullet List',
239
+ isEnabled: isEditAllowed(state) && isCommandValid(canInsert(schema.nodes.list)),
240
+ run: doCommand(insertList(schema.nodes.list, 'bullet')),
241
+ isHidden: !templateAllows(state, schema.nodes.list),
242
+ },
243
+ {
244
+ id: 'insert-order-list',
245
+ label: 'Ordered List',
246
+ isEnabled: isEditAllowed(state) && isCommandValid(canInsert(schema.nodes.list)),
247
+ run: doCommand(insertList(schema.nodes.list, 'order')),
248
+ isHidden: !templateAllows(state, schema.nodes.list),
249
+ },
250
+ {
251
+ role: 'separator',
252
+ },
202
253
  {
203
254
  id: 'insert-blockquote',
204
255
  label: 'Block Quote',
@@ -218,18 +269,6 @@ export const getEditorMenus = (editor) => {
218
269
  {
219
270
  role: 'separator',
220
271
  },
221
- {
222
- id: 'insert-boxed-text',
223
- label: 'Boxed Text',
224
- shortcut: {
225
- mac: 'Option+CommandOrControl+B',
226
- pc: 'CommandOrControl+Option+B',
227
- },
228
- isEnabled: isEditAllowed(state) &&
229
- isCommandValid(canInsert(schema.nodes.box_element)),
230
- run: doCommand(insertBoxElement),
231
- isHidden: !templateAllows(state, schema.nodes.box_element),
232
- },
233
272
  {
234
273
  id: 'insert-figure-element',
235
274
  label: 'Figure Panel',
@@ -244,20 +283,12 @@ export const getEditorMenus = (editor) => {
244
283
  },
245
284
  {
246
285
  id: 'insert-image-element',
247
- label: 'Simple Image',
286
+ label: 'Image',
248
287
  isEnabled: isEditAllowed(state) &&
249
288
  isCommandValid(canInsert(schema.nodes.image_element)),
250
289
  run: doCommand(insertBlock(schema.nodes.image_element)),
251
290
  isHidden: !templateAllows(state, schema.nodes.image_element),
252
291
  },
253
- {
254
- id: 'insert-hero-image',
255
- label: 'Hero Image',
256
- isEnabled: isEditAllowed(state) &&
257
- isCommandValid(canInsert(schema.nodes.hero_image)),
258
- run: doCommand(insertHeroImage()),
259
- isHidden: !templateAllows(state, schema.nodes.hero_image),
260
- },
261
292
  {
262
293
  id: 'insert-table-element',
263
294
  label: 'Table',
@@ -270,12 +301,24 @@ export const getEditorMenus = (editor) => {
270
301
  run: () => openInsertTableDialog(editor.state, editor.dispatch),
271
302
  isHidden: !templateAllows(state, schema.nodes.table_element),
272
303
  },
304
+ {
305
+ id: 'insert-boxed-text',
306
+ label: 'Boxed Text',
307
+ shortcut: {
308
+ mac: 'Option+CommandOrControl+B',
309
+ pc: 'CommandOrControl+Option+B',
310
+ },
311
+ isEnabled: isEditAllowed(state) &&
312
+ isCommandValid(canInsert(schema.nodes.box_element)),
313
+ run: doCommand(insertBoxElement),
314
+ isHidden: !templateAllows(state, schema.nodes.box_element),
315
+ },
273
316
  {
274
317
  role: 'separator',
275
318
  },
276
319
  {
277
320
  id: 'insert-embed-media',
278
- label: 'Embedded Media',
321
+ label: 'Media',
279
322
  isActive: blockActive(schema.nodes.embed)(state),
280
323
  isEnabled: isEditAllowed(state) && isCommandValid(canInsert(schema.nodes.embed)),
281
324
  run: doCommand(insertEmbed),
@@ -367,11 +410,12 @@ export const getEditorMenus = (editor) => {
367
410
  isHidden: !templateAllows(state, schema.nodes.text),
368
411
  },
369
412
  {
370
- id: 'insert-comment',
371
- label: 'Comment',
372
- isEnabled: isEditAllowed(state) && isCommandValid(addInlineComment),
373
- run: doCommand(addInlineComment),
374
- isHidden: !templateAllows(state, schema.nodes.comment),
413
+ id: 'insert-hero-image',
414
+ label: 'Hero Image',
415
+ isEnabled: isEditAllowed(state) &&
416
+ isCommandValid(canInsert(schema.nodes.hero_image)),
417
+ run: doCommand(insertHeroImage()),
418
+ isHidden: !templateAllows(state, schema.nodes.hero_image),
375
419
  },
376
420
  ],
377
421
  };
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.7.2';
1
+ export const VERSION = '3.7.3';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -84,3 +84,5 @@ export declare const activateSearch: (state: ManuscriptEditorState, dispatch?: D
84
84
  export declare const activateSearchReplace: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
85
85
  export declare const insertHeroImage: () => (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => boolean;
86
86
  export declare const ignoreEnterInSubtitles: (state: ManuscriptEditorState) => boolean;
87
+ export declare const copySelection: (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => boolean;
88
+ export declare const paste: (format: "html" | "text") => (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => boolean;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.7.2";
1
+ export declare const VERSION = "3.7.3";
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.2",
4
+ "version": "3.7.3",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",