@manuscripts/body-editor 1.11.6 → 1.11.7-LEAN-1330.0

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.
@@ -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 doi_1 = __importDefault(require("../plugins/doi"));
32
33
  const editor_props_1 = __importDefault(require("../plugins/editor-props"));
33
34
  const elements_1 = __importDefault(require("../plugins/elements"));
34
35
  const footnotes_1 = __importDefault(require("../plugins/footnotes"));
@@ -71,6 +72,7 @@ exports.default = (props) => {
71
72
  (0, footnotes_1.default)(props),
72
73
  (0, table_footnote_1.default)(),
73
74
  (0, editor_props_1.default)(props),
75
+ (0, doi_1.default)(),
74
76
  ];
75
77
  if (props.collabProvider) {
76
78
  allPlugins.push((0, prosemirror_collab_1.collab)({ version: props.collabProvider.currentVersion }));
@@ -0,0 +1,63 @@
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 prosemirror_state_1 = require("prosemirror-state");
19
+ const prosemirror_view_1 = require("prosemirror-view");
20
+ exports.default = () => {
21
+ return new prosemirror_state_1.Plugin({
22
+ state: {
23
+ init(_, { doc }) {
24
+ if (doc.attrs.doi) {
25
+ const decorations = createDecoration(doc);
26
+ return prosemirror_view_1.DecorationSet.create(doc, decorations);
27
+ }
28
+ },
29
+ apply(tr, oldDecorationSet, oldState, newState) {
30
+ if (tr.docChanged && newState.doc.attrs.doi) {
31
+ const decorations = createDecoration(newState.doc);
32
+ return prosemirror_view_1.DecorationSet.create(newState.doc, decorations);
33
+ }
34
+ return oldDecorationSet;
35
+ },
36
+ },
37
+ props: {
38
+ decorations(state) {
39
+ return this.getState(state);
40
+ },
41
+ },
42
+ });
43
+ };
44
+ function getPosition(doc) {
45
+ const positions = [];
46
+ const possibleNodesTypes = ['keywords', 'supplements', 'abstracts', 'body'];
47
+ doc.descendants((node, pos) => {
48
+ if (possibleNodesTypes.includes(node.type.name)) {
49
+ positions.push(pos);
50
+ }
51
+ });
52
+ const position = positions.length === 0 ? 0 : Math.min(...positions);
53
+ return position;
54
+ }
55
+ function createDecoration(doc) {
56
+ const decoration = prosemirror_view_1.Decoration.widget(getPosition(doc), () => {
57
+ const doiContainer = document.createElement('div');
58
+ doiContainer.classList.add('doi-container', 'block');
59
+ doiContainer.innerHTML = `<p>DOI: https://doi.org/${doc.attrs.doi}</p>`;
60
+ return doiContainer;
61
+ });
62
+ return [decoration];
63
+ }
@@ -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 doi from '../plugins/doi';
27
28
  import editorProps from '../plugins/editor-props';
28
29
  import elements from '../plugins/elements';
29
30
  import footnotes from '../plugins/footnotes';
@@ -66,6 +67,7 @@ export default (props) => {
66
67
  footnotes(props),
67
68
  table_footnote(),
68
69
  editorProps(props),
70
+ doi(),
69
71
  ];
70
72
  if (props.collabProvider) {
71
73
  allPlugins.push(collab({ version: props.collabProvider.currentVersion }));
@@ -0,0 +1,61 @@
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 { Decoration, DecorationSet } from 'prosemirror-view';
18
+ export default () => {
19
+ return new Plugin({
20
+ state: {
21
+ init(_, { doc }) {
22
+ if (doc.attrs.doi) {
23
+ const decorations = createDecoration(doc);
24
+ return DecorationSet.create(doc, decorations);
25
+ }
26
+ },
27
+ apply(tr, oldDecorationSet, oldState, newState) {
28
+ if (tr.docChanged && newState.doc.attrs.doi) {
29
+ const decorations = createDecoration(newState.doc);
30
+ return DecorationSet.create(newState.doc, decorations);
31
+ }
32
+ return oldDecorationSet;
33
+ },
34
+ },
35
+ props: {
36
+ decorations(state) {
37
+ return this.getState(state);
38
+ },
39
+ },
40
+ });
41
+ };
42
+ function getPosition(doc) {
43
+ const positions = [];
44
+ const possibleNodesTypes = ['keywords', 'supplements', 'abstracts', 'body'];
45
+ doc.descendants((node, pos) => {
46
+ if (possibleNodesTypes.includes(node.type.name)) {
47
+ positions.push(pos);
48
+ }
49
+ });
50
+ const position = positions.length === 0 ? 0 : Math.min(...positions);
51
+ return position;
52
+ }
53
+ function createDecoration(doc) {
54
+ const decoration = Decoration.widget(getPosition(doc), () => {
55
+ const doiContainer = document.createElement('div');
56
+ doiContainer.classList.add('doi-container', 'block');
57
+ doiContainer.innerHTML = `<p>DOI: https://doi.org/${doc.attrs.doi}</p>`;
58
+ return doiContainer;
59
+ });
60
+ return [decoration];
61
+ }
@@ -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 | undefined>;
19
+ export default _default;
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": "1.11.6",
4
+ "version": "1.11.7-LEAN-1330.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -30,9 +30,9 @@
30
30
  "@iarna/word-count": "^1.1.2",
31
31
  "@manuscripts/json-schema": "2.2.8",
32
32
  "@manuscripts/library": "1.3.7",
33
- "@manuscripts/style-guide": "1.12.14",
33
+ "@manuscripts/style-guide": "1.12.15-LEAN-1330.0",
34
34
  "@manuscripts/track-changes-plugin": "1.7.12",
35
- "@manuscripts/transform": "2.3.7",
35
+ "@manuscripts/transform": "2.3.8-LEAN-1330.1",
36
36
  "astrocite-eutils": "^0.16.4",
37
37
  "mathjax-full": "^3.2.2",
38
38
  "codemirror": "^5.58.1",
@@ -927,6 +927,13 @@ span.accepted .selected-suggestion,
927
927
  align-items: flex-start;
928
928
  }
929
929
 
930
+ .ProseMirror .doi-container {
931
+ margin: 1rem 64px 0;
932
+ font-size: 12px;
933
+ color: #6e6e6e;
934
+
935
+ }
936
+
930
937
  * {
931
938
  scroll-behavior: smooth;
932
939
  }