@manuscripts/transform 1.3.5 → 1.3.6-LEAN-2650

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/index.js CHANGED
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.isSectionLabelNode = void 0;
18
+ __exportStar(require("./lib/core-sections"), exports);
18
19
  __exportStar(require("./lib/table-cell-styles"), exports);
19
20
  __exportStar(require("./lib/utils"), exports);
20
21
  __exportStar(require("./mathjax"), exports);
@@ -25,7 +25,7 @@ const createSectionContainer = (type, createElement) => {
25
25
  sectionContainer.setAttribute('sec-type', sectionCategory ? (0, transformer_1.chooseSecType)(sectionCategory) : '');
26
26
  const title = createElement('title');
27
27
  title.textContent = sectionCategory
28
- ? (0, transformer_1.getSectionTitles)(sectionCategory)[0]
28
+ ? (0, transformer_1.getCoreSectionTitles)(sectionCategory)[0]
29
29
  : ' ';
30
30
  sectionContainer.appendChild(title);
31
31
  return sectionContainer;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coreSections = void 0;
4
+ exports.coreSections = [
5
+ {
6
+ _id: 'MPSectionCategory:abstracts',
7
+ name: 'Abstracts',
8
+ desc: 'Abstracts section for grouping',
9
+ objectType: 'MPSectionCategory',
10
+ titles: [],
11
+ priority: 120,
12
+ },
13
+ {
14
+ _id: 'MPSectionCategory:backmatter',
15
+ name: 'Backmatter',
16
+ desc: 'Backmatter section for grouping',
17
+ objectType: 'MPSectionCategory',
18
+ titles: [],
19
+ priority: 170,
20
+ },
21
+ {
22
+ _id: 'MPSectionCategory:body',
23
+ name: 'Body',
24
+ desc: 'Body section for grouping',
25
+ objectType: 'MPSectionCategory',
26
+ titles: [],
27
+ priority: 190,
28
+ },
29
+ ];
@@ -18,10 +18,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.convertMathMLToSVG = void 0;
19
19
  require("mathjax-full/js/util/entities/all");
20
20
  const HTMLAdaptor_1 = require("mathjax-full/js/adaptors/HTMLAdaptor");
21
+ const MmlFactory_1 = require("mathjax-full/js/core/MmlTree/MmlFactory");
21
22
  const HTMLDocument_1 = require("mathjax-full/js/handlers/html/HTMLDocument");
22
23
  const mathml_1 = require("mathjax-full/js/input/mathml");
23
24
  const svg_1 = require("mathjax-full/js/output/svg");
24
25
  const transformer_1 = require("../transformer");
26
+ class ManuscriptsMmlFactory extends MmlFactory_1.MmlFactory {
27
+ constructor() {
28
+ super();
29
+ this.nodeMap.set('image', this.nodeMap.get('none'));
30
+ }
31
+ create(kind, properties = {}, children = []) {
32
+ if (kind === 'image') {
33
+ return this.node['none'](properties, children);
34
+ }
35
+ return this.node[kind](properties, children);
36
+ }
37
+ }
25
38
  class ManuscriptsHTMLAdaptor extends HTMLAdaptor_1.HTMLAdaptor {
26
39
  setAttribute(node, name, value, ns) {
27
40
  if (name !== 'xmlns') {
@@ -37,6 +50,7 @@ const adaptor = new ManuscriptsHTMLAdaptor(window);
37
50
  const doc = new HTMLDocument_1.HTMLDocument(document, adaptor, {
38
51
  InputJax,
39
52
  OutputJax,
53
+ MmlFactory: new ManuscriptsMmlFactory(),
40
54
  });
41
55
  doc.addStyleSheet();
42
56
  const convertMathMLToSVG = (mathml, display) => {
@@ -14,13 +14,10 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
17
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseSecType = exports.chooseJatsFnType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = exports.getSectionTitles = void 0;
22
- const section_categories_json_1 = __importDefault(require("@manuscripts/data/dist/shared/section-categories.json"));
18
+ exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseSecType = exports.chooseJatsFnType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = exports.getCoreSectionTitles = void 0;
23
19
  const json_schema_1 = require("@manuscripts/json-schema");
20
+ const core_sections_1 = require("../lib/core-sections");
24
21
  const schema_1 = require("../schema");
25
22
  const sectionNodeTypes = [
26
23
  schema_1.schema.nodes.bibliography_section,
@@ -29,18 +26,14 @@ const sectionNodeTypes = [
29
26
  schema_1.schema.nodes.section,
30
27
  schema_1.schema.nodes.toc_section,
31
28
  ];
32
- const sectionCategoriesMap = new Map(section_categories_json_1.default.map((section) => [
33
- section._id,
34
- section,
35
- ]));
36
- const getSectionTitles = (sectionCategory) => {
37
- const category = sectionCategoriesMap.get(sectionCategory);
29
+ const getCoreSectionTitles = (sectionCategory) => {
30
+ const category = core_sections_1.coreSections.find((section) => section._id === sectionCategory);
38
31
  if (category) {
39
32
  return category.titles.length ? category.titles : [' '];
40
33
  }
41
- throw new Error(`${sectionCategory} not found in section categories`);
34
+ throw new Error(`${sectionCategory} not found in core sections`);
42
35
  };
43
- exports.getSectionTitles = getSectionTitles;
36
+ exports.getCoreSectionTitles = getCoreSectionTitles;
44
37
  const isAnySectionNode = (node) => sectionNodeTypes.includes(node.type);
45
38
  exports.isAnySectionNode = isAnySectionNode;
46
39
  const chooseSectionNodeType = (category) => {
package/dist/es/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './lib/core-sections';
1
2
  export * from './lib/table-cell-styles';
2
3
  export * from './lib/utils';
3
4
  export * from './mathjax';
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { chooseSectionCategoryByType, chooseSecType, getSectionTitles, } from '../../transformer';
16
+ import { chooseSectionCategoryByType, chooseSecType, getCoreSectionTitles, } from '../../transformer';
17
17
  const removeNodeFromParent = (node) => node.parentNode && node.parentNode.removeChild(node);
18
18
  const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
19
19
  const createSectionContainer = (type, createElement) => {
@@ -22,7 +22,7 @@ const createSectionContainer = (type, createElement) => {
22
22
  sectionContainer.setAttribute('sec-type', sectionCategory ? chooseSecType(sectionCategory) : '');
23
23
  const title = createElement('title');
24
24
  title.textContent = sectionCategory
25
- ? getSectionTitles(sectionCategory)[0]
25
+ ? getCoreSectionTitles(sectionCategory)[0]
26
26
  : ' ';
27
27
  sectionContainer.appendChild(title);
28
28
  return sectionContainer;
@@ -0,0 +1,26 @@
1
+ export const coreSections = [
2
+ {
3
+ _id: 'MPSectionCategory:abstracts',
4
+ name: 'Abstracts',
5
+ desc: 'Abstracts section for grouping',
6
+ objectType: 'MPSectionCategory',
7
+ titles: [],
8
+ priority: 120,
9
+ },
10
+ {
11
+ _id: 'MPSectionCategory:backmatter',
12
+ name: 'Backmatter',
13
+ desc: 'Backmatter section for grouping',
14
+ objectType: 'MPSectionCategory',
15
+ titles: [],
16
+ priority: 170,
17
+ },
18
+ {
19
+ _id: 'MPSectionCategory:body',
20
+ name: 'Body',
21
+ desc: 'Body section for grouping',
22
+ objectType: 'MPSectionCategory',
23
+ titles: [],
24
+ priority: 190,
25
+ },
26
+ ];
@@ -15,10 +15,23 @@
15
15
  */
16
16
  import 'mathjax-full/js/util/entities/all';
17
17
  import { HTMLAdaptor } from 'mathjax-full/js/adaptors/HTMLAdaptor';
18
+ import { MmlFactory } from 'mathjax-full/js/core/MmlTree/MmlFactory';
18
19
  import { HTMLDocument } from 'mathjax-full/js/handlers/html/HTMLDocument';
19
20
  import { MathML } from 'mathjax-full/js/input/mathml';
20
21
  import { SVG } from 'mathjax-full/js/output/svg';
21
22
  import { xmlSerializer } from '../transformer';
23
+ class ManuscriptsMmlFactory extends MmlFactory {
24
+ constructor() {
25
+ super();
26
+ this.nodeMap.set('image', this.nodeMap.get('none'));
27
+ }
28
+ create(kind, properties = {}, children = []) {
29
+ if (kind === 'image') {
30
+ return this.node['none'](properties, children);
31
+ }
32
+ return this.node[kind](properties, children);
33
+ }
34
+ }
22
35
  class ManuscriptsHTMLAdaptor extends HTMLAdaptor {
23
36
  setAttribute(node, name, value, ns) {
24
37
  if (name !== 'xmlns') {
@@ -34,6 +47,7 @@ const adaptor = new ManuscriptsHTMLAdaptor(window);
34
47
  const doc = new HTMLDocument(document, adaptor, {
35
48
  InputJax,
36
49
  OutputJax,
50
+ MmlFactory: new ManuscriptsMmlFactory(),
37
51
  });
38
52
  doc.addStyleSheet();
39
53
  export const convertMathMLToSVG = (mathml, display) => {
@@ -13,8 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import sectionCategories from '@manuscripts/data/dist/shared/section-categories.json';
17
- import { ObjectTypes, } from '@manuscripts/json-schema';
16
+ import { ObjectTypes } from '@manuscripts/json-schema';
17
+ import { coreSections } from '../lib/core-sections';
18
18
  import { schema } from '../schema';
19
19
  const sectionNodeTypes = [
20
20
  schema.nodes.bibliography_section,
@@ -23,16 +23,12 @@ const sectionNodeTypes = [
23
23
  schema.nodes.section,
24
24
  schema.nodes.toc_section,
25
25
  ];
26
- const sectionCategoriesMap = new Map(sectionCategories.map((section) => [
27
- section._id,
28
- section,
29
- ]));
30
- export const getSectionTitles = (sectionCategory) => {
31
- const category = sectionCategoriesMap.get(sectionCategory);
26
+ export const getCoreSectionTitles = (sectionCategory) => {
27
+ const category = coreSections.find((section) => section._id === sectionCategory);
32
28
  if (category) {
33
29
  return category.titles.length ? category.titles : [' '];
34
30
  }
35
- throw new Error(`${sectionCategory} not found in section categories`);
31
+ throw new Error(`${sectionCategory} not found in core sections`);
36
32
  };
37
33
  export const isAnySectionNode = (node) => sectionNodeTypes.includes(node.type);
38
34
  export const chooseSectionNodeType = (category) => {
@@ -1,3 +1,4 @@
1
+ export * from './lib/core-sections';
1
2
  export * from './lib/table-cell-styles';
2
3
  export * from './lib/utils';
3
4
  export * from './mathjax';
@@ -0,0 +1,8 @@
1
+ export declare const coreSections: {
2
+ _id: string;
3
+ name: string;
4
+ desc: string;
5
+ objectType: string;
6
+ titles: never[];
7
+ priority: number;
8
+ }[];
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { Element } from '@manuscripts/json-schema';
17
17
  import { ManuscriptNode, ManuscriptNodeType } from '../schema';
18
- export declare const getSectionTitles: (sectionCategory: SectionCategory) => string[];
18
+ export declare const getCoreSectionTitles: (sectionCategory: SectionCategory) => string[];
19
19
  export declare const isAnySectionNode: (node: ManuscriptNode) => boolean;
20
20
  export type SectionCategory = 'MPSectionCategory:abstract' | 'MPSectionCategory:abstract-teaser' | 'MPSectionCategory:abstract-graphical' | 'MPSectionCategory:acknowledgement' | 'MPSectionCategory:availability' | 'MPSectionCategory:bibliography' | 'MPSectionCategory:conclusions' | 'MPSectionCategory:discussion' | 'MPSectionCategory:endnotes' | 'MPSectionCategory:introduction' | 'MPSectionCategory:keywords' | 'MPSectionCategory:materials-method' | 'MPSectionCategory:results' | 'MPSectionCategory:toc' | 'MPSectionCategory:floating-element' | 'MPSectionCategory:appendices' | 'MPSectionCategory:competing-interests' | 'MPSectionCategory:financial-disclosure' | 'MPSectionCategory:con' | 'MPSectionCategory:deceased' | 'MPSectionCategory:equal' | 'MPSectionCategory:present-address' | 'MPSectionCategory:presented-at' | 'MPSectionCategory:previously-at' | 'MPSectionCategory:supplementary-material' | 'MPSectionCategory:supported-by' | 'MPSectionCategory:ethics-statement' | 'MPSectionCategory:body' | 'MPSectionCategory:abstracts' | 'MPSectionCategory:backmatter';
21
21
  export type SecType = 'abstract' | 'abstract-teaser' | 'abstract-graphical' | 'acknowledgments' | 'availability' | 'bibliography' | 'conclusions' | 'data-availability' | 'discussion' | 'endnotes' | 'intro' | 'keywords' | 'materials' | 'methods' | 'results' | 'toc' | 'floating-element' | 'appendices' | 'competing-interests' | 'financial-disclosure' | 'con' | 'deceased' | 'equal' | 'present-address' | 'presented-at' | 'previously-at' | 'supplementary-material' | 'supported-by' | 'ethics-statement' | 'abstracts' | 'body' | 'backmatter';
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": "1.3.5",
4
+ "version": "1.3.6-LEAN-2650",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -43,7 +43,6 @@
43
43
  "@babel/preset-env": "^7.20.2",
44
44
  "@babel/preset-typescript": "^7.18.6",
45
45
  "@jats4r/dtds": "^0.0.8",
46
- "@manuscripts/data": "^1.0.2",
47
46
  "@manuscripts/eslint-config": "^0.5.1",
48
47
  "@manuscripts/examples": "^0.1.0",
49
48
  "@types/debug": "^4.1.7",