@manuscripts/body-editor 1.7.31-LEAN-3144-0 → 1.7.31

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.
@@ -727,35 +727,22 @@ const updateCommentAnnotationState = (state, dispatch) => {
727
727
  }
728
728
  };
729
729
  exports.updateCommentAnnotationState = updateCommentAnnotationState;
730
- const insertTableFootnote = (node, position, view, inlineFootnote) => {
730
+ const insertTableFootnote = (node, position, view) => {
731
731
  var _a;
732
732
  const { state, dispatch } = view;
733
- const tr = state.tr;
734
733
  const footnote = state.schema.nodes.footnote.createAndFill({
735
734
  id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.Footnote),
736
735
  kind: 'footnote',
737
736
  });
738
737
  const insertedAt = state.selection.to;
739
- let footnoteIndex;
740
- if (inlineFootnote) {
741
- const contents = inlineFootnote.node.attrs.contents.split(',').map(Number);
742
- footnoteIndex = Math.max(...contents) + 1;
743
- tr.setNodeMarkup(inlineFootnote.pos, undefined, {
744
- rids: [...inlineFootnote.node.attrs.rids, footnote.attrs.id],
745
- contents: inlineFootnote.node.attrs.contents + ',' + footnoteIndex,
746
- });
747
- }
748
- else {
749
- const inlineFootnotes = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.inline_footnote);
750
- footnoteIndex =
751
- inlineFootnotes.filter(({ pos }) => position + pos <= insertedAt).length +
752
- 1;
753
- const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
754
- rids: [footnote.attrs.id],
755
- contents: footnoteIndex === -1 ? inlineFootnotes.length : footnoteIndex,
756
- });
757
- tr.insert(insertedAt, inlineFootnoteNode);
758
- }
738
+ const inlineFootnotes = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.inline_footnote);
739
+ const footnoteIndex = inlineFootnotes.filter(({ pos }) => position + pos <= insertedAt).length + 1;
740
+ const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
741
+ rids: [footnote.attrs.id],
742
+ contents: footnoteIndex === -1 ? inlineFootnotes.length : footnoteIndex,
743
+ });
744
+ const tr = state.tr;
745
+ tr.insert(insertedAt, inlineFootnoteNode);
759
746
  let insertionPos = position;
760
747
  const footnotesElement = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.footnotes_element).pop();
761
748
  if (footnotesElement &&
@@ -198,10 +198,9 @@ class ContextMenu {
198
198
  else {
199
199
  const tablesFootnoteLabels = (0, footnotes_utils_1.buildTableFootnoteLabels)(this.node);
200
200
  const footnotesWithPos = (0, prosemirror_utils_1.findChildrenByType)(footnotesElementWithPos.node, transform_1.schema.nodes.footnote);
201
- const footnotes = footnotesWithPos
202
- .map(({ node }) => ({
203
- node: node,
204
- index: tablesFootnoteLabels.get(node.attrs.id),
201
+ const footnotes = footnotesWithPos.map((nodeWithPos) => ({
202
+ node: nodeWithPos.node,
203
+ index: tablesFootnoteLabels.get(nodeWithPos.node.attrs.id),
205
204
  }));
206
205
  const targetDom = this.view.domAtPos(this.view.state.selection.from);
207
206
  if (targetDom.node instanceof Element && this.props) {
@@ -14,43 +14,16 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
17
  Object.defineProperty(exports, "__esModule", { value: true });
21
18
  exports.InlineFootnoteView = void 0;
22
- const style_guide_1 = require("@manuscripts/style-guide");
23
- const transform_1 = require("@manuscripts/transform");
24
- const prosemirror_utils_1 = require("prosemirror-utils");
25
- const commands_1 = require("../commands");
26
19
  const track_changes_utils_1 = require("../lib/track-changes-utils");
27
- const footnotes_utils_1 = require("../plugins/footnotes/footnotes-utils");
28
20
  const base_node_view_1 = require("./base_node_view");
29
21
  const creators_1 = require("./creators");
30
- const ReactSubView_1 = __importDefault(require("./ReactSubView"));
31
22
  class InlineFootnoteView extends base_node_view_1.BaseNodeView {
32
23
  constructor() {
33
24
  super(...arguments);
34
- this.findParentTableElement = () => (0, prosemirror_utils_1.findParentNodeClosestToPos)(this.view.state.doc.resolve(this.getPos()), (node) => node.type === transform_1.schema.nodes.table_element);
35
25
  this.handleClick = () => {
36
- if ((0, track_changes_utils_1.isDeleted)(this.node)) {
37
- return;
38
- }
39
- const tableElement = this.findParentTableElement();
40
- if (tableElement) {
41
- const componentProps = {
42
- notes: this.getNotes(tableElement),
43
- onAdd: this.onAdd,
44
- onInsert: this.onUpdate,
45
- onCancel: this.destroy,
46
- inlineFootnote: this.node,
47
- };
48
- this.popperContainer = (0, ReactSubView_1.default)(Object.assign(Object.assign({}, this.props), { dispatch: this.view.dispatch }), style_guide_1.TableFootnotesSelector, componentProps, this.node, this.getPos, this.view, 'table-footnote-editor');
49
- this.props.popper.show(this.dom, this.popperContainer, 'bottom-end');
50
- }
51
- else {
52
- this.props.history.push(Object.assign(Object.assign({}, this.props.history.location), { hash: '#' + this.node.attrs.rid }));
53
- }
26
+ this.props.history.push(Object.assign(Object.assign({}, this.props.history.location), { hash: '#' + this.node.attrs.rid }));
54
27
  };
55
28
  this.updateContents = () => {
56
29
  this.setDomAttrs(this.node, this.dom);
@@ -69,49 +42,6 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
69
42
  this.createDOM = () => {
70
43
  return document.createElement('span');
71
44
  };
72
- this.destroy = () => {
73
- var _a;
74
- this.props.popper.destroy();
75
- (_a = this.popperContainer) === null || _a === void 0 ? void 0 : _a.remove();
76
- };
77
- this.getNotes = (tableElement) => {
78
- var _a;
79
- const footnotesElement = (_a = (0, prosemirror_utils_1.findChildrenByType)(tableElement.node, transform_1.schema.nodes.footnotes_element).pop()) === null || _a === void 0 ? void 0 : _a.node;
80
- let footnotes = [];
81
- if (footnotesElement) {
82
- const tablesFootnoteLabels = (0, footnotes_utils_1.buildTableFootnoteLabels)(tableElement.node);
83
- footnotes = (0, prosemirror_utils_1.findChildrenByType)(footnotesElement, transform_1.schema.nodes.footnote)
84
- .map(({ node }) => ({
85
- node: node,
86
- index: tablesFootnoteLabels.get(node.attrs.id),
87
- }));
88
- }
89
- return footnotes;
90
- };
91
- this.onAdd = () => {
92
- const tableElement = this.findParentTableElement();
93
- if (tableElement) {
94
- (0, commands_1.insertTableFootnote)(tableElement.node, tableElement.pos, this.view, {
95
- node: this.node,
96
- pos: this.getPos(),
97
- });
98
- this.destroy();
99
- }
100
- };
101
- this.onUpdate = (notes) => {
102
- const contents = this.node.attrs.contents.split(',');
103
- const rids = notes.map((note) => note.node.attrs.id);
104
- const { tr } = this.view.state;
105
- this.view.dispatch(rids.length
106
- ? tr.setNodeMarkup(this.getPos(), undefined, {
107
- rids,
108
- contents: notes
109
- .map(({ index }) => (index ? index : Math.max(...contents) + 1))
110
- .join(),
111
- })
112
- : tr.delete(this.getPos(), this.getPos() + this.node.nodeSize));
113
- this.destroy();
114
- };
115
45
  }
116
46
  }
117
47
  exports.InlineFootnoteView = InlineFootnoteView;
@@ -690,35 +690,22 @@ export const updateCommentAnnotationState = (state, dispatch) => {
690
690
  dispatch(tr);
691
691
  }
692
692
  };
693
- export const insertTableFootnote = (node, position, view, inlineFootnote) => {
693
+ export const insertTableFootnote = (node, position, view) => {
694
694
  var _a;
695
695
  const { state, dispatch } = view;
696
- const tr = state.tr;
697
696
  const footnote = state.schema.nodes.footnote.createAndFill({
698
697
  id: generateID(ObjectTypes.Footnote),
699
698
  kind: 'footnote',
700
699
  });
701
700
  const insertedAt = state.selection.to;
702
- let footnoteIndex;
703
- if (inlineFootnote) {
704
- const contents = inlineFootnote.node.attrs.contents.split(',').map(Number);
705
- footnoteIndex = Math.max(...contents) + 1;
706
- tr.setNodeMarkup(inlineFootnote.pos, undefined, {
707
- rids: [...inlineFootnote.node.attrs.rids, footnote.attrs.id],
708
- contents: inlineFootnote.node.attrs.contents + ',' + footnoteIndex,
709
- });
710
- }
711
- else {
712
- const inlineFootnotes = findChildrenByType(node, schema.nodes.inline_footnote);
713
- footnoteIndex =
714
- inlineFootnotes.filter(({ pos }) => position + pos <= insertedAt).length +
715
- 1;
716
- const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
717
- rids: [footnote.attrs.id],
718
- contents: footnoteIndex === -1 ? inlineFootnotes.length : footnoteIndex,
719
- });
720
- tr.insert(insertedAt, inlineFootnoteNode);
721
- }
701
+ const inlineFootnotes = findChildrenByType(node, schema.nodes.inline_footnote);
702
+ const footnoteIndex = inlineFootnotes.filter(({ pos }) => position + pos <= insertedAt).length + 1;
703
+ const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
704
+ rids: [footnote.attrs.id],
705
+ contents: footnoteIndex === -1 ? inlineFootnotes.length : footnoteIndex,
706
+ });
707
+ const tr = state.tr;
708
+ tr.insert(insertedAt, inlineFootnoteNode);
722
709
  let insertionPos = position;
723
710
  const footnotesElement = findChildrenByType(node, schema.nodes.footnotes_element).pop();
724
711
  if (footnotesElement &&
@@ -191,10 +191,9 @@ export class ContextMenu {
191
191
  else {
192
192
  const tablesFootnoteLabels = buildTableFootnoteLabels(this.node);
193
193
  const footnotesWithPos = findChildrenByType(footnotesElementWithPos.node, schema.nodes.footnote);
194
- const footnotes = footnotesWithPos
195
- .map(({ node }) => ({
196
- node: node,
197
- index: tablesFootnoteLabels.get(node.attrs.id),
194
+ const footnotes = footnotesWithPos.map((nodeWithPos) => ({
195
+ node: nodeWithPos.node,
196
+ index: tablesFootnoteLabels.get(nodeWithPos.node.attrs.id),
198
197
  }));
199
198
  const targetDom = this.view.domAtPos(this.view.state.selection.from);
200
199
  if (targetDom.node instanceof Element && this.props) {
@@ -13,38 +13,14 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { TableFootnotesSelector, } from '@manuscripts/style-guide';
17
- import { schema, } from '@manuscripts/transform';
18
- import { findChildrenByType, findParentNodeClosestToPos, } from 'prosemirror-utils';
19
- import { insertTableFootnote } from '../commands';
20
- import { getChangeClasses, isDeleted, } from '../lib/track-changes-utils';
21
- import { buildTableFootnoteLabels } from '../plugins/footnotes/footnotes-utils';
16
+ import { getChangeClasses } from '../lib/track-changes-utils';
22
17
  import { BaseNodeView } from './base_node_view';
23
18
  import { createNodeView } from './creators';
24
- import ReactSubView from './ReactSubView';
25
19
  export class InlineFootnoteView extends BaseNodeView {
26
20
  constructor() {
27
21
  super(...arguments);
28
- this.findParentTableElement = () => findParentNodeClosestToPos(this.view.state.doc.resolve(this.getPos()), (node) => node.type === schema.nodes.table_element);
29
22
  this.handleClick = () => {
30
- if (isDeleted(this.node)) {
31
- return;
32
- }
33
- const tableElement = this.findParentTableElement();
34
- if (tableElement) {
35
- const componentProps = {
36
- notes: this.getNotes(tableElement),
37
- onAdd: this.onAdd,
38
- onInsert: this.onUpdate,
39
- onCancel: this.destroy,
40
- inlineFootnote: this.node,
41
- };
42
- this.popperContainer = ReactSubView(Object.assign(Object.assign({}, this.props), { dispatch: this.view.dispatch }), TableFootnotesSelector, componentProps, this.node, this.getPos, this.view, 'table-footnote-editor');
43
- this.props.popper.show(this.dom, this.popperContainer, 'bottom-end');
44
- }
45
- else {
46
- this.props.history.push(Object.assign(Object.assign({}, this.props.history.location), { hash: '#' + this.node.attrs.rid }));
47
- }
23
+ this.props.history.push(Object.assign(Object.assign({}, this.props.history.location), { hash: '#' + this.node.attrs.rid }));
48
24
  };
49
25
  this.updateContents = () => {
50
26
  this.setDomAttrs(this.node, this.dom);
@@ -63,49 +39,6 @@ export class InlineFootnoteView extends BaseNodeView {
63
39
  this.createDOM = () => {
64
40
  return document.createElement('span');
65
41
  };
66
- this.destroy = () => {
67
- var _a;
68
- this.props.popper.destroy();
69
- (_a = this.popperContainer) === null || _a === void 0 ? void 0 : _a.remove();
70
- };
71
- this.getNotes = (tableElement) => {
72
- var _a;
73
- const footnotesElement = (_a = findChildrenByType(tableElement.node, schema.nodes.footnotes_element).pop()) === null || _a === void 0 ? void 0 : _a.node;
74
- let footnotes = [];
75
- if (footnotesElement) {
76
- const tablesFootnoteLabels = buildTableFootnoteLabels(tableElement.node);
77
- footnotes = findChildrenByType(footnotesElement, schema.nodes.footnote)
78
- .map(({ node }) => ({
79
- node: node,
80
- index: tablesFootnoteLabels.get(node.attrs.id),
81
- }));
82
- }
83
- return footnotes;
84
- };
85
- this.onAdd = () => {
86
- const tableElement = this.findParentTableElement();
87
- if (tableElement) {
88
- insertTableFootnote(tableElement.node, tableElement.pos, this.view, {
89
- node: this.node,
90
- pos: this.getPos(),
91
- });
92
- this.destroy();
93
- }
94
- };
95
- this.onUpdate = (notes) => {
96
- const contents = this.node.attrs.contents.split(',');
97
- const rids = notes.map((note) => note.node.attrs.id);
98
- const { tr } = this.view.state;
99
- this.view.dispatch(rids.length
100
- ? tr.setNodeMarkup(this.getPos(), undefined, {
101
- rids,
102
- contents: notes
103
- .map(({ index }) => (index ? index : Math.max(...contents) + 1))
104
- .join(),
105
- })
106
- : tr.delete(this.getPos(), this.getPos() + this.node.nodeSize));
107
- this.destroy();
108
- };
109
42
  }
110
43
  }
111
44
  export default createNodeView(InlineFootnoteView);
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { CommentAnnotation } from '@manuscripts/json-schema';
17
17
  import { FileAttachment } from '@manuscripts/style-guide';
18
- import { InlineFootnoteNode, ManuscriptEditorState, ManuscriptEditorView, ManuscriptMarkType, ManuscriptNode, ManuscriptNodeType, ManuscriptTransaction } from '@manuscripts/transform';
18
+ import { ManuscriptEditorState, ManuscriptEditorView, ManuscriptMarkType, ManuscriptNode, ManuscriptNodeType, ManuscriptTransaction } from '@manuscripts/transform';
19
19
  import { ResolvedPos } from 'prosemirror-model';
20
20
  import { Command, NodeSelection, Selection, TextSelection, Transaction } from 'prosemirror-state';
21
21
  import { NodeWithPos } from 'prosemirror-utils';
@@ -57,9 +57,4 @@ export declare const deleteHighlightMarkers: (rid: string) => Command;
57
57
  export declare function addComment(state: ManuscriptEditorState, dispatch?: Dispatch): boolean;
58
58
  export declare function addComment(state: ManuscriptEditorState, dispatch?: Dispatch, viewNode?: ManuscriptNode, resolvePos?: ResolvedPos): boolean;
59
59
  export declare const updateCommentAnnotationState: (state: ManuscriptEditorState, dispatch?: Dispatch) => void;
60
- interface NodeWithPosition {
61
- node: InlineFootnoteNode;
62
- pos: number;
63
- }
64
- export declare const insertTableFootnote: (node: ManuscriptNode, position: number, view: EditorView, inlineFootnote?: NodeWithPosition) => void;
65
- export {};
60
+ export declare const insertTableFootnote: (node: ManuscriptNode, position: number, view: EditorView) => void;
@@ -13,27 +13,18 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { FootnoteWithIndex } from '@manuscripts/style-guide';
17
16
  import { ManuscriptNodeView } from '@manuscripts/transform';
18
17
  import { History } from 'history';
19
- import { ContentNodeWithPos } from 'prosemirror-utils';
20
18
  import { BaseNodeProps, BaseNodeView } from './base_node_view';
21
- import { EditableBlockProps } from './editable_block';
22
19
  export interface InlineFootnoteProps extends BaseNodeProps {
23
20
  history: History;
24
21
  }
25
- export declare class InlineFootnoteView<PropsType extends InlineFootnoteProps & EditableBlockProps> extends BaseNodeView<PropsType> implements ManuscriptNodeView {
26
- protected popperContainer: HTMLDivElement;
27
- findParentTableElement: () => ContentNodeWithPos | undefined;
22
+ export declare class InlineFootnoteView<PropsType extends InlineFootnoteProps> extends BaseNodeView<PropsType> implements ManuscriptNodeView {
28
23
  handleClick: () => void;
29
24
  updateContents: () => void;
30
25
  initialise: () => void;
31
26
  ignoreMutation: () => boolean;
32
27
  createDOM: () => HTMLSpanElement;
33
- destroy: () => void;
34
- getNotes: (tableElement: ContentNodeWithPos) => FootnoteWithIndex[];
35
- onAdd: () => void;
36
- onUpdate: (notes: FootnoteWithIndex[]) => void;
37
28
  }
38
- declare const _default: (props: BaseNodeProps, dispatch?: import("../commands").Dispatch | undefined) => import("../types").NodeViewCreator<InlineFootnoteView<any>>;
29
+ declare const _default: (props: BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<InlineFootnoteView<any>>;
39
30
  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.31-LEAN-3144-0",
4
+ "version": "1.7.31",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -31,7 +31,7 @@
31
31
  "@manuscripts/assets": "^0.6.4",
32
32
  "@manuscripts/json-schema": "^2.2.7",
33
33
  "@manuscripts/library": "^1.3.6",
34
- "@manuscripts/style-guide": "1.8.4-LEAN-3144-4",
34
+ "@manuscripts/style-guide": "1.8.4",
35
35
  "@manuscripts/track-changes-plugin": "1.7.9",
36
36
  "@manuscripts/transform": "^2.1.10",
37
37
  "astrocite-eutils": "^0.16.4",
@@ -112,4 +112,4 @@
112
112
  "@types/react": "^17.0.2",
113
113
  "prosemirror-tables": "^1.3.5"
114
114
  }
115
- }
115
+ }
@@ -724,13 +724,11 @@ Next levels are shifted 'up' by 1
724
724
  text-decoration: none;
725
725
  }
726
726
 
727
- .ProseMirror .deleted.pending::before,
728
727
  .ProseMirror .deleted.pending {
729
728
  background: var(--pending-bg-color);
730
729
  color: var(--deleted-color);
731
730
  text-decoration: line-through;
732
731
  }
733
- .ProseMirror .deleted.accepted::before,
734
732
  .ProseMirror .deleted.accepted {
735
733
  background: var(--accepted-bg-color);
736
734
  color: var(--deleted-color);
package/styles/Editor.css CHANGED
@@ -941,7 +941,6 @@
941
941
  cursor: pointer;
942
942
  vertical-align: super;
943
943
  font-size: 75%;
944
- color: #0d79d0;
945
944
  }
946
945
 
947
946
  .ProseMirror .table-footer {