@manuscripts/body-editor 1.6.12 → 1.6.13

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.
@@ -46,6 +46,7 @@ const pullquote_element_editable_1 = __importDefault(require("../views/pullquote
46
46
  const section_label_1 = __importDefault(require("../views/section_label"));
47
47
  const section_title_editable_1 = __importDefault(require("../views/section_title_editable"));
48
48
  const table_element_editable_1 = __importDefault(require("../views/table_element_editable"));
49
+ const table_element_footer_editable_1 = __importDefault(require("../views/table_element_footer_editable"));
49
50
  const title_editable_1 = __importDefault(require("../views/title_editable"));
50
51
  const toc_element_editable_1 = __importDefault(require("../views/toc_element_editable"));
51
52
  exports.default = (props, dispatch) => {
@@ -78,6 +79,7 @@ exports.default = (props, dispatch) => {
78
79
  section_title: (0, section_title_editable_1.default)(props),
79
80
  section_label: (0, section_label_1.default)(props),
80
81
  table_element: (0, table_element_editable_1.default)(props),
82
+ table_element_footer: (0, table_element_footer_editable_1.default)(props),
81
83
  toc_element: (0, toc_element_editable_1.default)(props),
82
84
  comments: (0, empty_1.default)('comments'),
83
85
  };
@@ -19,14 +19,18 @@ exports.buildPluginState = exports.footnotesKey = void 0;
19
19
  const transform_1 = require("@manuscripts/transform");
20
20
  const lodash_es_1 = require("lodash-es");
21
21
  const prosemirror_state_1 = require("prosemirror-state");
22
+ const prosemirror_utils_1 = require("prosemirror-utils");
22
23
  const prosemirror_view_1 = require("prosemirror-view");
24
+ const utils_1 = require("../../lib/utils");
23
25
  exports.footnotesKey = new prosemirror_state_1.PluginKey('footnotes');
24
26
  const buildPluginState = (doc) => {
25
27
  const nodes = [];
26
28
  let index = 0;
27
29
  const labels = new Map();
28
- doc.descendants((node, pos) => {
29
- if ((0, transform_1.isInlineFootnoteNode)(node)) {
30
+ doc.descendants((node, pos, parentNode) => {
31
+ if ((0, transform_1.isInlineFootnoteNode)(node) &&
32
+ parentNode &&
33
+ parentNode.type !== transform_1.schema.nodes.table_cell) {
30
34
  nodes.push([node, pos]);
31
35
  node.attrs.rids.forEach((rid) => {
32
36
  labels.set(rid, String(++index));
@@ -86,9 +90,18 @@ exports.default = () => {
86
90
  props: {
87
91
  decorations: (state) => {
88
92
  const decorations = [];
93
+ const isInTableElementFooter = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.table_element_footer)(state.selection);
94
+ if (isInTableElementFooter) {
95
+ const parent = (0, utils_1.findParentNodeWithIdValue)(state.selection);
96
+ if (parent) {
97
+ decorations.push(prosemirror_view_1.Decoration.node(parent.pos, parent.pos + parent.node.nodeSize, {
98
+ class: 'footnote-selected',
99
+ }));
100
+ }
101
+ }
89
102
  const { labels } = exports.footnotesKey.getState(state);
90
- if (labels) {
91
- state.doc.descendants((node, pos) => {
103
+ state.doc.descendants((node, pos) => {
104
+ if (labels) {
92
105
  if ((0, transform_1.isFootnoteNode)(node)) {
93
106
  const id = node.attrs.id;
94
107
  const label = labels.get(id);
@@ -98,8 +111,13 @@ exports.default = () => {
98
111
  }));
99
112
  }
100
113
  }
101
- });
102
- }
114
+ }
115
+ if (node.type === transform_1.schema.nodes.footnotes_element) {
116
+ decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
117
+ class: 'footnote-element',
118
+ }));
119
+ }
120
+ });
103
121
  return prosemirror_view_1.DecorationSet.create(state.doc, decorations);
104
122
  },
105
123
  },
@@ -0,0 +1,37 @@
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
+ exports.TableElementFooterView = void 0;
19
+ const base_node_view_1 = require("./base_node_view");
20
+ const creators_1 = require("./creators");
21
+ class TableElementFooterView extends base_node_view_1.BaseNodeView {
22
+ constructor() {
23
+ super(...arguments);
24
+ this.initialise = () => {
25
+ this.createDOM();
26
+ };
27
+ this.createDOM = () => {
28
+ this.dom = document.createElement('div');
29
+ this.dom.classList.add('table-footer');
30
+ this.dom.setAttribute('id', this.node.attrs.id);
31
+ this.contentDOM = document.createElement('div');
32
+ this.dom.appendChild(this.contentDOM);
33
+ };
34
+ }
35
+ }
36
+ exports.TableElementFooterView = TableElementFooterView;
37
+ exports.default = (0, creators_1.createNodeView)(TableElementFooterView);
@@ -0,0 +1,20 @@
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 table_element_footer_1 = require("./table_element_footer");
20
+ exports.default = (0, creators_1.createEditableNodeView)(table_element_footer_1.TableElementFooterView);
@@ -41,6 +41,7 @@ import pullquoteElement from '../views/pullquote_element_editable';
41
41
  import sectionLabel from '../views/section_label';
42
42
  import sectionTitle from '../views/section_title_editable';
43
43
  import tableElement from '../views/table_element_editable';
44
+ import tableElementFooter from '../views/table_element_footer_editable';
44
45
  import title from '../views/title_editable';
45
46
  import tocElement from '../views/toc_element_editable';
46
47
  export default (props, dispatch) => {
@@ -73,6 +74,7 @@ export default (props, dispatch) => {
73
74
  section_title: sectionTitle(props),
74
75
  section_label: sectionLabel(props),
75
76
  table_element: tableElement(props),
77
+ table_element_footer: tableElementFooter(props),
76
78
  toc_element: tocElement(props),
77
79
  comments: empty('comments'),
78
80
  };
@@ -13,17 +13,21 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { isFootnoteNode, isInlineFootnoteNode, } from '@manuscripts/transform';
16
+ import { isFootnoteNode, isInlineFootnoteNode, schema, } from '@manuscripts/transform';
17
17
  import { isEqual } from 'lodash-es';
18
18
  import { NodeSelection, Plugin, PluginKey } from 'prosemirror-state';
19
+ import { hasParentNodeOfType } from 'prosemirror-utils';
19
20
  import { Decoration, DecorationSet } from 'prosemirror-view';
21
+ import { findParentNodeWithIdValue } from '../../lib/utils';
20
22
  export const footnotesKey = new PluginKey('footnotes');
21
23
  export const buildPluginState = (doc) => {
22
24
  const nodes = [];
23
25
  let index = 0;
24
26
  const labels = new Map();
25
- doc.descendants((node, pos) => {
26
- if (isInlineFootnoteNode(node)) {
27
+ doc.descendants((node, pos, parentNode) => {
28
+ if (isInlineFootnoteNode(node) &&
29
+ parentNode &&
30
+ parentNode.type !== schema.nodes.table_cell) {
27
31
  nodes.push([node, pos]);
28
32
  node.attrs.rids.forEach((rid) => {
29
33
  labels.set(rid, String(++index));
@@ -82,9 +86,18 @@ export default () => {
82
86
  props: {
83
87
  decorations: (state) => {
84
88
  const decorations = [];
89
+ const isInTableElementFooter = hasParentNodeOfType(schema.nodes.table_element_footer)(state.selection);
90
+ if (isInTableElementFooter) {
91
+ const parent = findParentNodeWithIdValue(state.selection);
92
+ if (parent) {
93
+ decorations.push(Decoration.node(parent.pos, parent.pos + parent.node.nodeSize, {
94
+ class: 'footnote-selected',
95
+ }));
96
+ }
97
+ }
85
98
  const { labels } = footnotesKey.getState(state);
86
- if (labels) {
87
- state.doc.descendants((node, pos) => {
99
+ state.doc.descendants((node, pos) => {
100
+ if (labels) {
88
101
  if (isFootnoteNode(node)) {
89
102
  const id = node.attrs.id;
90
103
  const label = labels.get(id);
@@ -94,8 +107,13 @@ export default () => {
94
107
  }));
95
108
  }
96
109
  }
97
- });
98
- }
110
+ }
111
+ if (node.type === schema.nodes.footnotes_element) {
112
+ decorations.push(Decoration.node(pos, pos + node.nodeSize, {
113
+ class: 'footnote-element',
114
+ }));
115
+ }
116
+ });
99
117
  return DecorationSet.create(state.doc, decorations);
100
118
  },
101
119
  },
@@ -0,0 +1,33 @@
1
+ /*!
2
+ * © 2019 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 { BaseNodeView } from './base_node_view';
17
+ import { createNodeView } from './creators';
18
+ export class TableElementFooterView extends BaseNodeView {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.initialise = () => {
22
+ this.createDOM();
23
+ };
24
+ this.createDOM = () => {
25
+ this.dom = document.createElement('div');
26
+ this.dom.classList.add('table-footer');
27
+ this.dom.setAttribute('id', this.node.attrs.id);
28
+ this.contentDOM = document.createElement('div');
29
+ this.dom.appendChild(this.contentDOM);
30
+ };
31
+ }
32
+ }
33
+ export default createNodeView(TableElementFooterView);
@@ -0,0 +1,18 @@
1
+ /*!
2
+ * © 2019 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 { createEditableNodeView } from './creators';
17
+ import { TableElementFooterView } from './table_element_footer';
18
+ export default createEditableNodeView(TableElementFooterView);
@@ -532,6 +532,7 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
532
532
  updateNodeAttrs: (attrs: import("prosemirror-model").Attrs) => void;
533
533
  deleteNode: (id: string) => void;
534
534
  } & import("../views/table_element").TableElementView>;
535
+ table_element_footer: import("../types").NodeViewCreator<import("../views/table_element_footer").TableElementFooterView<any>>;
535
536
  toc_element: import("../types").NodeViewCreator<{
536
537
  gutterButtons: () => HTMLElement[];
537
538
  actionGutterButtons: () => HTMLElement[];
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * © 2019 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 { ManuscriptNodeView } from '@manuscripts/transform';
17
+ import { BaseNodeProps, BaseNodeView } from './base_node_view';
18
+ export declare class TableElementFooterView<PropsType extends BaseNodeProps> extends BaseNodeView<PropsType> implements ManuscriptNodeView {
19
+ initialise: () => void;
20
+ createDOM: () => void;
21
+ }
22
+ declare const _default: (props: BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<TableElementFooterView<any>>;
23
+ export default _default;
@@ -0,0 +1,18 @@
1
+ /*!
2
+ * © 2019 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 { TableElementFooterView } from './table_element_footer';
17
+ declare const _default: (props: import("./editable_block").EditableBlockProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<TableElementFooterView<any>>;
18
+ 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.6.12",
4
+ "version": "1.6.13",
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.1",
33
- "@manuscripts/library": "1.3.0",
34
- "@manuscripts/style-guide": "1.6.0",
32
+ "@manuscripts/json-schema": "^2.2.2",
33
+ "@manuscripts/library": "1.3.2",
34
+ "@manuscripts/style-guide": "1.6.1",
35
35
  "@manuscripts/track-changes-plugin": "^1.7.5",
36
- "@manuscripts/transform": "2.0.1",
36
+ "@manuscripts/transform": "2.0.4",
37
37
  "astrocite-eutils": "^0.16.4",
38
38
  "axios": "^1.2.2",
39
39
  "codemirror": "^5.58.1",
@@ -126,4 +126,4 @@
126
126
  "resolutions": {
127
127
  "@types/react": "^17.0.2"
128
128
  }
129
- }
129
+ }
package/styles/Editor.css CHANGED
@@ -939,6 +939,47 @@
939
939
  font-size: 75%;
940
940
  }
941
941
 
942
+ .ProseMirror .table-footer {
943
+ font-size: 14px;
944
+ }
945
+
946
+ .ProseMirror .table-footer .footnote-element:first-child {
947
+ padding-top: 8px;
948
+ }
949
+
950
+ .ProseMirror .table-footer .footnote-element:not(:first-child)::before {
951
+ content: '';
952
+ border-bottom: 1px dashed #C9C9C9;
953
+ display: block;
954
+ margin-bottom: 8px;
955
+ }
956
+
957
+ .ProseMirror .table-footer .footnote-element {
958
+ counter-reset: table_footnote;
959
+ }
960
+
961
+ .ProseMirror .table-footer .footnote-element p::before {
962
+ counter-increment: table_footnote;
963
+ content: counter(table_footnote);
964
+ display: inline-block;
965
+ position: relative;
966
+ cursor: pointer;
967
+ vertical-align: super;
968
+ font-size: 75%;
969
+ margin-right: 4px;
970
+ }
971
+
972
+ .ProseMirror .table-footer .footnote-element p {
973
+ margin-bottom: 0px;
974
+ margin-top: 0px;
975
+ }
976
+
977
+ .ProseMirror .table-footer .footnote-element .footnote-selected {
978
+ padding: 8px 0 8px 0;
979
+ border: 1px solid #bce7f6;
980
+ background-color: #f2fbfc;
981
+ }
982
+
942
983
  .ProseMirror .footnote-label {
943
984
  vertical-align: super;
944
985
  font-size: 75%;