@manuscripts/body-editor 1.10.5-LEAN-3535.1 → 1.10.5
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 +2 -7
- package/dist/cjs/lib/popper.js +5 -5
- package/dist/cjs/views/bibliography_element.js +1 -1
- package/dist/cjs/views/citation_editable.js +4 -0
- package/dist/cjs/views/editable_block.js +4 -2
- package/dist/es/lib/context-menu.js +1 -6
- package/dist/es/lib/popper.js +5 -5
- package/dist/es/views/bibliography_element.js +1 -1
- package/dist/es/views/citation_editable.js +4 -0
- package/dist/es/views/editable_block.js +5 -3
- package/dist/types/lib/context-menu.d.ts +0 -1
- package/dist/types/views/citation_editable.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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.
|
|
21
|
+
exports.ContextMenu = 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,7 +42,6 @@ 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';
|
|
46
45
|
class ContextMenu {
|
|
47
46
|
constructor(node, view, getPos, actions = {}, props) {
|
|
48
47
|
this.showAddMenu = (target, after) => {
|
|
@@ -356,11 +355,7 @@ class ContextMenu {
|
|
|
356
355
|
};
|
|
357
356
|
this.resolvePos = () => this.view.state.doc.resolve(this.getPos());
|
|
358
357
|
this.addPopperEventListeners = () => {
|
|
359
|
-
const mouseListener = (
|
|
360
|
-
const target = event.target;
|
|
361
|
-
if (target.classList.contains(exports.contextMenuBtnClass)) {
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
358
|
+
const mouseListener = () => {
|
|
364
359
|
window.requestAnimationFrame(() => {
|
|
365
360
|
window.removeEventListener('mousedown', mouseListener);
|
|
366
361
|
popper.destroy();
|
package/dist/cjs/lib/popper.js
CHANGED
|
@@ -22,7 +22,9 @@ 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
|
-
this.
|
|
25
|
+
if (this.activePopper) {
|
|
26
|
+
return this.destroy();
|
|
27
|
+
}
|
|
26
28
|
window.requestAnimationFrame(() => {
|
|
27
29
|
const container = document.createElement('div');
|
|
28
30
|
container.className = 'popper';
|
|
@@ -62,9 +64,7 @@ class PopperManager {
|
|
|
62
64
|
this.destroy();
|
|
63
65
|
}
|
|
64
66
|
};
|
|
65
|
-
|
|
66
|
-
window.addEventListener('click', this.handleDocumentClick);
|
|
67
|
-
}
|
|
67
|
+
document.addEventListener('click', this.handleDocumentClick);
|
|
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
|
+
document.removeEventListener('click', this.handleDocumentClick);
|
|
76
76
|
}
|
|
77
77
|
delete this.activePopper;
|
|
78
78
|
}
|
|
@@ -36,6 +36,7 @@ class BibliographyElementBlockView extends block_view_1.default {
|
|
|
36
36
|
constructor() {
|
|
37
37
|
super(...arguments);
|
|
38
38
|
this.showPopper = (id) => {
|
|
39
|
+
this.props.popper.destroy();
|
|
39
40
|
const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
|
|
40
41
|
if (!bib) {
|
|
41
42
|
return;
|
|
@@ -56,7 +57,6 @@ class BibliographyElementBlockView extends block_view_1.default {
|
|
|
56
57
|
this.showPopper(citationId);
|
|
57
58
|
};
|
|
58
59
|
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,6 +59,10 @@ 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
|
+
};
|
|
62
66
|
this.destroy = () => {
|
|
63
67
|
var _a;
|
|
64
68
|
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.remove();
|
|
@@ -41,12 +41,13 @@ 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');
|
|
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();
|
|
50
51
|
const menu = this.createMenu();
|
|
51
52
|
menu.showAddMenu(event.currentTarget, after);
|
|
52
53
|
});
|
|
@@ -58,11 +59,12 @@ const EditableBlock = (Base) => {
|
|
|
58
59
|
return null;
|
|
59
60
|
}
|
|
60
61
|
const button = document.createElement('a');
|
|
61
|
-
button.classList.add('edit-block'
|
|
62
|
+
button.classList.add('edit-block');
|
|
62
63
|
button.setAttribute('aria-label', 'Open menu');
|
|
63
64
|
button.setAttribute('data-balloon-pos', 'down-left');
|
|
64
65
|
button.addEventListener('mousedown', (event) => {
|
|
65
66
|
event.preventDefault();
|
|
67
|
+
event.stopPropagation();
|
|
66
68
|
const menu = this.createMenu();
|
|
67
69
|
menu.showEditMenu(event.currentTarget);
|
|
68
70
|
});
|
|
@@ -35,7 +35,6 @@ 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';
|
|
39
38
|
export class ContextMenu {
|
|
40
39
|
constructor(node, view, getPos, actions = {}, props) {
|
|
41
40
|
this.showAddMenu = (target, after) => {
|
|
@@ -349,11 +348,7 @@ export class ContextMenu {
|
|
|
349
348
|
};
|
|
350
349
|
this.resolvePos = () => this.view.state.doc.resolve(this.getPos());
|
|
351
350
|
this.addPopperEventListeners = () => {
|
|
352
|
-
const mouseListener = (
|
|
353
|
-
const target = event.target;
|
|
354
|
-
if (target.classList.contains(contextMenuBtnClass)) {
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
351
|
+
const mouseListener = () => {
|
|
357
352
|
window.requestAnimationFrame(() => {
|
|
358
353
|
window.removeEventListener('mousedown', mouseListener);
|
|
359
354
|
popper.destroy();
|
package/dist/es/lib/popper.js
CHANGED
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
import Popper from 'popper.js';
|
|
17
17
|
export class PopperManager {
|
|
18
18
|
show(target, contents, placement = 'bottom', showArrow = true, modifiers = {}) {
|
|
19
|
-
this.
|
|
19
|
+
if (this.activePopper) {
|
|
20
|
+
return this.destroy();
|
|
21
|
+
}
|
|
20
22
|
window.requestAnimationFrame(() => {
|
|
21
23
|
const container = document.createElement('div');
|
|
22
24
|
container.className = 'popper';
|
|
@@ -56,9 +58,7 @@ export class PopperManager {
|
|
|
56
58
|
this.destroy();
|
|
57
59
|
}
|
|
58
60
|
};
|
|
59
|
-
|
|
60
|
-
window.addEventListener('click', this.handleDocumentClick);
|
|
61
|
-
}
|
|
61
|
+
document.addEventListener('click', this.handleDocumentClick);
|
|
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
|
+
document.removeEventListener('click', this.handleDocumentClick);
|
|
70
70
|
}
|
|
71
71
|
delete this.activePopper;
|
|
72
72
|
}
|
|
@@ -30,6 +30,7 @@ export class BibliographyElementBlockView extends BlockView {
|
|
|
30
30
|
constructor() {
|
|
31
31
|
super(...arguments);
|
|
32
32
|
this.showPopper = (id) => {
|
|
33
|
+
this.props.popper.destroy();
|
|
33
34
|
const bib = getBibliographyPluginState(this.view.state);
|
|
34
35
|
if (!bib) {
|
|
35
36
|
return;
|
|
@@ -50,7 +51,6 @@ export class BibliographyElementBlockView extends BlockView {
|
|
|
50
51
|
this.showPopper(citationId);
|
|
51
52
|
};
|
|
52
53
|
this.handleComment = (citationId) => {
|
|
53
|
-
this.props.popper.destroy();
|
|
54
54
|
this.props.setComment(buildComment(citationId));
|
|
55
55
|
};
|
|
56
56
|
this.showContextMenu = (element) => {
|
|
@@ -53,6 +53,10 @@ 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
|
+
};
|
|
56
60
|
this.destroy = () => {
|
|
57
61
|
var _a;
|
|
58
62
|
(_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
|
|
18
|
+
import { ContextMenu } from '../lib/context-menu';
|
|
19
19
|
const isNotNull = (a) => a !== null;
|
|
20
20
|
const hasParent = ($pos, type) => {
|
|
21
21
|
return !!findParentNodeOfTypeClosestToPos($pos, type);
|
|
@@ -38,12 +38,13 @@ 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');
|
|
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();
|
|
47
48
|
const menu = this.createMenu();
|
|
48
49
|
menu.showAddMenu(event.currentTarget, after);
|
|
49
50
|
});
|
|
@@ -55,11 +56,12 @@ export const EditableBlock = (Base) => {
|
|
|
55
56
|
return null;
|
|
56
57
|
}
|
|
57
58
|
const button = document.createElement('a');
|
|
58
|
-
button.classList.add('edit-block'
|
|
59
|
+
button.classList.add('edit-block');
|
|
59
60
|
button.setAttribute('aria-label', 'Open menu');
|
|
60
61
|
button.setAttribute('data-balloon-pos', 'down-left');
|
|
61
62
|
button.addEventListener('mousedown', (event) => {
|
|
62
63
|
event.preventDefault();
|
|
64
|
+
event.stopPropagation();
|
|
63
65
|
const menu = this.createMenu();
|
|
64
66
|
menu.showEditMenu(event.currentTarget);
|
|
65
67
|
});
|
|
@@ -20,7 +20,6 @@ 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";
|
|
24
23
|
export declare class ContextMenu {
|
|
25
24
|
private readonly node;
|
|
26
25
|
private readonly view;
|
|
@@ -20,6 +20,7 @@ export declare class CitationEditableView extends CitationView<EditableBlockProp
|
|
|
20
20
|
private contextMenu;
|
|
21
21
|
stopEvent: (event: Event) => boolean;
|
|
22
22
|
selectNode: () => void;
|
|
23
|
+
deselectNode: () => void;
|
|
23
24
|
destroy: () => void;
|
|
24
25
|
showContextMenu: () => void;
|
|
25
26
|
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.5
|
|
4
|
+
"version": "1.10.5",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|