@manuscripts/body-editor 3.6.18 → 3.6.19

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.isCommentingAllowed = 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 = exports.addHeaderRow = void 0;
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;
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");
@@ -1118,31 +1118,7 @@ const getParentNode = (selection) => {
1118
1118
  }
1119
1119
  return node;
1120
1120
  };
1121
- const isCommentingAllowed = (type) => type === transform_1.schema.nodes.title ||
1122
- type === transform_1.schema.nodes.subtitles ||
1123
- type === transform_1.schema.nodes.section ||
1124
- type === transform_1.schema.nodes.citation ||
1125
- type === transform_1.schema.nodes.bibliography_item ||
1126
- type === transform_1.schema.nodes.footnotes_section ||
1127
- type === transform_1.schema.nodes.bibliography_section ||
1128
- type === transform_1.schema.nodes.box_element ||
1129
- type === transform_1.schema.nodes.graphical_abstract_section ||
1130
- type === transform_1.schema.nodes.keyword_group ||
1131
- type === transform_1.schema.nodes.paragraph ||
1132
- type === transform_1.schema.nodes.figure_element ||
1133
- type === transform_1.schema.nodes.list ||
1134
- type === transform_1.schema.nodes.table_element ||
1135
- type === transform_1.schema.nodes.embed ||
1136
- type === transform_1.schema.nodes.affiliations ||
1137
- type === transform_1.schema.nodes.contributors ||
1138
- type === transform_1.schema.nodes.image_element ||
1139
- type === transform_1.schema.nodes.hero_image ||
1140
- type === transform_1.schema.nodes.trans_abstract;
1141
- exports.isCommentingAllowed = isCommentingAllowed;
1142
1121
  const addNodeComment = (node, state, dispatch) => {
1143
- if (!(0, exports.isCommentingAllowed)(node.type)) {
1144
- return false;
1145
- }
1146
1122
  const props = (0, editor_props_1.getEditorProps)(state);
1147
1123
  const contribution = (0, json_schema_1.buildContribution)(props.userID);
1148
1124
  const attrs = {
@@ -1169,7 +1145,7 @@ exports.addNodeComment = addNodeComment;
1169
1145
  const addInlineComment = (state, dispatch) => {
1170
1146
  const selection = state.selection;
1171
1147
  const node = getParentNode(selection);
1172
- if (!node || !(0, exports.isCommentingAllowed)(node.type)) {
1148
+ if (!node) {
1173
1149
  return false;
1174
1150
  }
1175
1151
  let from = selection.from;
@@ -209,14 +209,12 @@ class ContextMenu {
209
209
  }
210
210
  }
211
211
  const commentTarget = this.getCommentTarget();
212
- if ((0, commands_1.isCommentingAllowed)(commentTarget.type)) {
213
- menu.appendChild(this.createMenuSection((section) => {
214
- section.appendChild(this.createMenuItem('Comment', () => {
215
- (0, commands_1.addNodeComment)(commentTarget, this.view.state, this.view.dispatch);
216
- popper.destroy();
217
- }));
212
+ menu.appendChild(this.createMenuSection((section) => {
213
+ section.appendChild(this.createMenuItem('Comment', () => {
214
+ (0, commands_1.addNodeComment)(commentTarget, this.view.state, this.view.dispatch);
215
+ popper.destroy();
218
216
  }));
219
- }
217
+ }));
220
218
  if (type === transform_1.schema.nodes.table_element) {
221
219
  const items = [];
222
220
  const isInsideNode = (0, utils_1.isSelectionInNode)(this.view.state, this.node);
@@ -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.6.18';
4
+ exports.VERSION = '3.6.19';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -21,7 +21,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.PullquoteElementView = void 0;
22
22
  const style_guide_1 = require("@manuscripts/style-guide");
23
23
  const transform_1 = require("@manuscripts/transform");
24
+ const prosemirror_state_1 = require("prosemirror-state");
24
25
  const prosemirror_utils_1 = require("prosemirror-utils");
26
+ const comments_1 = require("../plugins/comments");
25
27
  const block_view_1 = __importDefault(require("./block_view"));
26
28
  const creators_1 = require("./creators");
27
29
  const ReactSubView_1 = __importDefault(require("./ReactSubView"));
@@ -31,11 +33,24 @@ class PullquoteElementView extends block_view_1.default {
31
33
  this.elementType = 'aside';
32
34
  this.ignoreMutation = () => true;
33
35
  this.stopEvent = () => true;
36
+ this.handleClick = (event) => {
37
+ const element = event.target;
38
+ const marker = element.closest('.comment-marker');
39
+ if (marker) {
40
+ const key = marker.dataset.key;
41
+ const tr = this.view.state.tr;
42
+ (0, comments_1.setCommentSelection)(tr, key, undefined, false);
43
+ tr.setSelection(prosemirror_state_1.NodeSelection.create(this.view.state.doc, this.getPos()));
44
+ this.view.dispatch(tr);
45
+ return;
46
+ }
47
+ };
34
48
  this.createElement = () => {
35
49
  this.contentDOM = document.createElement(this.elementType);
36
50
  this.contentDOM.className = 'block';
37
51
  this.contentDOM.classList.add('pullquote');
38
52
  this.dom.appendChild(this.contentDOM);
53
+ this.dom.addEventListener('click', this.handleClick);
39
54
  };
40
55
  this.actionGutterButtons = () => {
41
56
  const contextMenu = this.addFigureContextMenu();
@@ -59,6 +74,10 @@ class PullquoteElementView extends block_view_1.default {
59
74
  }
60
75
  return undefined;
61
76
  };
77
+ this.destroy = () => {
78
+ this.dom.removeEventListener('click', this.handleClick);
79
+ super.destroy();
80
+ };
62
81
  }
63
82
  handleAddFigure() {
64
83
  const tr = this.view.state.tr;
@@ -1068,30 +1068,7 @@ const getParentNode = (selection) => {
1068
1068
  }
1069
1069
  return node;
1070
1070
  };
1071
- export const isCommentingAllowed = (type) => type === schema.nodes.title ||
1072
- type === schema.nodes.subtitles ||
1073
- type === schema.nodes.section ||
1074
- type === schema.nodes.citation ||
1075
- type === schema.nodes.bibliography_item ||
1076
- type === schema.nodes.footnotes_section ||
1077
- type === schema.nodes.bibliography_section ||
1078
- type === schema.nodes.box_element ||
1079
- type === schema.nodes.graphical_abstract_section ||
1080
- type === schema.nodes.keyword_group ||
1081
- type === schema.nodes.paragraph ||
1082
- type === schema.nodes.figure_element ||
1083
- type === schema.nodes.list ||
1084
- type === schema.nodes.table_element ||
1085
- type === schema.nodes.embed ||
1086
- type === schema.nodes.affiliations ||
1087
- type === schema.nodes.contributors ||
1088
- type === schema.nodes.image_element ||
1089
- type === schema.nodes.hero_image ||
1090
- type === schema.nodes.trans_abstract;
1091
1071
  export const addNodeComment = (node, state, dispatch) => {
1092
- if (!isCommentingAllowed(node.type)) {
1093
- return false;
1094
- }
1095
1072
  const props = getEditorProps(state);
1096
1073
  const contribution = buildContribution(props.userID);
1097
1074
  const attrs = {
@@ -1117,7 +1094,7 @@ export const addNodeComment = (node, state, dispatch) => {
1117
1094
  export const addInlineComment = (state, dispatch) => {
1118
1095
  const selection = state.selection;
1119
1096
  const node = getParentNode(selection);
1120
- if (!node || !isCommentingAllowed(node.type)) {
1097
+ if (!node) {
1121
1098
  return false;
1122
1099
  }
1123
1100
  let from = selection.from;
@@ -19,7 +19,7 @@ import { TextSelection } from 'prosemirror-state';
19
19
  import { findChildrenByType } from 'prosemirror-utils';
20
20
  import { createElement } from 'react';
21
21
  import { renderToStaticMarkup } from 'react-dom/server';
22
- import { addNodeComment, createBlock, findPosBeforeFirstSubsection, insertGeneralTableFootnote, insertInlineTableFootnote, isCommentingAllowed, } from '../commands';
22
+ import { addNodeComment, createBlock, findPosBeforeFirstSubsection, insertGeneralTableFootnote, insertInlineTableFootnote, } from '../commands';
23
23
  import { PopperManager } from './popper';
24
24
  import { createPositionOptions } from './position-menu';
25
25
  import { templateAllows } from './template';
@@ -205,14 +205,12 @@ export class ContextMenu {
205
205
  }
206
206
  }
207
207
  const commentTarget = this.getCommentTarget();
208
- if (isCommentingAllowed(commentTarget.type)) {
209
- menu.appendChild(this.createMenuSection((section) => {
210
- section.appendChild(this.createMenuItem('Comment', () => {
211
- addNodeComment(commentTarget, this.view.state, this.view.dispatch);
212
- popper.destroy();
213
- }));
208
+ menu.appendChild(this.createMenuSection((section) => {
209
+ section.appendChild(this.createMenuItem('Comment', () => {
210
+ addNodeComment(commentTarget, this.view.state, this.view.dispatch);
211
+ popper.destroy();
214
212
  }));
215
- }
213
+ }));
216
214
  if (type === schema.nodes.table_element) {
217
215
  const items = [];
218
216
  const isInsideNode = isSelectionInNode(this.view.state, this.node);
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.6.18';
1
+ export const VERSION = '3.6.19';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -15,7 +15,9 @@
15
15
  */
16
16
  import { ContextMenu } from '@manuscripts/style-guide';
17
17
  import { schema } from '@manuscripts/transform';
18
+ import { NodeSelection } from 'prosemirror-state';
18
19
  import { findChildrenByType } from 'prosemirror-utils';
20
+ import { setCommentSelection } from '../plugins/comments';
19
21
  import BlockView from './block_view';
20
22
  import { createNodeOrElementView } from './creators';
21
23
  import ReactSubView from './ReactSubView';
@@ -25,11 +27,24 @@ export class PullquoteElementView extends BlockView {
25
27
  this.elementType = 'aside';
26
28
  this.ignoreMutation = () => true;
27
29
  this.stopEvent = () => true;
30
+ this.handleClick = (event) => {
31
+ const element = event.target;
32
+ const marker = element.closest('.comment-marker');
33
+ if (marker) {
34
+ const key = marker.dataset.key;
35
+ const tr = this.view.state.tr;
36
+ setCommentSelection(tr, key, undefined, false);
37
+ tr.setSelection(NodeSelection.create(this.view.state.doc, this.getPos()));
38
+ this.view.dispatch(tr);
39
+ return;
40
+ }
41
+ };
28
42
  this.createElement = () => {
29
43
  this.contentDOM = document.createElement(this.elementType);
30
44
  this.contentDOM.className = 'block';
31
45
  this.contentDOM.classList.add('pullquote');
32
46
  this.dom.appendChild(this.contentDOM);
47
+ this.dom.addEventListener('click', this.handleClick);
33
48
  };
34
49
  this.actionGutterButtons = () => {
35
50
  const contextMenu = this.addFigureContextMenu();
@@ -53,6 +68,10 @@ export class PullquoteElementView extends BlockView {
53
68
  }
54
69
  return undefined;
55
70
  };
71
+ this.destroy = () => {
72
+ this.dom.removeEventListener('click', this.handleClick);
73
+ super.destroy();
74
+ };
56
75
  }
57
76
  handleAddFigure() {
58
77
  const tr = this.view.state.tr;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { FootnotesElementNode, ManuscriptEditorState, ManuscriptEditorView, ManuscriptMarkType, ManuscriptNode, ManuscriptNodeSelection, ManuscriptNodeType, ManuscriptResolvedPos, ManuscriptTextSelection, ManuscriptTransaction, SectionCategory } from '@manuscripts/transform';
17
- import { Attrs, NodeType, ResolvedPos } from 'prosemirror-model';
17
+ import { Attrs, ResolvedPos } from 'prosemirror-model';
18
18
  import { EditorState, Selection, Transaction } from 'prosemirror-state';
19
19
  import { EditorView } from 'prosemirror-view';
20
20
  import { FileAttachment } from './lib/files';
@@ -74,7 +74,6 @@ export type TableConfig = {
74
74
  includeHeader: boolean;
75
75
  };
76
76
  export declare const createAndFillTableElement: (attrs?: Attrs, config?: TableConfig) => import("prosemirror-model").Node;
77
- export declare const isCommentingAllowed: (type: NodeType) => boolean;
78
77
  export declare const addNodeComment: (node: ManuscriptNode, state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
79
78
  export declare const addInlineComment: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
80
79
  export declare const addRows: (direction: "top" | "bottom") => (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.6.18";
1
+ export declare const VERSION = "3.6.19";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
@@ -20,10 +20,12 @@ export declare class PullquoteElementView extends BlockView<PullquoteElementNode
20
20
  contextMenu: HTMLElement;
21
21
  ignoreMutation: () => boolean;
22
22
  stopEvent: () => boolean;
23
+ private handleClick;
23
24
  createElement: () => void;
24
25
  handleAddFigure(): void;
25
26
  actionGutterButtons: () => HTMLElement[];
26
27
  addFigureContextMenu: () => HTMLElement | undefined;
28
+ destroy: () => void;
27
29
  }
28
30
  declare const _default: (props: import("../configs/ManuscriptsEditor").EditorProps) => import("../types").NodeViewCreator<PullquoteElementView>;
29
31
  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.6.18",
4
+ "version": "3.6.19",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -2044,3 +2044,7 @@ th:hover > .table-context-menu-button,
2044
2044
  .ProseMirror a.link:empty::before {
2045
2045
  content: '\00a0';
2046
2046
  }
2047
+ .block-pullquote_element .tools-panel {
2048
+ top: 35px;
2049
+ right: 26px;
2050
+ }