@manuscripts/body-editor 1.10.5-LEAN-3535.0 → 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.js +0 -8
- package/dist/cjs/views/citation_editable.js +9 -9
- 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.js +0 -8
- package/dist/es/views/citation_editable.js +9 -9
- package/dist/es/views/editable_block.js +5 -3
- package/dist/types/lib/context-menu.d.ts +0 -1
- package/dist/types/views/citation.d.ts +0 -2
- package/dist/types/views/citation_editable.d.ts +1 -1
- 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) => {
|
|
@@ -27,7 +27,6 @@ class CitationView extends base_node_view_1.BaseNodeView {
|
|
|
27
27
|
constructor() {
|
|
28
28
|
super(...arguments);
|
|
29
29
|
this.ignoreMutation = () => true;
|
|
30
|
-
this.wasUpdated = false;
|
|
31
30
|
this.initialise = () => {
|
|
32
31
|
if (!this.node.type.spec.toDOM) {
|
|
33
32
|
throw Error(`Node view ${this.node.type} doesn't have toDOM method`);
|
|
@@ -41,7 +40,6 @@ class CitationView extends base_node_view_1.BaseNodeView {
|
|
|
41
40
|
};
|
|
42
41
|
this.updateContents = () => {
|
|
43
42
|
var _a;
|
|
44
|
-
console.log('citation view updateContents');
|
|
45
43
|
const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
|
|
46
44
|
if (!bib) {
|
|
47
45
|
return;
|
|
@@ -62,12 +60,6 @@ class CitationView extends base_node_view_1.BaseNodeView {
|
|
|
62
60
|
this.dom.appendChild(element);
|
|
63
61
|
(0, comment_annotation_1.addCommentToLeafNode)(this.getPos(), this.getPos() + this.node.nodeSize, this.view.state, this.dom);
|
|
64
62
|
this.setDomAttrs(this.node, this.dom, ['rids', 'contents', 'selectedText']);
|
|
65
|
-
if (!this.wasUpdated) {
|
|
66
|
-
this.dom.addEventListener('click', () => this.onClickHandler());
|
|
67
|
-
}
|
|
68
|
-
this.wasUpdated = true;
|
|
69
|
-
};
|
|
70
|
-
this.onClickHandler = () => {
|
|
71
63
|
};
|
|
72
64
|
}
|
|
73
65
|
}
|
|
@@ -47,16 +47,7 @@ class CitationEditableView extends citation_1.CitationView {
|
|
|
47
47
|
((_a = element.parentElement) === null || _a === void 0 ? void 0 : _a.classList.contains('comment-icon')));
|
|
48
48
|
};
|
|
49
49
|
this.selectNode = () => {
|
|
50
|
-
console.log('selectNode...');
|
|
51
50
|
this.dom.classList.add('ProseMirror-selectednode');
|
|
52
|
-
};
|
|
53
|
-
this.destroy = () => {
|
|
54
|
-
var _a;
|
|
55
|
-
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.remove();
|
|
56
|
-
this.props.popper.destroy();
|
|
57
|
-
};
|
|
58
|
-
this.onClickHandler = () => {
|
|
59
|
-
console.log('citation_editable click handler...');
|
|
60
51
|
const can = this.props.getCapabilities();
|
|
61
52
|
if (can.seeReferencesButtons && !(0, track_changes_utils_1.isDeleted)(this.node)) {
|
|
62
53
|
const attrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
|
|
@@ -68,6 +59,15 @@ class CitationEditableView extends citation_1.CitationView {
|
|
|
68
59
|
}
|
|
69
60
|
}
|
|
70
61
|
};
|
|
62
|
+
this.deselectNode = () => {
|
|
63
|
+
this.dom.classList.remove('ProseMirror-selectednode');
|
|
64
|
+
this.props.popper.destroy();
|
|
65
|
+
};
|
|
66
|
+
this.destroy = () => {
|
|
67
|
+
var _a;
|
|
68
|
+
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.remove();
|
|
69
|
+
this.props.popper.destroy();
|
|
70
|
+
};
|
|
71
71
|
this.showContextMenu = () => {
|
|
72
72
|
this.props.popper.destroy();
|
|
73
73
|
const componentProps = {
|
|
@@ -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) => {
|
|
@@ -24,7 +24,6 @@ export class CitationView extends BaseNodeView {
|
|
|
24
24
|
constructor() {
|
|
25
25
|
super(...arguments);
|
|
26
26
|
this.ignoreMutation = () => true;
|
|
27
|
-
this.wasUpdated = false;
|
|
28
27
|
this.initialise = () => {
|
|
29
28
|
if (!this.node.type.spec.toDOM) {
|
|
30
29
|
throw Error(`Node view ${this.node.type} doesn't have toDOM method`);
|
|
@@ -38,7 +37,6 @@ export class CitationView extends BaseNodeView {
|
|
|
38
37
|
};
|
|
39
38
|
this.updateContents = () => {
|
|
40
39
|
var _a;
|
|
41
|
-
console.log('citation view updateContents');
|
|
42
40
|
const bib = getBibliographyPluginState(this.view.state);
|
|
43
41
|
if (!bib) {
|
|
44
42
|
return;
|
|
@@ -59,12 +57,6 @@ export class CitationView extends BaseNodeView {
|
|
|
59
57
|
this.dom.appendChild(element);
|
|
60
58
|
addCommentToLeafNode(this.getPos(), this.getPos() + this.node.nodeSize, this.view.state, this.dom);
|
|
61
59
|
this.setDomAttrs(this.node, this.dom, ['rids', 'contents', 'selectedText']);
|
|
62
|
-
if (!this.wasUpdated) {
|
|
63
|
-
this.dom.addEventListener('click', () => this.onClickHandler());
|
|
64
|
-
}
|
|
65
|
-
this.wasUpdated = true;
|
|
66
|
-
};
|
|
67
|
-
this.onClickHandler = () => {
|
|
68
60
|
};
|
|
69
61
|
}
|
|
70
62
|
}
|
|
@@ -41,16 +41,7 @@ export class CitationEditableView extends CitationView {
|
|
|
41
41
|
((_a = element.parentElement) === null || _a === void 0 ? void 0 : _a.classList.contains('comment-icon')));
|
|
42
42
|
};
|
|
43
43
|
this.selectNode = () => {
|
|
44
|
-
console.log('selectNode...');
|
|
45
44
|
this.dom.classList.add('ProseMirror-selectednode');
|
|
46
|
-
};
|
|
47
|
-
this.destroy = () => {
|
|
48
|
-
var _a;
|
|
49
|
-
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.remove();
|
|
50
|
-
this.props.popper.destroy();
|
|
51
|
-
};
|
|
52
|
-
this.onClickHandler = () => {
|
|
53
|
-
console.log('citation_editable click handler...');
|
|
54
45
|
const can = this.props.getCapabilities();
|
|
55
46
|
if (can.seeReferencesButtons && !isDeleted(this.node)) {
|
|
56
47
|
const attrs = getActualAttrs(this.node);
|
|
@@ -62,6 +53,15 @@ export class CitationEditableView extends CitationView {
|
|
|
62
53
|
}
|
|
63
54
|
}
|
|
64
55
|
};
|
|
56
|
+
this.deselectNode = () => {
|
|
57
|
+
this.dom.classList.remove('ProseMirror-selectednode');
|
|
58
|
+
this.props.popper.destroy();
|
|
59
|
+
};
|
|
60
|
+
this.destroy = () => {
|
|
61
|
+
var _a;
|
|
62
|
+
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.remove();
|
|
63
|
+
this.props.popper.destroy();
|
|
64
|
+
};
|
|
65
65
|
this.showContextMenu = () => {
|
|
66
66
|
this.props.popper.destroy();
|
|
67
67
|
const componentProps = {
|
|
@@ -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;
|
|
@@ -17,10 +17,8 @@ import { ManuscriptNodeView } from '@manuscripts/transform';
|
|
|
17
17
|
import { BaseNodeProps, BaseNodeView } from './base_node_view';
|
|
18
18
|
export declare class CitationView<PropsType extends BaseNodeProps> extends BaseNodeView<PropsType> implements ManuscriptNodeView {
|
|
19
19
|
ignoreMutation: () => boolean;
|
|
20
|
-
wasUpdated: boolean;
|
|
21
20
|
initialise: () => this;
|
|
22
21
|
updateContents: () => void;
|
|
23
|
-
onClickHandler: () => void;
|
|
24
22
|
}
|
|
25
23
|
declare const _default: (props: BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<CitationView<any>>;
|
|
26
24
|
export default _default;
|
|
@@ -20,8 +20,8 @@ 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
|
-
onClickHandler: () => void;
|
|
25
25
|
showContextMenu: () => void;
|
|
26
26
|
showPopper: () => void;
|
|
27
27
|
private handleEdit;
|
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",
|