@manuscripts/article-editor 3.3.1-LEAN-4052.0 → 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/comments/CommentBody.js +2 -1
- package/dist/cjs/components/comments/CommentBody.js.map +1 -1
- 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 +17 -28
- package/dist/cjs/lib/utils.js.map +1 -1
- package/dist/es/components/comments/CommentBody.js +2 -1
- package/dist/es/components/comments/CommentBody.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 +15 -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 +2 -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
@@ -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,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AAC;YACb,OAAO,UAAU,CAAA;SAClB;QACD,KAAK,WAAW,CAAC,CAAC;YAChB,OAAO,SAAS,CAAA;SACjB;QACD,KAAK,gBAAgB,CAAC,CAAC;YACrB,OAAO,UAAU,CAAA;SAClB;QACD,OAAO,CAAC,CAAC;YACP,OAAO,MAAM,CAAA;SACd;KACF;AACH,CAAC,CAAA"}
|
package/dist/es/lib/utils.js
CHANGED
@@ -1,35 +1,25 @@
|
|
1
|
-
export const getNodeTextContent = (node) => {
|
2
|
-
let textContent = '';
|
3
|
-
// Traverse the node and its descendants
|
4
|
-
node.forEach((child) => {
|
5
|
-
if (child.isText) {
|
6
|
-
// If the child is a text node, add its text content
|
7
|
-
textContent += child.text;
|
8
|
-
}
|
9
|
-
else {
|
10
|
-
// If the child is not a text node, recursively collect text content
|
11
|
-
textContent += getNodeTextContent(child);
|
12
|
-
}
|
13
|
-
});
|
14
|
-
return textContent;
|
15
|
-
};
|
16
|
-
export const findPluginByKey = (state, keyName) => {
|
17
|
-
for (let i = 0; i < state.plugins.length; i++) {
|
18
|
-
const plugin = state.plugins[i];
|
19
|
-
if (plugin.key === keyName + '$') {
|
20
|
-
return plugin;
|
21
|
-
}
|
22
|
-
}
|
23
|
-
return null;
|
24
|
-
};
|
25
1
|
export const getParentNode = (state, pos) => {
|
26
2
|
const resolvedPos = state.doc.resolve(pos);
|
27
3
|
for (let depth = resolvedPos.depth; depth > 0; depth--) {
|
28
4
|
const parent = resolvedPos.node(depth);
|
29
|
-
if (parent.
|
5
|
+
if (parent.isText === false) {
|
6
|
+
if (parent.type == state.schema.nodes.paragraph) {
|
7
|
+
const grandParent = resolvedPos.node(depth - 1);
|
8
|
+
if (grandParent.type == state.schema.nodes.footnote) {
|
9
|
+
return grandParent;
|
10
|
+
}
|
11
|
+
else {
|
12
|
+
return parent;
|
13
|
+
}
|
14
|
+
}
|
30
15
|
return parent;
|
31
16
|
}
|
32
17
|
}
|
33
18
|
return null;
|
34
19
|
};
|
20
|
+
export const decodeHTMLEntities = (text) => {
|
21
|
+
const el = document.createElement('div');
|
22
|
+
el.innerHTML = text;
|
23
|
+
return el.innerText;
|
24
|
+
};
|
35
25
|
//# sourceMappingURL=utils.js.map
|
package/dist/es/lib/utils.js.map
CHANGED
@@ -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":"AAaA,MAAM,CAAC,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;AAED,MAAM,CAAC,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"}
|
@@ -7,9 +7,12 @@
|
|
7
7
|
*
|
8
8
|
* The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
|
9
9
|
*
|
10
|
-
* All portions of the code written by Atypon Systems LLC are Copyright (c)
|
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
|
-
|
14
|
-
|
15
|
-
|
12
|
+
import React from 'react';
|
13
|
+
interface ContentProps {
|
14
|
+
content: string;
|
15
|
+
isEquation?: boolean;
|
16
|
+
}
|
17
|
+
declare const SnippetContent: React.FC<ContentProps>;
|
18
|
+
export default SnippetContent;
|
@@ -0,0 +1,22 @@
|
|
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 { NodeAttrChange, NodeChange, TextChange } from '@manuscripts/track-changes-plugin';
|
13
|
+
interface SnippetData {
|
14
|
+
operation: string;
|
15
|
+
nodeName: string;
|
16
|
+
content: string | null;
|
17
|
+
isEquation?: boolean;
|
18
|
+
}
|
19
|
+
export declare const handleTextChange: (suggestion: TextChange, view: any, dataTracked: any) => SnippetData | null;
|
20
|
+
export declare const handleNodeChange: (suggestion: NodeChange | NodeAttrChange, view: any, doc: any, dataTracked: any) => SnippetData | null;
|
21
|
+
export declare const handleUnknownChange: () => SnippetData;
|
22
|
+
export {};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { ManuscriptEditorState, ManuscriptNode } from '@manuscripts/transform';
|
2
|
+
export declare class NodeTextContentRetriever {
|
3
|
+
private state;
|
4
|
+
constructor(state: ManuscriptEditorState);
|
5
|
+
/**
|
6
|
+
* Recursively retrieves text content from a ManuscriptNode.
|
7
|
+
*/
|
8
|
+
getNodeTextContent(node: ManuscriptNode): string;
|
9
|
+
/**
|
10
|
+
* Retrieves the text content of the first child node.
|
11
|
+
*/
|
12
|
+
getFirstChildContent(node: ManuscriptNode): string;
|
13
|
+
/**
|
14
|
+
* Retrieves the text content from a bibliography node.
|
15
|
+
*/
|
16
|
+
getContentFromBibliography(id: string, node: ManuscriptNode): string;
|
17
|
+
/**
|
18
|
+
* Retrieves the content of an equation node.
|
19
|
+
*/
|
20
|
+
getEquationContent(node: ManuscriptNode): string;
|
21
|
+
/**
|
22
|
+
* Retrieves the label of a figure node.
|
23
|
+
*/
|
24
|
+
getFigureLabel(node: ManuscriptNode): string;
|
25
|
+
/**
|
26
|
+
* Finds a footnote node by its ID.
|
27
|
+
*/
|
28
|
+
private findFootnoteById;
|
29
|
+
/**
|
30
|
+
* Retrieves the inline footnote content.
|
31
|
+
*/
|
32
|
+
getInlineFootnoteContent(doc: ManuscriptNode, attrs: Record<any, any>): string;
|
33
|
+
/**
|
34
|
+
* Retrieves the text content of a footnote node with decoration.
|
35
|
+
*/
|
36
|
+
getFootnoteContent(node: ManuscriptNode): string;
|
37
|
+
}
|
@@ -9,12 +9,6 @@
|
|
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 { EditorState, Plugin } from 'prosemirror-state';
|
14
|
-
interface ExtendedPlugin extends Plugin {
|
15
|
-
key: string;
|
16
|
-
}
|
17
|
-
export declare const getNodeTextContent: (node: ManuscriptNode) => string;
|
18
|
-
export declare const findPluginByKey: (state: ManuscriptEditorState, keyName: string) => ExtendedPlugin | null;
|
12
|
+
import { EditorState } from 'prosemirror-state';
|
19
13
|
export declare const getParentNode: (state: EditorState, pos: number) => import("prosemirror-model").Node | null;
|
20
|
-
export
|
14
|
+
export declare const decodeHTMLEntities: (text: string) => string;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@manuscripts/article-editor",
|
3
|
-
"version": "3.3.
|
3
|
+
"version": "3.3.2-LEAN-3958.1",
|
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.3.1-LEAN-
|
38
|
+
"@manuscripts/body-editor": "2.3.1-LEAN-3958.0",
|
39
39
|
"@manuscripts/json-schema": "2.2.11",
|
40
40
|
"@manuscripts/library": "1.3.11",
|
41
41
|
"@manuscripts/style-guide": "2.0.21",
|
42
42
|
"@manuscripts/track-changes-plugin": "1.8.0",
|
43
|
-
"@manuscripts/transform": "3.0.7-LEAN-
|
43
|
+
"@manuscripts/transform": "3.0.7-LEAN-3958.0",
|
44
44
|
"@popperjs/core": "^2.11.8",
|
45
45
|
"@reach/tabs": "^0.18.0",
|
46
46
|
"@types/use-sync-external-store": "^0.0.6",
|
@@ -1,49 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
/*!
|
3
|
-
* 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.
|
4
|
-
*
|
5
|
-
* 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.
|
6
|
-
*
|
7
|
-
* The Original Code is manuscripts-frontend.
|
8
|
-
*
|
9
|
-
* The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
|
10
|
-
*
|
11
|
-
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
|
12
|
-
*/
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
14
|
-
exports.getFootnoteText = exports.getInlineFootnoteContent = exports.findFootnoteById = void 0;
|
15
|
-
const utils_1 = require("./utils");
|
16
|
-
const findFootnoteById = (doc, id) => {
|
17
|
-
let footnoteNode = null;
|
18
|
-
doc.descendants((node) => {
|
19
|
-
if (node.type.name === 'footnote' && node.attrs.id === id) {
|
20
|
-
footnoteNode = node;
|
21
|
-
return false; // stop traversal
|
22
|
-
}
|
23
|
-
if (footnoteNode) {
|
24
|
-
return false;
|
25
|
-
}
|
26
|
-
return true; // continue traversal
|
27
|
-
});
|
28
|
-
return footnoteNode;
|
29
|
-
};
|
30
|
-
exports.findFootnoteById = findFootnoteById;
|
31
|
-
const getInlineFootnoteContent = (doc, attrs) => {
|
32
|
-
let footnote = null;
|
33
|
-
if (attrs.rids && attrs.rids.length > 0) {
|
34
|
-
footnote = (0, exports.findFootnoteById)(doc, attrs.rids[0]);
|
35
|
-
}
|
36
|
-
return `<sup class="footnote-decoration">${attrs.contents ? attrs.contents : ''}</sup>${footnote ? footnote.textContent : ''}`;
|
37
|
-
};
|
38
|
-
exports.getInlineFootnoteContent = getInlineFootnoteContent;
|
39
|
-
const getFootnoteText = (state, node) => {
|
40
|
-
const footnotesPlugin = (0, utils_1.findPluginByKey)(state, 'footnotes');
|
41
|
-
const pluginState = footnotesPlugin?.getState(state);
|
42
|
-
let decorationText = '';
|
43
|
-
if (pluginState) {
|
44
|
-
decorationText = pluginState.labels.get(node.attrs.id);
|
45
|
-
}
|
46
|
-
return `<sup class="footnote-decoration">${decorationText ? decorationText : ''}</sup>${(0, utils_1.getNodeTextContent)(node)}`;
|
47
|
-
};
|
48
|
-
exports.getFootnoteText = getFootnoteText;
|
49
|
-
//# sourceMappingURL=footnotes.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"footnotes.js","sourceRoot":"","sources":["../../../src/lib/footnotes.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAIH,mCAA6D;AAEtD,MAAM,gBAAgB,GAAG,CAC9B,GAAmB,EACnB,EAAU,EACa,EAAE;IACzB,IAAI,YAAY,GAA0B,IAAI,CAAA;IAE9C,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;QACvB,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE;YACzD,YAAY,GAAG,IAAI,CAAA;YACnB,OAAO,KAAK,CAAA,CAAC,iBAAiB;SAC/B;QACD,IAAI,YAAY,EAAE;YAChB,OAAO,KAAK,CAAA;SACb;QACD,OAAO,IAAI,CAAA,CAAC,qBAAqB;IACnC,CAAC,CAAC,CAAA;IACF,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA;AAjBY,QAAA,gBAAgB,oBAiB5B;AAEM,MAAM,wBAAwB,GAAG,CACtC,GAAmB,EACnB,KAAuB,EACf,EAAE;IACV,IAAI,QAAQ,GAAG,IAAI,CAAA;IACnB,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QACvC,QAAQ,GAAG,IAAA,wBAAgB,EAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;KAChD;IACD,OAAO,oCACL,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EACpC,SAAS,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;AACjD,CAAC,CAAA;AAXY,QAAA,wBAAwB,4BAWpC;AAEM,MAAM,eAAe,GAAG,CAC7B,KAA4B,EAC5B,IAAoB,EACpB,EAAE;IACF,MAAM,eAAe,GAAG,IAAA,uBAAe,EAAC,KAAK,EAAE,WAAW,CAAC,CAAA;IAC3D,MAAM,WAAW,GAAG,eAAe,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAA;IACpD,IAAI,cAAc,GAAG,EAAE,CAAA;IACvB,IAAI,WAAW,EAAE;QACf,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;KACvD;IACD,OAAO,oCACL,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EACpC,SAAS,IAAA,0BAAkB,EAAC,IAAI,CAAC,EAAE,CAAA;AACrC,CAAC,CAAA;AAbY,QAAA,eAAe,mBAa3B"}
|
package/dist/es/lib/footnotes.js
DELETED
@@ -1,43 +0,0 @@
|
|
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) 2019 Atypon Systems LLC. All Rights Reserved.
|
11
|
-
*/
|
12
|
-
import { findPluginByKey, getNodeTextContent } from './utils';
|
13
|
-
export const findFootnoteById = (doc, id) => {
|
14
|
-
let footnoteNode = null;
|
15
|
-
doc.descendants((node) => {
|
16
|
-
if (node.type.name === 'footnote' && node.attrs.id === id) {
|
17
|
-
footnoteNode = node;
|
18
|
-
return false; // stop traversal
|
19
|
-
}
|
20
|
-
if (footnoteNode) {
|
21
|
-
return false;
|
22
|
-
}
|
23
|
-
return true; // continue traversal
|
24
|
-
});
|
25
|
-
return footnoteNode;
|
26
|
-
};
|
27
|
-
export const getInlineFootnoteContent = (doc, attrs) => {
|
28
|
-
let footnote = null;
|
29
|
-
if (attrs.rids && attrs.rids.length > 0) {
|
30
|
-
footnote = findFootnoteById(doc, attrs.rids[0]);
|
31
|
-
}
|
32
|
-
return `<sup class="footnote-decoration">${attrs.contents ? attrs.contents : ''}</sup>${footnote ? footnote.textContent : ''}`;
|
33
|
-
};
|
34
|
-
export const getFootnoteText = (state, node) => {
|
35
|
-
const footnotesPlugin = findPluginByKey(state, 'footnotes');
|
36
|
-
const pluginState = footnotesPlugin?.getState(state);
|
37
|
-
let decorationText = '';
|
38
|
-
if (pluginState) {
|
39
|
-
decorationText = pluginState.labels.get(node.attrs.id);
|
40
|
-
}
|
41
|
-
return `<sup class="footnote-decoration">${decorationText ? decorationText : ''}</sup>${getNodeTextContent(node)}`;
|
42
|
-
};
|
43
|
-
//# sourceMappingURL=footnotes.js.map
|
@@ -1 +0,0 @@
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