@manuscripts/transform 3.0.24 → 3.0.26-LEAN-3837.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/jats/importer/jats-dom-parser.js +1 -6
- package/dist/cjs/jats/importer/jats-transformations.js +20 -1
- package/dist/cjs/jats/importer/parse-jats-article.js +1 -0
- package/dist/cjs/schema/migration/migration-scripts/3.0.22.js +21 -0
- package/dist/cjs/schema/migration/migration-scripts/index.js +2 -0
- package/dist/cjs/schema/nodes/table.js +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/es/jats/importer/jats-dom-parser.js +1 -6
- package/dist/es/jats/importer/jats-transformations.js +18 -0
- package/dist/es/jats/importer/parse-jats-article.js +2 -1
- package/dist/es/schema/migration/migration-scripts/3.0.22.js +19 -0
- package/dist/es/schema/migration/migration-scripts/index.js +2 -0
- package/dist/es/schema/nodes/table.js +1 -1
- package/dist/es/version.js +1 -1
- package/dist/types/jats/importer/jats-transformations.d.ts +1 -0
- package/dist/types/schema/migration/migration-scripts/3.0.22.d.ts +8 -0
- package/dist/types/schema/migration/migration-scripts/index.d.ts +2 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -443,7 +443,7 @@ class JATSDOMParser {
|
|
|
443
443
|
{
|
|
444
444
|
tag: 'caption',
|
|
445
445
|
node: 'figcaption',
|
|
446
|
-
context: 'figure_element/',
|
|
446
|
+
context: 'figure_element/|table_element/',
|
|
447
447
|
getContent: (node, schema) => {
|
|
448
448
|
const element = node;
|
|
449
449
|
const content = [];
|
|
@@ -462,11 +462,6 @@ class JATSDOMParser {
|
|
|
462
462
|
return prosemirror_model_1.Fragment.from(content);
|
|
463
463
|
},
|
|
464
464
|
},
|
|
465
|
-
{
|
|
466
|
-
tag: 'caption',
|
|
467
|
-
node: 'figcaption',
|
|
468
|
-
context: 'table_element/',
|
|
469
|
-
},
|
|
470
465
|
{
|
|
471
466
|
tag: 'caption',
|
|
472
467
|
node: 'figcaption',
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.fixTables = exports.orderTableFootnote = exports.moveReferencesToBackmatter = exports.createSupplementaryMaterialsSection = exports.createKeywordsSection = exports.moveCaptionsToEnd = exports.createBackmatter = exports.createAbstracts = exports.createBody = exports.createBoxedElementSection = exports.moveAbstracts = exports.moveAffiliations = exports.moveContributors = exports.moveAwards = exports.moveAuthorNotes = exports.moveTitle = void 0;
|
|
18
|
+
exports.fixTables = exports.orderTableFootnote = exports.moveReferencesToBackmatter = exports.createSupplementaryMaterialsSection = exports.createKeywordsSection = exports.moveCaptionsToEnd = exports.createBackmatter = exports.createAbstracts = exports.createBody = exports.createBoxedElementSection = exports.moveAbstracts = exports.moveAffiliations = exports.moveContributors = exports.moveAwards = exports.moveAuthorNotes = exports.moveTitle = exports.addMissingCaptions = void 0;
|
|
19
19
|
const deafults_1 = require("../../lib/deafults");
|
|
20
20
|
const jats_parser_utils_1 = require("./jats-parser-utils");
|
|
21
21
|
const removeNodeFromParent = (node) => node.parentNode && node.parentNode.removeChild(node);
|
|
@@ -25,6 +25,25 @@ const createSectionGroup = (type, createElement) => {
|
|
|
25
25
|
sec.setAttribute('sec-type', type);
|
|
26
26
|
return sec;
|
|
27
27
|
};
|
|
28
|
+
const addMissingCaptions = (doc, createElement) => {
|
|
29
|
+
const elements = doc.querySelectorAll('fig, table-wrap');
|
|
30
|
+
for (const element of elements) {
|
|
31
|
+
let caption = element.querySelector('caption');
|
|
32
|
+
if (!caption) {
|
|
33
|
+
caption = createElement('caption');
|
|
34
|
+
element.nodeName === 'fig'
|
|
35
|
+
? element.appendChild(caption)
|
|
36
|
+
: element.prepend(caption);
|
|
37
|
+
}
|
|
38
|
+
if (!caption.querySelector('title')) {
|
|
39
|
+
caption.prepend(createElement('title'));
|
|
40
|
+
}
|
|
41
|
+
if (!caption.querySelector('p')) {
|
|
42
|
+
caption.appendChild(createElement('p'));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.addMissingCaptions = addMissingCaptions;
|
|
28
47
|
const moveTitle = (front, createElement) => {
|
|
29
48
|
var _a, _b;
|
|
30
49
|
let title = front.querySelector('article-meta > title-group > article-title');
|
|
@@ -29,6 +29,7 @@ const processJATS = (doc, sectionCategories) => {
|
|
|
29
29
|
if (!front) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
+
(0, jats_transformations_1.addMissingCaptions)(doc, createElement);
|
|
32
33
|
(0, jats_transformations_1.moveTitle)(front, createElement);
|
|
33
34
|
(0, jats_transformations_1.moveContributors)(front, createElement);
|
|
34
35
|
(0, jats_transformations_1.moveAffiliations)(front, createElement);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Migration3021 {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.fromVersion = '3.0.21';
|
|
6
|
+
this.toVersion = '3.0.22';
|
|
7
|
+
}
|
|
8
|
+
migrateNode(node) {
|
|
9
|
+
if (node.type === 'table_header' || node.type === 'table_cell') {
|
|
10
|
+
return Object.assign(Object.assign({}, node), { content: [
|
|
11
|
+
{
|
|
12
|
+
type: 'paragraph',
|
|
13
|
+
attrs: {},
|
|
14
|
+
content: node.content,
|
|
15
|
+
},
|
|
16
|
+
] });
|
|
17
|
+
}
|
|
18
|
+
return node;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.default = Migration3021;
|
|
@@ -22,10 +22,12 @@ const _1_2_5_1 = __importDefault(require("./1.2.5"));
|
|
|
22
22
|
const _2_3_22_1 = __importDefault(require("./2.3.22"));
|
|
23
23
|
const _3_0_12_1 = require("./3.0.12");
|
|
24
24
|
const _3_0_21_1 = __importDefault(require("./3.0.21"));
|
|
25
|
+
const _3_0_22_1 = __importDefault(require("./3.0.22"));
|
|
25
26
|
const migrations = [
|
|
26
27
|
new _1_2_5_1.default(),
|
|
27
28
|
new _2_3_22_1.default(),
|
|
28
29
|
new _3_0_12_1.Migration3012(),
|
|
29
30
|
new _3_0_21_1.default(),
|
|
31
|
+
new _3_0_22_1.default(),
|
|
30
32
|
];
|
|
31
33
|
exports.default = migrations;
|
|
@@ -37,7 +37,7 @@ function createCellAttribute(attributeName, defaultValue = null, customGetFromDO
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
const tableOptions = {
|
|
40
|
-
cellContent: '
|
|
40
|
+
cellContent: 'paragraph+',
|
|
41
41
|
cellAttributes: {
|
|
42
42
|
placeholder: createCellAttribute('data-placeholder-text', 'Data', (dom) => dom.getAttribute('data-placeholder-text') || ''),
|
|
43
43
|
valign: createCellAttribute('valign'),
|
package/dist/cjs/version.js
CHANGED
|
@@ -437,7 +437,7 @@ export class JATSDOMParser {
|
|
|
437
437
|
{
|
|
438
438
|
tag: 'caption',
|
|
439
439
|
node: 'figcaption',
|
|
440
|
-
context: 'figure_element/',
|
|
440
|
+
context: 'figure_element/|table_element/',
|
|
441
441
|
getContent: (node, schema) => {
|
|
442
442
|
const element = node;
|
|
443
443
|
const content = [];
|
|
@@ -456,11 +456,6 @@ export class JATSDOMParser {
|
|
|
456
456
|
return Fragment.from(content);
|
|
457
457
|
},
|
|
458
458
|
},
|
|
459
|
-
{
|
|
460
|
-
tag: 'caption',
|
|
461
|
-
node: 'figcaption',
|
|
462
|
-
context: 'table_element/',
|
|
463
|
-
},
|
|
464
459
|
{
|
|
465
460
|
tag: 'caption',
|
|
466
461
|
node: 'figcaption',
|
|
@@ -22,6 +22,24 @@ const createSectionGroup = (type, createElement) => {
|
|
|
22
22
|
sec.setAttribute('sec-type', type);
|
|
23
23
|
return sec;
|
|
24
24
|
};
|
|
25
|
+
export const addMissingCaptions = (doc, createElement) => {
|
|
26
|
+
const elements = doc.querySelectorAll('fig, table-wrap');
|
|
27
|
+
for (const element of elements) {
|
|
28
|
+
let caption = element.querySelector('caption');
|
|
29
|
+
if (!caption) {
|
|
30
|
+
caption = createElement('caption');
|
|
31
|
+
element.nodeName === 'fig'
|
|
32
|
+
? element.appendChild(caption)
|
|
33
|
+
: element.prepend(caption);
|
|
34
|
+
}
|
|
35
|
+
if (!caption.querySelector('title')) {
|
|
36
|
+
caption.prepend(createElement('title'));
|
|
37
|
+
}
|
|
38
|
+
if (!caption.querySelector('p')) {
|
|
39
|
+
caption.appendChild(createElement('p'));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
25
43
|
export const moveTitle = (front, createElement) => {
|
|
26
44
|
var _a, _b;
|
|
27
45
|
let title = front.querySelector('article-meta > title-group > article-title');
|
|
@@ -18,7 +18,7 @@ import { markComments } from './jats-comments';
|
|
|
18
18
|
import { JATSDOMParser } from './jats-dom-parser';
|
|
19
19
|
import { parseJournal } from './jats-journal-meta-parser';
|
|
20
20
|
import { updateDocumentIDs } from './jats-parser-utils';
|
|
21
|
-
import { createAbstracts, createBackmatter, createBody, createBoxedElementSection, createKeywordsSection, createSupplementaryMaterialsSection, fixTables, moveAffiliations, moveAuthorNotes, moveAwards, moveCaptionsToEnd, moveContributors, moveReferencesToBackmatter, moveTitle, orderTableFootnote, } from './jats-transformations';
|
|
21
|
+
import { addMissingCaptions, createAbstracts, createBackmatter, createBody, createBoxedElementSection, createKeywordsSection, createSupplementaryMaterialsSection, fixTables, moveAffiliations, moveAuthorNotes, moveAwards, moveCaptionsToEnd, moveContributors, moveReferencesToBackmatter, moveTitle, orderTableFootnote, } from './jats-transformations';
|
|
22
22
|
const processJATS = (doc, sectionCategories) => {
|
|
23
23
|
const createElement = createElementFn(doc);
|
|
24
24
|
markComments(doc);
|
|
@@ -26,6 +26,7 @@ const processJATS = (doc, sectionCategories) => {
|
|
|
26
26
|
if (!front) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
+
addMissingCaptions(doc, createElement);
|
|
29
30
|
moveTitle(front, createElement);
|
|
30
31
|
moveContributors(front, createElement);
|
|
31
32
|
moveAffiliations(front, createElement);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class Migration3021 {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.fromVersion = '3.0.21';
|
|
4
|
+
this.toVersion = '3.0.22';
|
|
5
|
+
}
|
|
6
|
+
migrateNode(node) {
|
|
7
|
+
if (node.type === 'table_header' || node.type === 'table_cell') {
|
|
8
|
+
return Object.assign(Object.assign({}, node), { content: [
|
|
9
|
+
{
|
|
10
|
+
type: 'paragraph',
|
|
11
|
+
attrs: {},
|
|
12
|
+
content: node.content,
|
|
13
|
+
},
|
|
14
|
+
] });
|
|
15
|
+
}
|
|
16
|
+
return node;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export default Migration3021;
|
|
@@ -17,10 +17,12 @@ import Migration125 from './1.2.5';
|
|
|
17
17
|
import Migration2322 from './2.3.22';
|
|
18
18
|
import { Migration3012 } from './3.0.12';
|
|
19
19
|
import Migration3021 from './3.0.21';
|
|
20
|
+
import Migration3022 from './3.0.22';
|
|
20
21
|
const migrations = [
|
|
21
22
|
new Migration125(),
|
|
22
23
|
new Migration2322(),
|
|
23
24
|
new Migration3012(),
|
|
24
25
|
new Migration3021(),
|
|
26
|
+
new Migration3022(),
|
|
25
27
|
];
|
|
26
28
|
export default migrations;
|
|
@@ -34,7 +34,7 @@ function createCellAttribute(attributeName, defaultValue = null, customGetFromDO
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
const tableOptions = {
|
|
37
|
-
cellContent: '
|
|
37
|
+
cellContent: 'paragraph+',
|
|
38
38
|
cellAttributes: {
|
|
39
39
|
placeholder: createCellAttribute('data-placeholder-text', 'Data', (dom) => dom.getAttribute('data-placeholder-text') || ''),
|
|
40
40
|
valign: createCellAttribute('valign'),
|
package/dist/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "3.0.
|
|
1
|
+
export const VERSION = "3.0.26-LEAN-3837.1";
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { SectionCategory } from '../../schema';
|
|
17
17
|
export type CreateElement = (tagName: string) => HTMLElement;
|
|
18
|
+
export declare const addMissingCaptions: (doc: Document, createElement: CreateElement) => void;
|
|
18
19
|
export declare const moveTitle: (front: Element, createElement: CreateElement) => void;
|
|
19
20
|
export declare const moveAuthorNotes: (front: Element, createElement: CreateElement) => void;
|
|
20
21
|
export declare const moveAwards: (front: Element) => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { JSONNode } from '../migrate';
|
|
2
|
+
import { MigrationScript } from '../migration-script';
|
|
3
|
+
declare class Migration3021 implements MigrationScript {
|
|
4
|
+
fromVersion: string;
|
|
5
|
+
toVersion: string;
|
|
6
|
+
migrateNode(node: JSONNode): JSONNode;
|
|
7
|
+
}
|
|
8
|
+
export default Migration3021;
|
|
@@ -17,5 +17,6 @@ import Migration125 from './1.2.5';
|
|
|
17
17
|
import Migration2322 from './2.3.22';
|
|
18
18
|
import { Migration3012 } from './3.0.12';
|
|
19
19
|
import Migration3021 from './3.0.21';
|
|
20
|
-
|
|
20
|
+
import Migration3022 from './3.0.22';
|
|
21
|
+
declare const migrations: (Migration125 | Migration2322 | Migration3012 | Migration3021 | Migration3022)[];
|
|
21
22
|
export default migrations;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.0.
|
|
1
|
+
export declare const VERSION = "3.0.26-LEAN-3837.1";
|
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": "3.0.
|
|
4
|
+
"version": "3.0.26-LEAN-3837.1",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|