@manuscripts/body-editor 2.8.75-LEAN-4574.1 → 2.8.76

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.
Files changed (72) hide show
  1. package/dist/cjs/clipboard.js +2 -23
  2. package/dist/cjs/components/references/ImportBibliographyForm.js +8 -8
  3. package/dist/cjs/components/references/ReferenceForm/PersonDropDown.js +2 -2
  4. package/dist/cjs/components/references/ReferenceForm/ReferenceForm.js +31 -42
  5. package/dist/cjs/components/references/ReferenceForm/config.js +13 -1
  6. package/dist/cjs/components/views/TableCellContextMenu.js +12 -11
  7. package/dist/cjs/index.js +1 -2
  8. package/dist/cjs/lib/context-menu.js +12 -8
  9. package/dist/cjs/lib/crossref.js +32 -1
  10. package/dist/cjs/lib/references.js +1 -67
  11. package/dist/cjs/lib/utils.js +3 -1
  12. package/dist/cjs/plugins/bibliography/bibliography-utils.js +84 -0
  13. package/dist/cjs/plugins/bibliography/index.js +128 -0
  14. package/dist/cjs/plugins/tables-cursor-fix.js +4 -1
  15. package/dist/cjs/versions.js +1 -1
  16. package/dist/cjs/views/bibliography_element.js +1 -1
  17. package/dist/cjs/views/bullet_list.js +44 -0
  18. package/dist/cjs/views/bullet_list_editable.js +21 -0
  19. package/dist/cjs/views/list.js +6 -23
  20. package/dist/cjs/views/ordered_list.js +53 -0
  21. package/dist/cjs/views/ordered_list_editable.js +21 -0
  22. package/dist/cjs/views/table_element.js +0 -1
  23. package/dist/es/clipboard.js +2 -22
  24. package/dist/es/components/references/ImportBibliographyForm.js +8 -8
  25. package/dist/es/components/references/ReferenceForm/PersonDropDown.js +2 -2
  26. package/dist/es/components/references/ReferenceForm/ReferenceForm.js +30 -41
  27. package/dist/es/components/references/ReferenceForm/config.js +12 -0
  28. package/dist/es/components/views/TableCellContextMenu.js +12 -11
  29. package/dist/es/index.js +1 -1
  30. package/dist/es/lib/context-menu.js +13 -9
  31. package/dist/es/lib/crossref.js +32 -1
  32. package/dist/es/lib/references.js +0 -42
  33. package/dist/es/lib/utils.js +3 -1
  34. package/dist/es/plugins/bibliography/bibliography-utils.js +77 -0
  35. package/dist/es/plugins/bibliography/index.js +124 -0
  36. package/dist/es/plugins/tables-cursor-fix.js +4 -1
  37. package/dist/es/versions.js +1 -1
  38. package/dist/es/views/bibliography_element.js +1 -1
  39. package/dist/es/views/bullet_list.js +36 -0
  40. package/dist/es/views/bullet_list_editable.js +19 -0
  41. package/dist/es/views/citation_editable.js +1 -1
  42. package/dist/es/views/list.js +5 -21
  43. package/dist/es/views/ordered_list.js +45 -0
  44. package/dist/es/views/ordered_list_editable.js +19 -0
  45. package/dist/es/views/table_element.js +0 -1
  46. package/dist/types/clipboard.d.ts +0 -1
  47. package/dist/types/components/references/BibliographyItemSource.d.ts +1 -1
  48. package/dist/types/components/references/CitationEditor.d.ts +1 -1
  49. package/dist/types/components/references/CitationViewer.d.ts +1 -1
  50. package/dist/types/components/references/ReferenceForm/PersonDropDown.d.ts +4 -4
  51. package/dist/types/components/references/ReferenceForm/ReferenceForm.d.ts +1 -1
  52. package/dist/types/components/references/ReferenceForm/config.d.ts +1 -0
  53. package/dist/types/components/references/ReferenceLine.d.ts +1 -1
  54. package/dist/types/components/references/ReferenceSearch.d.ts +1 -1
  55. package/dist/types/components/references/ReferenceSearchResults.d.ts +1 -1
  56. package/dist/types/components/references/ReferenceSearchSection.d.ts +1 -1
  57. package/dist/types/components/references/ReferencesModal.d.ts +1 -1
  58. package/dist/types/index.d.ts +1 -1
  59. package/dist/types/lib/context-menu.d.ts +1 -0
  60. package/dist/types/lib/references.d.ts +4 -3
  61. package/dist/types/plugins/bibliography/bibliography-utils.d.ts +25 -0
  62. package/dist/types/plugins/{bibliography.d.ts → bibliography/index.d.ts} +9 -9
  63. package/dist/types/versions.d.ts +1 -1
  64. package/dist/types/views/bullet_list.d.ts +25 -0
  65. package/dist/types/views/bullet_list_editable.d.ts +44 -0
  66. package/dist/types/views/list.d.ts +1 -2
  67. package/dist/types/views/ordered_list.d.ts +30 -0
  68. package/dist/types/views/ordered_list_editable.d.ts +44 -0
  69. package/dist/types/views/table_element.d.ts +0 -1
  70. package/package.json +3 -11
  71. package/dist/cjs/plugins/bibliography.js +0 -177
  72. package/dist/es/plugins/bibliography.js +0 -149
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __rest = (this && this.__rest) || function (s, e) {
18
+ var t = {};
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
20
+ t[p] = s[p];
21
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
22
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
23
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
24
+ t[p[i]] = s[p[i]];
25
+ }
26
+ return t;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.getBibliographyPluginState = exports.bibliographyKey = void 0;
30
+ const json_schema_1 = require("@manuscripts/json-schema");
31
+ const library_1 = require("@manuscripts/library");
32
+ const transform_1 = require("@manuscripts/transform");
33
+ const lodash_1 = require("lodash");
34
+ const prosemirror_state_1 = require("prosemirror-state");
35
+ const prosemirror_utils_1 = require("prosemirror-utils");
36
+ const prosemirror_view_1 = require("prosemirror-view");
37
+ const track_changes_utils_1 = require("../../lib/track-changes-utils");
38
+ const bibliography_utils_1 = require("./bibliography-utils");
39
+ exports.bibliographyKey = new prosemirror_state_1.PluginKey('bibliography');
40
+ exports.default = (props) => {
41
+ return new prosemirror_state_1.Plugin({
42
+ key: exports.bibliographyKey,
43
+ state: {
44
+ init(config, instance) {
45
+ return buildBibliographyPluginState(instance.doc, props.cslProps);
46
+ },
47
+ apply(tr, value) {
48
+ if (!tr.steps.length) {
49
+ return value;
50
+ }
51
+ return buildBibliographyPluginState(tr.doc, props.cslProps, value);
52
+ },
53
+ },
54
+ props: {
55
+ decorations(state) {
56
+ const bib = (0, exports.getBibliographyPluginState)(state);
57
+ return prosemirror_view_1.DecorationSet.create(state.doc, bib ? (0, bibliography_utils_1.buildDecorations)(bib, state.doc) : []);
58
+ },
59
+ },
60
+ });
61
+ };
62
+ let version = 1;
63
+ const buildBibliographyPluginState = (doc, csl, $old) => {
64
+ const nodesMap = new Map();
65
+ doc.descendants((node, pos) => {
66
+ if ((0, transform_1.isCitationNode)(node)) {
67
+ nodesMap.set(node.attrs.id, [node, pos]);
68
+ }
69
+ });
70
+ const nodes = Array.from(nodesMap.values());
71
+ const bibliographyItems = getBibliographyItemAttrs(doc);
72
+ const citations = (0, bibliography_utils_1.buildCitations)(nodes);
73
+ const $new = {
74
+ citationNodes: nodes,
75
+ citations,
76
+ bibliographyItems,
77
+ };
78
+ if (!csl.style) {
79
+ return $new;
80
+ }
81
+ if ($old &&
82
+ (0, lodash_1.isEqual)(citations, $old.citations) &&
83
+ (0, lodash_1.isEqual)(bibliographyItems, $old.bibliographyItems)) {
84
+ $new.version = $old.version;
85
+ $new.citationCounts = $old.citationCounts;
86
+ $new.provider = $old.provider;
87
+ $new.renderedCitations = $old.renderedCitations;
88
+ }
89
+ else {
90
+ const citationCounts = new Map();
91
+ const rids = nodes.flatMap((e) => e[0].attrs.rids);
92
+ rids.forEach((rid) => {
93
+ const count = citationCounts.get(rid) || 0;
94
+ citationCounts.set(rid, count + 1);
95
+ });
96
+ const provider = new library_1.CitationProvider({
97
+ getLibraryItem: (id) => getBibliographyItem(bibliographyItems.get(id)),
98
+ citationStyle: csl.style || '',
99
+ locale: csl.locale,
100
+ });
101
+ const citationTexts = provider.rebuildState((0, bibliography_utils_1.buildCitations)(nodes));
102
+ $new.version = String(version++);
103
+ $new.citationCounts = citationCounts;
104
+ $new.provider = provider;
105
+ $new.renderedCitations = new Map(citationTexts.map((i) => [i[0], i[2]]));
106
+ }
107
+ return $new;
108
+ };
109
+ const getBibliographyItem = (attrs) => {
110
+ if (!attrs) {
111
+ return;
112
+ }
113
+ const { id } = attrs, rest = __rest(attrs, ["id"]);
114
+ const item = Object.assign({ _id: id, objectType: json_schema_1.ObjectTypes.BibliographyItem }, rest);
115
+ return (0, lodash_1.pickBy)(item, (v) => v !== undefined);
116
+ };
117
+ const getBibliographyItemAttrs = (doc) => {
118
+ const attrs = new Map();
119
+ (0, prosemirror_utils_1.findChildrenByType)(doc, transform_1.schema.nodes.bibliography_item)
120
+ .filter((n) => !(0, track_changes_utils_1.isHidden)(n.node))
121
+ .map((n) => n.node.attrs)
122
+ .forEach((a) => attrs.set(a.id, a));
123
+ return attrs;
124
+ };
125
+ const getBibliographyPluginState = (state) => {
126
+ return exports.bibliographyKey.getState(state);
127
+ };
128
+ exports.getBibliographyPluginState = getBibliographyPluginState;
@@ -44,7 +44,10 @@ exports.default = () => {
44
44
  const isTableShapeSelected = (state) => {
45
45
  if (state.selection instanceof prosemirror_tables_1.CellSelection) {
46
46
  const rect = (0, prosemirror_tables_1.selectedRect)(state);
47
- return rect.bottom === rect.map.height && rect.right === rect.map.width;
47
+ return (rect.left === 0 &&
48
+ rect.top === 0 &&
49
+ rect.right === rect.map.width &&
50
+ rect.bottom === rect.map.height);
48
51
  }
49
52
  return false;
50
53
  };
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MATHJAX_VERSION = exports.VERSION = void 0;
4
- exports.VERSION = '2.8.75-LEAN-4574.1';
4
+ exports.VERSION = '2.8.76';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -173,7 +173,7 @@ class BibliographyElementBlockView extends block_view_1.default {
173
173
  const wrapper = document.createElement('div');
174
174
  wrapper.classList.add('contents');
175
175
  wrapper.addEventListener('click', this.handleClick);
176
- const [meta, bibliography] = bib.engine.makeBibliography();
176
+ const [meta, bibliography] = bib.provider.makeBibliography();
177
177
  for (let i = 0; i < bibliography.length; i++) {
178
178
  const id = meta.entry_ids[i][0];
179
179
  const fragment = bibliography[i];
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.bulletListCallback = exports.BulletListView = void 0;
22
+ const block_view_1 = __importDefault(require("./block_view"));
23
+ const creators_1 = require("./creators");
24
+ const ordered_list_1 = require("./ordered_list");
25
+ class BulletListView extends block_view_1.default {
26
+ constructor() {
27
+ super(...arguments);
28
+ this.elementType = 'ul';
29
+ }
30
+ updateContents() {
31
+ super.updateContents();
32
+ if (this.contentDOM) {
33
+ const type = this.node.attrs.listStyleType || 'bullet';
34
+ this.contentDOM.style.listStyleType = ordered_list_1.JATS_HTML_LIST_STYLE_MAPPING[type];
35
+ }
36
+ }
37
+ }
38
+ exports.BulletListView = BulletListView;
39
+ const bulletListCallback = (node, dom) => {
40
+ const type = node.attrs.listStyleType || 'bullet';
41
+ dom.style.listStyleType = ordered_list_1.JATS_HTML_LIST_STYLE_MAPPING[type];
42
+ };
43
+ exports.bulletListCallback = bulletListCallback;
44
+ exports.default = (0, creators_1.createNodeOrElementView)(BulletListView, 'ul', exports.bulletListCallback);
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const bullet_list_1 = require("./bullet_list");
19
+ const creators_1 = require("./creators");
20
+ const editable_block_1 = require("./editable_block");
21
+ exports.default = (0, creators_1.createNodeOrElementView)((0, editable_block_1.EditableBlock)(bullet_list_1.BulletListView), 'ul', bullet_list_1.bulletListCallback);
@@ -18,7 +18,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.getCssListStyleType = exports.listCallback = exports.ListView = void 0;
21
+ exports.listCallback = exports.ListView = void 0;
22
+ const transform_1 = require("@manuscripts/transform");
22
23
  const block_view_1 = __importDefault(require("./block_view"));
23
24
  const creators_1 = require("./creators");
24
25
  const editable_block_1 = require("./editable_block");
@@ -29,9 +30,10 @@ class ListView extends block_view_1.default {
29
30
  }
30
31
  updateContents() {
31
32
  super.updateContents();
33
+ const actualAttrs = this.node.attrs;
32
34
  if (this.contentDOM) {
33
- const type = this.node.attrs.listStyleType;
34
- this.contentDOM.style.listStyleType = (0, exports.getCssListStyleType)(type);
35
+ const type = actualAttrs.listStyleType;
36
+ this.contentDOM.style.listStyleType = (0, transform_1.getListType)(type).style;
35
37
  }
36
38
  }
37
39
  }
@@ -39,26 +41,7 @@ exports.ListView = ListView;
39
41
  const listCallback = (node, dom) => {
40
42
  dom.classList.add('list');
41
43
  const type = node.attrs.listStyleType;
42
- dom.style.listStyleType = (0, exports.getCssListStyleType)(type);
44
+ dom.style.listStyleType = (0, transform_1.getListType)(type).style;
43
45
  };
44
46
  exports.listCallback = listCallback;
45
47
  exports.default = (0, creators_1.createNodeOrElementView)((0, editable_block_1.EditableBlock)(ListView), 'ul', exports.listCallback);
46
- const getCssListStyleType = (type) => {
47
- switch (type) {
48
- case 'bullet':
49
- return 'disc';
50
- case 'order':
51
- return 'decimal';
52
- case 'alpha-lower':
53
- return 'lower-alpha';
54
- case 'alpha-upper':
55
- return 'upper-alpha';
56
- case 'roman-lower':
57
- return 'lower-roman';
58
- case 'roman-upper':
59
- return 'upper-roman';
60
- case 'simple':
61
- return 'none';
62
- }
63
- };
64
- exports.getCssListStyleType = getCssListStyleType;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.orderedListCallback = exports.OrderedListView = exports.JATS_HTML_LIST_STYLE_MAPPING = void 0;
22
+ const block_view_1 = __importDefault(require("./block_view"));
23
+ const creators_1 = require("./creators");
24
+ exports.JATS_HTML_LIST_STYLE_MAPPING = {
25
+ simple: 'none',
26
+ bullet: 'disc',
27
+ order: 'decimal',
28
+ 'alpha-lower': 'lower-alpha',
29
+ 'alpha-upper': 'upper-alpha',
30
+ 'roman-lower': 'lower-roman',
31
+ 'roman-upper': 'upper-roman',
32
+ };
33
+ class OrderedListView extends block_view_1.default {
34
+ constructor() {
35
+ super(...arguments);
36
+ this.elementType = 'ol';
37
+ }
38
+ updateContents() {
39
+ super.updateContents();
40
+ if (this.contentDOM) {
41
+ const type = this.node.attrs.listStyleType || 'order';
42
+ this.contentDOM.style.listStyleType = exports.JATS_HTML_LIST_STYLE_MAPPING[type];
43
+ }
44
+ }
45
+ }
46
+ exports.OrderedListView = OrderedListView;
47
+ const orderedListCallback = (node, dom) => {
48
+ dom.classList.add('list');
49
+ const type = node.attrs.listStyleType || 'order';
50
+ dom.style.listStyleType = exports.JATS_HTML_LIST_STYLE_MAPPING[type];
51
+ };
52
+ exports.orderedListCallback = orderedListCallback;
53
+ exports.default = (0, creators_1.createNodeOrElementView)(OrderedListView, 'ol', exports.orderedListCallback);
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const creators_1 = require("./creators");
19
+ const editable_block_1 = require("./editable_block");
20
+ const ordered_list_1 = require("./ordered_list");
21
+ exports.default = (0, creators_1.createNodeOrElementView)((0, editable_block_1.EditableBlock)(ordered_list_1.OrderedListView), 'ol', ordered_list_1.orderedListCallback);
@@ -25,7 +25,6 @@ class TableElementView extends block_view_1.default {
25
25
  constructor() {
26
26
  super(...arguments);
27
27
  this.elementType = 'figure';
28
- this.ignoreMutation = () => true;
29
28
  this.createElement = () => {
30
29
  this.contentDOM = document.createElement('figure');
31
30
  this.contentDOM.classList.add('block');
@@ -1,4 +1,4 @@
1
- import { schema } from '@manuscripts/transform';
1
+ import { getJatsListType, schema } from '@manuscripts/transform';
2
2
  import { DOMParser } from 'prosemirror-model';
3
3
  const nodes = [
4
4
  {
@@ -11,7 +11,7 @@ const nodes = [
11
11
  getAttrs: (list) => {
12
12
  const dom = list;
13
13
  return {
14
- listStyleType: getListStyleType(dom.style.listStyleType ||
14
+ listStyleType: getJatsListType(dom.style.listStyleType ||
15
15
  (dom.firstChild &&
16
16
  dom.firstChild.style.listStyleType)),
17
17
  };
@@ -26,23 +26,3 @@ export const clipboardParser = new DOMParser(schema, [
26
26
  ...nodes,
27
27
  ...DOMParser.fromSchema(schema).rules,
28
28
  ]);
29
- export const getListStyleType = (cssStyle) => {
30
- switch (cssStyle) {
31
- case 'disc':
32
- return 'bullet';
33
- case 'decimal':
34
- return 'order';
35
- case 'lower-alpha':
36
- return 'alpha-lower';
37
- case 'upper-alpha':
38
- return 'alpha-upper';
39
- case 'lower-roman':
40
- return 'roman-lower';
41
- case 'upper-roman':
42
- return 'roman-upper';
43
- case 'simple':
44
- return 'none';
45
- default:
46
- return 'none';
47
- }
48
- };
@@ -22,12 +22,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
22
22
  step((generator = generator.apply(thisArg, _arguments || [])).next());
23
23
  });
24
24
  };
25
+ import { transformBibliography } from '@manuscripts/library';
25
26
  import { PrimaryButton, SecondaryButton, TextArea, } from '@manuscripts/style-guide';
26
27
  import { useFormik } from 'formik';
27
28
  import { debounce } from 'lodash';
28
29
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
29
30
  import styled, { css } from 'styled-components';
30
- import { importBibliographyItems } from '../../lib/references';
31
31
  import { ReferenceLine } from './ReferenceLine';
32
32
  export const ImportBibliographyForm = ({ onCancel, onSave, }) => {
33
33
  const [dragging, setDragging] = useState(false);
@@ -48,18 +48,18 @@ export const ImportBibliographyForm = ({ onCancel, onSave, }) => {
48
48
  const ERROR_CITATION = 'Error generating citation';
49
49
  try {
50
50
  if (!fileContent.trim()) {
51
- yield formik.setFieldValue('err', NO_CITATION);
52
- yield formik.setFieldValue('data', []);
51
+ formik.setFieldValue('err', NO_CITATION);
52
+ formik.setFieldValue('data', []);
53
53
  return;
54
54
  }
55
- const data = yield importBibliographyItems(fileContent.trim());
56
- yield formik.setFieldValue('data', data ? data : []);
57
- yield formik.setFieldValue('err', '');
55
+ const data = yield transformBibliography(fileContent.trim());
56
+ formik.setFieldValue('data', data ? data : []);
57
+ formik.setFieldValue('err', '');
58
58
  }
59
59
  catch (error) {
60
60
  console.error('Citation generation error:', error);
61
- yield formik.setFieldValue('err', ERROR_CITATION);
62
- yield formik.setFieldValue('data', []);
61
+ formik.setFieldValue('err', ERROR_CITATION);
62
+ formik.setFieldValue('data', []);
63
63
  }
64
64
  }), []);
65
65
  const debouncedGenerateData = useMemo(() => debounce(setDataField, 300), [setDataField]);
@@ -3,8 +3,8 @@ import { Field } from 'formik';
3
3
  import React, { useState } from 'react';
4
4
  import { DropdownIndicator, FieldLabel, NameField, NameFieldContainer, PersonForm, RemoveButton, Section, Title, ToggleButton, } from './styled-components';
5
5
  export const PersonDropDown = (props) => {
6
- const { person, isNew, index, remove, onChange, type } = props;
7
- const [isOpen, setIsOpen] = useState(isNew);
6
+ const { person, index, remove, onChange, type } = props;
7
+ const [isOpen, setIsOpen] = useState(!!person['isNew']);
8
8
  const fullName = [person.given, person.family].join(' ').trim();
9
9
  const title = fullName.length > 0 ? fullName : `Edit ${type} name`;
10
10
  const prefix = `${type}.${index}`;
@@ -13,12 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { buildBibliographicDate, buildBibliographicName, } from '@manuscripts/json-schema';
16
17
  import { AddAuthorIcon, ButtonGroup, Category, DeleteIcon, Dialog, IconButton, LinkIcon, PrimaryButton, SecondaryButton, SelectField, Tooltip, } from '@manuscripts/style-guide';
17
18
  import { Field, FieldArray, Formik } from 'formik';
18
19
  import React, { useEffect, useRef, useState } from 'react';
19
- import { bibliographyItemTypes } from '../../../lib/references';
20
20
  import { shouldRenderField } from '../../../lib/utils';
21
21
  import { ChangeHandlingForm } from '../../ChangeHandlingForm';
22
+ import { bibliographyItemTypes } from './config';
22
23
  import { PersonDropDown } from './PersonDropDown';
23
24
  import { Actions, Button, DeleteButton, FormField, FormFields, Label, LabelContainer, ReferenceTextArea, ReferenceTextField, YearField, } from './styled-components';
24
25
  const bibliographyItemTypeOptions = bibliographyItemTypes.map((i) => ({
@@ -28,8 +29,6 @@ const bibliographyItemTypeOptions = bibliographyItemTypes.map((i) => ({
28
29
  export const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel, onSave, actionsRef, }) => {
29
30
  const fieldsRef = useRef(null);
30
31
  const formRef = useRef(null);
31
- const [newAuthorIndex, setNewAuthorIndex] = useState();
32
- const [newEditorIndex, setNewEditorIndex] = useState();
33
32
  useEffect(() => {
34
33
  if (fieldsRef.current) {
35
34
  fieldsRef.current.scrollTop = 0;
@@ -90,38 +89,28 @@ export const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel
90
89
  React.createElement(LabelContainer, null,
91
90
  React.createElement(Label, { htmlFor: 'std' }, "Standard")),
92
91
  React.createElement(Field, { name: 'std' }, (props) => (React.createElement(ReferenceTextArea, Object.assign({ id: 'std' }, props.field)))))),
93
- shouldRenderField('author', formik.values.type) && (React.createElement(FieldArray, { name: 'author', render: ({ push, remove }) => {
94
- var _a;
95
- return (React.createElement(FormField, null,
96
- React.createElement(LabelContainer, null,
97
- React.createElement(Label, null, "Authors"),
98
- React.createElement(Button, { onClick: () => {
99
- var _a;
100
- setNewAuthorIndex((_a = formik.values.author) === null || _a === void 0 ? void 0 : _a.length);
101
- push({
102
- given: '',
103
- family: '',
104
- });
105
- } },
106
- React.createElement(AddAuthorIcon, { height: 17, width: 17 }))),
107
- React.createElement("div", null, (_a = formik.values.author) === null || _a === void 0 ? void 0 : _a.map((author, index) => (React.createElement(PersonDropDown, { key: index, index: index, person: author, isNew: newAuthorIndex === index, remove: remove, onChange: formik.handleChange, type: "author" }))))));
108
- } })),
109
- shouldRenderField('editor', formik.values.type) && (React.createElement(FieldArray, { name: 'editor', render: ({ push, remove }) => {
110
- var _a;
111
- return (React.createElement(FormField, null,
112
- React.createElement(LabelContainer, null,
113
- React.createElement(Label, null, "Editors"),
114
- React.createElement(Button, { onClick: () => {
115
- var _a;
116
- setNewEditorIndex((_a = formik.values.editor) === null || _a === void 0 ? void 0 : _a.length);
117
- push({
118
- given: '',
119
- family: '',
120
- });
121
- } },
122
- React.createElement(AddAuthorIcon, { height: 17, width: 17 }))),
123
- React.createElement("div", null, (_a = formik.values.editor) === null || _a === void 0 ? void 0 : _a.map((editor, index) => (React.createElement(PersonDropDown, { key: index, index: index, person: editor, isNew: newEditorIndex === index, remove: remove, onChange: formik.handleChange, type: "editor" }))))));
124
- } })),
92
+ shouldRenderField('author', formik.values.type) && (React.createElement(FieldArray, { name: 'author', render: ({ push, remove }) => (React.createElement(FormField, null,
93
+ React.createElement(LabelContainer, null,
94
+ React.createElement(Label, null, "Authors"),
95
+ React.createElement(Button, { onClick: () => push(buildBibliographicName({
96
+ given: '',
97
+ family: '',
98
+ isNew: true,
99
+ })) },
100
+ React.createElement(AddAuthorIcon, { height: 17, width: 17 }))),
101
+ React.createElement("div", null, formik.values.author &&
102
+ formik.values.author.map((author, index) => (React.createElement(PersonDropDown, { key: index, index: index, person: author, remove: remove, onChange: formik.handleChange, type: "author" })))))) })),
103
+ shouldRenderField('editor', formik.values.type) && (React.createElement(FieldArray, { name: 'editor', render: ({ push, remove }) => (React.createElement(FormField, null,
104
+ React.createElement(LabelContainer, null,
105
+ React.createElement(Label, null, "Editors"),
106
+ React.createElement(Button, { onClick: () => push(buildBibliographicName({
107
+ given: '',
108
+ family: '',
109
+ isNew: true,
110
+ })) },
111
+ React.createElement(AddAuthorIcon, { height: 17, width: 17 }))),
112
+ React.createElement("div", null, formik.values.editor &&
113
+ formik.values.editor.map((editor, index) => (React.createElement(PersonDropDown, { key: index, index: index, person: editor, remove: remove, onChange: formik.handleChange, type: "editor" })))))) })),
125
114
  shouldRenderField('issued', formik.values.type) && (React.createElement(FormField, null,
126
115
  React.createElement(LabelContainer, null,
127
116
  React.createElement(Label, { htmlFor: "issued['date-parts'][0][0]" }, "Issued (Year)")),
@@ -132,9 +121,9 @@ export const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel
132
121
  formik.setFieldValue("issued['date-parts'][0][0]", Number(value));
133
122
  }
134
123
  else {
135
- formik.setFieldValue('issued', {
124
+ formik.setFieldValue('issued', buildBibliographicDate({
136
125
  'date-parts': [[Number(value)]],
137
- });
126
+ }));
138
127
  }
139
128
  }
140
129
  else {
@@ -191,9 +180,9 @@ export const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel
191
180
  formik.setFieldValue("event-date['date-parts'][0][0]", Number(value));
192
181
  }
193
182
  else {
194
- formik.setFieldValue('event-date', {
183
+ formik.setFieldValue('event-date', buildBibliographicDate({
195
184
  'date-parts': [[Number(value)]],
196
- });
185
+ }));
197
186
  }
198
187
  }
199
188
  else {
@@ -234,9 +223,9 @@ export const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel
234
223
  formik.setFieldValue("accessed['date-parts'][0][0]", Number(value));
235
224
  }
236
225
  else {
237
- formik.setFieldValue('accessed', {
226
+ formik.setFieldValue('accessed', buildBibliographicDate({
238
227
  'date-parts': [[Number(value)]],
239
- });
228
+ }));
240
229
  }
241
230
  }
242
231
  else {
@@ -1,3 +1,15 @@
1
+ export const bibliographyItemTypes = [
2
+ ['article-journal', 'Journal Article'],
3
+ ['book', 'Book'],
4
+ ['chapter', 'Chapter'],
5
+ ['confproc', 'Conference Paper'],
6
+ ['thesis', 'Thesis'],
7
+ ['webpage', 'Web Page'],
8
+ ['other', 'Other'],
9
+ ['standard', 'Standard'],
10
+ ['dataset', 'Dataset'],
11
+ ['preprint', 'Preprint'],
12
+ ];
1
13
  export const fieldConfigMap = {
2
14
  'article-journal': new Set([
3
15
  'author',
@@ -25,21 +25,16 @@ const isHeaderCellSelected = (state) => {
25
25
  }
26
26
  return (((_a = state.doc.nodeAt(state.selection.from)) === null || _a === void 0 ? void 0 : _a.type) === schema.nodes.table_header);
27
27
  };
28
- const ColumnChangeWarningDialog = ({ isOpen, primaryAction, secondaryAction }) => (React.createElement(Dialog, { isOpen: isOpen, category: Category.confirmation, header: "This change can't be tracked", message: "This column action won't be marked as chnage. Do you want to continue?", actions: {
29
- primary: {
30
- action: primaryAction,
31
- title: 'Ok',
32
- },
33
- secondary: {
34
- action: secondaryAction,
35
- title: 'Cancel',
36
- },
28
+ const TableChangeWarningDialog = ({ isOpen, primaryAction, secondaryAction }) => (React.createElement(Dialog, { isOpen: isOpen, category: Category.confirmation, header: "This change can't be tracked", message: "This action won't be marked as chnage. Do you want to continue?", actions: {
29
+ primary: { action: primaryAction, title: 'Ok' },
30
+ secondary: { action: secondaryAction, title: 'Cancel' },
37
31
  } }));
38
32
  export const ContextMenu = ({ view, close, onCancelColumnDialog }) => {
39
33
  const runCommand = (command, noTracking) => {
40
34
  command(view.state, (tr) => view.dispatch((noTracking && skipTracking(tr)) || tr));
41
35
  close();
42
36
  };
37
+ const [rowDeleteAction, setRowDeleteAction] = useState();
43
38
  const [columnAction, setColumnAction] = useState();
44
39
  const isCellSelectionMerged = mergeCells(view.state);
45
40
  const isCellSelectionSplittable = splitCell(view.state);
@@ -74,7 +69,7 @@ export const ContextMenu = ({ view, close, onCancelColumnDialog }) => {
74
69
  " Insert header row ",
75
70
  headerPosition),
76
71
  React.createElement(Separator, null),
77
- React.createElement(ActionButton, { onClick: () => runCommand(deleteRow) },
72
+ React.createElement(ActionButton, { onClick: () => setRowDeleteAction(() => deleteRow) },
78
73
  React.createElement(GrayDeleteIcon, null),
79
74
  " Delete",
80
75
  isHeaderCellSelected(view.state) ? ' header ' : '',
@@ -87,7 +82,13 @@ export const ContextMenu = ({ view, close, onCancelColumnDialog }) => {
87
82
  (isCellSelectionMerged || isCellSelectionSplittable) && React.createElement(Separator, null),
88
83
  isCellSelectionMerged && (React.createElement(ActionButton, { onClick: () => runCommand(mergeCells, true) }, "Merge cells")),
89
84
  isCellSelectionSplittable && (React.createElement(ActionButton, { onClick: () => runCommand(splitCell, true) }, "Split cells")),
90
- React.createElement(ColumnChangeWarningDialog, { isOpen: !!columnAction, primaryAction: () => {
85
+ React.createElement(TableChangeWarningDialog, { isOpen: !!rowDeleteAction, primaryAction: () => {
86
+ if (rowDeleteAction) {
87
+ runCommand(rowDeleteAction, true);
88
+ setRowDeleteAction(undefined);
89
+ }
90
+ }, secondaryAction: () => setRowDeleteAction(undefined) }),
91
+ React.createElement(TableChangeWarningDialog, { isOpen: !!columnAction, primaryAction: () => {
91
92
  if (columnAction) {
92
93
  runCommand(columnAction, true);
93
94
  setColumnAction(undefined);