@manuscripts/body-editor 1.10.6-LEAN-3651.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/configs/ManuscriptsEditor.js +0 -2
- 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/configs/ManuscriptsEditor.js +0 -2
- 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/dist/cjs/clipboard.js +0 -15
- package/dist/es/clipboard.js +0 -12
- package/dist/types/clipboard.d.ts +0 -2
|
@@ -23,7 +23,6 @@ require("prosemirror-view/style/prosemirror.css");
|
|
|
23
23
|
const transform_1 = require("@manuscripts/transform");
|
|
24
24
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
25
25
|
const prosemirror_view_1 = require("prosemirror-view");
|
|
26
|
-
const clipboard_1 = require("../clipboard");
|
|
27
26
|
const paste_1 = require("../lib/paste");
|
|
28
27
|
const editor_plugins_1 = __importDefault(require("./editor-plugins"));
|
|
29
28
|
const editor_views_1 = __importDefault(require("./editor-views"));
|
|
@@ -47,7 +46,6 @@ const createEditorView = (props, root, state, dispatch) => {
|
|
|
47
46
|
nodeViews: (0, editor_views_1.default)(props, dispatch),
|
|
48
47
|
attributes: props.attributes,
|
|
49
48
|
transformPasted: paste_1.transformPasted,
|
|
50
|
-
clipboardParser: clipboard_1.clipboardParser,
|
|
51
49
|
});
|
|
52
50
|
const tr = view.state.tr.setMeta('INIT', true);
|
|
53
51
|
const nextState = view.state.apply(tr);
|
|
@@ -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
|
});
|
|
@@ -17,7 +17,6 @@ import 'prosemirror-view/style/prosemirror.css';
|
|
|
17
17
|
import { schema } from '@manuscripts/transform';
|
|
18
18
|
import { EditorState } from 'prosemirror-state';
|
|
19
19
|
import { EditorView } from 'prosemirror-view';
|
|
20
|
-
import { clipboardParser } from '../clipboard';
|
|
21
20
|
import { transformPasted } from '../lib/paste';
|
|
22
21
|
import plugins from './editor-plugins';
|
|
23
22
|
import views from './editor-views';
|
|
@@ -40,7 +39,6 @@ export const createEditorView = (props, root, state, dispatch) => {
|
|
|
40
39
|
nodeViews: views(props, dispatch),
|
|
41
40
|
attributes: props.attributes,
|
|
42
41
|
transformPasted,
|
|
43
|
-
clipboardParser,
|
|
44
42
|
});
|
|
45
43
|
const tr = view.state.tr.setMeta('INIT', true);
|
|
46
44
|
const nextState = view.state.apply(tr);
|
|
@@ -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",
|
package/dist/cjs/clipboard.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clipboardParser = void 0;
|
|
4
|
-
const transform_1 = require("@manuscripts/transform");
|
|
5
|
-
const prosemirror_model_1 = require("prosemirror-model");
|
|
6
|
-
const nodes = [
|
|
7
|
-
{
|
|
8
|
-
tag: 'p',
|
|
9
|
-
node: 'paragraph',
|
|
10
|
-
},
|
|
11
|
-
];
|
|
12
|
-
exports.clipboardParser = new prosemirror_model_1.DOMParser(transform_1.schema, [
|
|
13
|
-
...nodes,
|
|
14
|
-
...prosemirror_model_1.DOMParser.fromSchema(transform_1.schema).rules,
|
|
15
|
-
]);
|
package/dist/es/clipboard.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { schema } from '@manuscripts/transform';
|
|
2
|
-
import { DOMParser } from 'prosemirror-model';
|
|
3
|
-
const nodes = [
|
|
4
|
-
{
|
|
5
|
-
tag: 'p',
|
|
6
|
-
node: 'paragraph',
|
|
7
|
-
},
|
|
8
|
-
];
|
|
9
|
-
export const clipboardParser = new DOMParser(schema, [
|
|
10
|
-
...nodes,
|
|
11
|
-
...DOMParser.fromSchema(schema).rules,
|
|
12
|
-
]);
|