@manuscripts/body-editor 1.10.6-LEAN-3604.0 → 1.10.6
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/lib/context-menu.js +7 -2
- package/dist/cjs/lib/popper.js +5 -5
- package/dist/cjs/views/bibliography_element.js +1 -1
- package/dist/cjs/views/citation_editable.js +0 -4
- package/dist/cjs/views/editable_block.js +2 -4
- package/dist/es/lib/context-menu.js +6 -1
- package/dist/es/lib/popper.js +5 -5
- package/dist/es/views/bibliography_element.js +1 -1
- package/dist/es/views/citation_editable.js +0 -4
- package/dist/es/views/editable_block.js +3 -5
- package/dist/types/lib/context-menu.d.ts +1 -0
- package/dist/types/views/citation_editable.d.ts +0 -1
- package/package.json +1 -1
- package/styles/AdvancedEditor.css +33 -38
|
@@ -18,7 +18,7 @@ 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.ContextMenu = exports.sectionLevel = void 0;
|
|
21
|
+
exports.ContextMenu = exports.contextMenuBtnClass = exports.sectionLevel = void 0;
|
|
22
22
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
23
23
|
const transform_1 = require("@manuscripts/transform");
|
|
24
24
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
@@ -42,6 +42,7 @@ exports.sectionLevel = sectionLevel;
|
|
|
42
42
|
const hasAny = (set, ...items) => {
|
|
43
43
|
return items.some((i) => set.has(i));
|
|
44
44
|
};
|
|
45
|
+
exports.contextMenuBtnClass = 'btn-context-menu';
|
|
45
46
|
class ContextMenu {
|
|
46
47
|
constructor(node, view, getPos, actions = {}, props) {
|
|
47
48
|
this.showAddMenu = (target, after) => {
|
|
@@ -355,7 +356,11 @@ class ContextMenu {
|
|
|
355
356
|
};
|
|
356
357
|
this.resolvePos = () => this.view.state.doc.resolve(this.getPos());
|
|
357
358
|
this.addPopperEventListeners = () => {
|
|
358
|
-
const mouseListener = () => {
|
|
359
|
+
const mouseListener = (event) => {
|
|
360
|
+
const target = event.target;
|
|
361
|
+
if (target.classList.contains(exports.contextMenuBtnClass)) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
359
364
|
window.requestAnimationFrame(() => {
|
|
360
365
|
window.removeEventListener('mousedown', mouseListener);
|
|
361
366
|
popper.destroy();
|
package/dist/cjs/lib/popper.js
CHANGED
|
@@ -22,9 +22,7 @@ exports.PopperManager = void 0;
|
|
|
22
22
|
const popper_js_1 = __importDefault(require("popper.js"));
|
|
23
23
|
class PopperManager {
|
|
24
24
|
show(target, contents, placement = 'bottom', showArrow = true, modifiers = {}) {
|
|
25
|
-
|
|
26
|
-
return this.destroy();
|
|
27
|
-
}
|
|
25
|
+
this.destroy();
|
|
28
26
|
window.requestAnimationFrame(() => {
|
|
29
27
|
const container = document.createElement('div');
|
|
30
28
|
container.className = 'popper';
|
|
@@ -64,7 +62,9 @@ class PopperManager {
|
|
|
64
62
|
this.destroy();
|
|
65
63
|
}
|
|
66
64
|
};
|
|
67
|
-
|
|
65
|
+
if (contents.classList.contains('context-menu')) {
|
|
66
|
+
window.addEventListener('click', this.handleDocumentClick);
|
|
67
|
+
}
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
destroy() {
|
|
@@ -72,7 +72,7 @@ class PopperManager {
|
|
|
72
72
|
this.removeContainerClass(this.activePopper.reference);
|
|
73
73
|
this.activePopper.destroy();
|
|
74
74
|
if (this.handleDocumentClick) {
|
|
75
|
-
|
|
75
|
+
window.removeEventListener('click', this.handleDocumentClick);
|
|
76
76
|
}
|
|
77
77
|
delete this.activePopper;
|
|
78
78
|
}
|
|
@@ -36,7 +36,6 @@ class BibliographyElementBlockView extends block_view_1.default {
|
|
|
36
36
|
constructor() {
|
|
37
37
|
super(...arguments);
|
|
38
38
|
this.showPopper = (id) => {
|
|
39
|
-
this.props.popper.destroy();
|
|
40
39
|
const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
|
|
41
40
|
if (!bib) {
|
|
42
41
|
return;
|
|
@@ -57,6 +56,7 @@ class BibliographyElementBlockView extends block_view_1.default {
|
|
|
57
56
|
this.showPopper(citationId);
|
|
58
57
|
};
|
|
59
58
|
this.handleComment = (citationId) => {
|
|
59
|
+
this.props.popper.destroy();
|
|
60
60
|
this.props.setComment((0, transform_1.buildComment)(citationId));
|
|
61
61
|
};
|
|
62
62
|
this.showContextMenu = (element) => {
|
|
@@ -59,10 +59,6 @@ class CitationEditableView extends citation_1.CitationView {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
this.deselectNode = () => {
|
|
63
|
-
this.dom.classList.remove('ProseMirror-selectednode');
|
|
64
|
-
this.props.popper.destroy();
|
|
65
|
-
};
|
|
66
62
|
this.destroy = () => {
|
|
67
63
|
var _a;
|
|
68
64
|
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.remove();
|
|
@@ -41,13 +41,12 @@ const EditableBlock = (Base) => {
|
|
|
41
41
|
}
|
|
42
42
|
const after = !hasParent($pos, transform_1.schema.nodes.bibliography_section);
|
|
43
43
|
const button = document.createElement('a');
|
|
44
|
-
button.classList.add('add-block');
|
|
44
|
+
button.classList.add('add-block', context_menu_1.contextMenuBtnClass);
|
|
45
45
|
button.classList.add(after ? 'add-block-after' : 'add-block-before');
|
|
46
46
|
button.setAttribute('aria-label', `Add an element ${after ? 'below' : 'above'}`);
|
|
47
47
|
button.setAttribute('data-balloon-pos', 'down-left');
|
|
48
48
|
button.addEventListener('mousedown', (event) => {
|
|
49
49
|
event.preventDefault();
|
|
50
|
-
event.stopPropagation();
|
|
51
50
|
const menu = this.createMenu();
|
|
52
51
|
menu.showAddMenu(event.currentTarget, after);
|
|
53
52
|
});
|
|
@@ -59,12 +58,11 @@ const EditableBlock = (Base) => {
|
|
|
59
58
|
return null;
|
|
60
59
|
}
|
|
61
60
|
const button = document.createElement('a');
|
|
62
|
-
button.classList.add('edit-block');
|
|
61
|
+
button.classList.add('edit-block', context_menu_1.contextMenuBtnClass);
|
|
63
62
|
button.setAttribute('aria-label', 'Open menu');
|
|
64
63
|
button.setAttribute('data-balloon-pos', 'down-left');
|
|
65
64
|
button.addEventListener('mousedown', (event) => {
|
|
66
65
|
event.preventDefault();
|
|
67
|
-
event.stopPropagation();
|
|
68
66
|
const menu = this.createMenu();
|
|
69
67
|
menu.showEditMenu(event.currentTarget);
|
|
70
68
|
});
|
|
@@ -35,6 +35,7 @@ export const sectionLevel = (depth) => {
|
|
|
35
35
|
const hasAny = (set, ...items) => {
|
|
36
36
|
return items.some((i) => set.has(i));
|
|
37
37
|
};
|
|
38
|
+
export const contextMenuBtnClass = 'btn-context-menu';
|
|
38
39
|
export class ContextMenu {
|
|
39
40
|
constructor(node, view, getPos, actions = {}, props) {
|
|
40
41
|
this.showAddMenu = (target, after) => {
|
|
@@ -348,7 +349,11 @@ export class ContextMenu {
|
|
|
348
349
|
};
|
|
349
350
|
this.resolvePos = () => this.view.state.doc.resolve(this.getPos());
|
|
350
351
|
this.addPopperEventListeners = () => {
|
|
351
|
-
const mouseListener = () => {
|
|
352
|
+
const mouseListener = (event) => {
|
|
353
|
+
const target = event.target;
|
|
354
|
+
if (target.classList.contains(contextMenuBtnClass)) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
352
357
|
window.requestAnimationFrame(() => {
|
|
353
358
|
window.removeEventListener('mousedown', mouseListener);
|
|
354
359
|
popper.destroy();
|
package/dist/es/lib/popper.js
CHANGED
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
import Popper from 'popper.js';
|
|
17
17
|
export class PopperManager {
|
|
18
18
|
show(target, contents, placement = 'bottom', showArrow = true, modifiers = {}) {
|
|
19
|
-
|
|
20
|
-
return this.destroy();
|
|
21
|
-
}
|
|
19
|
+
this.destroy();
|
|
22
20
|
window.requestAnimationFrame(() => {
|
|
23
21
|
const container = document.createElement('div');
|
|
24
22
|
container.className = 'popper';
|
|
@@ -58,7 +56,9 @@ export class PopperManager {
|
|
|
58
56
|
this.destroy();
|
|
59
57
|
}
|
|
60
58
|
};
|
|
61
|
-
|
|
59
|
+
if (contents.classList.contains('context-menu')) {
|
|
60
|
+
window.addEventListener('click', this.handleDocumentClick);
|
|
61
|
+
}
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
destroy() {
|
|
@@ -66,7 +66,7 @@ export class PopperManager {
|
|
|
66
66
|
this.removeContainerClass(this.activePopper.reference);
|
|
67
67
|
this.activePopper.destroy();
|
|
68
68
|
if (this.handleDocumentClick) {
|
|
69
|
-
|
|
69
|
+
window.removeEventListener('click', this.handleDocumentClick);
|
|
70
70
|
}
|
|
71
71
|
delete this.activePopper;
|
|
72
72
|
}
|
|
@@ -30,7 +30,6 @@ export class BibliographyElementBlockView extends BlockView {
|
|
|
30
30
|
constructor() {
|
|
31
31
|
super(...arguments);
|
|
32
32
|
this.showPopper = (id) => {
|
|
33
|
-
this.props.popper.destroy();
|
|
34
33
|
const bib = getBibliographyPluginState(this.view.state);
|
|
35
34
|
if (!bib) {
|
|
36
35
|
return;
|
|
@@ -51,6 +50,7 @@ export class BibliographyElementBlockView extends BlockView {
|
|
|
51
50
|
this.showPopper(citationId);
|
|
52
51
|
};
|
|
53
52
|
this.handleComment = (citationId) => {
|
|
53
|
+
this.props.popper.destroy();
|
|
54
54
|
this.props.setComment(buildComment(citationId));
|
|
55
55
|
};
|
|
56
56
|
this.showContextMenu = (element) => {
|
|
@@ -53,10 +53,6 @@ export class CitationEditableView extends CitationView {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
this.deselectNode = () => {
|
|
57
|
-
this.dom.classList.remove('ProseMirror-selectednode');
|
|
58
|
-
this.props.popper.destroy();
|
|
59
|
-
};
|
|
60
56
|
this.destroy = () => {
|
|
61
57
|
var _a;
|
|
62
58
|
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.remove();
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { schema } from '@manuscripts/transform';
|
|
17
17
|
import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
|
|
18
|
-
import { ContextMenu } from '../lib/context-menu';
|
|
18
|
+
import { ContextMenu, contextMenuBtnClass } from '../lib/context-menu';
|
|
19
19
|
const isNotNull = (a) => a !== null;
|
|
20
20
|
const hasParent = ($pos, type) => {
|
|
21
21
|
return !!findParentNodeOfTypeClosestToPos($pos, type);
|
|
@@ -38,13 +38,12 @@ export const EditableBlock = (Base) => {
|
|
|
38
38
|
}
|
|
39
39
|
const after = !hasParent($pos, schema.nodes.bibliography_section);
|
|
40
40
|
const button = document.createElement('a');
|
|
41
|
-
button.classList.add('add-block');
|
|
41
|
+
button.classList.add('add-block', contextMenuBtnClass);
|
|
42
42
|
button.classList.add(after ? 'add-block-after' : 'add-block-before');
|
|
43
43
|
button.setAttribute('aria-label', `Add an element ${after ? 'below' : 'above'}`);
|
|
44
44
|
button.setAttribute('data-balloon-pos', 'down-left');
|
|
45
45
|
button.addEventListener('mousedown', (event) => {
|
|
46
46
|
event.preventDefault();
|
|
47
|
-
event.stopPropagation();
|
|
48
47
|
const menu = this.createMenu();
|
|
49
48
|
menu.showAddMenu(event.currentTarget, after);
|
|
50
49
|
});
|
|
@@ -56,12 +55,11 @@ export const EditableBlock = (Base) => {
|
|
|
56
55
|
return null;
|
|
57
56
|
}
|
|
58
57
|
const button = document.createElement('a');
|
|
59
|
-
button.classList.add('edit-block');
|
|
58
|
+
button.classList.add('edit-block', contextMenuBtnClass);
|
|
60
59
|
button.setAttribute('aria-label', 'Open menu');
|
|
61
60
|
button.setAttribute('data-balloon-pos', 'down-left');
|
|
62
61
|
button.addEventListener('mousedown', (event) => {
|
|
63
62
|
event.preventDefault();
|
|
64
|
-
event.stopPropagation();
|
|
65
63
|
const menu = this.createMenu();
|
|
66
64
|
menu.showEditMenu(event.currentTarget);
|
|
67
65
|
});
|
|
@@ -20,6 +20,7 @@ export declare const sectionLevel: (depth: number) => string;
|
|
|
20
20
|
interface Actions {
|
|
21
21
|
setComment?: (comment: CommentAnnotation) => void;
|
|
22
22
|
}
|
|
23
|
+
export declare const contextMenuBtnClass = "btn-context-menu";
|
|
23
24
|
export declare class ContextMenu {
|
|
24
25
|
private readonly node;
|
|
25
26
|
private readonly view;
|
|
@@ -20,7 +20,6 @@ export declare class CitationEditableView extends CitationView<EditableBlockProp
|
|
|
20
20
|
private contextMenu;
|
|
21
21
|
stopEvent: (event: Event) => boolean;
|
|
22
22
|
selectNode: () => void;
|
|
23
|
-
deselectNode: () => void;
|
|
24
23
|
destroy: () => void;
|
|
25
24
|
showContextMenu: () => void;
|
|
26
25
|
showPopper: () => void;
|
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.10.6
|
|
4
|
+
"version": "1.10.6",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -687,78 +687,64 @@ Next levels are shifted 'up' by 1
|
|
|
687
687
|
}
|
|
688
688
|
|
|
689
689
|
.ProseMirror {
|
|
690
|
-
--
|
|
691
|
-
--
|
|
692
|
-
--
|
|
693
|
-
--deleted-color: #F35143;
|
|
694
|
-
--deleted-pending-bg-color: #FFF1F0;
|
|
690
|
+
--pending-bg-color: #e6f7fc;
|
|
691
|
+
--accepted-bg-color: #d1edaf;
|
|
692
|
+
--deleted-color: #f35143;
|
|
695
693
|
--highlight-bg-color: #ffeebf;
|
|
694
|
+
--selection-bg-color: #bce7f6;
|
|
696
695
|
}
|
|
697
696
|
|
|
698
697
|
.selected-suggestion::selection {
|
|
699
698
|
background: none;
|
|
700
699
|
}
|
|
701
700
|
|
|
702
|
-
span.selected-suggestion,
|
|
703
|
-
|
|
704
|
-
div.selected-suggestion:not(:has(> .block-container)) {
|
|
705
|
-
background-color: #bce7f6 !important;
|
|
706
|
-
color: #353535 !important;
|
|
707
|
-
text-decoration: none !important;
|
|
701
|
+
span.selected-suggestion, div.selected-suggestion > .block-container .block, div.selected-suggestion:not(:has(> .block-container)) {
|
|
702
|
+
background: #bce7f6 !important;
|
|
708
703
|
border-width: 2px 0 2px 0 !important;
|
|
709
704
|
border-color: #20aedf !important;
|
|
710
705
|
border-radius: 3px !important;
|
|
711
706
|
border-style: solid !important;
|
|
712
707
|
}
|
|
713
708
|
|
|
714
|
-
.accepted span.selected-suggestion,
|
|
715
|
-
.accepted div.selected-suggestion > .block-container .block,
|
|
716
|
-
.accepted div.selected-suggestion:not(:has(> .block-container)) {
|
|
717
|
-
background-color: #F2F2F2 !important;
|
|
718
|
-
border-width: 2px 0 2px 0 !important;
|
|
719
|
-
border-color: #C9C9C9 !important;
|
|
720
|
-
border-radius: 3px !important;
|
|
721
|
-
border-style: solid !important;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
709
|
.block-bullet_list .selected-suggestion p, .block-ordered_list .selected-suggestion p {
|
|
725
710
|
margin: 0;
|
|
726
711
|
}
|
|
727
712
|
|
|
728
713
|
.block-bullet_list .selected-suggestion, .block-ordered_list .selected-suggestion {
|
|
729
714
|
margin: 16px 0;
|
|
715
|
+
}
|
|
730
716
|
|
|
731
717
|
.ProseMirror .inserted.pending {
|
|
732
|
-
background: var(--
|
|
733
|
-
|
|
734
|
-
text-decoration: underline;
|
|
718
|
+
background: var(--pending-bg-color);
|
|
719
|
+
text-decoration: none;
|
|
735
720
|
}
|
|
736
721
|
.ProseMirror .inserted.accepted {
|
|
722
|
+
background: var(--accepted-bg-color);
|
|
737
723
|
text-decoration: none;
|
|
738
724
|
}
|
|
739
725
|
.ProseMirror .inserted.rejected {
|
|
740
726
|
display: none;
|
|
741
727
|
}
|
|
742
728
|
|
|
743
|
-
/* Is this needed? */
|
|
744
729
|
.ProseMirror .set_attrs.pending {
|
|
745
|
-
background: var(--
|
|
730
|
+
background: var(--pending-bg-color);
|
|
746
731
|
text-decoration: none;
|
|
747
732
|
}
|
|
748
|
-
/* Is this needed? */
|
|
749
733
|
.ProseMirror .set_attrs.accepted {
|
|
750
734
|
background: var(--accepted-bg-color);
|
|
751
735
|
text-decoration: none;
|
|
752
736
|
}
|
|
753
737
|
.ProseMirror .deleted.pending::before,
|
|
754
738
|
.ProseMirror .deleted.pending {
|
|
755
|
-
background: var(--
|
|
739
|
+
background: var(--pending-bg-color);
|
|
756
740
|
color: var(--deleted-color);
|
|
757
741
|
text-decoration: line-through;
|
|
758
742
|
}
|
|
759
743
|
|
|
760
744
|
.ProseMirror .deleted.accepted::before,
|
|
761
745
|
.ProseMirror .deleted.accepted {
|
|
746
|
+
background: var(--accepted-bg-color);
|
|
747
|
+
color: var(--deleted-color);
|
|
762
748
|
text-decoration: line-through;
|
|
763
749
|
}
|
|
764
750
|
.ProseMirror .deleted.rejected {
|
|
@@ -785,6 +771,13 @@ div.selected-suggestion:not(:has(> .block-container)) {
|
|
|
785
771
|
display: inline-block;
|
|
786
772
|
}
|
|
787
773
|
|
|
774
|
+
.affiliation[data-track-status='pending'],
|
|
775
|
+
.contributor[data-track-status='pending'],
|
|
776
|
+
.ProseMirror .inserted.pending,
|
|
777
|
+
.ProseMirror .set_attrs.pending,
|
|
778
|
+
.ProseMirror .deleted.pending {
|
|
779
|
+
background: #ddf3fa;
|
|
780
|
+
}
|
|
788
781
|
.ProseMirror .affiliation[data-track-status='rejected'][data-track-op='insert'],
|
|
789
782
|
.ProseMirror .contributor[data-track-status='rejected'][data-track-op='insert'],
|
|
790
783
|
.ProseMirror figure[data-track-status='rejected'][data-track-op='insert'],
|
|
@@ -794,22 +787,24 @@ div.selected-suggestion:not(:has(> .block-container)) {
|
|
|
794
787
|
display: none;
|
|
795
788
|
}
|
|
796
789
|
|
|
797
|
-
.contributor[data-track-
|
|
798
|
-
.affiliation[data-track-
|
|
790
|
+
.contributor[data-track-op='delete']:not([data-track-status='rejected']) .name,
|
|
791
|
+
.affiliation[data-track-op='delete']:not([data-track-status='rejected']) {
|
|
799
792
|
text-decoration: line-through;
|
|
800
793
|
color: var(--deleted-color);
|
|
801
|
-
background-color: var(--deleted-pending-bg-color)
|
|
802
794
|
}
|
|
803
795
|
|
|
804
|
-
.contributor[data-track-op='delete']:not([data-track-status='rejected'])
|
|
805
|
-
|
|
796
|
+
.contributor[data-track-op='delete']:not([data-track-status='rejected']) {
|
|
797
|
+
color: var(--deleted-color);
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
.affiliation[data-track-status='pending'],
|
|
801
|
+
.contributor[data-track-status='pending'] {
|
|
802
|
+
background: var(--pending-bg-color);
|
|
806
803
|
}
|
|
807
804
|
|
|
808
|
-
.affiliation[data-track-status='
|
|
809
|
-
.contributor[data-track-status='
|
|
810
|
-
background: var(--
|
|
811
|
-
color: var(--inserted-pending-color);
|
|
812
|
-
text-decoration: underline;
|
|
805
|
+
.affiliation[data-track-status='accepted'],
|
|
806
|
+
.contributor[data-track-status='accepted'] {
|
|
807
|
+
background: var(--accepted-bg-color);
|
|
813
808
|
}
|
|
814
809
|
|
|
815
810
|
.contributors {
|