@manuscripts/body-editor 2.6.13 → 2.6.14

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.
@@ -147,10 +147,9 @@ const CrossReferenceItems = ({ targets, handleSelect, handleCancel, currentTarge
147
147
  react_1.default.createElement(style_guide_1.ButtonGroup, null,
148
148
  react_1.default.createElement(style_guide_1.SecondaryButton, { onClick: handleCancel }, "Cancel"),
149
149
  react_1.default.createElement(style_guide_1.PrimaryButton, { onClick: () => {
150
- var _a, _b;
150
+ var _a;
151
151
  return selectedItem &&
152
- handleSelect(selectedItem, ((_a = customTextRef.current) === null || _a === void 0 ? void 0 : _a.value) ||
153
- ((_b = targets.find(({ id }) => id === selectedItem)) === null || _b === void 0 ? void 0 : _b.label));
152
+ handleSelect(selectedItem, ((_a = customTextRef.current) === null || _a === void 0 ? void 0 : _a.value) || '');
154
153
  }, disabled: !selectedItem }, "Insert")))));
155
154
  };
156
155
  exports.CrossReferenceItems = CrossReferenceItems;
@@ -29,6 +29,7 @@ const keys_1 = __importDefault(require("../keys"));
29
29
  const affiliations_1 = __importDefault(require("../plugins/affiliations"));
30
30
  const bibliography_1 = __importDefault(require("../plugins/bibliography"));
31
31
  const comments_1 = __importDefault(require("../plugins/comments"));
32
+ const cross_references_1 = __importDefault(require("../plugins/cross-references"));
32
33
  const doi_1 = __importDefault(require("../plugins/doi"));
33
34
  const editor_props_1 = __importDefault(require("../plugins/editor-props"));
34
35
  const elements_1 = __importDefault(require("../plugins/elements"));
@@ -73,6 +74,7 @@ exports.default = (props) => {
73
74
  (0, editor_props_1.default)(props),
74
75
  (0, doi_1.default)(),
75
76
  (0, section_category_1.default)(props),
77
+ (0, cross_references_1.default)(),
76
78
  ];
77
79
  if (props.collabProvider) {
78
80
  allPlugins.push((0, prosemirror_collab_1.collab)({ version: props.collabProvider.currentVersion }));
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2024 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 transform_1 = require("@manuscripts/transform");
19
+ const lodash_1 = require("lodash");
20
+ const prosemirror_state_1 = require("prosemirror-state");
21
+ const prosemirror_view_1 = require("prosemirror-view");
22
+ const objects_1 = require("./objects");
23
+ exports.default = () => {
24
+ return new prosemirror_state_1.Plugin({
25
+ state: {
26
+ init(_, state) {
27
+ return prosemirror_view_1.DecorationSet.empty;
28
+ },
29
+ apply(tr, oldDecorationSet, oldState, newState) {
30
+ let decoSet = oldDecorationSet;
31
+ const oldTargets = objects_1.objectsKey.getState(oldState);
32
+ const newTargets = objects_1.objectsKey.getState(newState);
33
+ if (tr.docChanged && !(0, lodash_1.isEqual)(oldTargets, newTargets)) {
34
+ const decorations = createDecorations(tr.doc);
35
+ decoSet = prosemirror_view_1.DecorationSet.create(tr.doc, decorations);
36
+ }
37
+ return decoSet;
38
+ },
39
+ },
40
+ props: {
41
+ decorations(state) {
42
+ return this.getState(state);
43
+ },
44
+ },
45
+ });
46
+ };
47
+ function createDecorations(doc) {
48
+ const decorations = [];
49
+ doc.descendants((node, pos) => {
50
+ if (node.type === transform_1.schema.nodes.cross_reference) {
51
+ decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
52
+ class: `decorated-${Date.now()}`,
53
+ }));
54
+ }
55
+ });
56
+ return decorations;
57
+ }
@@ -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.6.13';
4
+ exports.VERSION = '2.6.14';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -39,7 +39,10 @@ class CrossReferenceView extends base_node_view_1.BaseNodeView {
39
39
  var _a;
40
40
  const targets = objects_1.objectsKey.getState(this.view.state);
41
41
  const attrs = this.node.attrs;
42
- const classes = ['cross-reference', ...(0, track_changes_utils_1.getChangeClasses)(attrs.dataTracked)];
42
+ const classes = [
43
+ 'cross-reference',
44
+ ...(0, track_changes_utils_1.getChangeClasses)(attrs.dataTracked),
45
+ ];
43
46
  this.dom.className = classes.join(' ');
44
47
  const label = attrs.rids.length && ((_a = targets.get(attrs.rids[0])) === null || _a === void 0 ? void 0 : _a.label);
45
48
  this.dom.textContent = attrs.label || label || '';
@@ -118,9 +118,8 @@ export const CrossReferenceItems = ({ targets, handleSelect, handleCancel, curre
118
118
  React.createElement(ButtonGroup, null,
119
119
  React.createElement(SecondaryButton, { onClick: handleCancel }, "Cancel"),
120
120
  React.createElement(PrimaryButton, { onClick: () => {
121
- var _a, _b;
121
+ var _a;
122
122
  return selectedItem &&
123
- handleSelect(selectedItem, ((_a = customTextRef.current) === null || _a === void 0 ? void 0 : _a.value) ||
124
- ((_b = targets.find(({ id }) => id === selectedItem)) === null || _b === void 0 ? void 0 : _b.label));
123
+ handleSelect(selectedItem, ((_a = customTextRef.current) === null || _a === void 0 ? void 0 : _a.value) || '');
125
124
  }, disabled: !selectedItem }, "Insert")))));
126
125
  };
@@ -24,6 +24,7 @@ import keys from '../keys';
24
24
  import affiliations from '../plugins/affiliations';
25
25
  import bibliography from '../plugins/bibliography';
26
26
  import comments from '../plugins/comments';
27
+ import cross_references from '../plugins/cross-references';
27
28
  import doi from '../plugins/doi';
28
29
  import editorProps from '../plugins/editor-props';
29
30
  import elements from '../plugins/elements';
@@ -68,6 +69,7 @@ export default (props) => {
68
69
  editorProps(props),
69
70
  doi(),
70
71
  section_category(props),
72
+ cross_references(),
71
73
  ];
72
74
  if (props.collabProvider) {
73
75
  allPlugins.push(collab({ version: props.collabProvider.currentVersion }));
@@ -0,0 +1,55 @@
1
+ /*!
2
+ * © 2024 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { schema } from '@manuscripts/transform';
17
+ import { isEqual } from 'lodash';
18
+ import { Plugin } from 'prosemirror-state';
19
+ import { Decoration, DecorationSet } from 'prosemirror-view';
20
+ import { objectsKey } from './objects';
21
+ export default () => {
22
+ return new Plugin({
23
+ state: {
24
+ init(_, state) {
25
+ return DecorationSet.empty;
26
+ },
27
+ apply(tr, oldDecorationSet, oldState, newState) {
28
+ let decoSet = oldDecorationSet;
29
+ const oldTargets = objectsKey.getState(oldState);
30
+ const newTargets = objectsKey.getState(newState);
31
+ if (tr.docChanged && !isEqual(oldTargets, newTargets)) {
32
+ const decorations = createDecorations(tr.doc);
33
+ decoSet = DecorationSet.create(tr.doc, decorations);
34
+ }
35
+ return decoSet;
36
+ },
37
+ },
38
+ props: {
39
+ decorations(state) {
40
+ return this.getState(state);
41
+ },
42
+ },
43
+ });
44
+ };
45
+ function createDecorations(doc) {
46
+ const decorations = [];
47
+ doc.descendants((node, pos) => {
48
+ if (node.type === schema.nodes.cross_reference) {
49
+ decorations.push(Decoration.node(pos, pos + node.nodeSize, {
50
+ class: `decorated-${Date.now()}`,
51
+ }));
52
+ }
53
+ });
54
+ return decorations;
55
+ }
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.6.13';
1
+ export const VERSION = '2.6.14';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -36,7 +36,10 @@ export class CrossReferenceView extends BaseNodeView {
36
36
  var _a;
37
37
  const targets = objectsKey.getState(this.view.state);
38
38
  const attrs = this.node.attrs;
39
- const classes = ['cross-reference', ...getChangeClasses(attrs.dataTracked)];
39
+ const classes = [
40
+ 'cross-reference',
41
+ ...getChangeClasses(attrs.dataTracked),
42
+ ];
40
43
  this.dom.className = classes.join(' ');
41
44
  const label = attrs.rids.length && ((_a = targets.get(attrs.rids[0])) === null || _a === void 0 ? void 0 : _a.label);
42
45
  this.dom.textContent = attrs.label || label || '';
@@ -0,0 +1,19 @@
1
+ /*!
2
+ * © 2024 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Plugin } from 'prosemirror-state';
17
+ import { DecorationSet } from 'prosemirror-view';
18
+ declare const _default: () => Plugin<DecorationSet>;
19
+ export default _default;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.6.13";
1
+ export declare const VERSION = "2.6.14";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/body-editor",
3
3
  "description": "Prosemirror components for editing and viewing manuscripts",
4
- "version": "2.6.13",
4
+ "version": "2.6.14",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -34,7 +34,7 @@
34
34
  "@manuscripts/library": "1.3.11",
35
35
  "@manuscripts/style-guide": "2.0.23",
36
36
  "@manuscripts/track-changes-plugin": "1.8.1",
37
- "@manuscripts/transform": "3.0.17",
37
+ "@manuscripts/transform": "3.0.18",
38
38
  "@popperjs/core": "^2.11.8",
39
39
  "astrocite-eutils": "^0.16.4",
40
40
  "codemirror": "^5.58.1",