@manuscripts/body-editor 1.7.8 → 1.7.9

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.
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.editAttrsTrackingIcon = exports.commentIcon = exports.editIcon = void 0;
18
+ exports.alertIcon = exports.editAttrsTrackingIcon = exports.commentIcon = exports.editIcon = void 0;
19
19
  exports.editIcon = `
20
20
  <svg
21
21
  width="14"
@@ -102,3 +102,19 @@ exports.editAttrsTrackingIcon = `
102
102
  />
103
103
  </svg>
104
104
  `;
105
+ exports.alertIcon = `
106
+ <svg
107
+ width="12"
108
+ height="12"
109
+ viewBox="0 0 12 12"
110
+ fill="none"
111
+ xmlns="http://www.w3.org/2000/svg"
112
+ >
113
+ <path
114
+ fill-rule="evenodd"
115
+ clip-rule="evenodd"
116
+ d="M6 12C2.68629 12 1.18852e-06 9.31371 1.47821e-06 6C1.7679e-06 2.68629 2.68629 1.39444e-07 6 4.29138e-07C9.31371 7.18831e-07 12 2.68629 12 6C12 9.31371 9.31371 12 6 12ZM6.74998 2.99996L6.75 6.37462C6.75 6.78819 6.41522 7.12243 6.00166 7.12334C5.58681 7.12426 5.25001 6.78821 5.25001 6.37335L5.25 3.00082C5.25 2.58629 5.58629 2.25037 6.00082 2.25083C6.4147 2.25128 6.74998 2.58607 6.74998 2.99996ZM6.75 8.99263C6.75 9.46884 6.47288 9.75 5.99853 9.75C5.52419 9.75 5.25 9.47179 5.25 8.99558C5.25 8.51937 5.52421 8.25 5.99855 8.25C6.47289 8.25 6.75 8.51642 6.75 8.99263Z"
117
+ fill="#FE8F1F"
118
+ />
119
+ </svg>
120
+ `;
@@ -0,0 +1,30 @@
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
+ exports.findTableInlineFootnoteIds = void 0;
19
+ const transform_1 = require("@manuscripts/transform");
20
+ const prosemirror_utils_1 = require("prosemirror-utils");
21
+ const findTableInlineFootnoteIds = ($pos) => {
22
+ var _a;
23
+ const tableElement = (_a = (0, prosemirror_utils_1.findParentNodeClosestToPos)($pos, (node) => node.type === transform_1.schema.nodes.table_element)) === null || _a === void 0 ? void 0 : _a.node.firstChild;
24
+ return new Set(tableElement
25
+ ? (0, prosemirror_utils_1.findChildren)(tableElement, (node) => node.type === transform_1.schema.nodes.inline_footnote)
26
+ .map(({ node }) => node.attrs.rids)
27
+ .flat()
28
+ : []);
29
+ };
30
+ exports.findTableInlineFootnoteIds = findTableInlineFootnoteIds;
@@ -15,14 +15,16 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.buildPluginState = exports.footnotesKey = void 0;
18
+ exports.uncitedFootnoteWidget = exports.buildPluginState = exports.footnotesKey = void 0;
19
19
  const transform_1 = require("@manuscripts/transform");
20
20
  const lodash_1 = require("lodash");
21
21
  const prosemirror_state_1 = require("prosemirror-state");
22
22
  const prosemirror_utils_1 = require("prosemirror-utils");
23
23
  const prosemirror_view_1 = require("prosemirror-view");
24
+ const assets_1 = require("../../assets");
24
25
  const utils_1 = require("../../lib/utils");
25
26
  const placeholder_1 = require("../placeholder");
27
+ const footnotes_utils_1 = require("./footnotes-utils");
26
28
  exports.footnotesKey = new prosemirror_state_1.PluginKey('footnotes');
27
29
  const buildPluginState = (doc) => {
28
30
  const nodes = [];
@@ -59,6 +61,13 @@ const labelWidget = (label, id) => (view) => {
59
61
  });
60
62
  return element;
61
63
  };
64
+ const uncitedFootnoteWidget = () => () => {
65
+ const element = document.createElement('span');
66
+ element.className = 'unctied-table-footnote';
67
+ element.innerHTML = assets_1.alertIcon;
68
+ return element;
69
+ };
70
+ exports.uncitedFootnoteWidget = uncitedFootnoteWidget;
62
71
  exports.default = () => {
63
72
  return new prosemirror_state_1.Plugin({
64
73
  key: exports.footnotesKey,
@@ -101,7 +110,8 @@ exports.default = () => {
101
110
  }
102
111
  }
103
112
  const { labels } = exports.footnotesKey.getState(state);
104
- state.doc.descendants((node, pos) => {
113
+ let tableInlineFootnoteIds = undefined;
114
+ state.doc.descendants((node, pos, parent) => {
105
115
  var _a;
106
116
  if ((0, transform_1.isFootnoteNode)(node)) {
107
117
  const id = node.attrs.id;
@@ -116,11 +126,21 @@ exports.default = () => {
116
126
  if (!((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.textContent)) {
117
127
  decorations.push(prosemirror_view_1.Decoration.widget(pos + 2, (0, placeholder_1.placeholderWidget)('Add new note here')));
118
128
  }
129
+ if (tableInlineFootnoteIds &&
130
+ !tableInlineFootnoteIds.has(node.attrs.id)) {
131
+ decorations.push(prosemirror_view_1.Decoration.widget(pos + node.nodeSize - 1, (0, exports.uncitedFootnoteWidget)()));
132
+ }
119
133
  }
120
134
  if (node.type === transform_1.schema.nodes.footnotes_element) {
121
135
  decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
122
136
  class: 'footnote-element',
123
137
  }));
138
+ if ((parent === null || parent === void 0 ? void 0 : parent.type) === transform_1.schema.nodes.table_element_footer) {
139
+ tableInlineFootnoteIds = (0, footnotes_utils_1.findTableInlineFootnoteIds)(state.doc.resolve(pos));
140
+ }
141
+ else {
142
+ tableInlineFootnoteIds = undefined;
143
+ }
124
144
  }
125
145
  });
126
146
  return prosemirror_view_1.DecorationSet.create(state.doc, decorations);
package/dist/es/assets.js CHANGED
@@ -99,3 +99,19 @@ export const editAttrsTrackingIcon = `
99
99
  />
100
100
  </svg>
101
101
  `;
102
+ export const alertIcon = `
103
+ <svg
104
+ width="12"
105
+ height="12"
106
+ viewBox="0 0 12 12"
107
+ fill="none"
108
+ xmlns="http://www.w3.org/2000/svg"
109
+ >
110
+ <path
111
+ fill-rule="evenodd"
112
+ clip-rule="evenodd"
113
+ d="M6 12C2.68629 12 1.18852e-06 9.31371 1.47821e-06 6C1.7679e-06 2.68629 2.68629 1.39444e-07 6 4.29138e-07C9.31371 7.18831e-07 12 2.68629 12 6C12 9.31371 9.31371 12 6 12ZM6.74998 2.99996L6.75 6.37462C6.75 6.78819 6.41522 7.12243 6.00166 7.12334C5.58681 7.12426 5.25001 6.78821 5.25001 6.37335L5.25 3.00082C5.25 2.58629 5.58629 2.25037 6.00082 2.25083C6.4147 2.25128 6.74998 2.58607 6.74998 2.99996ZM6.75 8.99263C6.75 9.46884 6.47288 9.75 5.99853 9.75C5.52419 9.75 5.25 9.47179 5.25 8.99558C5.25 8.51937 5.52421 8.25 5.99855 8.25C6.47289 8.25 6.75 8.51642 6.75 8.99263Z"
114
+ fill="#FE8F1F"
115
+ />
116
+ </svg>
117
+ `;
@@ -0,0 +1,26 @@
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 { findChildren, findParentNodeClosestToPos } from 'prosemirror-utils';
18
+ export const findTableInlineFootnoteIds = ($pos) => {
19
+ var _a;
20
+ const tableElement = (_a = findParentNodeClosestToPos($pos, (node) => node.type === schema.nodes.table_element)) === null || _a === void 0 ? void 0 : _a.node.firstChild;
21
+ return new Set(tableElement
22
+ ? findChildren(tableElement, (node) => node.type === schema.nodes.inline_footnote)
23
+ .map(({ node }) => node.attrs.rids)
24
+ .flat()
25
+ : []);
26
+ };
@@ -18,8 +18,10 @@ import { isEqual } from 'lodash';
18
18
  import { NodeSelection, Plugin, PluginKey } from 'prosemirror-state';
19
19
  import { hasParentNodeOfType } from 'prosemirror-utils';
20
20
  import { Decoration, DecorationSet } from 'prosemirror-view';
21
+ import { alertIcon } from '../../assets';
21
22
  import { findParentNodeWithIdValue } from '../../lib/utils';
22
23
  import { placeholderWidget } from '../placeholder';
24
+ import { findTableInlineFootnoteIds } from './footnotes-utils';
23
25
  export const footnotesKey = new PluginKey('footnotes');
24
26
  export const buildPluginState = (doc) => {
25
27
  const nodes = [];
@@ -55,6 +57,12 @@ const labelWidget = (label, id) => (view) => {
55
57
  });
56
58
  return element;
57
59
  };
60
+ export const uncitedFootnoteWidget = () => () => {
61
+ const element = document.createElement('span');
62
+ element.className = 'unctied-table-footnote';
63
+ element.innerHTML = alertIcon;
64
+ return element;
65
+ };
58
66
  export default () => {
59
67
  return new Plugin({
60
68
  key: footnotesKey,
@@ -97,7 +105,8 @@ export default () => {
97
105
  }
98
106
  }
99
107
  const { labels } = footnotesKey.getState(state);
100
- state.doc.descendants((node, pos) => {
108
+ let tableInlineFootnoteIds = undefined;
109
+ state.doc.descendants((node, pos, parent) => {
101
110
  var _a;
102
111
  if (isFootnoteNode(node)) {
103
112
  const id = node.attrs.id;
@@ -112,11 +121,21 @@ export default () => {
112
121
  if (!((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.textContent)) {
113
122
  decorations.push(Decoration.widget(pos + 2, placeholderWidget('Add new note here')));
114
123
  }
124
+ if (tableInlineFootnoteIds &&
125
+ !tableInlineFootnoteIds.has(node.attrs.id)) {
126
+ decorations.push(Decoration.widget(pos + node.nodeSize - 1, uncitedFootnoteWidget()));
127
+ }
115
128
  }
116
129
  if (node.type === schema.nodes.footnotes_element) {
117
130
  decorations.push(Decoration.node(pos, pos + node.nodeSize, {
118
131
  class: 'footnote-element',
119
132
  }));
133
+ if ((parent === null || parent === void 0 ? void 0 : parent.type) === schema.nodes.table_element_footer) {
134
+ tableInlineFootnoteIds = findTableInlineFootnoteIds(state.doc.resolve(pos));
135
+ }
136
+ else {
137
+ tableInlineFootnoteIds = undefined;
138
+ }
120
139
  }
121
140
  });
122
141
  return DecorationSet.create(state.doc, decorations);
@@ -16,3 +16,4 @@
16
16
  export declare const editIcon = "\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 14 14\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M8.706 2.33624L11.553 5.19824L4.345 12.4422L1.498 9.58124L8.706 2.33624V2.33624ZM13.714 1.64624L12.444 0.37024C12.3273 0.253047 12.1886 0.160056 12.0359 0.0966039C11.8831 0.0331518 11.7194 0.000488281 11.554 0.000488281C11.3886 0.000488281 11.2249 0.0331518 11.0721 0.0966039C10.9194 0.160056 10.7807 0.253047 10.664 0.37024L9.447 1.59224L12.295 4.45424L13.715 3.02824C13.8976 2.84462 14.0001 2.59619 14.0001 2.33724C14.0001 2.07829 13.8976 1.82986 13.715 1.64624H13.714ZM0.00800253 13.6032C-0.00418388 13.6571 -0.00246802 13.7131 0.0129883 13.7661C0.0284447 13.819 0.0571327 13.8672 0.096349 13.906C0.135565 13.9448 0.184019 13.973 0.237143 13.9879C0.290268 14.0028 0.346315 14.004 0.400003 13.9912L3.573 13.2172L0.727003 10.3552L0.0070026 13.6032H0.00800253Z\"\n fill=\"#6E6E6E\"\n />\n </svg>\n";
17
17
  export declare const commentIcon = "\n<svg\n width=\"20\"\n height=\"15\"\n viewBox=\"0 0 20 15\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M7.94841 4.18311C7.98238 3.9602 8 3.73191 8 3.49951C8 3.22073 7.97465 2.94787 7.92613 2.68311H13.5C14.8854 2.68311 16.25 3.6425 16.25 5.09977V9.02453L19.1086 12.9949C19.2731 13.2233 19.2958 13.5245 19.1675 13.775C19.0392 14.0255 18.7814 14.1831 18.5 14.1831H5.5C4.11463 14.1831 2.75 13.2237 2.75 11.7664V7.93729C2.9939 7.97821 3.24446 7.99951 3.5 7.99951C3.75553 7.99951 4.00609 7.97821 4.25 7.93729V11.7664C4.25 12.1508 4.67537 12.6831 5.5 12.6831H17.0358L14.8913 9.70467C14.7994 9.57703 14.75 9.42372 14.75 9.26644V5.09977C14.75 4.71538 14.3246 4.18311 13.5 4.18311H7.94841Z\"\n fill=\"#FFBD26\"\n />\n <path\n d=\"M11.5 6.99951H8.5\"\n stroke=\"#FFBD26\"\n stroke-width=\"1.5\"\n stroke-miterlimit=\"10\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n <path\n d=\"M12 9.99951H7\"\n stroke=\"#FFBD26\"\n stroke-width=\"1.5\"\n stroke-miterlimit=\"10\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n <path\n d=\"M3.5 1L3.5 6\"\n stroke=\"#FFBD26\"\n stroke-width=\"1.5\"\n stroke-miterlimit=\"10\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n <path\n d=\"M6 3.5L1 3.5\"\n stroke=\"#FFBD26\"\n stroke-width=\"1.5\"\n stroke-miterlimit=\"10\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n";
18
18
  export declare const editAttrsTrackingIcon = "\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M12 2L14 4L9 9L6 10L7 7L12 2Z\"\n stroke=\"#353535\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n <path\n d=\"M13 10V11.5C13 12.328 12.328 13 11.5 13H4.5C3.672 13 3 12.328 3 11.5V4.5C3 3.672 3.672 3 4.5 3H6\"\n stroke=\"#353535\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n";
19
+ export declare const alertIcon = "\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 12 12\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M6 12C2.68629 12 1.18852e-06 9.31371 1.47821e-06 6C1.7679e-06 2.68629 2.68629 1.39444e-07 6 4.29138e-07C9.31371 7.18831e-07 12 2.68629 12 6C12 9.31371 9.31371 12 6 12ZM6.74998 2.99996L6.75 6.37462C6.75 6.78819 6.41522 7.12243 6.00166 7.12334C5.58681 7.12426 5.25001 6.78821 5.25001 6.37335L5.25 3.00082C5.25 2.58629 5.58629 2.25037 6.00082 2.25083C6.4147 2.25128 6.74998 2.58607 6.74998 2.99996ZM6.75 8.99263C6.75 9.46884 6.47288 9.75 5.99853 9.75C5.52419 9.75 5.25 9.47179 5.25 8.99558C5.25 8.51937 5.52421 8.25 5.99855 8.25C6.47289 8.25 6.75 8.51642 6.75 8.99263Z\"\n fill=\"#FE8F1F\"\n />\n </svg>\n";
@@ -0,0 +1,17 @@
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 { ResolvedPos } from 'prosemirror-model';
17
+ export declare const findTableInlineFootnoteIds: ($pos: ResolvedPos) => Set<string>;
@@ -21,5 +21,6 @@ interface PluginState {
21
21
  }
22
22
  export declare const footnotesKey: PluginKey<PluginState>;
23
23
  export declare const buildPluginState: (doc: ManuscriptNode) => PluginState;
24
+ export declare const uncitedFootnoteWidget: () => () => HTMLSpanElement;
24
25
  declare const _default: () => Plugin<PluginState>;
25
26
  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.7.8",
4
+ "version": "1.7.9",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -29,11 +29,11 @@
29
29
  "dependencies": {
30
30
  "@iarna/word-count": "^1.1.2",
31
31
  "@manuscripts/assets": "^0.6.4",
32
- "@manuscripts/json-schema": "^2.2.2",
33
- "@manuscripts/library": "1.3.2",
34
- "@manuscripts/style-guide": "1.7.5",
32
+ "@manuscripts/json-schema": "^2.2.4",
33
+ "@manuscripts/library": "^1.3.3",
34
+ "@manuscripts/style-guide": "^1.7.6",
35
35
  "@manuscripts/track-changes-plugin": "^1.7.5",
36
- "@manuscripts/transform": "2.1.1",
36
+ "@manuscripts/transform": "^2.1.2",
37
37
  "astrocite-eutils": "^0.16.4",
38
38
  "axios": "^1.6.7",
39
39
  "codemirror": "^5.58.1",
package/styles/Editor.css CHANGED
@@ -955,7 +955,7 @@
955
955
  counter-reset: table_footnote;
956
956
  }
957
957
 
958
- .ProseMirror .table-footer .footnote-element p::before {
958
+ .ProseMirror .table-footer .footnote-element > div:not(:has(.unctied-table-footnote)) p::before {
959
959
  counter-increment: table_footnote;
960
960
  content: counter(table_footnote);
961
961
  display: inline-block;
@@ -998,6 +998,18 @@
998
998
  cursor: pointer;
999
999
  }
1000
1000
 
1001
+ .ProseMirror .footnote-element > div:has(.unctied-table-footnote) {
1002
+ position: relative;
1003
+ }
1004
+
1005
+ .ProseMirror .unctied-table-footnote {
1006
+ display: flex;
1007
+ position: absolute;
1008
+ margin-right: 4px;
1009
+ top: 10%;
1010
+ right: 100%;
1011
+ }
1012
+
1001
1013
  .graphical-abstract .listing {
1002
1014
  display: none;
1003
1015
  }