@manuscripts/article-editor 3.3.1 → 3.3.2-LEAN-3958.1
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/components/track-changes/suggestion-list/SnippetContent.js +72 -0
- package/dist/cjs/components/track-changes/suggestion-list/SnippetContent.js.map +1 -0
- package/dist/cjs/components/track-changes/suggestion-list/Suggestion.js +3 -3
- package/dist/cjs/components/track-changes/suggestion-list/Suggestion.js.map +1 -1
- package/dist/cjs/components/track-changes/suggestion-list/SuggestionSnippet.js +26 -118
- package/dist/cjs/components/track-changes/suggestion-list/SuggestionSnippet.js.map +1 -1
- package/dist/cjs/lib/change-handlers.js +123 -0
- package/dist/cjs/lib/change-handlers.js.map +1 -0
- package/dist/cjs/lib/fonts.js +3 -0
- package/dist/cjs/lib/fonts.js.map +1 -1
- package/dist/cjs/lib/node-content-retriever.js +130 -0
- package/dist/cjs/lib/node-content-retriever.js.map +1 -0
- package/dist/cjs/lib/tracking.js +3 -0
- package/dist/cjs/lib/tracking.js.map +1 -1
- package/dist/cjs/lib/utils.js +11 -28
- package/dist/cjs/lib/utils.js.map +1 -1
- package/dist/es/components/track-changes/suggestion-list/SnippetContent.js +44 -0
- package/dist/es/components/track-changes/suggestion-list/SnippetContent.js.map +1 -0
- package/dist/es/components/track-changes/suggestion-list/Suggestion.js +3 -3
- package/dist/es/components/track-changes/suggestion-list/Suggestion.js.map +1 -1
- package/dist/es/components/track-changes/suggestion-list/SuggestionSnippet.js +27 -119
- package/dist/es/components/track-changes/suggestion-list/SuggestionSnippet.js.map +1 -1
- package/dist/es/lib/change-handlers.js +117 -0
- package/dist/es/lib/change-handlers.js.map +1 -0
- package/dist/es/lib/fonts.js +3 -0
- package/dist/es/lib/fonts.js.map +1 -1
- package/dist/es/lib/node-content-retriever.js +123 -0
- package/dist/es/lib/node-content-retriever.js.map +1 -0
- package/dist/es/lib/tracking.js +3 -0
- package/dist/es/lib/tracking.js.map +1 -1
- package/dist/es/lib/utils.js +10 -25
- package/dist/es/lib/utils.js.map +1 -1
- package/dist/types/{lib/footnotes.d.ts → components/track-changes/suggestion-list/SnippetContent.d.ts} +8 -5
- package/dist/types/lib/change-handlers.d.ts +22 -0
- package/dist/types/lib/fonts.d.ts +3 -0
- package/dist/types/lib/node-content-retriever.d.ts +37 -0
- package/dist/types/lib/utils.d.ts +1 -8
- package/package.json +3 -3
- package/dist/cjs/lib/footnotes.js +0 -49
- package/dist/cjs/lib/footnotes.js.map +0 -1
- package/dist/es/lib/footnotes.js +0 -43
- package/dist/es/lib/footnotes.js.map +0 -1
package/dist/cjs/lib/utils.js
CHANGED
@@ -1,37 +1,20 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.decodeHTMLEntities = exports.getParentNode =
|
4
|
-
const getNodeTextContent = (node) => {
|
5
|
-
let textContent = '';
|
6
|
-
// Traverse the node and its descendants
|
7
|
-
node.forEach((child) => {
|
8
|
-
if (child.isText) {
|
9
|
-
// If the child is a text node, add its text content
|
10
|
-
textContent += child.text;
|
11
|
-
}
|
12
|
-
else {
|
13
|
-
// If the child is not a text node, recursively collect text content
|
14
|
-
textContent += (0, exports.getNodeTextContent)(child);
|
15
|
-
}
|
16
|
-
});
|
17
|
-
return textContent;
|
18
|
-
};
|
19
|
-
exports.getNodeTextContent = getNodeTextContent;
|
20
|
-
const findPluginByKey = (state, keyName) => {
|
21
|
-
for (let i = 0; i < state.plugins.length; i++) {
|
22
|
-
const plugin = state.plugins[i];
|
23
|
-
if (plugin.key === keyName + '$') {
|
24
|
-
return plugin;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
return null;
|
28
|
-
};
|
29
|
-
exports.findPluginByKey = findPluginByKey;
|
3
|
+
exports.decodeHTMLEntities = exports.getParentNode = void 0;
|
30
4
|
const getParentNode = (state, pos) => {
|
31
5
|
const resolvedPos = state.doc.resolve(pos);
|
32
6
|
for (let depth = resolvedPos.depth; depth > 0; depth--) {
|
33
7
|
const parent = resolvedPos.node(depth);
|
34
|
-
if (parent.
|
8
|
+
if (parent.isText === false) {
|
9
|
+
if (parent.type == state.schema.nodes.paragraph) {
|
10
|
+
const grandParent = resolvedPos.node(depth - 1);
|
11
|
+
if (grandParent.type == state.schema.nodes.footnote) {
|
12
|
+
return grandParent;
|
13
|
+
}
|
14
|
+
else {
|
15
|
+
return parent;
|
16
|
+
}
|
17
|
+
}
|
35
18
|
return parent;
|
36
19
|
}
|
37
20
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":";;;AAaO,MAAM,aAAa,GAAG,CAAC,KAAkB,EAAE,GAAW,EAAE,EAAE;IAC/D,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAE1C,KAAK,IAAI,KAAK,GAAG,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE;QACtD,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACtC,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,EAAE;YAC3B,IAAI,MAAM,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE;gBAC/C,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;gBAC/C,IAAI,WAAW,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE;oBACnD,OAAO,WAAW,CAAA;iBACnB;qBAAM;oBACL,OAAO,MAAM,CAAA;iBACd;aACF;YACD,OAAO,MAAM,CAAA;SACd;KACF;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAnBY,QAAA,aAAa,iBAmBzB;AAEM,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAE;IACjD,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IACxC,EAAE,CAAC,SAAS,GAAG,IAAI,CAAA;IACnB,OAAO,EAAE,CAAC,SAAS,CAAA;AACrB,CAAC,CAAA;AAJY,QAAA,kBAAkB,sBAI9B"}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/*!
|
2
|
+
* The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
|
3
|
+
*
|
4
|
+
* Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
|
5
|
+
*
|
6
|
+
* The Original Code is manuscripts-frontend.
|
7
|
+
*
|
8
|
+
* The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
|
9
|
+
*
|
10
|
+
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
|
11
|
+
*/
|
12
|
+
import { renderMath } from '@manuscripts/body-editor';
|
13
|
+
import purify from 'dompurify';
|
14
|
+
import React, { useEffect, useRef } from 'react';
|
15
|
+
import styled from 'styled-components';
|
16
|
+
const SnippetContent = ({ content, isEquation }) => {
|
17
|
+
const contentRef = useRef(null);
|
18
|
+
useEffect(() => {
|
19
|
+
if (contentRef.current && content) {
|
20
|
+
contentRef.current.innerHTML = purify.sanitize(': ' + content) || '';
|
21
|
+
if (isEquation) {
|
22
|
+
renderMath(contentRef.current);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}, [content, isEquation]);
|
26
|
+
return React.createElement(StyledContent, { ref: contentRef, "data-mathjax": isEquation });
|
27
|
+
};
|
28
|
+
export default SnippetContent;
|
29
|
+
const StyledContent = styled.span `
|
30
|
+
color: #353535;
|
31
|
+
font-family: Lato, sans-serif;
|
32
|
+
font-size: 12px;
|
33
|
+
font-weight: 400;
|
34
|
+
line-height: 16px;
|
35
|
+
|
36
|
+
&[data-mathjax='true'] {
|
37
|
+
text-overflow: unset;
|
38
|
+
}
|
39
|
+
|
40
|
+
.inspector-list-item::after {
|
41
|
+
content: '...';
|
42
|
+
}
|
43
|
+
`;
|
44
|
+
//# sourceMappingURL=SnippetContent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"SnippetContent.js","sourceRoot":"","sources":["../../../../../src/components/track-changes/suggestion-list/SnippetContent.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,MAAM,MAAM,WAAW,CAAA;AAC9B,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAChD,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAOtC,MAAM,cAAc,GAA2B,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE;IACzE,MAAM,UAAU,GAAG,MAAM,CAAkB,IAAI,CAAC,CAAA;IAEhD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,UAAU,CAAC,OAAO,IAAI,OAAO,EAAE;YACjC,UAAU,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAA;YACpE,IAAI,UAAU,EAAE;gBACd,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;aAC/B;SACF;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAA;IAEzB,OAAO,oBAAC,aAAa,IAAC,GAAG,EAAE,UAAU,kBAAgB,UAAU,GAAI,CAAA;AACrE,CAAC,CAAA;AAED,eAAe,cAAc,CAAA;AAE7B,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAA;;;;;;;;;;;;;;CAchC,CAAA"}
|
@@ -51,8 +51,7 @@ const Wrapper = styled.li `
|
|
51
51
|
justify-content: space-between;
|
52
52
|
align-items: center;
|
53
53
|
gap: ${(props) => props.theme.grid.unit * 4}px;
|
54
|
-
padding:
|
55
|
-
${(props) => props.theme.grid.unit * 2}px !important;
|
54
|
+
padding: 6px 8px;
|
56
55
|
min-height: 28px;
|
57
56
|
margin-bottom: 6px;
|
58
57
|
border: ${(props) => props.isFocused
|
@@ -63,7 +62,8 @@ const Wrapper = styled.li `
|
|
63
62
|
: `none`};
|
64
63
|
list-style-type: none;
|
65
64
|
font-size: ${(props) => props.theme.font.size.small};
|
66
|
-
|
65
|
+
border-radius: 4px;
|
66
|
+
max-height: 40px;
|
67
67
|
/* FocusHandle should cover entire card: */
|
68
68
|
position: relative;
|
69
69
|
color: ${(props) => props.theme.colors.text.primary};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Suggestion.js","sourceRoot":"","sources":["../../../../../src/components/track-changes/suggestion-list/Suggestion.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC1D,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,UAAU,MAAM,eAAe,CAAA;AACtC,OAAO,iBAAiB,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,MAAM,cAAc,GAAG,CAAC,OAAoB,EAAE,EAAE;IAC9C,MAAM,IAAI,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAA;IAC5C,IAAI,IAAI,CAAC,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B,UAAU,EAAE,eAAe,GACf,CACf,CACO,CACX,CAAA;AACH,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAA;;CAEzB,CAAA;AAED,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,CAEvB;;;;;SAKO,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC
|
1
|
+
{"version":3,"file":"Suggestion.js","sourceRoot":"","sources":["../../../../../src/components/track-changes/suggestion-list/Suggestion.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC1D,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,UAAU,MAAM,eAAe,CAAA;AACtC,OAAO,iBAAiB,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,MAAM,cAAc,GAAG,CAAC,OAAoB,EAAE,EAAE;IAC9C,MAAM,IAAI,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAA;IAC5C,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,GAAG,GAAG,GAAG,EAAE;QACtD,OAAO,CAAC,cAAc,EAAE,CAAA;KACzB;AACH,CAAC,CAAA;AAUD,MAAM,CAAC,MAAM,UAAU,GAAoB,CAAC,EAC1C,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,UAAU,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAA;IAC9C,MAAM,CAAC,iBAAiB,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAE5D,MAAM,WAAW,GAAG,CAAC,CAAmB,EAAE,EAAE;QAC1C,CAAC,C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AC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE;gBAChD,CAAC,KAAK,EAAE,EAAE,CACtB,KAAK,CAAC,SAAS;IACb,CAAC,CAAC,eAAe,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE;IAC3D,CAAC,CAAC,MAAM;;eAEC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;;;;;WAK1C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;gBACrC,CAAC,KAAK,EAAE,EAAE,CACtB,KAAK,CAAC,SAAS;IACb,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,GAAG,aAAa;IAC9D,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO;;IAEjD,CAAC,KAAK,EAAE,EAAE,CACV,KAAK,CAAC,SAAS;IACb,CAAC,CAAC,GAAG,OAAO;;QAEV;IACF,CAAC,CAAC,EAAE;;;kBAGQ,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK;;MAElE,OAAO;;;;CAIZ,CAAA;AAED,MAAM,WAAW,GAAG,MAAM,CAAC,CAAC,CAAA;;SAEnB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;;;;;;;CAO5C,CAAA"}
|
@@ -9,129 +9,41 @@
|
|
9
9
|
*
|
10
10
|
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
|
11
11
|
*/
|
12
|
-
import {
|
13
|
-
import { schema } from '@manuscripts/transform';
|
14
|
-
import parse from 'html-react-parser';
|
12
|
+
import { ChangeSet } from '@manuscripts/track-changes-plugin';
|
15
13
|
import React, { useEffect, useState } from 'react';
|
16
14
|
import styled from 'styled-components';
|
17
|
-
import {
|
18
|
-
import { changeOperationAlias } from '../../../lib/tracking';
|
19
|
-
import { getParentNode } from '../../../lib/utils';
|
15
|
+
import { handleNodeChange, handleTextChange, handleUnknownChange, } from '../../../lib/change-handlers';
|
20
16
|
import { useStore } from '../../../store';
|
17
|
+
import SnippetContent from './SnippetContent';
|
21
18
|
export const SuggestionSnippet = ({ suggestion, }) => {
|
22
19
|
const [{ doc, view }] = useStore((store) => ({
|
23
20
|
view: store.view,
|
24
21
|
doc: store.doc,
|
25
22
|
}));
|
26
23
|
const [snippet, setSnippet] = useState(null);
|
27
|
-
const [message, setMessage] = useState('');
|
28
24
|
const { dataTracked } = suggestion;
|
29
25
|
useEffect(() => {
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
};
|
42
|
-
}
|
43
|
-
else {
|
44
|
-
return { snippet: null, message: suggestion.text };
|
45
|
-
}
|
46
|
-
}
|
47
|
-
if (ChangeSet.isNodeChange(suggestion) && view) {
|
48
|
-
if (suggestion.node.type === schema.nodes.inline_footnote) {
|
49
|
-
return {
|
50
|
-
snippet: {
|
51
|
-
operation: changeOperationAlias(dataTracked.operation),
|
52
|
-
nodeName: suggestion.node.type.spec.name,
|
53
|
-
content: getInlineFootnoteContent(doc, suggestion.attrs),
|
54
|
-
},
|
55
|
-
message: '',
|
56
|
-
};
|
57
|
-
}
|
58
|
-
else if (suggestion.node.type === schema.nodes.footnote) {
|
59
|
-
return {
|
60
|
-
snippet: {
|
61
|
-
operation: changeOperationAlias(dataTracked.operation),
|
62
|
-
nodeName: suggestion.node.type.name,
|
63
|
-
content: getFootnoteText(view.state, suggestion.node),
|
64
|
-
},
|
65
|
-
message: '',
|
66
|
-
};
|
67
|
-
}
|
68
|
-
else if (suggestion.dataTracked.operation === CHANGE_OPERATION.node_split) {
|
69
|
-
return {
|
70
|
-
snippet: null,
|
71
|
-
message: `Split ${suggestion.node.type.name}`,
|
72
|
-
};
|
73
|
-
}
|
74
|
-
else if (suggestion.dataTracked.operation === CHANGE_OPERATION.wrap_with_node) {
|
75
|
-
return {
|
76
|
-
snippet: null,
|
77
|
-
message: `${suggestion.node.type.name
|
78
|
-
.charAt(0)
|
79
|
-
.toUpperCase()}${suggestion.node.type.name.slice(1)} insert`,
|
80
|
-
};
|
81
|
-
}
|
82
|
-
else {
|
83
|
-
return {
|
84
|
-
snippet: null,
|
85
|
-
message: `${suggestion.node.type.name
|
86
|
-
.charAt(0)
|
87
|
-
.toUpperCase()}${suggestion.node.type.name.slice(1)} ${dataTracked.operation}`,
|
88
|
-
};
|
89
|
-
}
|
90
|
-
}
|
91
|
-
if (ChangeSet.isNodeAttrChange(suggestion) && view) {
|
92
|
-
if (suggestion.node.type === schema.nodes.inline_footnote) {
|
93
|
-
return {
|
94
|
-
snippet: {
|
95
|
-
operation: changeOperationAlias(dataTracked.operation),
|
96
|
-
nodeName: suggestion.node.type.spec.name,
|
97
|
-
content: getInlineFootnoteContent(doc, suggestion.newAttrs),
|
98
|
-
},
|
99
|
-
message: '',
|
100
|
-
};
|
101
|
-
}
|
102
|
-
else if (suggestion.node.type === schema.nodes.footnote) {
|
103
|
-
return {
|
104
|
-
snippet: {
|
105
|
-
operation: changeOperationAlias(dataTracked.operation),
|
106
|
-
nodeName: suggestion.node.type.name,
|
107
|
-
content: getFootnoteText(view.state, suggestion.node),
|
108
|
-
},
|
109
|
-
message: '',
|
110
|
-
};
|
111
|
-
}
|
112
|
-
else {
|
113
|
-
return {
|
114
|
-
snippet: null,
|
115
|
-
message: `${suggestion.node.type.name
|
116
|
-
.charAt(0)
|
117
|
-
.toUpperCase()}${suggestion.node.type.name.slice(1)} ${dataTracked.operation}`,
|
118
|
-
};
|
119
|
-
}
|
120
|
-
}
|
121
|
-
return { snippet: null, message: 'Unknown change!' };
|
122
|
-
};
|
123
|
-
const { snippet: newSnippet, message: newMessage } = getSnippetData();
|
26
|
+
let newSnippet = null;
|
27
|
+
if (ChangeSet.isTextChange(suggestion)) {
|
28
|
+
newSnippet = handleTextChange(suggestion, view, dataTracked);
|
29
|
+
}
|
30
|
+
else if (ChangeSet.isNodeChange(suggestion) ||
|
31
|
+
ChangeSet.isNodeAttrChange(suggestion)) {
|
32
|
+
newSnippet = handleNodeChange(suggestion, view, doc, dataTracked);
|
33
|
+
}
|
34
|
+
else {
|
35
|
+
newSnippet = handleUnknownChange();
|
36
|
+
}
|
124
37
|
setSnippet(newSnippet);
|
125
|
-
|
126
|
-
}, [suggestion, doc
|
127
|
-
return (React.createElement(SnippetText,
|
128
|
-
React.createElement(
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
snippet
|
133
|
-
|
134
|
-
React.createElement(Content, null, parse(snippet.content)))) : dataTracked.operation === CHANGE_OPERATION.delete ? (React.createElement("del", null, message)) : (message)));
|
38
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
39
|
+
}, [suggestion, doc]);
|
40
|
+
return (React.createElement(SnippetText, { "data-mathjax": snippet?.isEquation },
|
41
|
+
React.createElement(React.Fragment, null,
|
42
|
+
React.createElement(Operation, { color: dataTracked.operation },
|
43
|
+
snippet?.operation,
|
44
|
+
":"),
|
45
|
+
React.createElement(NodeName, null, snippet?.nodeName),
|
46
|
+
React.createElement(SnippetContent, { content: snippet?.content || '', isEquation: snippet?.isEquation }))));
|
135
47
|
};
|
136
48
|
const SnippetText = styled.div `
|
137
49
|
font-size: ${(props) => props.theme.font.size.small};
|
@@ -142,6 +54,9 @@ const SnippetText = styled.div `
|
|
142
54
|
color: ${(props) => props.theme.colors.text.primary};
|
143
55
|
display: block;
|
144
56
|
text-overflow: ellipsis;
|
57
|
+
&[data-mathjax='true'] {
|
58
|
+
text-overflow: unset;
|
59
|
+
}
|
145
60
|
`;
|
146
61
|
const Operation = styled.span `
|
147
62
|
font-family: Lato, sans-serif;
|
@@ -153,6 +68,7 @@ const Operation = styled.span `
|
|
153
68
|
color: ${(props) => {
|
154
69
|
switch (props.color) {
|
155
70
|
case 'insert':
|
71
|
+
case 'wrap_with_node':
|
156
72
|
return '#01872E';
|
157
73
|
case 'delete':
|
158
74
|
return '#F35143';
|
@@ -170,13 +86,5 @@ const NodeName = styled.span `
|
|
170
86
|
font-size: 12px;
|
171
87
|
font-weight: bold;
|
172
88
|
line-height: 16px;
|
173
|
-
margin-right: 3.2px;
|
174
|
-
`;
|
175
|
-
const Content = styled.span `
|
176
|
-
color: #353535;
|
177
|
-
font-family: Lato, sans-serif;
|
178
|
-
font-size: 12px;
|
179
|
-
font-weight: 400;
|
180
|
-
line-height: 16px;
|
181
89
|
`;
|
182
90
|
//# sourceMappingURL=SuggestionSnippet.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SuggestionSnippet.js","sourceRoot":"","sources":["../../../../../src/components/track-changes/suggestion-list/SuggestionSnippet.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,
|
1
|
+
{"version":3,"file":"SuggestionSnippet.js","sourceRoot":"","sources":["../../../../../src/components/track-changes/suggestion-list/SuggestionSnippet.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,SAAS,EAAiB,MAAM,mCAAmC,CAAA;AAC5E,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAS7C,MAAM,CAAC,MAAM,i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AU,GAC/B,CACD,CACS,CACf,CAAA;AACH,CAAC,CAAA;AAED,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAA;eACf,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;iBACpC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM;;;;WAInD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;;;;;;CAMpD,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAmB;;;;;;;WAOrC,CAAC,KAAK,EAAE,EAAE;IACjB,QAAQ,KAAK,CAAC,KAAK,EAAE;QACnB,KAAK,QAAQ,CAAC;QACd,KAAK,gBAAgB;YACnB,OAAO,SAAS,CAAA;QAClB,KAAK,QAAQ;YACX,OAAO,SAAS,CAAA;QAClB,KAAK,WAAW;YACd,OAAO,SAAS,CAAA;QAClB;YACE,OAAO,SAAS,CAAA;KACnB;AACH,CAAC;CACF,CAAA;AAED,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAA;;;;;;;CAO3B,CAAA"}
|
@@ -0,0 +1,117 @@
|
|
1
|
+
import { nodeNames, schema } from '@manuscripts/transform';
|
2
|
+
import { NodeTextContentRetriever } from './node-content-retriever';
|
3
|
+
import { changeOperationAlias } from './tracking';
|
4
|
+
import { getParentNode } from './utils';
|
5
|
+
export const handleTextChange = (suggestion, view, dataTracked) => {
|
6
|
+
const parentNodeType = getParentNode(view.state, suggestion.from)?.type;
|
7
|
+
let nodeName;
|
8
|
+
if (parentNodeType) {
|
9
|
+
const parentNodeName = nodeNames.get(parentNodeType) || parentNodeType?.name;
|
10
|
+
nodeName =
|
11
|
+
parentNodeType === schema.nodes.paragraph
|
12
|
+
? 'text'
|
13
|
+
: parentNodeName + ' text';
|
14
|
+
}
|
15
|
+
return {
|
16
|
+
operation: changeOperationAlias(dataTracked.operation),
|
17
|
+
nodeName: nodeName || suggestion.nodeType.name,
|
18
|
+
content: suggestion.text,
|
19
|
+
};
|
20
|
+
};
|
21
|
+
export const handleNodeChange = (suggestion, view, doc, dataTracked) => {
|
22
|
+
const nodeContentRetriever = new NodeTextContentRetriever(view.state);
|
23
|
+
const { node } = suggestion;
|
24
|
+
const operation = changeOperationAlias(dataTracked.operation);
|
25
|
+
const nodeName = nodeNames.get(node.type) || node.type.name;
|
26
|
+
switch (node.type) {
|
27
|
+
case schema.nodes.inline_footnote: {
|
28
|
+
return {
|
29
|
+
operation,
|
30
|
+
nodeName,
|
31
|
+
content: nodeContentRetriever.getInlineFootnoteContent(doc, node.attrs),
|
32
|
+
};
|
33
|
+
}
|
34
|
+
case schema.nodes.footnote: {
|
35
|
+
return {
|
36
|
+
operation,
|
37
|
+
nodeName,
|
38
|
+
content: nodeContentRetriever.getFootnoteContent(node),
|
39
|
+
};
|
40
|
+
}
|
41
|
+
case schema.nodes.contributor: {
|
42
|
+
const contributorTextContent = `${node.attrs.bibliographicName.given} ${node.attrs.bibliographicName.family}`;
|
43
|
+
return {
|
44
|
+
operation,
|
45
|
+
nodeName,
|
46
|
+
content: contributorTextContent,
|
47
|
+
};
|
48
|
+
}
|
49
|
+
case schema.nodes.affiliation: {
|
50
|
+
const affiliationTextContent = node.attrs.institution;
|
51
|
+
return {
|
52
|
+
operation,
|
53
|
+
nodeName,
|
54
|
+
content: affiliationTextContent,
|
55
|
+
};
|
56
|
+
}
|
57
|
+
case schema.nodes.citation: {
|
58
|
+
return {
|
59
|
+
operation,
|
60
|
+
nodeName,
|
61
|
+
content: nodeContentRetriever.getContentFromBibliography(node.attrs.id, node),
|
62
|
+
};
|
63
|
+
}
|
64
|
+
case schema.nodes.bibliography_item: {
|
65
|
+
return {
|
66
|
+
operation,
|
67
|
+
nodeName,
|
68
|
+
content: nodeContentRetriever.getContentFromBibliography(node.attrs.id, node),
|
69
|
+
};
|
70
|
+
}
|
71
|
+
case schema.nodes.figure_element:
|
72
|
+
case schema.nodes.table_element:
|
73
|
+
return {
|
74
|
+
operation,
|
75
|
+
nodeName,
|
76
|
+
content: nodeContentRetriever.getFigureLabel(node),
|
77
|
+
};
|
78
|
+
case schema.nodes.inline_equation:
|
79
|
+
case schema.nodes.equation_element:
|
80
|
+
return {
|
81
|
+
operation,
|
82
|
+
nodeName,
|
83
|
+
content: nodeContentRetriever.getEquationContent(node),
|
84
|
+
isEquation: true,
|
85
|
+
};
|
86
|
+
case schema.nodes.section: {
|
87
|
+
const nodeName = node.attrs.category === 'MPSectionCategory:subsection'
|
88
|
+
? 'Subsection'
|
89
|
+
: 'Section';
|
90
|
+
return {
|
91
|
+
operation,
|
92
|
+
nodeName,
|
93
|
+
content: nodeContentRetriever.getFirstChildContent(node),
|
94
|
+
};
|
95
|
+
}
|
96
|
+
case schema.nodes.list:
|
97
|
+
return {
|
98
|
+
operation,
|
99
|
+
nodeName,
|
100
|
+
content: `<span class="inspector-list-item">${nodeContentRetriever.getFirstChildContent(node)}</span>`,
|
101
|
+
};
|
102
|
+
default:
|
103
|
+
return {
|
104
|
+
operation,
|
105
|
+
nodeName,
|
106
|
+
content: nodeContentRetriever.getNodeTextContent(node),
|
107
|
+
};
|
108
|
+
}
|
109
|
+
};
|
110
|
+
export const handleUnknownChange = () => {
|
111
|
+
return {
|
112
|
+
operation: '',
|
113
|
+
nodeName: '',
|
114
|
+
content: 'Unknown change!',
|
115
|
+
};
|
116
|
+
};
|
117
|
+
//# sourceMappingURL=change-handlers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"change-handlers.js","sourceRoot":"","sources":["../../../src/lib/change-handlers.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAE1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAE,oBAAo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.js","sourceRoot":"","sources":["../../../src/lib/fonts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,kBAAkB,CAAA;AACzB,OAAO,qBAAqB,CAAA;AAC5B,OAAO,sBAAsB,CAAA"}
|
1
|
+
{"version":3,"file":"fonts.js","sourceRoot":"","sources":["../../../src/lib/fonts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,kBAAkB,CAAA;AACzB,OAAO,qBAAqB,CAAA;AAC5B,OAAO,sBAAsB,CAAA;AAC7B,OAAO,0BAA0B,CAAA;AACjC,OAAO,0BAA0B,CAAA;AACjC,OAAO,0BAA0B,CAAA"}
|
@@ -0,0 +1,123 @@
|
|
1
|
+
/*!
|
2
|
+
* The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
|
3
|
+
*
|
4
|
+
* Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
|
5
|
+
*
|
6
|
+
* The Original Code is manuscripts-frontend.
|
7
|
+
*
|
8
|
+
* The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
|
9
|
+
*
|
10
|
+
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
|
11
|
+
*/
|
12
|
+
import { bibliographyPluginKey, footnotesPluginKey, metadata, objectsPluginKey, } from '@manuscripts/body-editor';
|
13
|
+
import { isElementNodeType, isSectionNodeType, schema, } from '@manuscripts/transform';
|
14
|
+
import domPurify from 'dompurify';
|
15
|
+
export class NodeTextContentRetriever {
|
16
|
+
constructor(state) {
|
17
|
+
this.state = state;
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* Recursively retrieves text content from a ManuscriptNode.
|
21
|
+
*/
|
22
|
+
getNodeTextContent(node) {
|
23
|
+
let textContent = '';
|
24
|
+
if (!isElementNodeType(node.type) && !isSectionNodeType(node.type)) {
|
25
|
+
node.forEach((child) => {
|
26
|
+
if (child.isText) {
|
27
|
+
textContent += child.text;
|
28
|
+
}
|
29
|
+
else {
|
30
|
+
textContent += this.getNodeTextContent(child);
|
31
|
+
}
|
32
|
+
});
|
33
|
+
}
|
34
|
+
return textContent;
|
35
|
+
}
|
36
|
+
/**
|
37
|
+
* Retrieves the text content of the first child node.
|
38
|
+
*/
|
39
|
+
getFirstChildContent(node) {
|
40
|
+
return node.firstChild ? node.firstChild.textContent : '';
|
41
|
+
}
|
42
|
+
/**
|
43
|
+
* Retrieves the text content from a bibliography node.
|
44
|
+
*/
|
45
|
+
getContentFromBibliography(id, node) {
|
46
|
+
const bibPlugin = bibliographyPluginKey.get(this.state);
|
47
|
+
const bib = bibPlugin?.getState(this.state);
|
48
|
+
if (!bib) {
|
49
|
+
return '';
|
50
|
+
}
|
51
|
+
if (node.type === schema.nodes.citation) {
|
52
|
+
const text = bib?.renderedCitations.get(id);
|
53
|
+
const citation = domPurify.sanitize(text && text !== '[NO_PRINTED_FORM]' ? text : ' ', {
|
54
|
+
ALLOWED_TAGS: ['i', 'b', 'span', 'sup', 'sub', '#text'],
|
55
|
+
});
|
56
|
+
return citation ? citation.replace(/<[^>]*>/g, '') : '';
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
const [meta, bibliography] = bib.provider.makeBibliography();
|
60
|
+
const selectedBib = meta.entry_ids.findIndex((entry) => entry[0] === id);
|
61
|
+
if (selectedBib === -1) {
|
62
|
+
return `<span> ${node.attrs.title || 'untitled'} </span> ${metadata(node.attrs)}`;
|
63
|
+
}
|
64
|
+
const parser = new DOMParser();
|
65
|
+
const textContent = parser.parseFromString(bibliography[selectedBib], 'text/html').body.textContent;
|
66
|
+
return textContent || '';
|
67
|
+
}
|
68
|
+
}
|
69
|
+
/**
|
70
|
+
* Retrieves the content of an equation node.
|
71
|
+
*/
|
72
|
+
getEquationContent(node) {
|
73
|
+
if (node.firstChild && node.type === schema.nodes.equation_element) {
|
74
|
+
return node.firstChild.attrs.contents;
|
75
|
+
}
|
76
|
+
else if (node) {
|
77
|
+
return node.attrs.contents;
|
78
|
+
}
|
79
|
+
return '';
|
80
|
+
}
|
81
|
+
/**
|
82
|
+
* Retrieves the label of a figure node.
|
83
|
+
*/
|
84
|
+
getFigureLabel(node) {
|
85
|
+
const objectsPlugin = objectsPluginKey.get(this.state);
|
86
|
+
const pluginState = objectsPlugin?.getState(this.state);
|
87
|
+
const target = pluginState?.get(node.attrs.id);
|
88
|
+
return target?.label || '';
|
89
|
+
}
|
90
|
+
/**
|
91
|
+
* Finds a footnote node by its ID.
|
92
|
+
*/
|
93
|
+
findFootnoteById(doc, id) {
|
94
|
+
let footnoteNode = null;
|
95
|
+
doc.descendants((node) => {
|
96
|
+
if (node.type === schema.nodes.footnote && node.attrs.id === id) {
|
97
|
+
footnoteNode = node;
|
98
|
+
return false;
|
99
|
+
}
|
100
|
+
return !footnoteNode;
|
101
|
+
});
|
102
|
+
return footnoteNode;
|
103
|
+
}
|
104
|
+
/**
|
105
|
+
* Retrieves the inline footnote content.
|
106
|
+
*/
|
107
|
+
getInlineFootnoteContent(doc, attrs) {
|
108
|
+
const footnote = attrs.rids && attrs.rids.length > 0
|
109
|
+
? this.findFootnoteById(doc, attrs.rids[0])
|
110
|
+
: null;
|
111
|
+
return `<sup class="footnote-decoration">${attrs.contents || ''}</sup>${footnote ? footnote.textContent : ''}`;
|
112
|
+
}
|
113
|
+
/**
|
114
|
+
* Retrieves the text content of a footnote node with decoration.
|
115
|
+
*/
|
116
|
+
getFootnoteContent(node) {
|
117
|
+
const footnotesPlugin = footnotesPluginKey.get(this.state);
|
118
|
+
const pluginState = footnotesPlugin?.getState(this.state);
|
119
|
+
const decorationText = pluginState?.labels.get(node.attrs.id) || '';
|
120
|
+
return `<sup class="footnote-decoration">${decorationText}</sup>${node.textContent || this.getNodeTextContent(node)}`;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
//# sourceMappingURL=node-content-retriever.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"node-content-retriever.js","sourceRoot":"","sources":["../../../src/lib/node-content-retriever.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAEL,qBAAqB,EACrB,kBAAkB,EAClB,QAAQ,EACR,gBAAgB,GACjB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EAGjB,MAAM,GACP,MAAM,wBAAwB,CAAA;AAC/B,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,MAAM,OAAO,wBAAwB;IAGnC,YAAY,KAA4B;QACtC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED;;OAEG;IACI,kBAAkB,CAAC,IAAoB;QAC5C,IAAI,WAAW,GAAG,EAAE,CAAA;QACpB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAClE,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;gBACrB,IAAI,KAAK,CAAC,MAAM,EAAE;oBAChB,WAAW,IAAI,KAAK,CAAC,IAAI,CAAA;iBAC1B;qBAAM;oBACL,WAAW,IAAI,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAA;iBAC9C;YACH,CAAC,CAAC,CAAA;SACH;QACD,OAAO,WAAW,CAAA;IACpB,CAAC;IAED;;OAEG;IACI,oBAAoB,CAAC,IAAoB;QAC9C,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAA;IAC3D,CAAC;IAED;;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