@manuscripts/body-editor 1.7.20 → 1.7.22
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.
- package/dist/cjs/commands.js +26 -11
- package/dist/cjs/lib/context-menu.js +8 -5
- package/dist/cjs/plugins/footnotes/index.js +3 -3
- package/dist/cjs/views/footnote.js +12 -2
- package/dist/cjs/views/footnote_editable.js +1 -1
- package/dist/cjs/views/footnotes_element.js +2 -1
- package/dist/cjs/views/footnotes_element_editable.js +2 -1
- package/dist/cjs/views/inline_footnote.js +5 -0
- package/dist/es/commands.js +26 -11
- package/dist/es/lib/context-menu.js +8 -5
- package/dist/es/plugins/footnotes/index.js +3 -3
- package/dist/es/views/footnote.js +10 -1
- package/dist/es/views/footnote_editable.js +2 -2
- package/dist/es/views/footnotes_element.js +2 -1
- package/dist/es/views/footnotes_element_editable.js +2 -1
- package/dist/es/views/inline_footnote.js +5 -0
- package/dist/types/views/footnote.d.ts +2 -0
- package/package.json +2 -2
- package/styles/Editor.css +5 -5
package/dist/cjs/commands.js
CHANGED
|
@@ -26,6 +26,7 @@ const prosemirror_transform_1 = require("prosemirror-transform");
|
|
|
26
26
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
27
27
|
const list_1 = require("./keys/list");
|
|
28
28
|
const helpers_1 = require("./lib/helpers");
|
|
29
|
+
const track_changes_utils_1 = require("./lib/track-changes-utils");
|
|
29
30
|
const utils_1 = require("./lib/utils");
|
|
30
31
|
const comment_annotation_1 = require("./plugins/comment_annotation");
|
|
31
32
|
const highlight_1 = require("./plugins/highlight");
|
|
@@ -127,10 +128,14 @@ const insertGeneralFootnote = (tableNode, position, view, tableElementFooter) =>
|
|
|
127
128
|
const generalNote = state.schema.nodes.paragraph.create({
|
|
128
129
|
placeholder: 'Add general note here',
|
|
129
130
|
});
|
|
131
|
+
const tableColGroup = (0, prosemirror_utils_1.findChildrenByType)(tableNode, transform_1.schema.nodes.table_colgroup)[0];
|
|
130
132
|
const tr = state.tr;
|
|
131
133
|
const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
|
|
132
134
|
? position + tableElementFooter[0].pos + 2
|
|
133
|
-
: position +
|
|
135
|
+
: position +
|
|
136
|
+
(!tableColGroup
|
|
137
|
+
? ((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0
|
|
138
|
+
: tableColGroup.pos + tableColGroup.node.nodeSize);
|
|
134
139
|
if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
|
|
135
140
|
tr.insert(pos, generalNote);
|
|
136
141
|
}
|
|
@@ -737,10 +742,12 @@ const insertTableFootnote = (node, position, state, dispatch) => {
|
|
|
737
742
|
const tr = state.tr;
|
|
738
743
|
tr.insert(insertedAt, inlineFootnoteNode);
|
|
739
744
|
let insertionPos;
|
|
740
|
-
const footnotesElement = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.footnotes_element);
|
|
741
|
-
if (footnotesElement
|
|
742
|
-
|
|
743
|
-
|
|
745
|
+
const footnotesElement = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.footnotes_element).pop();
|
|
746
|
+
if (footnotesElement &&
|
|
747
|
+
!(0, track_changes_utils_1.isDeleted)(footnotesElement.node) &&
|
|
748
|
+
!(0, track_changes_utils_1.isRejectedInsert)(footnotesElement.node)) {
|
|
749
|
+
const pos = footnotesElement.pos;
|
|
750
|
+
insertionPos = position + pos + footnotesElement.node.nodeSize + 1;
|
|
744
751
|
tr.insert(insertionPos, footnote);
|
|
745
752
|
}
|
|
746
753
|
else {
|
|
@@ -752,14 +759,22 @@ const insertTableFootnote = (node, position, state, dispatch) => {
|
|
|
752
759
|
tr.insert(insertionPos, footnoteElement);
|
|
753
760
|
}
|
|
754
761
|
else {
|
|
755
|
-
const
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
762
|
+
const tableElementFooter = transform_1.schema.nodes.table_element_footer.create({
|
|
763
|
+
id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.TableElementFooter),
|
|
764
|
+
}, [footnoteElement]);
|
|
765
|
+
const tableColGroup = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.table_colgroup)[0];
|
|
766
|
+
if (tableColGroup) {
|
|
767
|
+
insertionPos =
|
|
768
|
+
position + tableColGroup.pos + tableColGroup.node.nodeSize + 2;
|
|
761
769
|
tr.insert(insertionPos, tableElementFooter);
|
|
762
770
|
}
|
|
771
|
+
else {
|
|
772
|
+
const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
|
|
773
|
+
if (tableSize) {
|
|
774
|
+
insertionPos = position + tableSize + 2;
|
|
775
|
+
tr.insert(insertionPos, tableElementFooter);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
763
778
|
}
|
|
764
779
|
}
|
|
765
780
|
if (dispatch && insertionPos) {
|
|
@@ -25,6 +25,7 @@ const prosemirror_utils_1 = require("prosemirror-utils");
|
|
|
25
25
|
const commands_1 = require("../commands");
|
|
26
26
|
const ReactSubView_1 = __importDefault(require("../views/ReactSubView"));
|
|
27
27
|
const popper_1 = require("./popper");
|
|
28
|
+
const track_changes_utils_1 = require("./track-changes-utils");
|
|
28
29
|
const popper = new popper_1.PopperManager();
|
|
29
30
|
const listTypes = [transform_1.schema.nodes.ordered_list, transform_1.schema.nodes.bullet_list];
|
|
30
31
|
const readonlyTypes = [transform_1.schema.nodes.keywords, transform_1.schema.nodes.bibliography_element];
|
|
@@ -186,14 +187,16 @@ class ContextMenu {
|
|
|
186
187
|
if (isInTable) {
|
|
187
188
|
menu.appendChild(this.createMenuSection((section) => {
|
|
188
189
|
section.appendChild(this.createMenuItem('Add Reference Note', () => {
|
|
189
|
-
var _a;
|
|
190
|
-
const footnotesElement = (0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.footnotes_element);
|
|
191
|
-
if (!footnotesElement
|
|
190
|
+
var _a, _b;
|
|
191
|
+
const footnotesElement = (_a = (0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.footnotes_element).pop()) === null || _a === void 0 ? void 0 : _a.node;
|
|
192
|
+
if (!footnotesElement ||
|
|
193
|
+
(0, track_changes_utils_1.isDeleted)(footnotesElement) ||
|
|
194
|
+
(0, track_changes_utils_1.isRejectedInsert)(footnotesElement)) {
|
|
192
195
|
const { state, dispatch } = this.view;
|
|
193
196
|
(0, commands_1.insertTableFootnote)(this.node, this.getPos(), state, dispatch);
|
|
194
197
|
}
|
|
195
198
|
else {
|
|
196
|
-
const footnotes = (0, prosemirror_utils_1.findChildrenByType)(footnotesElement
|
|
199
|
+
const footnotes = (0, prosemirror_utils_1.findChildrenByType)(footnotesElement, transform_1.schema.nodes.footnote).map((nodeWithPos) => {
|
|
197
200
|
return nodeWithPos.node;
|
|
198
201
|
});
|
|
199
202
|
const targetDom = this.view.domAtPos(this.view.state.selection.from);
|
|
@@ -225,7 +228,7 @@ class ContextMenu {
|
|
|
225
228
|
(_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.destroy();
|
|
226
229
|
},
|
|
227
230
|
}, this.node, this.getPos, this.view, 'table-footnote-editor');
|
|
228
|
-
(
|
|
231
|
+
(_b = this.props) === null || _b === void 0 ? void 0 : _b.popper.show(targetDom.node, popperContainer, 'bottom-end');
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
234
|
}));
|
|
@@ -132,10 +132,10 @@ exports.default = () => {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
if (node.type === transform_1.schema.nodes.footnotes_element) {
|
|
135
|
-
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
|
|
136
|
-
class: 'footnote-element',
|
|
137
|
-
}));
|
|
138
135
|
if ((parent === null || parent === void 0 ? void 0 : parent.type) === transform_1.schema.nodes.table_element_footer) {
|
|
136
|
+
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
|
|
137
|
+
class: 'table-footnotes-element',
|
|
138
|
+
}));
|
|
139
139
|
tableInlineFootnoteIds = (0, footnotes_utils_1.findTableInlineFootnoteIds)(state.doc.resolve(pos));
|
|
140
140
|
}
|
|
141
141
|
else {
|
|
@@ -18,7 +18,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.FootnoteView = void 0;
|
|
21
|
+
exports.setTCClasses = exports.FootnoteView = void 0;
|
|
22
|
+
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
22
23
|
const block_view_1 = __importDefault(require("./block_view"));
|
|
23
24
|
const creators_1 = require("./creators");
|
|
24
25
|
class FootnoteView extends block_view_1.default {
|
|
@@ -28,4 +29,13 @@ class FootnoteView extends block_view_1.default {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
exports.FootnoteView = FootnoteView;
|
|
31
|
-
|
|
32
|
+
const setTCClasses = (node, dom) => {
|
|
33
|
+
const dataTracked = node.attrs.dataTracked;
|
|
34
|
+
if (dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.length) {
|
|
35
|
+
const lastChange = dataTracked[dataTracked.length - 1];
|
|
36
|
+
const changeClasses = (0, track_changes_utils_1.getChangeClasses)([lastChange]);
|
|
37
|
+
dom.classList.add(...changeClasses);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.setTCClasses = setTCClasses;
|
|
41
|
+
exports.default = (0, creators_1.createNodeOrElementView)(FootnoteView, 'div', exports.setTCClasses);
|
|
@@ -18,4 +18,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
const creators_1 = require("./creators");
|
|
19
19
|
const editable_block_1 = require("./editable_block");
|
|
20
20
|
const footnote_1 = require("./footnote");
|
|
21
|
-
exports.default = (0, creators_1.createNodeOrElementView)((0, editable_block_1.EditableBlock)(footnote_1.FootnoteView), 'div');
|
|
21
|
+
exports.default = (0, creators_1.createNodeOrElementView)((0, editable_block_1.EditableBlock)(footnote_1.FootnoteView), 'div', footnote_1.setTCClasses);
|
|
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
exports.FootnotesElementView = void 0;
|
|
22
22
|
const block_view_1 = __importDefault(require("./block_view"));
|
|
23
23
|
const creators_1 = require("./creators");
|
|
24
|
+
const footnote_1 = require("./footnote");
|
|
24
25
|
class FootnotesElementView extends block_view_1.default {
|
|
25
26
|
constructor() {
|
|
26
27
|
super(...arguments);
|
|
@@ -37,4 +38,4 @@ class FootnotesElementView extends block_view_1.default {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
exports.FootnotesElementView = FootnotesElementView;
|
|
40
|
-
exports.default = (0, creators_1.createNodeOrElementView)(FootnotesElementView, 'div');
|
|
41
|
+
exports.default = (0, creators_1.createNodeOrElementView)(FootnotesElementView, 'div', footnote_1.setTCClasses);
|
|
@@ -17,5 +17,6 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
const creators_1 = require("./creators");
|
|
19
19
|
const editable_block_1 = require("./editable_block");
|
|
20
|
+
const footnote_1 = require("./footnote");
|
|
20
21
|
const footnotes_element_1 = require("./footnotes_element");
|
|
21
|
-
exports.default = (0, creators_1.createNodeOrElementView)((0, editable_block_1.EditableBlock)(footnotes_element_1.FootnotesElementView), 'div');
|
|
22
|
+
exports.default = (0, creators_1.createNodeOrElementView)((0, editable_block_1.EditableBlock)(footnotes_element_1.FootnotesElementView), 'div', footnote_1.setTCClasses);
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.InlineFootnoteView = void 0;
|
|
19
|
+
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
19
20
|
const base_node_view_1 = require("./base_node_view");
|
|
20
21
|
const creators_1 = require("./creators");
|
|
21
22
|
class InlineFootnoteView extends base_node_view_1.BaseNodeView {
|
|
@@ -26,6 +27,10 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
|
|
|
26
27
|
};
|
|
27
28
|
this.updateContents = () => {
|
|
28
29
|
this.setDomAttrs(this.node, this.dom);
|
|
30
|
+
this.dom.className = [
|
|
31
|
+
'footnote',
|
|
32
|
+
...(0, track_changes_utils_1.getChangeClasses)(this.node.attrs.dataTracked),
|
|
33
|
+
].join(' ');
|
|
29
34
|
};
|
|
30
35
|
this.initialise = () => {
|
|
31
36
|
this.dom = this.createDOM();
|
package/dist/es/commands.js
CHANGED
|
@@ -23,6 +23,7 @@ import { findWrapping } from 'prosemirror-transform';
|
|
|
23
23
|
import { findChildrenByType, findParentNodeOfType, } from 'prosemirror-utils';
|
|
24
24
|
import { skipCommandTracking } from './keys/list';
|
|
25
25
|
import { isNodeOfType, nearestAncestor } from './lib/helpers';
|
|
26
|
+
import { isDeleted, isRejectedInsert } from './lib/track-changes-utils';
|
|
26
27
|
import { findParentNodeWithId, getChildOfType } from './lib/utils';
|
|
27
28
|
import { commentAnnotation } from './plugins/comment_annotation';
|
|
28
29
|
import { highlightKey, SET_COMMENT } from './plugins/highlight';
|
|
@@ -118,10 +119,14 @@ export const insertGeneralFootnote = (tableNode, position, view, tableElementFoo
|
|
|
118
119
|
const generalNote = state.schema.nodes.paragraph.create({
|
|
119
120
|
placeholder: 'Add general note here',
|
|
120
121
|
});
|
|
122
|
+
const tableColGroup = findChildrenByType(tableNode, schema.nodes.table_colgroup)[0];
|
|
121
123
|
const tr = state.tr;
|
|
122
124
|
const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
|
|
123
125
|
? position + tableElementFooter[0].pos + 2
|
|
124
|
-
: position +
|
|
126
|
+
: position +
|
|
127
|
+
(!tableColGroup
|
|
128
|
+
? ((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0
|
|
129
|
+
: tableColGroup.pos + tableColGroup.node.nodeSize);
|
|
125
130
|
if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
|
|
126
131
|
tr.insert(pos, generalNote);
|
|
127
132
|
}
|
|
@@ -700,10 +705,12 @@ export const insertTableFootnote = (node, position, state, dispatch) => {
|
|
|
700
705
|
const tr = state.tr;
|
|
701
706
|
tr.insert(insertedAt, inlineFootnoteNode);
|
|
702
707
|
let insertionPos;
|
|
703
|
-
const footnotesElement = findChildrenByType(node, schema.nodes.footnotes_element);
|
|
704
|
-
if (footnotesElement
|
|
705
|
-
|
|
706
|
-
|
|
708
|
+
const footnotesElement = findChildrenByType(node, schema.nodes.footnotes_element).pop();
|
|
709
|
+
if (footnotesElement &&
|
|
710
|
+
!isDeleted(footnotesElement.node) &&
|
|
711
|
+
!isRejectedInsert(footnotesElement.node)) {
|
|
712
|
+
const pos = footnotesElement.pos;
|
|
713
|
+
insertionPos = position + pos + footnotesElement.node.nodeSize + 1;
|
|
707
714
|
tr.insert(insertionPos, footnote);
|
|
708
715
|
}
|
|
709
716
|
else {
|
|
@@ -715,14 +722,22 @@ export const insertTableFootnote = (node, position, state, dispatch) => {
|
|
|
715
722
|
tr.insert(insertionPos, footnoteElement);
|
|
716
723
|
}
|
|
717
724
|
else {
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
725
|
+
const tableElementFooter = schema.nodes.table_element_footer.create({
|
|
726
|
+
id: generateID(ObjectTypes.TableElementFooter),
|
|
727
|
+
}, [footnoteElement]);
|
|
728
|
+
const tableColGroup = findChildrenByType(node, schema.nodes.table_colgroup)[0];
|
|
729
|
+
if (tableColGroup) {
|
|
730
|
+
insertionPos =
|
|
731
|
+
position + tableColGroup.pos + tableColGroup.node.nodeSize + 2;
|
|
724
732
|
tr.insert(insertionPos, tableElementFooter);
|
|
725
733
|
}
|
|
734
|
+
else {
|
|
735
|
+
const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
|
|
736
|
+
if (tableSize) {
|
|
737
|
+
insertionPos = position + tableSize + 2;
|
|
738
|
+
tr.insert(insertionPos, tableElementFooter);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
726
741
|
}
|
|
727
742
|
}
|
|
728
743
|
if (dispatch && insertionPos) {
|
|
@@ -19,6 +19,7 @@ import { findChildrenByType, hasParentNodeOfType } from 'prosemirror-utils';
|
|
|
19
19
|
import { addComment, createBlock, insertGeneralFootnote, insertTableFootnote, } from '../commands';
|
|
20
20
|
import ReactSubView from '../views/ReactSubView';
|
|
21
21
|
import { PopperManager } from './popper';
|
|
22
|
+
import { isDeleted, isRejectedInsert } from './track-changes-utils';
|
|
22
23
|
const popper = new PopperManager();
|
|
23
24
|
const listTypes = [schema.nodes.ordered_list, schema.nodes.bullet_list];
|
|
24
25
|
const readonlyTypes = [schema.nodes.keywords, schema.nodes.bibliography_element];
|
|
@@ -179,14 +180,16 @@ export class ContextMenu {
|
|
|
179
180
|
if (isInTable) {
|
|
180
181
|
menu.appendChild(this.createMenuSection((section) => {
|
|
181
182
|
section.appendChild(this.createMenuItem('Add Reference Note', () => {
|
|
182
|
-
var _a;
|
|
183
|
-
const footnotesElement = findChildrenByType(this.node, schema.nodes.footnotes_element);
|
|
184
|
-
if (!footnotesElement
|
|
183
|
+
var _a, _b;
|
|
184
|
+
const footnotesElement = (_a = findChildrenByType(this.node, schema.nodes.footnotes_element).pop()) === null || _a === void 0 ? void 0 : _a.node;
|
|
185
|
+
if (!footnotesElement ||
|
|
186
|
+
isDeleted(footnotesElement) ||
|
|
187
|
+
isRejectedInsert(footnotesElement)) {
|
|
185
188
|
const { state, dispatch } = this.view;
|
|
186
189
|
insertTableFootnote(this.node, this.getPos(), state, dispatch);
|
|
187
190
|
}
|
|
188
191
|
else {
|
|
189
|
-
const footnotes = findChildrenByType(footnotesElement
|
|
192
|
+
const footnotes = findChildrenByType(footnotesElement, schema.nodes.footnote).map((nodeWithPos) => {
|
|
190
193
|
return nodeWithPos.node;
|
|
191
194
|
});
|
|
192
195
|
const targetDom = this.view.domAtPos(this.view.state.selection.from);
|
|
@@ -218,7 +221,7 @@ export class ContextMenu {
|
|
|
218
221
|
(_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.destroy();
|
|
219
222
|
},
|
|
220
223
|
}, this.node, this.getPos, this.view, 'table-footnote-editor');
|
|
221
|
-
(
|
|
224
|
+
(_b = this.props) === null || _b === void 0 ? void 0 : _b.popper.show(targetDom.node, popperContainer, 'bottom-end');
|
|
222
225
|
}
|
|
223
226
|
}
|
|
224
227
|
}));
|
|
@@ -127,10 +127,10 @@ export default () => {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
if (node.type === schema.nodes.footnotes_element) {
|
|
130
|
-
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
131
|
-
class: 'footnote-element',
|
|
132
|
-
}));
|
|
133
130
|
if ((parent === null || parent === void 0 ? void 0 : parent.type) === schema.nodes.table_element_footer) {
|
|
131
|
+
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
132
|
+
class: 'table-footnotes-element',
|
|
133
|
+
}));
|
|
134
134
|
tableInlineFootnoteIds = findTableInlineFootnoteIds(state.doc.resolve(pos));
|
|
135
135
|
}
|
|
136
136
|
else {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { getChangeClasses } from '../lib/track-changes-utils';
|
|
16
17
|
import BlockView from './block_view';
|
|
17
18
|
import { createNodeOrElementView } from './creators';
|
|
18
19
|
export class FootnoteView extends BlockView {
|
|
@@ -21,4 +22,12 @@ export class FootnoteView extends BlockView {
|
|
|
21
22
|
this.elementType = 'div';
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
export
|
|
25
|
+
export const setTCClasses = (node, dom) => {
|
|
26
|
+
const dataTracked = node.attrs.dataTracked;
|
|
27
|
+
if (dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.length) {
|
|
28
|
+
const lastChange = dataTracked[dataTracked.length - 1];
|
|
29
|
+
const changeClasses = getChangeClasses([lastChange]);
|
|
30
|
+
dom.classList.add(...changeClasses);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export default createNodeOrElementView(FootnoteView, 'div', setTCClasses);
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { createNodeOrElementView } from './creators';
|
|
17
17
|
import { EditableBlock } from './editable_block';
|
|
18
|
-
import { FootnoteView } from './footnote';
|
|
19
|
-
export default createNodeOrElementView(EditableBlock(FootnoteView), 'div');
|
|
18
|
+
import { FootnoteView, setTCClasses } from './footnote';
|
|
19
|
+
export default createNodeOrElementView(EditableBlock(FootnoteView), 'div', setTCClasses);
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import BlockView from './block_view';
|
|
17
17
|
import { createNodeOrElementView } from './creators';
|
|
18
|
+
import { setTCClasses } from './footnote';
|
|
18
19
|
export class FootnotesElementView extends BlockView {
|
|
19
20
|
constructor() {
|
|
20
21
|
super(...arguments);
|
|
@@ -30,4 +31,4 @@ export class FootnotesElementView extends BlockView {
|
|
|
30
31
|
this.checkEditability();
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
export default createNodeOrElementView(FootnotesElementView, 'div');
|
|
34
|
+
export default createNodeOrElementView(FootnotesElementView, 'div', setTCClasses);
|
|
@@ -15,5 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { createNodeOrElementView } from './creators';
|
|
17
17
|
import { EditableBlock } from './editable_block';
|
|
18
|
+
import { setTCClasses } from './footnote';
|
|
18
19
|
import { FootnotesElementView } from './footnotes_element';
|
|
19
|
-
export default createNodeOrElementView(EditableBlock(FootnotesElementView), 'div');
|
|
20
|
+
export default createNodeOrElementView(EditableBlock(FootnotesElementView), 'div', setTCClasses);
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { getChangeClasses } from '../lib/track-changes-utils';
|
|
16
17
|
import { BaseNodeView } from './base_node_view';
|
|
17
18
|
import { createNodeView } from './creators';
|
|
18
19
|
export class InlineFootnoteView extends BaseNodeView {
|
|
@@ -23,6 +24,10 @@ export class InlineFootnoteView extends BaseNodeView {
|
|
|
23
24
|
};
|
|
24
25
|
this.updateContents = () => {
|
|
25
26
|
this.setDomAttrs(this.node, this.dom);
|
|
27
|
+
this.dom.className = [
|
|
28
|
+
'footnote',
|
|
29
|
+
...getChangeClasses(this.node.attrs.dataTracked),
|
|
30
|
+
].join(' ');
|
|
26
31
|
};
|
|
27
32
|
this.initialise = () => {
|
|
28
33
|
this.dom = this.createDOM();
|
|
@@ -13,10 +13,12 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { ManuscriptNode } from '@manuscripts/transform';
|
|
16
17
|
import { BaseNodeProps } from './base_node_view';
|
|
17
18
|
import BlockView from './block_view';
|
|
18
19
|
export declare class FootnoteView<PropsType extends BaseNodeProps> extends BlockView<PropsType> {
|
|
19
20
|
elementType: string;
|
|
20
21
|
}
|
|
22
|
+
export declare const setTCClasses: (node: ManuscriptNode, dom: HTMLElement) => void;
|
|
21
23
|
declare const _default: (props: BaseNodeProps) => import("../types").NodeViewCreator<FootnoteView<any>>;
|
|
22
24
|
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.
|
|
4
|
+
"version": "1.7.22",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -111,4 +111,4 @@
|
|
|
111
111
|
"resolutions": {
|
|
112
112
|
"@types/react": "^17.0.2"
|
|
113
113
|
}
|
|
114
|
-
}
|
|
114
|
+
}
|
package/styles/Editor.css
CHANGED
|
@@ -944,18 +944,18 @@
|
|
|
944
944
|
padding-top: 8px;
|
|
945
945
|
}
|
|
946
946
|
|
|
947
|
-
.ProseMirror .table-
|
|
947
|
+
.ProseMirror .table-footnotes-element:not(:first-child)::before {
|
|
948
948
|
content: '';
|
|
949
949
|
border-bottom: 1px dashed #C9C9C9;
|
|
950
950
|
display: block;
|
|
951
951
|
margin-bottom: 8px;
|
|
952
952
|
}
|
|
953
953
|
|
|
954
|
-
.ProseMirror .table-
|
|
954
|
+
.ProseMirror .table-footnotes-element {
|
|
955
955
|
counter-reset: table_footnote;
|
|
956
956
|
}
|
|
957
957
|
|
|
958
|
-
.ProseMirror .table-
|
|
958
|
+
.ProseMirror .table-footnotes-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;
|
|
@@ -978,7 +978,7 @@
|
|
|
978
978
|
.table-footer > div > p {
|
|
979
979
|
padding-bottom: 10px;
|
|
980
980
|
}
|
|
981
|
-
.ProseMirror .table-
|
|
981
|
+
.ProseMirror .table-footnotes-element .footnote-selected {
|
|
982
982
|
border: 1px solid #bce7f6;
|
|
983
983
|
}
|
|
984
984
|
.table-footer > div:has(> p.footnote-selected) > p {
|
|
@@ -998,7 +998,7 @@
|
|
|
998
998
|
cursor: pointer;
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
|
-
.ProseMirror .
|
|
1001
|
+
.ProseMirror .table-footnotes-element > div:has(.unctied-table-footnote) {
|
|
1002
1002
|
position: relative;
|
|
1003
1003
|
}
|
|
1004
1004
|
|