@manuscripts/article-editor 3.5.2 → 3.5.4
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 +3 -11
- package/dist/cjs/components/track-changes/suggestion-list/SnippetContent.js.map +1 -1
- package/dist/cjs/components/track-changes/suggestion-list/SuggestionSnippet.js +14 -12
- package/dist/cjs/components/track-changes/suggestion-list/SuggestionSnippet.js.map +1 -1
- package/dist/cjs/lib/change-handlers.js +23 -19
- package/dist/cjs/lib/change-handlers.js.map +1 -1
- package/dist/cjs/lib/node-content-retriever.js +1 -25
- package/dist/cjs/lib/node-content-retriever.js.map +1 -1
- package/dist/es/components/track-changes/suggestion-list/SnippetContent.js +3 -11
- package/dist/es/components/track-changes/suggestion-list/SnippetContent.js.map +1 -1
- package/dist/es/components/track-changes/suggestion-list/SuggestionSnippet.js +14 -12
- package/dist/es/components/track-changes/suggestion-list/SuggestionSnippet.js.map +1 -1
- package/dist/es/lib/change-handlers.js +24 -20
- package/dist/es/lib/change-handlers.js.map +1 -1
- package/dist/es/lib/node-content-retriever.js +2 -26
- package/dist/es/lib/node-content-retriever.js.map +1 -1
- package/dist/types/components/track-changes/suggestion-list/SnippetContent.d.ts +0 -1
- package/dist/types/lib/change-handlers.d.ts +3 -14
- package/dist/types/lib/node-content-retriever.d.ts +0 -4
- package/package.json +3 -3
@@ -37,21 +37,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
38
38
|
};
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
40
|
-
const body_editor_1 = require("@manuscripts/body-editor");
|
41
40
|
const dompurify_1 = __importDefault(require("dompurify"));
|
42
41
|
const react_1 = __importStar(require("react"));
|
43
42
|
const styled_components_1 = __importDefault(require("styled-components"));
|
44
|
-
const SnippetContent = ({ content
|
43
|
+
const SnippetContent = ({ content }) => {
|
45
44
|
const contentRef = (0, react_1.useRef)(null);
|
46
45
|
(0, react_1.useEffect)(() => {
|
47
46
|
if (contentRef.current && content) {
|
48
47
|
contentRef.current.innerHTML = dompurify_1.default.sanitize(': ' + content) || '';
|
49
|
-
if (isEquation) {
|
50
|
-
(0, body_editor_1.renderMath)(contentRef.current);
|
51
|
-
}
|
52
48
|
}
|
53
|
-
}, [content
|
54
|
-
return react_1.default.createElement(StyledContent, { ref: contentRef
|
49
|
+
}, [content]);
|
50
|
+
return react_1.default.createElement(StyledContent, { ref: contentRef });
|
55
51
|
};
|
56
52
|
exports.default = SnippetContent;
|
57
53
|
const StyledContent = styled_components_1.default.span `
|
@@ -61,10 +57,6 @@ const StyledContent = styled_components_1.default.span `
|
|
61
57
|
font-weight: 400;
|
62
58
|
line-height: 16px;
|
63
59
|
|
64
|
-
&[data-mathjax='true'] {
|
65
|
-
text-overflow: unset;
|
66
|
-
}
|
67
|
-
|
68
60
|
.inspector-list-item::after {
|
69
61
|
content: '...';
|
70
62
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SnippetContent.js","sourceRoot":"","sources":["../../../../../src/components/track-changes/suggestion-list/SnippetContent.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,
|
1
|
+
{"version":3,"file":"SnippetContent.js","sourceRoot":"","sources":["../../../../../src/components/track-changes/suggestion-list/SnippetContent.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,0DAA8B;AAC9B,+CAAgD;AAChD,0EAAsC;AAMtC,MAAM,cAAc,GAA2B,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;IAC7D,MAAM,UAAU,GAAG,IAAA,cAAM,EAAkB,IAAI,CAAC,CAAA;IAEhD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,UAAU,CAAC,OAAO,IAAI,OAAO,EAAE;YACjC,UAAU,CAAC,OAAO,CAAC,SAAS,GAAG,mBAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAA;SACrE;IACH,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IAEb,OAAO,8BAAC,aAAa,IAAC,GAAG,EAAE,UAAU,GAAI,CAAA;AAC3C,CAAC,CAAA;AAED,kBAAe,cAAc,CAAA;AAE7B,MAAM,aAAa,GAAG,2BAAM,CAAC,IAAI,CAAA;;;;;;;;;;CAUhC,CAAA"}
|
@@ -53,26 +53,28 @@ const SuggestionSnippet = ({ suggestion, }) => {
|
|
53
53
|
const { dataTracked } = suggestion;
|
54
54
|
(0, react_1.useEffect)(() => {
|
55
55
|
let newSnippet = null;
|
56
|
-
if (
|
57
|
-
|
56
|
+
if (view) {
|
57
|
+
if (track_changes_plugin_1.ChangeSet.isTextChange(suggestion)) {
|
58
|
+
newSnippet = (0, change_handlers_1.handleTextChange)(suggestion, view.state);
|
59
|
+
}
|
60
|
+
else if (track_changes_plugin_1.ChangeSet.isNodeChange(suggestion) ||
|
61
|
+
track_changes_plugin_1.ChangeSet.isNodeAttrChange(suggestion)) {
|
62
|
+
newSnippet = (0, change_handlers_1.handleNodeChange)(suggestion, view.state);
|
63
|
+
}
|
64
|
+
else {
|
65
|
+
newSnippet = (0, change_handlers_1.handleUnknownChange)();
|
66
|
+
}
|
67
|
+
setSnippet(newSnippet);
|
58
68
|
}
|
59
|
-
else if (track_changes_plugin_1.ChangeSet.isNodeChange(suggestion) ||
|
60
|
-
track_changes_plugin_1.ChangeSet.isNodeAttrChange(suggestion)) {
|
61
|
-
newSnippet = (0, change_handlers_1.handleNodeChange)(suggestion, view, doc, dataTracked);
|
62
|
-
}
|
63
|
-
else {
|
64
|
-
newSnippet = (0, change_handlers_1.handleUnknownChange)();
|
65
|
-
}
|
66
|
-
setSnippet(newSnippet);
|
67
69
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
68
70
|
}, [suggestion, doc, view]);
|
69
|
-
return (react_1.default.createElement(SnippetText,
|
71
|
+
return (react_1.default.createElement(SnippetText, null,
|
70
72
|
react_1.default.createElement(react_1.default.Fragment, null,
|
71
73
|
react_1.default.createElement(Operation, { color: dataTracked.operation },
|
72
74
|
snippet?.operation,
|
73
75
|
":"),
|
74
76
|
react_1.default.createElement(NodeName, null, snippet?.nodeName),
|
75
|
-
react_1.default.createElement(SnippetContent_1.default, { content: snippet?.content || ''
|
77
|
+
react_1.default.createElement(SnippetContent_1.default, { content: snippet?.content || '' }))));
|
76
78
|
};
|
77
79
|
exports.SuggestionSnippet = SuggestionSnippet;
|
78
80
|
const SnippetText = styled_components_1.default.div `
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SuggestionSnippet.js","sourceRoot":"","sources":["../../../../../src/components/track-changes/suggestion-list/SuggestionSnippet.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;GAUG;AACH,4EAA4E;AAC5E,+CAAkD;AAClD,0EAAsC;AAEtC,kEAIqC;AACrC,0CAAyC;AACzC,sEAA6C;
|
1
|
+
{"version":3,"file":"SuggestionSnippet.js","sourceRoot":"","sources":["../../../../../src/components/track-changes/suggestion-list/SuggestionSnippet.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;GAUG;AACH,4EAA4E;AAC5E,+CAAkD;AAClD,0EAAsC;AAEtC,kEAIqC;AACrC,0CAAyC;AACzC,sEAA6C;AAQtC,MAAM,iBAAiB,GAA4C,CAAC,EACzE,UAAU,GACX,EAAE,EAAE;IACH,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC3C,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,GAAG,EAAE,KAAK,CAAC,GAAG;KACf,CAAC,CAAC,CAAA;IACH,M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,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,2BAAM,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,2BAAM,CAAC,IAAI,CAAA;;;;;;;CAO3B,CAAA"}
|
@@ -1,15 +1,25 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.handleUnknownChange = exports.handleNodeChange = exports.handleTextChange = void 0;
|
4
|
+
/*!
|
5
|
+
* 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.
|
6
|
+
*
|
7
|
+
* 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.
|
8
|
+
*
|
9
|
+
* The Original Code is manuscripts-frontend.
|
10
|
+
*
|
11
|
+
* The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
|
12
|
+
*
|
13
|
+
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
|
14
|
+
*/
|
15
|
+
const body_editor_1 = require("@manuscripts/body-editor");
|
4
16
|
const transform_1 = require("@manuscripts/transform");
|
5
17
|
const node_content_retriever_1 = require("./node-content-retriever");
|
6
18
|
const tracking_1 = require("./tracking");
|
7
19
|
const utils_1 = require("./utils");
|
8
|
-
const handleTextChange = (suggestion,
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
const parentNodeType = (0, utils_1.getParentNode)(view.state, suggestion.from)?.type;
|
20
|
+
const handleTextChange = (suggestion, state) => {
|
21
|
+
const { dataTracked } = suggestion;
|
22
|
+
const parentNodeType = (0, utils_1.getParentNode)(state, suggestion.from)?.type;
|
13
23
|
let nodeName;
|
14
24
|
if (parentNodeType) {
|
15
25
|
const parentNodeName = transform_1.nodeNames.get(parentNodeType) || parentNodeType?.name;
|
@@ -25,12 +35,9 @@ const handleTextChange = (suggestion, view, dataTracked) => {
|
|
25
35
|
};
|
26
36
|
};
|
27
37
|
exports.handleTextChange = handleTextChange;
|
28
|
-
const handleNodeChange = (suggestion,
|
29
|
-
|
30
|
-
|
31
|
-
}
|
32
|
-
const nodeContentRetriever = new node_content_retriever_1.NodeTextContentRetriever(view.state);
|
33
|
-
const { node } = suggestion;
|
38
|
+
const handleNodeChange = (suggestion, state) => {
|
39
|
+
const nodeContentRetriever = new node_content_retriever_1.NodeTextContentRetriever(state);
|
40
|
+
const { node, dataTracked } = suggestion;
|
34
41
|
const operation = (0, tracking_1.changeOperationAlias)(dataTracked.operation);
|
35
42
|
const nodeName = transform_1.nodeNames.get(node.type) || node.type.name;
|
36
43
|
switch (node.type) {
|
@@ -38,30 +45,28 @@ const handleNodeChange = (suggestion, view, doc, dataTracked) => {
|
|
38
45
|
return {
|
39
46
|
operation,
|
40
47
|
nodeName,
|
41
|
-
content: nodeContentRetriever.getInlineFootnoteContent(
|
48
|
+
content: nodeContentRetriever.getInlineFootnoteContent(state, node.attrs),
|
42
49
|
};
|
43
50
|
}
|
44
51
|
case transform_1.schema.nodes.footnote: {
|
45
52
|
return {
|
46
53
|
operation,
|
47
54
|
nodeName,
|
48
|
-
content: nodeContentRetriever.getFootnoteContent(
|
55
|
+
content: nodeContentRetriever.getFootnoteContent(state, node),
|
49
56
|
};
|
50
57
|
}
|
51
58
|
case transform_1.schema.nodes.contributor: {
|
52
|
-
const contributorTextContent = `${node.attrs.bibliographicName.given} ${node.attrs.bibliographicName.family}`;
|
53
59
|
return {
|
54
60
|
operation,
|
55
61
|
nodeName,
|
56
|
-
content:
|
62
|
+
content: (0, body_editor_1.authorLabel)(node.attrs),
|
57
63
|
};
|
58
64
|
}
|
59
65
|
case transform_1.schema.nodes.affiliation: {
|
60
|
-
const affiliationTextContent = node.attrs.institution;
|
61
66
|
return {
|
62
67
|
operation,
|
63
68
|
nodeName,
|
64
|
-
content:
|
69
|
+
content: (0, body_editor_1.affiliationLabel)(node.attrs),
|
65
70
|
};
|
66
71
|
}
|
67
72
|
case transform_1.schema.nodes.citation: {
|
@@ -91,7 +96,6 @@ const handleNodeChange = (suggestion, view, doc, dataTracked) => {
|
|
91
96
|
operation,
|
92
97
|
nodeName,
|
93
98
|
content: nodeContentRetriever.getEquationContent(node),
|
94
|
-
isEquation: true,
|
95
99
|
};
|
96
100
|
case transform_1.schema.nodes.section: {
|
97
101
|
const nodeName = node.attrs.category === 'MPSectionCategory:subsection'
|
@@ -113,7 +117,7 @@ const handleNodeChange = (suggestion, view, doc, dataTracked) => {
|
|
113
117
|
return {
|
114
118
|
operation,
|
115
119
|
nodeName,
|
116
|
-
content:
|
120
|
+
content: node.textContent,
|
117
121
|
};
|
118
122
|
}
|
119
123
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"change-handlers.js","sourceRoot":"","sources":["../../../src/lib/change-handlers.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"change-handlers.js","sourceRoot":"","sources":["../../../src/lib/change-handlers.ts"],"names":[],"mappings":";;;AAAA;;;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SAAS;gBACT,QAAQ;gBACR,OAAO,EAAE,oBAAoB,CAAC,cAAc,CAAC,IAAI,CAAC;aACnD,CAAA;QACH,KAAK,kBAAM,CAAC,KAAK,CAAC,eAAe,CAAC;QAClC,KAAK,kBAAM,CAAC,KAAK,CAAC,gBAAgB;YAChC,OAAO;gBACL,SAAS;gBACT,QAAQ;gBACR,OAAO,EAAE,oBAAoB,CAAC,kBAAkB,CAAC,IAAI,CAAC;aACvD,CAAA;QACH,KAAK,kBAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACzB,MAAM,QAAQ,GACZ,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,8BAA8B;gBACpD,CAAC,CAAC,YAAY;gBACd,CAAC,CAAC,SAAS,CAAA;YACf,OAAO;gBACL,SAAS;gBACT,QAAQ;gBACR,OAAO,EAAE,oBAAoB,CAAC,oBAAoB,CAAC,IAAI,CAAC;aACzD,CAAA;SACF;QACD,KAAK,kBAAM,CAAC,KAAK,CAAC,IAAI;YACpB,OAAO;gBACL,SAAS;gBACT,QAAQ;gBACR,OAAO,EAAE,qCAAqC,oBAAoB,CAAC,oBAAoB,CACrF,IAAI,CACL,SAAS;aACX,CAAA;QACH;YACE,OAAO;gBACL,SAAS;gBACT,QAAQ;gBACR,OAAO,EAAE,IAAI,CAAC,WAAW;aAC1B,CAAA;KACJ;AACH,CAAC,CAAA;AArGY,QAAA,gBAAgB,oBAqG5B;AAEM,MAAM,mBAAmB,GAAG,GAAgB,EAAE;IACnD,OAAO;QACL,SAAS,EAAE,EAAE;QACb,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,iBAAiB;KAC3B,CAAA;AACH,CAAC,CAAA;AANY,QAAA,mBAAmB,uBAM/B"}
|
@@ -22,23 +22,6 @@ class NodeTextContentRetriever {
|
|
22
22
|
constructor(state) {
|
23
23
|
this.state = state;
|
24
24
|
}
|
25
|
-
/**
|
26
|
-
* Recursively retrieves text content from a ManuscriptNode.
|
27
|
-
*/
|
28
|
-
getNodeTextContent(node) {
|
29
|
-
let textContent = '';
|
30
|
-
if (!(0, transform_1.isElementNodeType)(node.type) && !(0, transform_1.isSectionNodeType)(node.type)) {
|
31
|
-
node.forEach((child) => {
|
32
|
-
if (child.isText) {
|
33
|
-
textContent += child.text;
|
34
|
-
}
|
35
|
-
else {
|
36
|
-
textContent += this.getNodeTextContent(child);
|
37
|
-
}
|
38
|
-
});
|
39
|
-
}
|
40
|
-
return textContent;
|
41
|
-
}
|
42
25
|
/**
|
43
26
|
* Retrieves the text content of the first child node.
|
44
27
|
*/
|
@@ -62,14 +45,7 @@ class NodeTextContentRetriever {
|
|
62
45
|
return citation ? citation.replace(/<[^>]*>/g, '') : '';
|
63
46
|
}
|
64
47
|
else {
|
65
|
-
|
66
|
-
const selectedBib = meta.entry_ids.findIndex((entry) => entry[0] === id);
|
67
|
-
if (selectedBib === -1) {
|
68
|
-
return `<span> ${node.attrs.title || 'untitled'} </span> ${(0, body_editor_1.metadata)(node.attrs)}`;
|
69
|
-
}
|
70
|
-
const parser = new DOMParser();
|
71
|
-
const textContent = parser.parseFromString(bibliography[selectedBib], 'text/html').body.textContent;
|
72
|
-
return textContent || '';
|
48
|
+
return `<span> ${node.attrs.title || 'untitled'} </span> ${(0, body_editor_1.metadata)(node.attrs)}`;
|
73
49
|
}
|
74
50
|
}
|
75
51
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"node-content-retriever.js","sourceRoot":"","sources":["../../../src/lib/node-content-retriever.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;GAUG;AACH,0DAOiC;AACjC,
|
1
|
+
{"version":3,"file":"node-content-retriever.js","sourceRoot":"","sources":["../../../src/lib/node-content-retriever.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;GAUG;AACH,0DAOiC;AACjC,sDAK+B;AAC/B,0DAAiC;AACjC,MAAa,wBAAwB;IAGnC,YAAY,KAA4B;QACtC,IAAI,CAAC,KAAK,GAAG,KAAK,CA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AM,IAAI,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,CAAA;QACnC,OAAO,oCAAoC,KAAK,SAAS,IAAI,EAAE,CAAA;IACjE,CAAC;CACF;AA7FD,4DA6FC"}
|
@@ -9,21 +9,17 @@
|
|
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 { renderMath } from '@manuscripts/body-editor';
|
13
12
|
import purify from 'dompurify';
|
14
13
|
import React, { useEffect, useRef } from 'react';
|
15
14
|
import styled from 'styled-components';
|
16
|
-
const SnippetContent = ({ content
|
15
|
+
const SnippetContent = ({ content }) => {
|
17
16
|
const contentRef = useRef(null);
|
18
17
|
useEffect(() => {
|
19
18
|
if (contentRef.current && content) {
|
20
19
|
contentRef.current.innerHTML = purify.sanitize(': ' + content) || '';
|
21
|
-
if (isEquation) {
|
22
|
-
renderMath(contentRef.current);
|
23
|
-
}
|
24
20
|
}
|
25
|
-
}, [content
|
26
|
-
return React.createElement(StyledContent, { ref: contentRef
|
21
|
+
}, [content]);
|
22
|
+
return React.createElement(StyledContent, { ref: contentRef });
|
27
23
|
};
|
28
24
|
export default SnippetContent;
|
29
25
|
const StyledContent = styled.span `
|
@@ -33,10 +29,6 @@ const StyledContent = styled.span `
|
|
33
29
|
font-weight: 400;
|
34
30
|
line-height: 16px;
|
35
31
|
|
36
|
-
&[data-mathjax='true'] {
|
37
|
-
text-overflow: unset;
|
38
|
-
}
|
39
|
-
|
40
32
|
.inspector-list-item::after {
|
41
33
|
content: '...';
|
42
34
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SnippetContent.js","sourceRoot":"","sources":["../../../../../src/components/track-changes/suggestion-list/SnippetContent.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,
|
1
|
+
{"version":3,"file":"SnippetContent.js","sourceRoot":"","sources":["../../../../../src/components/track-changes/suggestion-list/SnippetContent.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,MAAM,MAAM,WAAW,CAAA;AAC9B,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAChD,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAMtC,MAAM,cAAc,GAA2B,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;IAC7D,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;SACrE;IACH,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IAEb,OAAO,oBAAC,aAAa,IAAC,GAAG,EAAE,UAAU,GAAI,CAAA;AAC3C,CAAC,CAAA;AAED,eAAe,cAAc,CAAA;AAE7B,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAA;;;;;;;;;;CAUhC,CAAA"}
|
@@ -24,26 +24,28 @@ export const SuggestionSnippet = ({ suggestion, }) => {
|
|
24
24
|
const { dataTracked } = suggestion;
|
25
25
|
useEffect(() => {
|
26
26
|
let newSnippet = null;
|
27
|
-
if (
|
28
|
-
|
27
|
+
if (view) {
|
28
|
+
if (ChangeSet.isTextChange(suggestion)) {
|
29
|
+
newSnippet = handleTextChange(suggestion, view.state);
|
30
|
+
}
|
31
|
+
else if (ChangeSet.isNodeChange(suggestion) ||
|
32
|
+
ChangeSet.isNodeAttrChange(suggestion)) {
|
33
|
+
newSnippet = handleNodeChange(suggestion, view.state);
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
newSnippet = handleUnknownChange();
|
37
|
+
}
|
38
|
+
setSnippet(newSnippet);
|
29
39
|
}
|
30
|
-
else if (ChangeSet.isNodeChange(suggestion) ||
|
31
|
-
ChangeSet.isNodeAttrChange(suggestion)) {
|
32
|
-
newSnippet = handleNodeChange(suggestion, view, doc, dataTracked);
|
33
|
-
}
|
34
|
-
else {
|
35
|
-
newSnippet = handleUnknownChange();
|
36
|
-
}
|
37
|
-
setSnippet(newSnippet);
|
38
40
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
39
41
|
}, [suggestion, doc, view]);
|
40
|
-
return (React.createElement(SnippetText,
|
42
|
+
return (React.createElement(SnippetText, null,
|
41
43
|
React.createElement(React.Fragment, null,
|
42
44
|
React.createElement(Operation, { color: dataTracked.operation },
|
43
45
|
snippet?.operation,
|
44
46
|
":"),
|
45
47
|
React.createElement(NodeName, null, snippet?.nodeName),
|
46
|
-
React.createElement(SnippetContent, { content: snippet?.content || ''
|
48
|
+
React.createElement(SnippetContent, { content: snippet?.content || '' }))));
|
47
49
|
};
|
48
50
|
const SnippetText = styled.div `
|
49
51
|
font-size: ${(props) => props.theme.font.size.small};
|
@@ -1 +1 @@
|
|
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;
|
1
|
+
{"version":3,"file":"SuggestionSnippet.js","sourceRoot":"","sources":["../../../../../src/components/track-changes/suggestion-list/SuggestionSnippet.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG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CAAA;SACvB;QACD,uDAAuD;IACzD,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;IAE3B,OAAO,CACL,oBAAC,WAAW;QACV;YACE,oBAAC,SAAS,IAAC,KAAK,EAAE,WAAW,CAAC,SAAS;gBACpC,OAAO,EAAE,SAAS;oBACT;YACZ,oBAAC,QAAQ,QAAE,OAAO,EAAE,QAAQ,CAAY;YACxC,oBAAC,cAAc,IAAC,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,GAAI,CAClD,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"}
|
@@ -1,12 +1,22 @@
|
|
1
|
-
|
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 { affiliationLabel, authorLabel, } from '@manuscripts/body-editor';
|
13
|
+
import { nodeNames, schema, } from '@manuscripts/transform';
|
2
14
|
import { NodeTextContentRetriever } from './node-content-retriever';
|
3
15
|
import { changeOperationAlias } from './tracking';
|
4
16
|
import { getParentNode } from './utils';
|
5
|
-
export const handleTextChange = (suggestion,
|
6
|
-
|
7
|
-
|
8
|
-
}
|
9
|
-
const parentNodeType = getParentNode(view.state, suggestion.from)?.type;
|
17
|
+
export const handleTextChange = (suggestion, state) => {
|
18
|
+
const { dataTracked } = suggestion;
|
19
|
+
const parentNodeType = getParentNode(state, suggestion.from)?.type;
|
10
20
|
let nodeName;
|
11
21
|
if (parentNodeType) {
|
12
22
|
const parentNodeName = nodeNames.get(parentNodeType) || parentNodeType?.name;
|
@@ -21,12 +31,9 @@ export const handleTextChange = (suggestion, view, dataTracked) => {
|
|
21
31
|
content: suggestion.text,
|
22
32
|
};
|
23
33
|
};
|
24
|
-
export const handleNodeChange = (suggestion,
|
25
|
-
|
26
|
-
|
27
|
-
}
|
28
|
-
const nodeContentRetriever = new NodeTextContentRetriever(view.state);
|
29
|
-
const { node } = suggestion;
|
34
|
+
export const handleNodeChange = (suggestion, state) => {
|
35
|
+
const nodeContentRetriever = new NodeTextContentRetriever(state);
|
36
|
+
const { node, dataTracked } = suggestion;
|
30
37
|
const operation = changeOperationAlias(dataTracked.operation);
|
31
38
|
const nodeName = nodeNames.get(node.type) || node.type.name;
|
32
39
|
switch (node.type) {
|
@@ -34,30 +41,28 @@ export const handleNodeChange = (suggestion, view, doc, dataTracked) => {
|
|
34
41
|
return {
|
35
42
|
operation,
|
36
43
|
nodeName,
|
37
|
-
content: nodeContentRetriever.getInlineFootnoteContent(
|
44
|
+
content: nodeContentRetriever.getInlineFootnoteContent(state, node.attrs),
|
38
45
|
};
|
39
46
|
}
|
40
47
|
case schema.nodes.footnote: {
|
41
48
|
return {
|
42
49
|
operation,
|
43
50
|
nodeName,
|
44
|
-
content: nodeContentRetriever.getFootnoteContent(
|
51
|
+
content: nodeContentRetriever.getFootnoteContent(state, node),
|
45
52
|
};
|
46
53
|
}
|
47
54
|
case schema.nodes.contributor: {
|
48
|
-
const contributorTextContent = `${node.attrs.bibliographicName.given} ${node.attrs.bibliographicName.family}`;
|
49
55
|
return {
|
50
56
|
operation,
|
51
57
|
nodeName,
|
52
|
-
content:
|
58
|
+
content: authorLabel(node.attrs),
|
53
59
|
};
|
54
60
|
}
|
55
61
|
case schema.nodes.affiliation: {
|
56
|
-
const affiliationTextContent = node.attrs.institution;
|
57
62
|
return {
|
58
63
|
operation,
|
59
64
|
nodeName,
|
60
|
-
content:
|
65
|
+
content: affiliationLabel(node.attrs),
|
61
66
|
};
|
62
67
|
}
|
63
68
|
case schema.nodes.citation: {
|
@@ -87,7 +92,6 @@ export const handleNodeChange = (suggestion, view, doc, dataTracked) => {
|
|
87
92
|
operation,
|
88
93
|
nodeName,
|
89
94
|
content: nodeContentRetriever.getEquationContent(node),
|
90
|
-
isEquation: true,
|
91
95
|
};
|
92
96
|
case schema.nodes.section: {
|
93
97
|
const nodeName = node.attrs.category === 'MPSectionCategory:subsection'
|
@@ -109,7 +113,7 @@ export const handleNodeChange = (suggestion, view, doc, dataTracked) => {
|
|
109
113
|
return {
|
110
114
|
operation,
|
111
115
|
nodeName,
|
112
|
-
content:
|
116
|
+
content: node.textContent,
|
113
117
|
};
|
114
118
|
}
|
115
119
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"change-handlers.js","sourceRoot":"","sources":["../../../src/lib/change-handlers.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"change-handlers.js","sourceRoot":"","sources":["../../../src/lib/change-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAEL,gBAAgB,EAChB,WAAW,GAEZ,MAAM,0BAA0B,CAAA;AAMjC,OAAO,EAEL,SAAS,EACT,MAAM,GACP,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAQvC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,UAAsB,EACtB,KAA4B,EACR,EAAE;IACtB,MAAM,EAAE,WAAW,EAAE,GAAG,UAAU,CAAA;IAClC,MAAM,cAAc,GAAG,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA;IAClE,IAAI,QAAQ,CAAA;IACZ,IAAI,cAAc,EAAE;QAClB,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,cAAc,EAAE,IAAI,CAAA;QAC5E,QAAQ;YACN,cAAc,KAAK,MAAM,CAAC,KAAK,CAAC,SAAS;gBACvC,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC,cAAc,GAAG,OAAO,CAAA;KAC/B;IAED,OAAO;QACL,SAAS,EAAE,oBAAoB,CAAC,WAAW,CAAC,SAAS,CAAC;QACtD,QAAQ,EAAE,QAAQ,IAAI,UAAU,CA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QACH;YACE,OAAO;gBACL,SAAS;gBACT,QAAQ;gBACR,OAAO,EAAE,IAAI,CAAC,WAAW;aAC1B,CAAA;KACJ;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAgB,EAAE;IACnD,OAAO;QACL,SAAS,EAAE,EAAE;QACb,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,iBAAiB;KAC3B,CAAA;AACH,CAAC,CAAA"}
|
@@ -10,29 +10,12 @@
|
|
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
12
|
import { bibliographyPluginKey, findNodeByID, getFootnoteLabel, metadata, objectsPluginKey, } from '@manuscripts/body-editor';
|
13
|
-
import {
|
13
|
+
import { schema, } from '@manuscripts/transform';
|
14
14
|
import domPurify from 'dompurify';
|
15
15
|
export class NodeTextContentRetriever {
|
16
16
|
constructor(state) {
|
17
17
|
this.state = state;
|
18
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
19
|
/**
|
37
20
|
* Retrieves the text content of the first child node.
|
38
21
|
*/
|
@@ -56,14 +39,7 @@ export class NodeTextContentRetriever {
|
|
56
39
|
return citation ? citation.replace(/<[^>]*>/g, '') : '';
|
57
40
|
}
|
58
41
|
else {
|
59
|
-
|
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 || '';
|
42
|
+
return `<span> ${node.attrs.title || 'untitled'} </span> ${metadata(node.attrs)}`;
|
67
43
|
}
|
68
44
|
}
|
69
45
|
/**
|
@@ -1 +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,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,GACjB,MAAM,0BAA0B,CAAA;AACjC,OAAO,
|
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,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,GACjB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAIL,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,oBAAoB,CAAC,IAAoB;QAC9C,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAA;IAC3D,CAAC;IAED;;OAEG;IACI,0BAA0B,CAAC,EAAU,EAAE,IAAoB;QAChE,MAAM,SAAS,GAAG,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACvD,MAAM,GAAG,GAAG,SAAS,EAAE,QAAQ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QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACvD,MAAM,MAAM,GAAG,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC9C,OAAO,MAAM,EAAE,KAAK,IAAI,EAAE,CAAA;IAC5B,CAAC;IAED;;OAEG;IACI,wBAAwB,CAC7B,KAA4B,EAC5B,KAAuB;QAEvB,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACzB,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,EAAE,CAAA;SACV;QACD,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,IAAI,CAAA;QACnD,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO,EAAE,CAAA;SACV;QACD,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,EAAE,QAAwB,CAAC,CAAA;QAC/D,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,IAAI,EAAE,CAAA;QACvC,OAAO,oCAAoC,KAAK,SAAS,IAAI,EAAE,CAAA;IACjE,CAAC;IAED;;OAEG;IACI,kBAAkB,CACvB,KAA4B,EAC5B,IAAoB;QAEpB,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,EAAE,IAAoB,CAAC,CAAA;QAC3D,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,CAAA;QACnC,OAAO,oCAAoC,KAAK,SAAS,IAAI,EAAE,CAAA;IACjE,CAAC;CACF"}
|
@@ -1,22 +1,11 @@
|
|
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
1
|
import { NodeAttrChange, NodeChange, TextChange } from '@manuscripts/track-changes-plugin';
|
2
|
+
import { ManuscriptEditorState } from '@manuscripts/transform';
|
13
3
|
interface SnippetData {
|
14
4
|
operation: string;
|
15
5
|
nodeName: string;
|
16
6
|
content: string | null;
|
17
|
-
isEquation?: boolean;
|
18
7
|
}
|
19
|
-
export declare const handleTextChange: (suggestion: TextChange,
|
20
|
-
export declare const handleNodeChange: (suggestion: NodeChange | NodeAttrChange,
|
8
|
+
export declare const handleTextChange: (suggestion: TextChange, state: ManuscriptEditorState) => SnippetData | null;
|
9
|
+
export declare const handleNodeChange: (suggestion: NodeChange | NodeAttrChange, state: ManuscriptEditorState) => SnippetData | null;
|
21
10
|
export declare const handleUnknownChange: () => SnippetData;
|
22
11
|
export {};
|
@@ -2,10 +2,6 @@ import { ManuscriptEditorState, ManuscriptNode } from '@manuscripts/transform';
|
|
2
2
|
export declare class NodeTextContentRetriever {
|
3
3
|
private state;
|
4
4
|
constructor(state: ManuscriptEditorState);
|
5
|
-
/**
|
6
|
-
* Recursively retrieves text content from a ManuscriptNode.
|
7
|
-
*/
|
8
|
-
getNodeTextContent(node: ManuscriptNode): string;
|
9
5
|
/**
|
10
6
|
* Retrieves the text content of the first child node.
|
11
7
|
*/
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@manuscripts/article-editor",
|
3
|
-
"version": "3.5.
|
3
|
+
"version": "3.5.4",
|
4
4
|
"license": "CPAL-1.0",
|
5
5
|
"description": "React components for editing and viewing manuscripts",
|
6
6
|
"repository": "github:Atypon-OpenSource/manuscripts-article-editor",
|
@@ -35,12 +35,12 @@
|
|
35
35
|
"@fontsource/lato": "^4.5.10",
|
36
36
|
"@fontsource/pt-sans": "^4.5.11",
|
37
37
|
"@fontsource/pt-serif": "^4.5.11",
|
38
|
-
"@manuscripts/body-editor": "2.6.
|
38
|
+
"@manuscripts/body-editor": "2.6.4",
|
39
39
|
"@manuscripts/json-schema": "2.2.11",
|
40
40
|
"@manuscripts/library": "1.3.11",
|
41
41
|
"@manuscripts/style-guide": "2.0.23",
|
42
42
|
"@manuscripts/track-changes-plugin": "1.8.1",
|
43
|
-
"@manuscripts/transform": "3.0.
|
43
|
+
"@manuscripts/transform": "3.0.13",
|
44
44
|
"@popperjs/core": "^2.11.8",
|
45
45
|
"@types/use-sync-external-store": "^0.0.6",
|
46
46
|
"autotrack": "^2.4.1",
|