@manuscripts/body-editor 3.8.7 → 3.8.9

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.
@@ -15,8 +15,8 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.addRows = exports.addInlineComment = exports.addNodeComment = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreMetaNodeBackspaceCommand = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.insertTransAbstract = 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.paste = exports.copySelection = exports.exitEditorToContainer = exports.ignoreEnterInSubtitles = exports.insertHeroImage = exports.activateSearchReplace = exports.activateSearch = exports.autoComplete = exports.addColumns = exports.addHeaderRow = void 0;
18
+ exports.addInlineComment = exports.addNodeComment = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreMetaNodeBackspaceCommand = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.insertTransGraphicalAbstract = exports.insertTransAbstract = 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.paste = exports.copySelection = exports.exitEditorToContainer = exports.ignoreEnterInSubtitles = exports.insertHeroImage = exports.activateSearchReplace = exports.activateSearch = exports.autoComplete = exports.addColumns = exports.addHeaderRow = exports.addRows = 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");
@@ -923,7 +923,7 @@ const insertTOCSection = () => {
923
923
  return false;
924
924
  };
925
925
  exports.insertTOCSection = insertTOCSection;
926
- const insertTransAbstract = (state, dispatch, category) => {
926
+ const insertTransAbstract = (state, dispatch, category, insertAfterPos) => {
927
927
  if (!(0, template_1.templateAllows)(state, transform_1.schema.nodes.trans_abstract)) {
928
928
  return false;
929
929
  }
@@ -938,7 +938,9 @@ const insertTransAbstract = (state, dispatch, category) => {
938
938
  category,
939
939
  }, [title, paragraph]);
940
940
  const abstracts = (0, doc_1.findAbstractsNode)(state.doc);
941
- const pos = abstracts.pos + abstracts.node.nodeSize - 1;
941
+ const pos = insertAfterPos != null
942
+ ? insertAfterPos
943
+ : abstracts.pos + abstracts.node.nodeSize - 1;
942
944
  const tr = state.tr.insert(pos, node);
943
945
  const selection = prosemirror_state_1.TextSelection.create(tr.doc, pos + 1);
944
946
  tr.setSelection(selection).scrollIntoView();
@@ -946,6 +948,37 @@ const insertTransAbstract = (state, dispatch, category) => {
946
948
  return true;
947
949
  };
948
950
  exports.insertTransAbstract = insertTransAbstract;
951
+ const insertTransGraphicalAbstract = (category, insertAfterPos) => (state, dispatch, view) => {
952
+ if (!(0, template_1.templateAllows)(state, transform_1.schema.nodes.trans_graphical_abstract)) {
953
+ return false;
954
+ }
955
+ if (!dispatch) {
956
+ return true;
957
+ }
958
+ const lang = state.doc.attrs.primaryLanguageCode || 'en';
959
+ const abstracts = (0, doc_1.findAbstractsNode)(state.doc);
960
+ const pos = insertAfterPos != null
961
+ ? insertAfterPos
962
+ : abstracts.pos + abstracts.node.content.size + 1;
963
+ const node = transform_1.schema.nodes.trans_graphical_abstract.createAndFill({
964
+ lang,
965
+ category: category.id,
966
+ }, [
967
+ transform_1.schema.nodes.section_title.create({}, transform_1.schema.text(category.titles[0])),
968
+ createAndFillFigureElement(state),
969
+ ]);
970
+ const tr = state.tr.insert(pos, node);
971
+ if (node.lastChild) {
972
+ (0, accessibility_element_1.expandAccessibilitySection)(tr, node.lastChild);
973
+ }
974
+ const selection = prosemirror_state_1.TextSelection.create(tr.doc, pos + 1);
975
+ if (view) {
976
+ view.focus();
977
+ }
978
+ dispatch(tr.setSelection(selection).scrollIntoView());
979
+ return true;
980
+ };
981
+ exports.insertTransGraphicalAbstract = insertTransGraphicalAbstract;
949
982
  const findCutBefore = ($pos) => {
950
983
  if (!$pos.parent.type.spec.isolating) {
951
984
  for (let i = $pos.depth - 1; i >= 0; i--) {
@@ -61,6 +61,7 @@ const excludedTypes = [
61
61
  transform_1.schema.nodes.alt_text,
62
62
  transform_1.schema.nodes.long_desc,
63
63
  transform_1.schema.nodes.trans_abstract,
64
+ transform_1.schema.nodes.trans_graphical_abstract,
64
65
  transform_1.schema.nodes.subtitles,
65
66
  transform_1.schema.nodes.subtitle,
66
67
  transform_1.schema.nodes.supplement,
@@ -56,6 +56,7 @@ const table_element_editable_1 = __importDefault(require("../views/table_element
56
56
  const table_element_footer_1 = __importDefault(require("../views/table_element_footer"));
57
57
  const title_editable_1 = __importDefault(require("../views/title_editable"));
58
58
  const translated_abstract_editable_1 = __importDefault(require("../views/translated_abstract_editable"));
59
+ const trans_graphical_abstract_editable_1 = __importDefault(require("../views/trans_graphical_abstract_editable"));
59
60
  exports.default = (props, dispatch) => {
60
61
  return {
61
62
  title: (0, title_editable_1.default)(props, dispatch),
@@ -112,6 +113,7 @@ exports.default = (props, dispatch) => {
112
113
  hero_image: (0, hero_image_editable_1.default)(props, dispatch),
113
114
  abstracts: (0, abstracts_1.default)(props),
114
115
  trans_abstract: (0, translated_abstract_editable_1.default)(props),
116
+ trans_graphical_abstract: (0, trans_graphical_abstract_editable_1.default)(props),
115
117
  attachment: (0, attachment_1.default)(props, dispatch),
116
118
  attachments: (0, attachments_1.default)(props, dispatch),
117
119
  };
@@ -38,6 +38,7 @@ const icons = new Map([
38
38
  [nodes.section, style_guide_1.OutlineSectionIcon],
39
39
  [nodes.table_element, style_guide_1.OutlineTableIcon],
40
40
  [nodes.graphical_abstract_section, style_guide_1.OutlineSectionIcon],
41
+ [nodes.trans_graphical_abstract, style_guide_1.OutlineSectionIcon],
41
42
  [nodes.footnotes_section, style_guide_1.OutlineSectionIcon],
42
43
  [nodes.image_element, OutlineImageIcon],
43
44
  [nodes.hero_image, OutlineImageIcon],
@@ -21,6 +21,7 @@ const prosemirror_view_1 = require("prosemirror-view");
21
21
  const commands_1 = require("../commands");
22
22
  const icons_1 = require("../icons");
23
23
  const languages_1 = require("../lib/languages");
24
+ const template_1 = require("../lib/template");
24
25
  const createMenuItem = (props, contents, handler, isSelected = false) => {
25
26
  const item = document.createElement('div');
26
27
  item.className = `menu-item ${isSelected ? 'selected' : ''}`;
@@ -44,26 +45,50 @@ exports.default = (props) => new prosemirror_state_1.Plugin({
44
45
  props: {
45
46
  decorations: (state) => {
46
47
  const can = props.getCapabilities();
47
- const canEdit = can.editArticle && (0, commands_1.insertTransAbstract)(state);
48
+ const canEditTransAbstract = can.editArticle &&
49
+ (0, template_1.templateAllows)(state, transform_1.schema.nodes.trans_abstract) &&
50
+ (0, commands_1.insertTransAbstract)(state);
51
+ const canEditTransGraphicalAbstract = can.editArticle &&
52
+ (0, template_1.templateAllows)(state, transform_1.schema.nodes.trans_graphical_abstract);
48
53
  const widgets = [];
49
54
  state.doc.descendants((node, pos, parent) => {
50
- if (node.type === transform_1.schema.nodes.section &&
51
- parent?.type === transform_1.schema.nodes.abstracts &&
52
- canEdit) {
53
- widgets.push(prosemirror_view_1.Decoration.widget(pos + 1, (view) => {
54
- const $span = document.createElement('span');
55
- $span.className = 'add-trans-abstract';
56
- $span.title = 'Add translation';
57
- $span.innerHTML = `${icons_1.addAuthorIcon} <span class="add-trans-abstract-text">Add translation</span>`;
58
- $span.addEventListener('mousedown', (event) => {
59
- event.preventDefault();
60
- event.stopPropagation();
61
- (0, commands_1.insertTransAbstract)(view.state, view.dispatch, node.attrs.category);
62
- });
63
- return $span;
64
- }));
55
+ const isAbstractSection = (node.type === transform_1.schema.nodes.section ||
56
+ node.type === transform_1.schema.nodes.graphical_abstract_section) &&
57
+ parent?.type === transform_1.schema.nodes.abstracts;
58
+ if (isAbstractSection) {
59
+ const isGraphical = node.type === transform_1.schema.nodes.graphical_abstract_section;
60
+ const category = props.sectionCategories.get(node.attrs.category);
61
+ const canEdit = isGraphical
62
+ ? canEditTransGraphicalAbstract &&
63
+ category &&
64
+ (0, commands_1.insertTransGraphicalAbstract)(category)(state)
65
+ : canEditTransAbstract;
66
+ if (canEdit) {
67
+ widgets.push(prosemirror_view_1.Decoration.widget(pos + 1, (view) => {
68
+ const $span = document.createElement('span');
69
+ $span.className = 'add-trans-abstract';
70
+ $span.title = 'Add translation';
71
+ $span.innerHTML = `${icons_1.addAuthorIcon} <span class="add-trans-abstract-text">Add translation</span>`;
72
+ $span.addEventListener('mousedown', (event) => {
73
+ event.preventDefault();
74
+ event.stopPropagation();
75
+ if (isGraphical && category) {
76
+ (0, commands_1.insertTransGraphicalAbstract)(category, pos + node.nodeSize)(view.state, view.dispatch, view);
77
+ }
78
+ else {
79
+ (0, commands_1.insertTransAbstract)(view.state, view.dispatch, node.attrs.category, pos + node.nodeSize);
80
+ }
81
+ });
82
+ return $span;
83
+ }));
84
+ }
65
85
  }
66
- if (node.type === transform_1.schema.nodes.trans_abstract) {
86
+ const isTransNode = node.type === transform_1.schema.nodes.trans_abstract ||
87
+ node.type === transform_1.schema.nodes.trans_graphical_abstract;
88
+ if (isTransNode) {
89
+ const canEdit = node.type === transform_1.schema.nodes.trans_abstract
90
+ ? canEditTransAbstract
91
+ : canEditTransGraphicalAbstract;
67
92
  widgets.push(prosemirror_view_1.Decoration.widget(pos + 1, (view) => {
68
93
  const $btn = document.createElement('span');
69
94
  $btn.className = 'language-selector-btn';
@@ -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.8.7';
4
+ exports.VERSION = '3.8.9';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -32,6 +32,7 @@ class SectionTitleView extends block_view_1.default {
32
32
  transform_1.schema.nodes.bibliography_section,
33
33
  transform_1.schema.nodes.footnotes_section,
34
34
  transform_1.schema.nodes.graphical_abstract_section,
35
+ transform_1.schema.nodes.trans_graphical_abstract,
35
36
  transform_1.schema.nodes.supplements,
36
37
  ];
37
38
  this.createElement = () => {
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2025 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.TransGraphicalAbstractView = void 0;
22
+ const block_view_1 = __importDefault(require("./block_view"));
23
+ const creators_1 = require("./creators");
24
+ class TransGraphicalAbstractView extends block_view_1.default {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.elementType = 'section';
28
+ }
29
+ createDOM() {
30
+ super.createDOM();
31
+ this.dom.classList.add('block-section');
32
+ }
33
+ createElement() {
34
+ super.createElement();
35
+ if (this.contentDOM) {
36
+ this.contentDOM.classList.add('trans-graphical-abstract');
37
+ }
38
+ }
39
+ updateContents() {
40
+ super.updateContents();
41
+ this.updateAttributes();
42
+ }
43
+ updateAttributes() {
44
+ if (this.contentDOM && this.node.attrs.lang) {
45
+ this.contentDOM.lang = this.node.attrs.lang;
46
+ }
47
+ if (this.dom && this.node.attrs.category) {
48
+ this.dom.setAttribute('data-category', this.node.attrs.category);
49
+ }
50
+ }
51
+ }
52
+ exports.TransGraphicalAbstractView = TransGraphicalAbstractView;
53
+ exports.default = (0, creators_1.createNodeView)(TransGraphicalAbstractView);
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2025 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
+ const creators_1 = require("./creators");
19
+ const editable_block_1 = require("./editable_block");
20
+ const trans_graphical_abstract_1 = require("./trans_graphical_abstract");
21
+ exports.default = (0, creators_1.createEditableNodeView)((0, editable_block_1.EditableBlock)(trans_graphical_abstract_1.TransGraphicalAbstractView));
@@ -881,7 +881,7 @@ export const insertBibliographySection = () => {
881
881
  export const insertTOCSection = () => {
882
882
  return false;
883
883
  };
884
- export const insertTransAbstract = (state, dispatch, category) => {
884
+ export const insertTransAbstract = (state, dispatch, category, insertAfterPos) => {
885
885
  if (!templateAllows(state, schema.nodes.trans_abstract)) {
886
886
  return false;
887
887
  }
@@ -896,13 +896,45 @@ export const insertTransAbstract = (state, dispatch, category) => {
896
896
  category,
897
897
  }, [title, paragraph]);
898
898
  const abstracts = findAbstractsNode(state.doc);
899
- const pos = abstracts.pos + abstracts.node.nodeSize - 1;
899
+ const pos = insertAfterPos != null
900
+ ? insertAfterPos
901
+ : abstracts.pos + abstracts.node.nodeSize - 1;
900
902
  const tr = state.tr.insert(pos, node);
901
903
  const selection = TextSelection.create(tr.doc, pos + 1);
902
904
  tr.setSelection(selection).scrollIntoView();
903
905
  dispatch(tr);
904
906
  return true;
905
907
  };
908
+ export const insertTransGraphicalAbstract = (category, insertAfterPos) => (state, dispatch, view) => {
909
+ if (!templateAllows(state, schema.nodes.trans_graphical_abstract)) {
910
+ return false;
911
+ }
912
+ if (!dispatch) {
913
+ return true;
914
+ }
915
+ const lang = state.doc.attrs.primaryLanguageCode || 'en';
916
+ const abstracts = findAbstractsNode(state.doc);
917
+ const pos = insertAfterPos != null
918
+ ? insertAfterPos
919
+ : abstracts.pos + abstracts.node.content.size + 1;
920
+ const node = schema.nodes.trans_graphical_abstract.createAndFill({
921
+ lang,
922
+ category: category.id,
923
+ }, [
924
+ schema.nodes.section_title.create({}, schema.text(category.titles[0])),
925
+ createAndFillFigureElement(state),
926
+ ]);
927
+ const tr = state.tr.insert(pos, node);
928
+ if (node.lastChild) {
929
+ expandAccessibilitySection(tr, node.lastChild);
930
+ }
931
+ const selection = TextSelection.create(tr.doc, pos + 1);
932
+ if (view) {
933
+ view.focus();
934
+ }
935
+ dispatch(tr.setSelection(selection).scrollIntoView());
936
+ return true;
937
+ };
906
938
  const findCutBefore = ($pos) => {
907
939
  if (!$pos.parent.type.spec.isolating) {
908
940
  for (let i = $pos.depth - 1; i >= 0; i--) {
@@ -25,6 +25,7 @@ const excludedTypes = [
25
25
  schema.nodes.alt_text,
26
26
  schema.nodes.long_desc,
27
27
  schema.nodes.trans_abstract,
28
+ schema.nodes.trans_graphical_abstract,
28
29
  schema.nodes.subtitles,
29
30
  schema.nodes.subtitle,
30
31
  schema.nodes.supplement,
@@ -51,6 +51,7 @@ import tableElement from '../views/table_element_editable';
51
51
  import tableElementFooter from '../views/table_element_footer';
52
52
  import title from '../views/title_editable';
53
53
  import transAbstract from '../views/translated_abstract_editable';
54
+ import transGraphicalAbstract from '../views/trans_graphical_abstract_editable';
54
55
  export default (props, dispatch) => {
55
56
  return {
56
57
  title: title(props, dispatch),
@@ -107,6 +108,7 @@ export default (props, dispatch) => {
107
108
  hero_image: heroImage(props, dispatch),
108
109
  abstracts: abstracts(props),
109
110
  trans_abstract: transAbstract(props),
111
+ trans_graphical_abstract: transGraphicalAbstract(props),
110
112
  attachment: attachment(props, dispatch),
111
113
  attachments: attachments(props, dispatch),
112
114
  };
@@ -32,6 +32,7 @@ const icons = new Map([
32
32
  [nodes.section, OutlineSectionIcon],
33
33
  [nodes.table_element, OutlineTableIcon],
34
34
  [nodes.graphical_abstract_section, OutlineSectionIcon],
35
+ [nodes.trans_graphical_abstract, OutlineSectionIcon],
35
36
  [nodes.footnotes_section, OutlineSectionIcon],
36
37
  [nodes.image_element, OutlineImageIcon],
37
38
  [nodes.hero_image, OutlineImageIcon],
@@ -16,9 +16,10 @@
16
16
  import { schema } from '@manuscripts/transform';
17
17
  import { Plugin } from 'prosemirror-state';
18
18
  import { Decoration, DecorationSet } from 'prosemirror-view';
19
- import { insertTransAbstract } from '../commands';
19
+ import { insertTransAbstract, insertTransGraphicalAbstract } from '../commands';
20
20
  import { addAuthorIcon, translateIcon } from '../icons';
21
21
  import { getLanguage, getLanguageLabel } from '../lib/languages';
22
+ import { templateAllows } from '../lib/template';
22
23
  const createMenuItem = (props, contents, handler, isSelected = false) => {
23
24
  const item = document.createElement('div');
24
25
  item.className = `menu-item ${isSelected ? 'selected' : ''}`;
@@ -42,26 +43,50 @@ export default (props) => new Plugin({
42
43
  props: {
43
44
  decorations: (state) => {
44
45
  const can = props.getCapabilities();
45
- const canEdit = can.editArticle && insertTransAbstract(state);
46
+ const canEditTransAbstract = can.editArticle &&
47
+ templateAllows(state, schema.nodes.trans_abstract) &&
48
+ insertTransAbstract(state);
49
+ const canEditTransGraphicalAbstract = can.editArticle &&
50
+ templateAllows(state, schema.nodes.trans_graphical_abstract);
46
51
  const widgets = [];
47
52
  state.doc.descendants((node, pos, parent) => {
48
- if (node.type === schema.nodes.section &&
49
- parent?.type === schema.nodes.abstracts &&
50
- canEdit) {
51
- widgets.push(Decoration.widget(pos + 1, (view) => {
52
- const $span = document.createElement('span');
53
- $span.className = 'add-trans-abstract';
54
- $span.title = 'Add translation';
55
- $span.innerHTML = `${addAuthorIcon} <span class="add-trans-abstract-text">Add translation</span>`;
56
- $span.addEventListener('mousedown', (event) => {
57
- event.preventDefault();
58
- event.stopPropagation();
59
- insertTransAbstract(view.state, view.dispatch, node.attrs.category);
60
- });
61
- return $span;
62
- }));
53
+ const isAbstractSection = (node.type === schema.nodes.section ||
54
+ node.type === schema.nodes.graphical_abstract_section) &&
55
+ parent?.type === schema.nodes.abstracts;
56
+ if (isAbstractSection) {
57
+ const isGraphical = node.type === schema.nodes.graphical_abstract_section;
58
+ const category = props.sectionCategories.get(node.attrs.category);
59
+ const canEdit = isGraphical
60
+ ? canEditTransGraphicalAbstract &&
61
+ category &&
62
+ insertTransGraphicalAbstract(category)(state)
63
+ : canEditTransAbstract;
64
+ if (canEdit) {
65
+ widgets.push(Decoration.widget(pos + 1, (view) => {
66
+ const $span = document.createElement('span');
67
+ $span.className = 'add-trans-abstract';
68
+ $span.title = 'Add translation';
69
+ $span.innerHTML = `${addAuthorIcon} <span class="add-trans-abstract-text">Add translation</span>`;
70
+ $span.addEventListener('mousedown', (event) => {
71
+ event.preventDefault();
72
+ event.stopPropagation();
73
+ if (isGraphical && category) {
74
+ insertTransGraphicalAbstract(category, pos + node.nodeSize)(view.state, view.dispatch, view);
75
+ }
76
+ else {
77
+ insertTransAbstract(view.state, view.dispatch, node.attrs.category, pos + node.nodeSize);
78
+ }
79
+ });
80
+ return $span;
81
+ }));
82
+ }
63
83
  }
64
- if (node.type === schema.nodes.trans_abstract) {
84
+ const isTransNode = node.type === schema.nodes.trans_abstract ||
85
+ node.type === schema.nodes.trans_graphical_abstract;
86
+ if (isTransNode) {
87
+ const canEdit = node.type === schema.nodes.trans_abstract
88
+ ? canEditTransAbstract
89
+ : canEditTransGraphicalAbstract;
65
90
  widgets.push(Decoration.widget(pos + 1, (view) => {
66
91
  const $btn = document.createElement('span');
67
92
  $btn.className = 'language-selector-btn';
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.8.7';
1
+ export const VERSION = '3.8.9';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -26,6 +26,7 @@ export class SectionTitleView extends BlockView {
26
26
  schema.nodes.bibliography_section,
27
27
  schema.nodes.footnotes_section,
28
28
  schema.nodes.graphical_abstract_section,
29
+ schema.nodes.trans_graphical_abstract,
29
30
  schema.nodes.supplements,
30
31
  ];
31
32
  this.createElement = () => {
@@ -0,0 +1,46 @@
1
+ /*!
2
+ * © 2025 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import BlockView from './block_view';
17
+ import { createNodeView } from './creators';
18
+ export class TransGraphicalAbstractView extends BlockView {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.elementType = 'section';
22
+ }
23
+ createDOM() {
24
+ super.createDOM();
25
+ this.dom.classList.add('block-section');
26
+ }
27
+ createElement() {
28
+ super.createElement();
29
+ if (this.contentDOM) {
30
+ this.contentDOM.classList.add('trans-graphical-abstract');
31
+ }
32
+ }
33
+ updateContents() {
34
+ super.updateContents();
35
+ this.updateAttributes();
36
+ }
37
+ updateAttributes() {
38
+ if (this.contentDOM && this.node.attrs.lang) {
39
+ this.contentDOM.lang = this.node.attrs.lang;
40
+ }
41
+ if (this.dom && this.node.attrs.category) {
42
+ this.dom.setAttribute('data-category', this.node.attrs.category);
43
+ }
44
+ }
45
+ }
46
+ export default createNodeView(TransGraphicalAbstractView);
@@ -0,0 +1,19 @@
1
+ /*!
2
+ * © 2025 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { createEditableNodeView } from './creators';
17
+ import { EditableBlock } from './editable_block';
18
+ import { TransGraphicalAbstractView } from './trans_graphical_abstract';
19
+ export default createEditableNodeView(EditableBlock(TransGraphicalAbstractView));
@@ -61,7 +61,8 @@ export declare const insertKeywords: (state: ManuscriptEditorState, dispatch?: D
61
61
  export declare const insertList: (type: ManuscriptNodeType, style?: string) => (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => boolean;
62
62
  export declare const insertBibliographySection: () => boolean;
63
63
  export declare const insertTOCSection: () => boolean;
64
- export declare const insertTransAbstract: (state: ManuscriptEditorState, dispatch?: Dispatch, category?: string) => boolean;
64
+ export declare const insertTransAbstract: (state: ManuscriptEditorState, dispatch?: Dispatch, category?: string, insertAfterPos?: number) => boolean;
65
+ export declare const insertTransGraphicalAbstract: (category: SectionCategory, insertAfterPos?: number) => (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => boolean;
65
66
  export declare const isAtStartOfTextBlock: (state: ManuscriptEditorState, $cursor: ResolvedPos, view?: ManuscriptEditorView) => boolean;
66
67
  export declare const isTextSelection: (selection: Selection) => selection is ManuscriptTextSelection;
67
68
  export declare const ignoreAtomBlockNodeBackward: (state: ManuscriptEditorState, dispatch?: Dispatch, view?: ManuscriptEditorView) => boolean;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.8.7";
1
+ export declare const VERSION = "3.8.9";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
@@ -0,0 +1,27 @@
1
+ /*!
2
+ * © 2025 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { TransGraphicalAbstractNode } from '@manuscripts/transform';
17
+ import { Trackable } from '../types';
18
+ import BlockView from './block_view';
19
+ export declare class TransGraphicalAbstractView extends BlockView<Trackable<TransGraphicalAbstractNode>> {
20
+ elementType: string;
21
+ createDOM(): void;
22
+ createElement(): void;
23
+ updateContents(): void;
24
+ private updateAttributes;
25
+ }
26
+ declare const _default: (props: import("../configs/ManuscriptsEditor").EditorProps, dispatch?: import("..").Dispatch) => import("../types").NodeViewCreator<TransGraphicalAbstractView>;
27
+ export default _default;
@@ -0,0 +1,44 @@
1
+ /*!
2
+ * © 2025 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { TransGraphicalAbstractView } from './trans_graphical_abstract';
17
+ declare const _default: (props: import("../configs/ManuscriptsEditor").EditorProps, dispatch?: import("..").Dispatch) => import("../types").NodeViewCreator<{
18
+ gutterButtons(): HTMLElement[];
19
+ actionGutterButtons(): never[];
20
+ createAddButton(): HTMLAnchorElement | null;
21
+ createEditButton(): HTMLElement | null;
22
+ createMenu: () => import("../lib/context-menu").ContextMenu;
23
+ initialise(): void;
24
+ updateContents(): void;
25
+ handleTrackChanges(): void;
26
+ updateClasses(): void;
27
+ updatePlaceholder(): void;
28
+ createElement(): void;
29
+ createDOM(): void;
30
+ gutter: Record<string, HTMLElement>;
31
+ createGutter(className: string, buttons: HTMLElement[]): void;
32
+ dom: HTMLElement;
33
+ contentDOM?: HTMLElement;
34
+ elementType: string;
35
+ readonly props: import("../configs/ManuscriptsEditor").EditorProps;
36
+ node: import("prosemirror-model").Node;
37
+ readonly view: import("@manuscripts/transform").ManuscriptEditorView;
38
+ readonly getPos: () => number;
39
+ update(newNode: import("@manuscripts/transform").ManuscriptNode): boolean;
40
+ selectNode(): void;
41
+ deselectNode(): void;
42
+ destroy(): void;
43
+ } & TransGraphicalAbstractView>;
44
+ export default _default;
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.8.7",
4
+ "version": "3.8.9",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -40,7 +40,7 @@
40
40
  "@manuscripts/json-schema": "2.2.12",
41
41
  "@manuscripts/style-guide": "3.4.1",
42
42
  "@manuscripts/track-changes-plugin": "2.2.3",
43
- "@manuscripts/transform": "4.3.15",
43
+ "@manuscripts/transform": "4.3.17",
44
44
  "@popperjs/core": "2.11.8",
45
45
  "citeproc": "2.4.63",
46
46
  "codemirror": "5.65.19",
@@ -985,7 +985,7 @@ figure .selected-suggestion {
985
985
  }
986
986
 
987
987
  .selected-suggestion[data-track-status='pending']
988
- .block:not(.box-element):not(.trans-abstract),
988
+ .block:not(.box-element):not(.trans-abstract):not(.trans-graphical-abstract),
989
989
  .block:has(figure.selected-suggestion),
990
990
  figure.block:has(.equation.selected-suggestion) {
991
991
  box-shadow: inset 6px 0 0 black, inset 9px 0 0 lightgray;
@@ -996,7 +996,7 @@ figure.block:has(.equation.selected-suggestion) {
996
996
  .tracking-visible
997
997
  .ProseMirror
998
998
  [data-track-op='insert'][data-track-status='pending']
999
- .block:not(.box-element):not(.trans-abstract),
999
+ .block:not(.box-element):not(.trans-abstract):not(.trans-graphical-abstract),
1000
1000
  .tracking-visible
1001
1001
  .ProseMirror
1002
1002
  [data-track-op='wrap_with_node'][data-track-status='pending']
@@ -1006,7 +1006,7 @@ figure.block:has(.equation.selected-suggestion) {
1006
1006
 
1007
1007
  .tracking-visible
1008
1008
  .selected-suggestion[data-track-status='pending'][data-track-op='insert']
1009
- .block:not(.box-element):not(.trans-abstract),
1009
+ .block:not(.box-element):not(.trans-abstract):not(.trans-graphical-abstract),
1010
1010
  .tracking-visible
1011
1011
  .selected-suggestion
1012
1012
  [data-track-status='pending'][data-track-op='insert']
@@ -1034,7 +1034,7 @@ figure.block:has(.equation.selected-suggestion) {
1034
1034
  .tracking-visible
1035
1035
  .ProseMirror
1036
1036
  [data-track-status='pending'][data-track-op='delete']
1037
- .block:not(.box-element):not(.trans-abstract),
1037
+ .block:not(.box-element):not(.trans-abstract):not(.trans-graphical-abstract),
1038
1038
  .tracking-visible
1039
1039
  .ProseMirror
1040
1040
  .figure-block
@@ -1052,7 +1052,7 @@ figure.block:has(.equation.selected-suggestion) {
1052
1052
  }
1053
1053
 
1054
1054
  .selected-suggestion[data-track-status='pending'][data-track-op='delete']
1055
- .block:not(.box-element):not(.trans-abstract) {
1055
+ .block:not(.box-element):not(.trans-abstract):not(.trans-graphical-abstract) {
1056
1056
  box-shadow: inset 6px 0 0 var(--deleted-color),
1057
1057
  inset 9px 0 0 var(--deleted-pending-bg-color) !important;
1058
1058
  animation: fadeOutBackground 3s forwards;
@@ -1063,7 +1063,7 @@ figure.block:has(.equation.selected-suggestion) {
1063
1063
  .tracking-visible
1064
1064
  .ProseMirror
1065
1065
  [data-track-op='set_attrs']
1066
- .block:not(.trans-abstract),
1066
+ .block:not(.trans-abstract):not(.trans-graphical-abstract),
1067
1067
  .tracking-visible .block:has(figure[data-track-op='set_attrs']),
1068
1068
  .tracking-visible figure.block:has(.equation.set_attrs),
1069
1069
  .tracking-visible
@@ -1088,7 +1088,7 @@ figure.block:has(.equation.selected-suggestion) {
1088
1088
 
1089
1089
  .tracking-visible
1090
1090
  .selected-suggestion[data-track-op='set_attrs']
1091
- .block:not(.trans-abstract),
1091
+ .block:not(.trans-abstract):not(.trans-graphical-abstract),
1092
1092
  .tracking-visible
1093
1093
  .block:has(figure.selected-suggestion[data-track-op='set_attrs']),
1094
1094
  .tracking-visible .selected-suggestion[data-track-op='node_split'] .block,
@@ -1871,7 +1871,8 @@ th:hover > .table-context-menu-button,
1871
1871
  color: #353535;
1872
1872
  }
1873
1873
 
1874
- .ProseMirror .block-trans_abstract .language-selector-btn {
1874
+ .ProseMirror .block-trans_abstract .language-selector-btn,
1875
+ .ProseMirror .block-trans_graphical_abstract .language-selector-btn {
1875
1876
  display: flex;
1876
1877
  position: absolute;
1877
1878
  top: 14px;
@@ -1913,6 +1914,15 @@ th:hover > .table-context-menu-button,
1913
1914
  .ProseMirror .block-trans_abstract section.block.trans-abstract {
1914
1915
  padding: 0 !important;
1915
1916
  }
1917
+
1918
+ .ProseMirror .block-trans_graphical_abstract p.empty-node[data-placeholder] {
1919
+ font-style: italic;
1920
+ color: #c9c9c9;
1921
+ margin: 0;
1922
+ }
1923
+ .ProseMirror .block-trans_graphical_abstract section.block.trans-graphical-abstract {
1924
+ padding: 0 !important;
1925
+ }
1916
1926
  .ProseMirror .abstracts.empty-node .add-translation-container {
1917
1927
  display: none;
1918
1928
  }