@manuscripts/body-editor 2.6.36 → 2.6.37

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.
package/dist/cjs/index.js CHANGED
@@ -52,6 +52,7 @@ __exportStar(require("./lib/doc"), exports);
52
52
  __exportStar(require("./plugins/comments"), exports);
53
53
  var selected_suggestion_1 = require("./plugins/selected-suggestion");
54
54
  Object.defineProperty(exports, "selectedSuggestionKey", { enumerable: true, get: function () { return selected_suggestion_1.selectedSuggestionKey; } });
55
+ __exportStar(require("./selection"), exports);
55
56
  __exportStar(require("./lib/utils"), exports);
56
57
  __exportStar(require("./lib/track-changes-utils"), exports);
57
58
  __exportStar(require("./useEditor"), exports);
@@ -6,6 +6,7 @@ const transform_1 = require("@manuscripts/transform");
6
6
  const prosemirror_state_1 = require("prosemirror-state");
7
7
  const prosemirror_view_1 = require("prosemirror-view");
8
8
  const commands_1 = require("../commands");
9
+ const selection_1 = require("../selection");
9
10
  exports.selectedSuggestionKey = new prosemirror_state_1.PluginKey('selected-suggestion');
10
11
  const EMPTY = {
11
12
  decorations: prosemirror_view_1.DecorationSet.empty,
@@ -27,6 +28,10 @@ exports.default = () => {
27
28
  };
28
29
  const buildPluginState = (state) => {
29
30
  const selection = state.selection;
31
+ const changes = (0, selection_1.getSelectionChangeGroup)(state);
32
+ if (changes) {
33
+ return buildGroupOfChangesDecoration(state.doc, changes);
34
+ }
30
35
  const $pos = (0, commands_1.isTextSelection)(selection) ? selection.$cursor : selection.$to;
31
36
  if (!$pos) {
32
37
  return EMPTY;
@@ -112,6 +117,16 @@ const buildTextDecoration = (doc, selection) => {
112
117
  decorations: prosemirror_view_1.DecorationSet.create(doc, [decoration]),
113
118
  };
114
119
  };
120
+ const buildGroupOfChangesDecoration = (doc, changes) => {
121
+ const from = changes[0].from, to = changes[changes.length - 1].to;
122
+ const decoration = prosemirror_view_1.Decoration.inline(from, to, {
123
+ class: 'selected-suggestion',
124
+ });
125
+ return {
126
+ decorations: prosemirror_view_1.DecorationSet.create(doc, [decoration]),
127
+ suggestion: changes[0].dataTracked,
128
+ };
129
+ };
115
130
  const trackedMarkTypes = new Set([
116
131
  transform_1.schema.marks.tracked_insert,
117
132
  transform_1.schema.marks.tracked_delete,
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSelectionChangeGroup = exports.NodesSelection = void 0;
4
+ const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
5
+ const prosemirror_state_1 = require("prosemirror-state");
6
+ const commands_1 = require("./commands");
7
+ class NodesSelection extends prosemirror_state_1.Selection {
8
+ constructor($from, $to) {
9
+ super($to, $to);
10
+ this.$startNode = $from;
11
+ this.$endNode = $to;
12
+ }
13
+ eq(selection) {
14
+ return (selection instanceof NodesSelection &&
15
+ selection.$startNode.pos == this.$startNode.pos &&
16
+ selection.$endNode.pos == this.$endNode.pos);
17
+ }
18
+ map(doc, mapping) {
19
+ const $from = doc.resolve(mapping.map(this.$startNode.pos));
20
+ const $to = doc.resolve(mapping.map(this.$endNode.pos));
21
+ return new NodesSelection($from, $to);
22
+ }
23
+ toJSON() {
24
+ return {
25
+ type: 'inlineNodes',
26
+ startNode: this.$startNode,
27
+ endNode: this.$endNode,
28
+ };
29
+ }
30
+ }
31
+ exports.NodesSelection = NodesSelection;
32
+ const getSelectionChangeGroup = (state) => {
33
+ var _a;
34
+ const selection = state.selection;
35
+ const $pos = (0, commands_1.isTextSelection)(selection)
36
+ ? selection.$cursor
37
+ : selection instanceof NodesSelection && selection.$from;
38
+ if ($pos) {
39
+ return (_a = track_changes_plugin_1.trackChangesPluginKey
40
+ .getState(state)) === null || _a === void 0 ? void 0 : _a.changeSet.groupChanges.find((changes) => changes.length > 1 &&
41
+ $pos.pos >= changes[0].from &&
42
+ $pos.pos <= changes[changes.length - 1].to);
43
+ }
44
+ };
45
+ exports.getSelectionChangeGroup = getSelectionChangeGroup;
@@ -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 = '2.6.36';
4
+ exports.VERSION = '2.6.37';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
package/dist/es/index.js CHANGED
@@ -29,6 +29,7 @@ export * from './lib/footnotes';
29
29
  export * from './lib/doc';
30
30
  export * from './plugins/comments';
31
31
  export { selectedSuggestionKey } from './plugins/selected-suggestion';
32
+ export * from './selection';
32
33
  export * from './lib/utils';
33
34
  export * from './lib/track-changes-utils';
34
35
  export * from './useEditor';
@@ -1,8 +1,9 @@
1
- import { CHANGE_STATUS } from '@manuscripts/track-changes-plugin';
1
+ import { CHANGE_STATUS, } from '@manuscripts/track-changes-plugin';
2
2
  import { schema, } from '@manuscripts/transform';
3
3
  import { Plugin, PluginKey } from 'prosemirror-state';
4
4
  import { Decoration, DecorationSet } from 'prosemirror-view';
5
5
  import { isTextSelection } from '../commands';
6
+ import { getSelectionChangeGroup } from '../selection';
6
7
  export const selectedSuggestionKey = new PluginKey('selected-suggestion');
7
8
  const EMPTY = {
8
9
  decorations: DecorationSet.empty,
@@ -24,6 +25,10 @@ export default () => {
24
25
  };
25
26
  const buildPluginState = (state) => {
26
27
  const selection = state.selection;
28
+ const changes = getSelectionChangeGroup(state);
29
+ if (changes) {
30
+ return buildGroupOfChangesDecoration(state.doc, changes);
31
+ }
27
32
  const $pos = isTextSelection(selection) ? selection.$cursor : selection.$to;
28
33
  if (!$pos) {
29
34
  return EMPTY;
@@ -109,6 +114,16 @@ const buildTextDecoration = (doc, selection) => {
109
114
  decorations: DecorationSet.create(doc, [decoration]),
110
115
  };
111
116
  };
117
+ const buildGroupOfChangesDecoration = (doc, changes) => {
118
+ const from = changes[0].from, to = changes[changes.length - 1].to;
119
+ const decoration = Decoration.inline(from, to, {
120
+ class: 'selected-suggestion',
121
+ });
122
+ return {
123
+ decorations: DecorationSet.create(doc, [decoration]),
124
+ suggestion: changes[0].dataTracked,
125
+ };
126
+ };
112
127
  const trackedMarkTypes = new Set([
113
128
  schema.marks.tracked_insert,
114
129
  schema.marks.tracked_delete,
@@ -0,0 +1,40 @@
1
+ import { trackChangesPluginKey } from '@manuscripts/track-changes-plugin';
2
+ import { Selection } from 'prosemirror-state';
3
+ import { isTextSelection } from './commands';
4
+ export class NodesSelection extends Selection {
5
+ constructor($from, $to) {
6
+ super($to, $to);
7
+ this.$startNode = $from;
8
+ this.$endNode = $to;
9
+ }
10
+ eq(selection) {
11
+ return (selection instanceof NodesSelection &&
12
+ selection.$startNode.pos == this.$startNode.pos &&
13
+ selection.$endNode.pos == this.$endNode.pos);
14
+ }
15
+ map(doc, mapping) {
16
+ const $from = doc.resolve(mapping.map(this.$startNode.pos));
17
+ const $to = doc.resolve(mapping.map(this.$endNode.pos));
18
+ return new NodesSelection($from, $to);
19
+ }
20
+ toJSON() {
21
+ return {
22
+ type: 'inlineNodes',
23
+ startNode: this.$startNode,
24
+ endNode: this.$endNode,
25
+ };
26
+ }
27
+ }
28
+ export const getSelectionChangeGroup = (state) => {
29
+ var _a;
30
+ const selection = state.selection;
31
+ const $pos = isTextSelection(selection)
32
+ ? selection.$cursor
33
+ : selection instanceof NodesSelection && selection.$from;
34
+ if ($pos) {
35
+ return (_a = trackChangesPluginKey
36
+ .getState(state)) === null || _a === void 0 ? void 0 : _a.changeSet.groupChanges.find((changes) => changes.length > 1 &&
37
+ $pos.pos >= changes[0].from &&
38
+ $pos.pos <= changes[changes.length - 1].to);
39
+ }
40
+ };
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.6.36';
1
+ export const VERSION = '2.6.37';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -30,6 +30,7 @@ export * from './lib/footnotes';
30
30
  export * from './lib/doc';
31
31
  export * from './plugins/comments';
32
32
  export { selectedSuggestionKey } from './plugins/selected-suggestion';
33
+ export * from './selection';
33
34
  export * from './lib/utils';
34
35
  export * from './lib/track-changes-utils';
35
36
  export * from './useEditor';
@@ -0,0 +1,13 @@
1
+ import { ManuscriptEditorState } from '@manuscripts/transform';
2
+ import { Node, ResolvedPos } from 'prosemirror-model';
3
+ import { Selection } from 'prosemirror-state';
4
+ import { Mappable } from 'prosemirror-transform';
5
+ export declare class NodesSelection extends Selection {
6
+ $startNode: ResolvedPos;
7
+ $endNode: ResolvedPos;
8
+ constructor($from: ResolvedPos, $to: ResolvedPos);
9
+ eq(selection: Selection): boolean;
10
+ map(doc: Node, mapping: Mappable): Selection;
11
+ toJSON(): any;
12
+ }
13
+ export declare const getSelectionChangeGroup: (state: ManuscriptEditorState) => import("@manuscripts/track-changes-plugin").TrackedChange[] | undefined;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.6.36";
1
+ export declare const VERSION = "2.6.37";
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": "2.6.36",
4
+ "version": "2.6.37",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -33,7 +33,7 @@
33
33
  "@manuscripts/json-schema": "2.2.11",
34
34
  "@manuscripts/library": "1.3.11",
35
35
  "@manuscripts/style-guide": "2.0.27",
36
- "@manuscripts/track-changes-plugin": "1.8.5",
36
+ "@manuscripts/track-changes-plugin": "1.8.6",
37
37
  "@manuscripts/transform": "3.0.27",
38
38
  "@popperjs/core": "^2.11.8",
39
39
  "astrocite-eutils": "^0.16.4",
@@ -555,7 +555,6 @@ span.comment-marker {
555
555
  .keywords
556
556
  ):not(figure):not(figure .equation) {
557
557
  border-width: 2px 0 2px 0 !important;
558
- border-radius: 3px !important;
559
558
  border-style: solid !important;
560
559
  }
561
560
 
package/styles/Editor.css CHANGED
@@ -171,7 +171,6 @@
171
171
  .ProseMirror .cross-reference {
172
172
  font-weight: bold;
173
173
  background-color: #ddf3fa;
174
- border-radius: 5px;
175
174
  color: #353535;
176
175
  padding: 0 2px;
177
176
  cursor: pointer;
@@ -715,7 +714,7 @@
715
714
  .ProseMirror p .equation {
716
715
  display: inline;
717
716
  vertical-align: baseline;
718
- margin: 0 5px;
717
+ padding: 0 5px;
719
718
  }
720
719
 
721
720
  .ProseMirror figcaption .equation-placeholder,
@@ -987,7 +986,7 @@
987
986
  position: absolute;
988
987
  background: #E2E2E2;
989
988
  pointer-events: none;
990
- }
989
+ }
991
990
  .ProseMirror .block-container:not(.block-footnotes_element) .footnote-marker::before {
992
991
  left: 0;
993
992
  }