@manuscripts/body-editor 2.5.6 → 2.5.8
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/commands.js +6 -6
- package/dist/cjs/lib/comments.js +5 -1
- package/dist/cjs/plugins/comments.js +10 -8
- package/dist/cjs/versions.js +1 -1
- package/dist/es/commands.js +6 -6
- package/dist/es/lib/comments.js +3 -0
- package/dist/es/plugins/comments.js +11 -9
- package/dist/es/versions.js +1 -1
- package/dist/types/lib/comments.d.ts +1 -0
- package/dist/types/versions.d.ts +1 -1
- package/package.json +3 -3
package/dist/cjs/commands.js
CHANGED
|
@@ -983,6 +983,11 @@ const addInlineComment = (state, dispatch) => {
|
|
|
983
983
|
}
|
|
984
984
|
let from = selection.from;
|
|
985
985
|
let to = selection.to;
|
|
986
|
+
if (from === to) {
|
|
987
|
+
const result = (0, helpers_1.findWordBoundaries)(state, from);
|
|
988
|
+
from = result.from;
|
|
989
|
+
to = result.to;
|
|
990
|
+
}
|
|
986
991
|
const props = (0, editor_props_1.getEditorProps)(state);
|
|
987
992
|
const contribution = (0, json_schema_1.buildContribution)(props.userID);
|
|
988
993
|
const attrs = {
|
|
@@ -990,7 +995,7 @@ const addInlineComment = (state, dispatch) => {
|
|
|
990
995
|
contents: '',
|
|
991
996
|
target: node.attrs.id,
|
|
992
997
|
contributions: [contribution],
|
|
993
|
-
originalText: selectedText(),
|
|
998
|
+
originalText: selectedText() || state.doc.textBetween(from, to),
|
|
994
999
|
selector: {
|
|
995
1000
|
from,
|
|
996
1001
|
to,
|
|
@@ -1001,11 +1006,6 @@ const addInlineComment = (state, dispatch) => {
|
|
|
1001
1006
|
if (comments) {
|
|
1002
1007
|
const pos = comments.pos + 1;
|
|
1003
1008
|
const tr = state.tr.insert(pos, comment);
|
|
1004
|
-
if (from === to) {
|
|
1005
|
-
const result = (0, helpers_1.findWordBoundaries)(state, from);
|
|
1006
|
-
from = result.from;
|
|
1007
|
-
to = result.to;
|
|
1008
|
-
}
|
|
1009
1009
|
const start = transform_1.schema.nodes.highlight_marker.create({
|
|
1010
1010
|
id: comment.attrs.id,
|
|
1011
1011
|
tid: node.attrs.id,
|
package/dist/cjs/lib/comments.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCommentMarker = exports.getCommentRange = exports.getCommentKey = exports.isNodeComment = void 0;
|
|
3
|
+
exports.createCommentMarker = exports.getCommentRange = exports.getCommentKey = exports.isReply = exports.isNodeComment = void 0;
|
|
4
4
|
const isNodeComment = (c) => !c.range;
|
|
5
5
|
exports.isNodeComment = isNodeComment;
|
|
6
|
+
const isReply = (comment) => {
|
|
7
|
+
return comment.node.attrs.target.includes('MPCommentAnnotation');
|
|
8
|
+
};
|
|
9
|
+
exports.isReply = isReply;
|
|
6
10
|
const getCommentKey = (comment, range, target) => {
|
|
7
11
|
if (!range) {
|
|
8
12
|
return target.attrs.id;
|
|
@@ -133,14 +133,16 @@ const buildPluginState = (doc, selection) => {
|
|
|
133
133
|
})
|
|
134
134
|
.forEach((c) => {
|
|
135
135
|
allComments.push(c);
|
|
136
|
-
if (!
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
136
|
+
if (!(0, comments_1.isReply)(c)) {
|
|
137
|
+
if (!c.range) {
|
|
138
|
+
nodeComments.push(c);
|
|
139
|
+
}
|
|
140
|
+
else if (c.range.size) {
|
|
141
|
+
highlightComments.push(c);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
pointComments.push(c);
|
|
145
|
+
}
|
|
144
146
|
}
|
|
145
147
|
});
|
|
146
148
|
for (const comment of highlightComments) {
|
package/dist/cjs/versions.js
CHANGED
package/dist/es/commands.js
CHANGED
|
@@ -937,6 +937,11 @@ export const addInlineComment = (state, dispatch) => {
|
|
|
937
937
|
}
|
|
938
938
|
let from = selection.from;
|
|
939
939
|
let to = selection.to;
|
|
940
|
+
if (from === to) {
|
|
941
|
+
const result = findWordBoundaries(state, from);
|
|
942
|
+
from = result.from;
|
|
943
|
+
to = result.to;
|
|
944
|
+
}
|
|
940
945
|
const props = getEditorProps(state);
|
|
941
946
|
const contribution = buildContribution(props.userID);
|
|
942
947
|
const attrs = {
|
|
@@ -944,7 +949,7 @@ export const addInlineComment = (state, dispatch) => {
|
|
|
944
949
|
contents: '',
|
|
945
950
|
target: node.attrs.id,
|
|
946
951
|
contributions: [contribution],
|
|
947
|
-
originalText: selectedText(),
|
|
952
|
+
originalText: selectedText() || state.doc.textBetween(from, to),
|
|
948
953
|
selector: {
|
|
949
954
|
from,
|
|
950
955
|
to,
|
|
@@ -955,11 +960,6 @@ export const addInlineComment = (state, dispatch) => {
|
|
|
955
960
|
if (comments) {
|
|
956
961
|
const pos = comments.pos + 1;
|
|
957
962
|
const tr = state.tr.insert(pos, comment);
|
|
958
|
-
if (from === to) {
|
|
959
|
-
const result = findWordBoundaries(state, from);
|
|
960
|
-
from = result.from;
|
|
961
|
-
to = result.to;
|
|
962
|
-
}
|
|
963
963
|
const start = schema.nodes.highlight_marker.create({
|
|
964
964
|
id: comment.attrs.id,
|
|
965
965
|
tid: node.attrs.id,
|
package/dist/es/lib/comments.js
CHANGED
|
@@ -2,7 +2,7 @@ import { schema, } from '@manuscripts/transform';
|
|
|
2
2
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
3
3
|
import { findChildrenByType } from 'prosemirror-utils';
|
|
4
4
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
5
|
-
import { createCommentMarker, getCommentKey, } from '../lib/comments';
|
|
5
|
+
import { createCommentMarker, getCommentKey, isReply, } from '../lib/comments';
|
|
6
6
|
export const commentsKey = new PluginKey('comments');
|
|
7
7
|
const COMMENT_SELECTION = 'comment-selection';
|
|
8
8
|
const EMPTY_SELECTION = {};
|
|
@@ -128,14 +128,16 @@ const buildPluginState = (doc, selection) => {
|
|
|
128
128
|
})
|
|
129
129
|
.forEach((c) => {
|
|
130
130
|
allComments.push(c);
|
|
131
|
-
if (!c
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
131
|
+
if (!isReply(c)) {
|
|
132
|
+
if (!c.range) {
|
|
133
|
+
nodeComments.push(c);
|
|
134
|
+
}
|
|
135
|
+
else if (c.range.size) {
|
|
136
|
+
highlightComments.push(c);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
pointComments.push(c);
|
|
140
|
+
}
|
|
139
141
|
}
|
|
140
142
|
});
|
|
141
143
|
for (const comment of highlightComments) {
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '2.5.
|
|
1
|
+
export const VERSION = '2.5.8';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
|
@@ -27,6 +27,7 @@ export type CommentSelection = {
|
|
|
27
27
|
isNew: boolean;
|
|
28
28
|
};
|
|
29
29
|
export declare const isNodeComment: (c: any) => c is NodeComment;
|
|
30
|
+
export declare const isReply: (comment: Comment) => boolean;
|
|
30
31
|
export declare const getCommentKey: (comment: CommentAttrs, range: CommentRange | undefined, target: ManuscriptNode) => CommentKey;
|
|
31
32
|
export declare const getCommentRange: (comment: CommentAttrs) => {
|
|
32
33
|
pos: number;
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.5.
|
|
1
|
+
export declare const VERSION = "2.5.8";
|
|
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.5.
|
|
4
|
+
"version": "2.5.8",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@manuscripts/library": "1.3.11",
|
|
35
35
|
"@manuscripts/style-guide": "2.0.22",
|
|
36
36
|
"@manuscripts/track-changes-plugin": "1.8.1",
|
|
37
|
-
"@manuscripts/transform": "3.0.
|
|
37
|
+
"@manuscripts/transform": "3.0.11",
|
|
38
38
|
"@popperjs/core": "^2.11.8",
|
|
39
39
|
"astrocite-eutils": "^0.16.4",
|
|
40
40
|
"codemirror": "^5.58.1",
|
|
@@ -116,4 +116,4 @@
|
|
|
116
116
|
"engines": {
|
|
117
117
|
"node": ">=20.16.0"
|
|
118
118
|
}
|
|
119
|
-
}
|
|
119
|
+
}
|