@manuscripts/transform 2.1.1-LEAN-3092-3 → 2.1.1-LEAN-3092-7
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/jats/importer/jats-body-dom-parser.js +3 -3
- package/dist/cjs/jats/importer/jats-parser-utils.js +6 -0
- package/dist/cjs/schema/nodes/inline_equation.js +4 -2
- package/dist/es/jats/importer/jats-body-dom-parser.js +3 -3
- package/dist/es/jats/importer/jats-parser-utils.js +6 -0
- package/dist/es/schema/nodes/inline_equation.js +4 -2
- package/dist/types/schema/nodes/inline_equation.d.ts +1 -0
- package/package.json +1 -1
|
@@ -40,6 +40,7 @@ const chooseContentType = (graphicNode) => {
|
|
|
40
40
|
const getEquationContent = (p) => {
|
|
41
41
|
var _a;
|
|
42
42
|
const element = p;
|
|
43
|
+
const id = element.getAttribute('id');
|
|
43
44
|
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
44
45
|
let contents = '';
|
|
45
46
|
let format = '';
|
|
@@ -56,7 +57,7 @@ const getEquationContent = (p) => {
|
|
|
56
57
|
break;
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
|
-
return { format, contents };
|
|
60
|
+
return { id, format, contents };
|
|
60
61
|
};
|
|
61
62
|
const marks = [
|
|
62
63
|
{
|
|
@@ -184,9 +185,8 @@ const nodes = [
|
|
|
184
185
|
getContent: (node, schema) => {
|
|
185
186
|
const element = node;
|
|
186
187
|
const attrs = getEquationContent(element);
|
|
187
|
-
const id = element.getAttribute('id');
|
|
188
188
|
return prosemirror_model_1.Fragment.from([
|
|
189
|
-
schema.nodes.equation.createChecked(Object.assign({
|
|
189
|
+
schema.nodes.equation.createChecked(Object.assign({}, attrs)),
|
|
190
190
|
]);
|
|
191
191
|
},
|
|
192
192
|
},
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.htmlFromJatsNode = exports.updateDocumentIDs = void 0;
|
|
19
|
+
const crypto_1 = require("crypto");
|
|
20
|
+
const schema_1 = require("../../schema");
|
|
19
21
|
const transformer_1 = require("../../transformer");
|
|
20
22
|
const updateDocumentIDs = (node, replacements) => {
|
|
21
23
|
const warnings = [];
|
|
@@ -30,6 +32,10 @@ function recurseDoc(node, fn) {
|
|
|
30
32
|
node.descendants((n) => fn(n));
|
|
31
33
|
}
|
|
32
34
|
const updateNodeID = (node, replacements, warnings) => {
|
|
35
|
+
if (node.type === schema_1.schema.nodes.inline_equation) {
|
|
36
|
+
node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `InlineMathFragment:${(0, crypto_1.randomUUID)()}` });
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
33
39
|
if (!('id' in node.attrs)) {
|
|
34
40
|
return;
|
|
35
41
|
}
|
|
@@ -20,10 +20,10 @@ exports.inlineEquation = {
|
|
|
20
20
|
attrs: {
|
|
21
21
|
dataTracked: { default: null },
|
|
22
22
|
comments: { default: null },
|
|
23
|
+
id: { default: '' },
|
|
23
24
|
contents: { default: '' },
|
|
24
25
|
format: { default: '' },
|
|
25
26
|
},
|
|
26
|
-
selectable: false,
|
|
27
27
|
atom: true,
|
|
28
28
|
inline: true,
|
|
29
29
|
draggable: true,
|
|
@@ -35,6 +35,7 @@ exports.inlineEquation = {
|
|
|
35
35
|
const dom = p;
|
|
36
36
|
return {
|
|
37
37
|
format: dom.getAttribute('data-equation-format'),
|
|
38
|
+
id: dom.getAttribute('id'),
|
|
38
39
|
contents: dom.innerHTML,
|
|
39
40
|
};
|
|
40
41
|
},
|
|
@@ -42,8 +43,9 @@ exports.inlineEquation = {
|
|
|
42
43
|
],
|
|
43
44
|
toDOM: (node) => {
|
|
44
45
|
const inlineEquationNode = node;
|
|
45
|
-
const { contents, format } = inlineEquationNode.attrs;
|
|
46
|
+
const { id, contents, format } = inlineEquationNode.attrs;
|
|
46
47
|
const dom = document.createElement('span');
|
|
48
|
+
dom.setAttribute('id', id);
|
|
47
49
|
dom.classList.add('MPInlineMathFragment');
|
|
48
50
|
if (format) {
|
|
49
51
|
dom.setAttribute('data-equation-format', format);
|
|
@@ -34,6 +34,7 @@ const chooseContentType = (graphicNode) => {
|
|
|
34
34
|
const getEquationContent = (p) => {
|
|
35
35
|
var _a;
|
|
36
36
|
const element = p;
|
|
37
|
+
const id = element.getAttribute('id');
|
|
37
38
|
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
38
39
|
let contents = '';
|
|
39
40
|
let format = '';
|
|
@@ -50,7 +51,7 @@ const getEquationContent = (p) => {
|
|
|
50
51
|
break;
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
|
-
return { format, contents };
|
|
54
|
+
return { id, format, contents };
|
|
54
55
|
};
|
|
55
56
|
const marks = [
|
|
56
57
|
{
|
|
@@ -178,9 +179,8 @@ const nodes = [
|
|
|
178
179
|
getContent: (node, schema) => {
|
|
179
180
|
const element = node;
|
|
180
181
|
const attrs = getEquationContent(element);
|
|
181
|
-
const id = element.getAttribute('id');
|
|
182
182
|
return Fragment.from([
|
|
183
|
-
schema.nodes.equation.createChecked(Object.assign({
|
|
183
|
+
schema.nodes.equation.createChecked(Object.assign({}, attrs)),
|
|
184
184
|
]);
|
|
185
185
|
},
|
|
186
186
|
},
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { randomUUID } from 'crypto';
|
|
17
|
+
import { schema } from '../../schema';
|
|
16
18
|
import { generateID, nodeTypesMap } from '../../transformer';
|
|
17
19
|
export const updateDocumentIDs = (node, replacements) => {
|
|
18
20
|
const warnings = [];
|
|
@@ -26,6 +28,10 @@ function recurseDoc(node, fn) {
|
|
|
26
28
|
node.descendants((n) => fn(n));
|
|
27
29
|
}
|
|
28
30
|
const updateNodeID = (node, replacements, warnings) => {
|
|
31
|
+
if (node.type === schema.nodes.inline_equation) {
|
|
32
|
+
node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `InlineMathFragment:${randomUUID()}` });
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
29
35
|
if (!('id' in node.attrs)) {
|
|
30
36
|
return;
|
|
31
37
|
}
|
|
@@ -17,10 +17,10 @@ export const inlineEquation = {
|
|
|
17
17
|
attrs: {
|
|
18
18
|
dataTracked: { default: null },
|
|
19
19
|
comments: { default: null },
|
|
20
|
+
id: { default: '' },
|
|
20
21
|
contents: { default: '' },
|
|
21
22
|
format: { default: '' },
|
|
22
23
|
},
|
|
23
|
-
selectable: false,
|
|
24
24
|
atom: true,
|
|
25
25
|
inline: true,
|
|
26
26
|
draggable: true,
|
|
@@ -32,6 +32,7 @@ export const inlineEquation = {
|
|
|
32
32
|
const dom = p;
|
|
33
33
|
return {
|
|
34
34
|
format: dom.getAttribute('data-equation-format'),
|
|
35
|
+
id: dom.getAttribute('id'),
|
|
35
36
|
contents: dom.innerHTML,
|
|
36
37
|
};
|
|
37
38
|
},
|
|
@@ -39,8 +40,9 @@ export const inlineEquation = {
|
|
|
39
40
|
],
|
|
40
41
|
toDOM: (node) => {
|
|
41
42
|
const inlineEquationNode = node;
|
|
42
|
-
const { contents, format } = inlineEquationNode.attrs;
|
|
43
|
+
const { id, contents, format } = inlineEquationNode.attrs;
|
|
43
44
|
const dom = document.createElement('span');
|
|
45
|
+
dom.setAttribute('id', id);
|
|
44
46
|
dom.classList.add('MPInlineMathFragment');
|
|
45
47
|
if (format) {
|
|
46
48
|
dom.setAttribute('data-equation-format', format);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/transform",
|
|
3
3
|
"description": "ProseMirror transformer for Manuscripts applications",
|
|
4
|
-
"version": "2.1.1-LEAN-3092-
|
|
4
|
+
"version": "2.1.1-LEAN-3092-7",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|