@manuscripts/body-editor 3.2.5 → 3.2.7

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.
@@ -58,7 +58,7 @@ exports.default = (props) => {
58
58
  (0, track_changes_plugin_1.trackChangesPlugin)({
59
59
  userID: props.userID,
60
60
  debug: props.debug,
61
- initialStatus: props.isViewingMode
61
+ initialStatus: props.isViewingMode || props.isComparingMode
62
62
  ? track_changes_plugin_1.TrackChangesStatus.viewSnapshots
63
63
  : props.getCapabilities().editWithoutTracking
64
64
  ? track_changes_plugin_1.TrackChangesStatus.disabled
@@ -279,6 +279,28 @@ class ContextMenu {
279
279
  }));
280
280
  }));
281
281
  }
282
+ if (type === transform_1.schema.nodes.box_element) {
283
+ const tr = this.view.state.tr;
284
+ const boxElementNode = $pos.node($pos.depth - 1);
285
+ const boxStartPos = $pos.start($pos.depth - 1);
286
+ const figcaptions = (0, prosemirror_utils_1.findChildrenByType)(boxElementNode, transform_1.schema.nodes.figcaption);
287
+ const hasLabel = figcaptions.length > 0;
288
+ menu.insertBefore(this.createMenuItem(hasLabel ? 'Hide Label' : 'Show Label', () => {
289
+ if (hasLabel) {
290
+ const figcaptionNode = figcaptions[0].node;
291
+ const figcaptionPos = boxStartPos + figcaptions[0].pos;
292
+ tr.delete(figcaptionPos, figcaptionPos + figcaptionNode.nodeSize);
293
+ }
294
+ else {
295
+ const newFigcaption = transform_1.schema.nodes.figcaption.create({}, [
296
+ transform_1.schema.nodes.caption_title.create(),
297
+ ]);
298
+ tr.insert(boxStartPos, newFigcaption);
299
+ }
300
+ this.view.dispatch(tr);
301
+ popper.destroy();
302
+ }), menu.firstChild);
303
+ }
282
304
  popper.show(target, menu, 'right', true);
283
305
  this.addPopperEventListeners();
284
306
  };
@@ -31,7 +31,14 @@ const useEditor = (externalProps) => {
31
31
  const [state, setState] = (0, react_1.useState)(() => (0, ManuscriptsEditor_1.createEditorState)(props));
32
32
  const location = (0, react_router_dom_1.useLocation)();
33
33
  const { collabProvider } = props;
34
- if (collabProvider) {
34
+ (0, react_1.useEffect)(() => {
35
+ if (view.current && props.isComparingMode) {
36
+ const newState = (0, ManuscriptsEditor_1.createEditorState)(props);
37
+ setState(newState);
38
+ view.current.updateState(newState);
39
+ }
40
+ }, [props.doc, props.isComparingMode]);
41
+ if (collabProvider && !props.isComparingMode) {
35
42
  collabProvider.onNewSteps(async () => {
36
43
  if (state && view.current) {
37
44
  const localVersion = (0, prosemirror_collab_1.getVersion)(view.current.state);
@@ -57,7 +64,9 @@ const useEditor = (externalProps) => {
57
64
  view.current.updateState(nextState);
58
65
  const trackState = track_changes_plugin_1.trackChangesPluginKey.getState(view.current.state);
59
66
  if (collabProvider &&
60
- (!trackState || trackState.status !== track_changes_plugin_1.TrackChangesStatus.viewSnapshots)) {
67
+ (!trackState ||
68
+ trackState.status !== track_changes_plugin_1.TrackChangesStatus.viewSnapshots) &&
69
+ !props.isComparingMode) {
61
70
  const sendable = (0, prosemirror_collab_1.sendableSteps)(nextState);
62
71
  if (sendable) {
63
72
  collabProvider.sendSteps(sendable.version, sendable.steps, sendable.clientID, false);
@@ -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.2.5';
4
+ exports.VERSION = '3.2.7';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -134,10 +134,9 @@ class ContributorsView extends block_view_1.default {
134
134
  action: () => this.handleEdit(''),
135
135
  icon: 'Edit',
136
136
  });
137
- this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
138
- return this.contextMenu;
139
137
  }
140
- return undefined;
138
+ this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
139
+ return this.contextMenu;
141
140
  };
142
141
  this.actionGutterButtons = () => {
143
142
  const contextMenu = this.authorContextMenu();
@@ -53,7 +53,7 @@ export default (props) => {
53
53
  trackChangesPlugin({
54
54
  userID: props.userID,
55
55
  debug: props.debug,
56
- initialStatus: props.isViewingMode
56
+ initialStatus: props.isViewingMode || props.isComparingMode
57
57
  ? TrackChangesStatus.viewSnapshots
58
58
  : props.getCapabilities().editWithoutTracking
59
59
  ? TrackChangesStatus.disabled
@@ -275,6 +275,28 @@ export class ContextMenu {
275
275
  }));
276
276
  }));
277
277
  }
278
+ if (type === schema.nodes.box_element) {
279
+ const tr = this.view.state.tr;
280
+ const boxElementNode = $pos.node($pos.depth - 1);
281
+ const boxStartPos = $pos.start($pos.depth - 1);
282
+ const figcaptions = findChildrenByType(boxElementNode, schema.nodes.figcaption);
283
+ const hasLabel = figcaptions.length > 0;
284
+ menu.insertBefore(this.createMenuItem(hasLabel ? 'Hide Label' : 'Show Label', () => {
285
+ if (hasLabel) {
286
+ const figcaptionNode = figcaptions[0].node;
287
+ const figcaptionPos = boxStartPos + figcaptions[0].pos;
288
+ tr.delete(figcaptionPos, figcaptionPos + figcaptionNode.nodeSize);
289
+ }
290
+ else {
291
+ const newFigcaption = schema.nodes.figcaption.create({}, [
292
+ schema.nodes.caption_title.create(),
293
+ ]);
294
+ tr.insert(boxStartPos, newFigcaption);
295
+ }
296
+ this.view.dispatch(tr);
297
+ popper.destroy();
298
+ }), menu.firstChild);
299
+ }
278
300
  popper.show(target, menu, 'right', true);
279
301
  this.addPopperEventListeners();
280
302
  };
@@ -28,7 +28,14 @@ export const useEditor = (externalProps) => {
28
28
  const [state, setState] = useState(() => createEditorState(props));
29
29
  const location = useLocation();
30
30
  const { collabProvider } = props;
31
- if (collabProvider) {
31
+ useEffect(() => {
32
+ if (view.current && props.isComparingMode) {
33
+ const newState = createEditorState(props);
34
+ setState(newState);
35
+ view.current.updateState(newState);
36
+ }
37
+ }, [props.doc, props.isComparingMode]);
38
+ if (collabProvider && !props.isComparingMode) {
32
39
  collabProvider.onNewSteps(async () => {
33
40
  if (state && view.current) {
34
41
  const localVersion = getVersion(view.current.state);
@@ -54,7 +61,9 @@ export const useEditor = (externalProps) => {
54
61
  view.current.updateState(nextState);
55
62
  const trackState = trackChangesPluginKey.getState(view.current.state);
56
63
  if (collabProvider &&
57
- (!trackState || trackState.status !== TrackChangesStatus.viewSnapshots)) {
64
+ (!trackState ||
65
+ trackState.status !== TrackChangesStatus.viewSnapshots) &&
66
+ !props.isComparingMode) {
58
67
  const sendable = sendableSteps(nextState);
59
68
  if (sendable) {
60
69
  collabProvider.sendSteps(sendable.version, sendable.steps, sendable.clientID, false);
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.2.5';
1
+ export const VERSION = '3.2.7';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -128,10 +128,9 @@ export class ContributorsView extends BlockView {
128
128
  action: () => this.handleEdit(''),
129
129
  icon: 'Edit',
130
130
  });
131
- this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
132
- return this.contextMenu;
133
131
  }
134
- return undefined;
132
+ this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
133
+ return this.contextMenu;
135
134
  };
136
135
  this.actionGutterButtons = () => {
137
136
  const contextMenu = this.authorContextMenu();
@@ -49,6 +49,7 @@ export interface EditorProps {
49
49
  collabProvider?: CollabProvider;
50
50
  navigate: NavigateFunction;
51
51
  location: Location;
52
+ isComparingMode?: boolean;
52
53
  dispatch?: Dispatch;
53
54
  onEditorClick: (pos: number, node: ManuscriptNode, nodePos: number, event: MouseEvent) => void;
54
55
  lockBody: boolean;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.2.5";
1
+ export declare const VERSION = "3.2.7";
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.2.5",
4
+ "version": "3.2.7",
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.1.0",
42
42
  "@manuscripts/track-changes-plugin": "2.0.1",
43
- "@manuscripts/transform": "4.2.0",
43
+ "@manuscripts/transform": "4.2.1",
44
44
  "@popperjs/core": "2.11.8",
45
45
  "citeproc": "2.4.63",
46
46
  "codemirror": "5.65.19",
@@ -1053,6 +1053,19 @@ figure.block:has(.equation.selected-suggestion) {
1053
1053
  border-color: var(--updated-border-color);
1054
1054
  }
1055
1055
 
1056
+ /* Needed for the snapshot comparison */
1057
+ .tracking-visible .block-list [data-track-op="insert"][data-track-status="pending"] {
1058
+ background: var(--inserted-pending-bg-color);
1059
+ color: var(--inserted-pending-color);
1060
+ text-decoration: underline;
1061
+ }
1062
+ /* Needed for the snapshot comparison */
1063
+ .tracking-visible .block-list [data-track-op="delete"][data-track-status="pending"] {
1064
+ background: var(--deleted-pending-bg-color);
1065
+ color: var(--deleted-color);
1066
+ text-decoration: line-through;
1067
+ }
1068
+
1056
1069
  .selected-suggestion.contributor,
1057
1070
  .selected-suggestion.affiliation {
1058
1071
  text-decoration: none !important;