@manuscripts/body-editor 1.6.5 → 1.6.6-LEAN-3209
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/components/keywords/DeleteKeywordDialog.js +46 -0
- package/dist/cjs/configs/ManuscriptsEditor.js +21 -22
- package/dist/cjs/configs/editor-plugins.js +0 -2
- package/dist/cjs/configs/editor-views.js +1 -1
- package/dist/cjs/index.js +3 -11
- package/dist/cjs/menus.js +3 -1
- package/dist/cjs/useEditor.js +8 -20
- package/dist/cjs/views/keyword.js +52 -2
- package/dist/cjs/views/keywords_element.js +0 -5
- package/dist/es/components/keywords/DeleteKeywordDialog.js +19 -0
- package/dist/es/configs/ManuscriptsEditor.js +18 -22
- package/dist/es/configs/editor-plugins.js +0 -2
- package/dist/es/configs/editor-views.js +1 -1
- package/dist/es/index.js +2 -4
- package/dist/es/menus.js +1 -1
- package/dist/es/useEditor.js +6 -20
- package/dist/es/views/keyword.js +49 -2
- package/dist/es/views/keywords_element.js +0 -5
- package/dist/types/components/keywords/DeleteKeywordDialog.d.ts +6 -0
- package/dist/types/configs/ManuscriptsEditor.d.ts +4 -6
- package/dist/types/configs/editor-views.d.ts +1 -1
- package/dist/types/index.d.ts +2 -4
- package/dist/types/menus.d.ts +2 -3
- package/dist/types/useEditor.d.ts +1 -4
- package/dist/types/views/keyword.d.ts +9 -9
- package/dist/types/views/keywords_element.d.ts +0 -1
- package/package.json +2 -2
- package/styles/AdvancedEditor.css +19 -36
- package/dist/cjs/components/keywords/DeleteKeyword.js +0 -92
- package/dist/cjs/plugins/keywords.js +0 -121
- package/dist/es/components/keywords/DeleteKeyword.js +0 -65
- package/dist/es/plugins/keywords.js +0 -115
- package/dist/types/components/keywords/DeleteKeyword.d.ts +0 -10
- package/dist/types/plugins/keywords.d.ts +0 -28
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.DeleteKeywordDialog = void 0;
|
|
27
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const DeleteKeywordDialog = ({ keyword, handleDelete, }) => {
|
|
30
|
+
const [isOpen, setOpen] = (0, react_1.useState)(true);
|
|
31
|
+
return (react_1.default.createElement(style_guide_1.Dialog, { isOpen: isOpen, actions: {
|
|
32
|
+
primary: {
|
|
33
|
+
action: () => setOpen(false),
|
|
34
|
+
title: 'Cancel',
|
|
35
|
+
},
|
|
36
|
+
secondary: {
|
|
37
|
+
action: () => {
|
|
38
|
+
setOpen(false);
|
|
39
|
+
handleDelete();
|
|
40
|
+
},
|
|
41
|
+
title: 'Delete',
|
|
42
|
+
},
|
|
43
|
+
}, category: style_guide_1.Category.confirmation, header: 'Delete Keyword', message: `Are you sure you want to delete "${keyword}" keyword?
|
|
44
|
+
` }));
|
|
45
|
+
};
|
|
46
|
+
exports.DeleteKeywordDialog = DeleteKeywordDialog;
|
|
@@ -18,6 +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.createEditorView = exports.createEditorState = void 0;
|
|
21
22
|
require("prosemirror-view/style/prosemirror.css");
|
|
22
23
|
const transform_1 = require("@manuscripts/transform");
|
|
23
24
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
@@ -25,26 +26,24 @@ const prosemirror_view_1 = require("prosemirror-view");
|
|
|
25
26
|
const paste_1 = require("../lib/paste");
|
|
26
27
|
const editor_plugins_1 = __importDefault(require("./editor-plugins"));
|
|
27
28
|
const editor_views_1 = __importDefault(require("./editor-views"));
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
const createEditorState = (props) => prosemirror_state_1.EditorState.create({
|
|
30
|
+
doc: props.doc,
|
|
31
|
+
schema: transform_1.schema,
|
|
32
|
+
plugins: (0, editor_plugins_1.default)(props),
|
|
33
|
+
});
|
|
34
|
+
exports.createEditorState = createEditorState;
|
|
35
|
+
const createEditorView = (props, root, state, dispatch) => new prosemirror_view_1.EditorView(root, {
|
|
36
|
+
state,
|
|
37
|
+
editable: () => props.getCapabilities().editArticle,
|
|
38
|
+
scrollMargin: {
|
|
39
|
+
top: 100,
|
|
40
|
+
bottom: 100,
|
|
41
|
+
left: 0,
|
|
42
|
+
right: 0,
|
|
35
43
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
left: 0,
|
|
43
|
-
right: 0,
|
|
44
|
-
},
|
|
45
|
-
dispatchTransaction: dispatch,
|
|
46
|
-
nodeViews: (0, editor_views_1.default)(props, dispatch),
|
|
47
|
-
attributes: props.attributes,
|
|
48
|
-
transformPasted: paste_1.transformPasted,
|
|
49
|
-
}),
|
|
50
|
-
};
|
|
44
|
+
dispatchTransaction: dispatch,
|
|
45
|
+
nodeViews: (0, editor_views_1.default)(props, dispatch),
|
|
46
|
+
attributes: props.attributes,
|
|
47
|
+
transformPasted: paste_1.transformPasted,
|
|
48
|
+
});
|
|
49
|
+
exports.createEditorView = createEditorView;
|
|
@@ -30,7 +30,6 @@ const comment_annotation_1 = __importDefault(require("../plugins/comment_annotat
|
|
|
30
30
|
const elements_1 = __importDefault(require("../plugins/elements"));
|
|
31
31
|
const footnotes_1 = __importDefault(require("../plugins/footnotes"));
|
|
32
32
|
const highlight_1 = __importDefault(require("../plugins/highlight"));
|
|
33
|
-
const keywords_1 = __importDefault(require("../plugins/keywords"));
|
|
34
33
|
const objects_1 = __importDefault(require("../plugins/objects"));
|
|
35
34
|
const paragraphs_1 = __importDefault(require("../plugins/paragraphs"));
|
|
36
35
|
const persist_1 = __importDefault(require("../plugins/persist"));
|
|
@@ -54,7 +53,6 @@ exports.default = (props) => {
|
|
|
54
53
|
(0, persist_1.default)(),
|
|
55
54
|
(0, sections_1.default)(),
|
|
56
55
|
(0, toc_1.default)(props),
|
|
57
|
-
(0, keywords_1.default)(props),
|
|
58
56
|
(0, bibliography_1.default)(props),
|
|
59
57
|
(0, objects_1.default)(props),
|
|
60
58
|
(0, comment_annotation_1.default)(props),
|
|
@@ -65,7 +65,7 @@ exports.default = (props, dispatch) => {
|
|
|
65
65
|
footnotes_element: (0, footnotes_element_1.default)(props),
|
|
66
66
|
inline_equation: (0, inline_equation_editable_1.default)(props),
|
|
67
67
|
inline_footnote: (0, inline_footnote_editable_1.default)(props),
|
|
68
|
-
keyword: (0, keyword_1.default)(props),
|
|
68
|
+
keyword: (0, keyword_1.default)(props, dispatch),
|
|
69
69
|
keywords_element: (0, keywords_element_1.default)(props, dispatch),
|
|
70
70
|
link: (0, link_editable_1.default)(props),
|
|
71
71
|
listing: (0, listing_editable_1.default)(props),
|
package/dist/cjs/index.js
CHANGED
|
@@ -28,11 +28,8 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
28
28
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
29
29
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
30
|
};
|
|
31
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
-
};
|
|
34
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.
|
|
32
|
+
exports.isHighlightComment = exports.isThereSelector = exports.commentScroll = exports.toolbar = exports.PopperManager = exports.CollabProvider = exports.ManuscriptToolbar = exports.OutlineManuscript = exports.OutlineItemIcon = exports.ManuscriptOutline = exports.DialogNames = exports.DialogController = void 0;
|
|
36
33
|
__exportStar(require("./citation-sources"), exports);
|
|
37
34
|
__exportStar(require("./commands"), exports);
|
|
38
35
|
__exportStar(require("./components/application-menu"), exports);
|
|
@@ -47,8 +44,7 @@ var OutlineManuscript_1 = require("./components/outline/OutlineManuscript");
|
|
|
47
44
|
Object.defineProperty(exports, "OutlineManuscript", { enumerable: true, get: function () { return OutlineManuscript_1.OutlineManuscript; } });
|
|
48
45
|
var ManuscriptToolbar_1 = require("./components/toolbar/ManuscriptToolbar");
|
|
49
46
|
Object.defineProperty(exports, "ManuscriptToolbar", { enumerable: true, get: function () { return ManuscriptToolbar_1.ManuscriptToolbar; } });
|
|
50
|
-
|
|
51
|
-
Object.defineProperty(exports, "getMenus", { enumerable: true, get: function () { return __importDefault(menus_1).default; } });
|
|
47
|
+
__exportStar(require("./menus"), exports);
|
|
52
48
|
var collabProvider_1 = require("./classes/collabProvider");
|
|
53
49
|
Object.defineProperty(exports, "CollabProvider", { enumerable: true, get: function () { return collabProvider_1.CollabProvider; } });
|
|
54
50
|
var popper_1 = require("./lib/popper");
|
|
@@ -60,9 +56,5 @@ var comment_annotation_1 = require("./plugins/comment_annotation");
|
|
|
60
56
|
Object.defineProperty(exports, "commentScroll", { enumerable: true, get: function () { return comment_annotation_1.commentScroll; } });
|
|
61
57
|
Object.defineProperty(exports, "isThereSelector", { enumerable: true, get: function () { return comment_annotation_1.isThereSelector; } });
|
|
62
58
|
Object.defineProperty(exports, "isHighlightComment", { enumerable: true, get: function () { return comment_annotation_1.isHighlightComment; } });
|
|
63
|
-
__exportStar(require("./plugins/keywords"), exports);
|
|
64
59
|
__exportStar(require("./lib/utils"), exports);
|
|
65
|
-
|
|
66
|
-
Object.defineProperty(exports, "useEditor", { enumerable: true, get: function () { return __importDefault(useEditor_1).default; } });
|
|
67
|
-
var ManuscriptsEditor_1 = require("./configs//ManuscriptsEditor");
|
|
68
|
-
Object.defineProperty(exports, "ManuscriptsEditor", { enumerable: true, get: function () { return __importDefault(ManuscriptsEditor_1).default; } });
|
|
60
|
+
__exportStar(require("./useEditor"), exports);
|
package/dist/cjs/menus.js
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.getMenus = void 0;
|
|
18
19
|
const transform_1 = require("@manuscripts/transform");
|
|
19
20
|
const prosemirror_commands_1 = require("prosemirror-commands");
|
|
20
21
|
const prosemirror_history_1 = require("prosemirror-history");
|
|
@@ -24,7 +25,7 @@ const commands_1 = require("./commands");
|
|
|
24
25
|
const dialog_1 = require("./components/dialog");
|
|
25
26
|
const list_1 = require("./keys/list");
|
|
26
27
|
const hierarchy_1 = require("./lib/hierarchy");
|
|
27
|
-
|
|
28
|
+
const getMenus = (editor, handleOpenDialog, footnotesEnabled, contentEditable) => {
|
|
28
29
|
const { isCommandValid, state } = editor;
|
|
29
30
|
const wrap = (command) => () => editor.doCommand(command);
|
|
30
31
|
let menus = [
|
|
@@ -438,3 +439,4 @@ exports.default = (editor, handleOpenDialog, footnotesEnabled, contentEditable)
|
|
|
438
439
|
return menuGroup;
|
|
439
440
|
});
|
|
440
441
|
};
|
|
442
|
+
exports.getMenus = getMenus;
|
package/dist/cjs/useEditor.js
CHANGED
|
@@ -24,19 +24,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.useEditor = void 0;
|
|
27
28
|
const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
|
|
28
29
|
const prosemirror_collab_1 = require("prosemirror-collab");
|
|
29
30
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
30
31
|
const react_1 = require("react");
|
|
31
32
|
const react_router_dom_1 = require("react-router-dom");
|
|
33
|
+
const ManuscriptsEditor_1 = require("./configs/ManuscriptsEditor");
|
|
32
34
|
const use_do_with_debounce_1 = require("./lib/use-do-with-debounce");
|
|
33
|
-
const
|
|
34
|
-
const useEditor = (initialState, createView, editorProps) => {
|
|
35
|
+
const useEditor = (props) => {
|
|
35
36
|
const view = (0, react_1.useRef)();
|
|
36
|
-
const [state, setState] = (0, react_1.useState)(
|
|
37
|
-
const [viewElement, setViewElement] = (0, react_1.useState)(null);
|
|
37
|
+
const [state, setState] = (0, react_1.useState)(() => (0, ManuscriptsEditor_1.createEditorState)(props));
|
|
38
38
|
const history = (0, react_router_dom_1.useHistory)();
|
|
39
|
-
const { collabProvider } =
|
|
39
|
+
const { collabProvider } = props;
|
|
40
40
|
if (collabProvider) {
|
|
41
41
|
collabProvider.onNewSteps((newVersion, steps, clientIDs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
42
|
if (state && view.current) {
|
|
@@ -70,26 +70,15 @@ const useEditor = (initialState, createView, editorProps) => {
|
|
|
70
70
|
debounce(() => {
|
|
71
71
|
setState(nextState);
|
|
72
72
|
}, 200, !tr.isGeneric);
|
|
73
|
-
return
|
|
73
|
+
return nextState;
|
|
74
74
|
}, []);
|
|
75
|
-
const replaceView = (state, createView) => {
|
|
76
|
-
if (viewElement && view.current) {
|
|
77
|
-
view.current.destroy();
|
|
78
|
-
view.current = createView(viewElement, state, dispatch);
|
|
79
|
-
setState(view.current.state);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
75
|
const onRender = (0, react_1.useCallback)((el) => {
|
|
83
76
|
var _a;
|
|
84
77
|
if (!el) {
|
|
85
78
|
return;
|
|
86
79
|
}
|
|
87
|
-
view.current =
|
|
80
|
+
view.current = (0, ManuscriptsEditor_1.createEditorView)(props, el, ((_a = view.current) === null || _a === void 0 ? void 0 : _a.state) || state, dispatch);
|
|
88
81
|
setState(view.current.state);
|
|
89
|
-
setViewElement(el);
|
|
90
|
-
view.current.dispatch(view.current.state.tr.setMeta(bibliography_1.bibliographyKey, {
|
|
91
|
-
initCitations: true,
|
|
92
|
-
}));
|
|
93
82
|
}, []);
|
|
94
83
|
const isCommandValid = (0, react_1.useCallback)((command) => command(state), [state]);
|
|
95
84
|
const doCommand = (0, react_1.useCallback)((command) => command(state, dispatch, view.current), [state, dispatch]);
|
|
@@ -138,9 +127,8 @@ const useEditor = (initialState, createView, editorProps) => {
|
|
|
138
127
|
isCommandValid,
|
|
139
128
|
doCommand,
|
|
140
129
|
replaceState,
|
|
141
|
-
replaceView,
|
|
142
130
|
view: view.current,
|
|
143
131
|
dispatch,
|
|
144
132
|
};
|
|
145
133
|
};
|
|
146
|
-
exports.
|
|
134
|
+
exports.useEditor = useEditor;
|
|
@@ -14,15 +14,65 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
17
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
21
|
exports.KeywordView = void 0;
|
|
22
|
+
const DeleteKeywordDialog_1 = require("../components/keywords/DeleteKeywordDialog");
|
|
23
|
+
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
19
24
|
const base_node_view_1 = require("./base_node_view");
|
|
20
25
|
const creators_1 = require("./creators");
|
|
26
|
+
const ReactSubView_1 = __importDefault(require("./ReactSubView"));
|
|
27
|
+
const icon = '<svg width="8px" height="8px" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg">\n' +
|
|
28
|
+
' <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\n' +
|
|
29
|
+
' <g fill="#6E6E6E">\n' +
|
|
30
|
+
' <rect id="Rectangle-23-Copy" transform="translate(13.000000, 13.000000) rotate(-45.000000) translate(-13.000000, -13.000000) " x="-3" y="11" width="32" height="4" rx="2"></rect>\n' +
|
|
31
|
+
' <rect id="Rectangle-23-Copy-2" transform="translate(13.000000, 13.000000) scale(1, -1) rotate(-45.000000) translate(-13.000000, -13.000000) " x="-3" y="11" width="32" height="4" rx="2"></rect>\n' +
|
|
32
|
+
' </g>\n' +
|
|
33
|
+
' </g>\n' +
|
|
34
|
+
'</svg>';
|
|
21
35
|
class KeywordView extends base_node_view_1.BaseNodeView {
|
|
22
36
|
constructor() {
|
|
23
37
|
super(...arguments);
|
|
24
|
-
this.
|
|
25
|
-
|
|
38
|
+
this.initialise = () => {
|
|
39
|
+
this.createDOM();
|
|
40
|
+
this.updateContents();
|
|
41
|
+
};
|
|
42
|
+
this.createDOM = () => {
|
|
43
|
+
this.dom = document.createElement('span');
|
|
44
|
+
this.contentDOM = document.createElement('span');
|
|
45
|
+
};
|
|
46
|
+
this.updateContents = () => {
|
|
47
|
+
const keyword = document.createElement('span');
|
|
48
|
+
const classes = ['keyword', ...(0, track_changes_utils_1.getChangeClasses)(this.node)];
|
|
49
|
+
keyword.classList.add(...classes);
|
|
50
|
+
keyword.appendChild(this.contentDOM);
|
|
51
|
+
const can = this.props.getCapabilities();
|
|
52
|
+
if (can.editArticle) {
|
|
53
|
+
const svg = new DOMParser()
|
|
54
|
+
.parseFromString(icon, 'image/svg+xml')
|
|
55
|
+
.querySelector('svg');
|
|
56
|
+
svg.classList.add('delete-keyword');
|
|
57
|
+
svg.addEventListener('click', this.showConfirmationDialog);
|
|
58
|
+
keyword.appendChild(svg);
|
|
59
|
+
}
|
|
60
|
+
this.dom.innerHTML = '';
|
|
61
|
+
this.dom.appendChild(keyword);
|
|
62
|
+
};
|
|
63
|
+
this.showConfirmationDialog = () => {
|
|
64
|
+
var _a;
|
|
65
|
+
(_a = this.dialog) === null || _a === void 0 ? void 0 : _a.remove();
|
|
66
|
+
const keyword = this.node;
|
|
67
|
+
const componentProps = {
|
|
68
|
+
keyword: keyword.textContent,
|
|
69
|
+
handleDelete: () => this.deleteNode(keyword.attrs.id),
|
|
70
|
+
};
|
|
71
|
+
this.dialog = (0, ReactSubView_1.default)(this.props, DeleteKeywordDialog_1.DeleteKeywordDialog, componentProps, this.node, this.getPos, this.view, 'keywords-delete');
|
|
72
|
+
if (this.dialog) {
|
|
73
|
+
this.dom.appendChild(this.dialog);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
26
76
|
}
|
|
27
77
|
}
|
|
28
78
|
exports.KeywordView = KeywordView;
|
|
@@ -20,7 +20,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.KeywordsElementView = void 0;
|
|
22
22
|
const AddKeywordInline_1 = require("../components/keywords/AddKeywordInline");
|
|
23
|
-
const DeleteKeyword_1 = require("../components/keywords/DeleteKeyword");
|
|
24
23
|
const block_view_1 = __importDefault(require("./block_view"));
|
|
25
24
|
const creators_1 = require("./creators");
|
|
26
25
|
const ReactSubView_1 = __importDefault(require("./ReactSubView"));
|
|
@@ -42,10 +41,6 @@ class KeywordsElementView extends block_view_1.default {
|
|
|
42
41
|
if (this.addingTools && this.props.getCapabilities().editArticle) {
|
|
43
42
|
this.element.appendChild(this.addingTools);
|
|
44
43
|
}
|
|
45
|
-
this.deleteTools = (0, ReactSubView_1.default)(this.props, DeleteKeyword_1.DeleteKeyword, { getUpdatedNode: () => this.node }, this.node, this.getPos, this.view, 'keywords-delete');
|
|
46
|
-
if (this.deleteTools) {
|
|
47
|
-
this.element.appendChild(this.deleteTools);
|
|
48
|
-
}
|
|
49
44
|
};
|
|
50
45
|
}
|
|
51
46
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Category, Dialog } from '@manuscripts/style-guide';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
export const DeleteKeywordDialog = ({ keyword, handleDelete, }) => {
|
|
4
|
+
const [isOpen, setOpen] = useState(true);
|
|
5
|
+
return (React.createElement(Dialog, { isOpen: isOpen, actions: {
|
|
6
|
+
primary: {
|
|
7
|
+
action: () => setOpen(false),
|
|
8
|
+
title: 'Cancel',
|
|
9
|
+
},
|
|
10
|
+
secondary: {
|
|
11
|
+
action: () => {
|
|
12
|
+
setOpen(false);
|
|
13
|
+
handleDelete();
|
|
14
|
+
},
|
|
15
|
+
title: 'Delete',
|
|
16
|
+
},
|
|
17
|
+
}, category: Category.confirmation, header: 'Delete Keyword', message: `Are you sure you want to delete "${keyword}" keyword?
|
|
18
|
+
` }));
|
|
19
|
+
};
|
|
@@ -20,26 +20,22 @@ import { EditorView } from 'prosemirror-view';
|
|
|
20
20
|
import { transformPasted } from '../lib/paste';
|
|
21
21
|
import plugins from './editor-plugins';
|
|
22
22
|
import views from './editor-views';
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
export const createEditorState = (props) => EditorState.create({
|
|
24
|
+
doc: props.doc,
|
|
25
|
+
schema,
|
|
26
|
+
plugins: plugins(props),
|
|
27
|
+
});
|
|
28
|
+
export const createEditorView = (props, root, state, dispatch) => new EditorView(root, {
|
|
29
|
+
state,
|
|
30
|
+
editable: () => props.getCapabilities().editArticle,
|
|
31
|
+
scrollMargin: {
|
|
32
|
+
top: 100,
|
|
33
|
+
bottom: 100,
|
|
34
|
+
left: 0,
|
|
35
|
+
right: 0,
|
|
30
36
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
bottom: 100,
|
|
37
|
-
left: 0,
|
|
38
|
-
right: 0,
|
|
39
|
-
},
|
|
40
|
-
dispatchTransaction: dispatch,
|
|
41
|
-
nodeViews: views(props, dispatch),
|
|
42
|
-
attributes: props.attributes,
|
|
43
|
-
transformPasted,
|
|
44
|
-
}),
|
|
45
|
-
};
|
|
37
|
+
dispatchTransaction: dispatch,
|
|
38
|
+
nodeViews: views(props, dispatch),
|
|
39
|
+
attributes: props.attributes,
|
|
40
|
+
transformPasted,
|
|
41
|
+
});
|
|
@@ -25,7 +25,6 @@ import comment_annotation from '../plugins/comment_annotation';
|
|
|
25
25
|
import elements from '../plugins/elements';
|
|
26
26
|
import footnotes from '../plugins/footnotes';
|
|
27
27
|
import highlights from '../plugins/highlight';
|
|
28
|
-
import keywords from '../plugins/keywords';
|
|
29
28
|
import objects from '../plugins/objects';
|
|
30
29
|
import paragraphs from '../plugins/paragraphs';
|
|
31
30
|
import persist from '../plugins/persist';
|
|
@@ -49,7 +48,6 @@ export default (props) => {
|
|
|
49
48
|
persist(),
|
|
50
49
|
sections(),
|
|
51
50
|
toc(props),
|
|
52
|
-
keywords(props),
|
|
53
51
|
bibliography(props),
|
|
54
52
|
objects(props),
|
|
55
53
|
comment_annotation(props),
|
|
@@ -60,7 +60,7 @@ export default (props, dispatch) => {
|
|
|
60
60
|
footnotes_element: footnotesElement(props),
|
|
61
61
|
inline_equation: inlineEquation(props),
|
|
62
62
|
inline_footnote: inlineFootnote(props),
|
|
63
|
-
keyword: keyword(props),
|
|
63
|
+
keyword: keyword(props, dispatch),
|
|
64
64
|
keywords_element: keywordsElement(props, dispatch),
|
|
65
65
|
link: link(props),
|
|
66
66
|
listing: listing(props),
|
package/dist/es/index.js
CHANGED
|
@@ -21,13 +21,11 @@ export { ManuscriptOutline } from './components/outline/ManuscriptOutline';
|
|
|
21
21
|
export { OutlineItemIcon } from './components/outline/Outline';
|
|
22
22
|
export { OutlineManuscript } from './components/outline/OutlineManuscript';
|
|
23
23
|
export { ManuscriptToolbar, } from './components/toolbar/ManuscriptToolbar';
|
|
24
|
-
export
|
|
24
|
+
export * from './menus';
|
|
25
25
|
export { CollabProvider } from './classes/collabProvider';
|
|
26
26
|
export { PopperManager } from './lib/popper';
|
|
27
27
|
export { toolbar } from './toolbar';
|
|
28
28
|
export * from './plugins/highlight';
|
|
29
29
|
export { commentScroll, isThereSelector, isHighlightComment, } from './plugins/comment_annotation';
|
|
30
|
-
export * from './plugins/keywords';
|
|
31
30
|
export * from './lib/utils';
|
|
32
|
-
export
|
|
33
|
-
export { default as ManuscriptsEditor } from './configs//ManuscriptsEditor';
|
|
31
|
+
export * from './useEditor';
|
package/dist/es/menus.js
CHANGED
|
@@ -22,7 +22,7 @@ import { addComment, blockActive, canInsert, ifInTableBody, insertBibliographySe
|
|
|
22
22
|
import { DialogNames } from './components/dialog';
|
|
23
23
|
import { skipTrackingChanges } from './keys/list';
|
|
24
24
|
import { deleteClosestParentElement, findClosestParentElementNodeName, } from './lib/hierarchy';
|
|
25
|
-
export
|
|
25
|
+
export const getMenus = (editor, handleOpenDialog, footnotesEnabled, contentEditable) => {
|
|
26
26
|
const { isCommandValid, state } = editor;
|
|
27
27
|
const wrap = (command) => () => editor.doCommand(command);
|
|
28
28
|
let menus = [
|
package/dist/es/useEditor.js
CHANGED
|
@@ -27,14 +27,13 @@ import { getVersion, receiveTransaction, sendableSteps, } from 'prosemirror-coll
|
|
|
27
27
|
import { NodeSelection, } from 'prosemirror-state';
|
|
28
28
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
29
29
|
import { useHistory } from 'react-router-dom';
|
|
30
|
+
import { createEditorState, createEditorView, } from './configs/ManuscriptsEditor';
|
|
30
31
|
import { useDoWithDebounce } from './lib/use-do-with-debounce';
|
|
31
|
-
|
|
32
|
-
const useEditor = (initialState, createView, editorProps) => {
|
|
32
|
+
export const useEditor = (props) => {
|
|
33
33
|
const view = useRef();
|
|
34
|
-
const [state, setState] = useState(
|
|
35
|
-
const [viewElement, setViewElement] = useState(null);
|
|
34
|
+
const [state, setState] = useState(() => createEditorState(props));
|
|
36
35
|
const history = useHistory();
|
|
37
|
-
const { collabProvider } =
|
|
36
|
+
const { collabProvider } = props;
|
|
38
37
|
if (collabProvider) {
|
|
39
38
|
collabProvider.onNewSteps((newVersion, steps, clientIDs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
39
|
if (state && view.current) {
|
|
@@ -68,26 +67,15 @@ const useEditor = (initialState, createView, editorProps) => {
|
|
|
68
67
|
debounce(() => {
|
|
69
68
|
setState(nextState);
|
|
70
69
|
}, 200, !tr.isGeneric);
|
|
71
|
-
return
|
|
70
|
+
return nextState;
|
|
72
71
|
}, []);
|
|
73
|
-
const replaceView = (state, createView) => {
|
|
74
|
-
if (viewElement && view.current) {
|
|
75
|
-
view.current.destroy();
|
|
76
|
-
view.current = createView(viewElement, state, dispatch);
|
|
77
|
-
setState(view.current.state);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
72
|
const onRender = useCallback((el) => {
|
|
81
73
|
var _a;
|
|
82
74
|
if (!el) {
|
|
83
75
|
return;
|
|
84
76
|
}
|
|
85
|
-
view.current =
|
|
77
|
+
view.current = createEditorView(props, el, ((_a = view.current) === null || _a === void 0 ? void 0 : _a.state) || state, dispatch);
|
|
86
78
|
setState(view.current.state);
|
|
87
|
-
setViewElement(el);
|
|
88
|
-
view.current.dispatch(view.current.state.tr.setMeta(bibliographyKey, {
|
|
89
|
-
initCitations: true,
|
|
90
|
-
}));
|
|
91
79
|
}, []);
|
|
92
80
|
const isCommandValid = useCallback((command) => command(state), [state]);
|
|
93
81
|
const doCommand = useCallback((command) => command(state, dispatch, view.current), [state, dispatch]);
|
|
@@ -136,9 +124,7 @@ const useEditor = (initialState, createView, editorProps) => {
|
|
|
136
124
|
isCommandValid,
|
|
137
125
|
doCommand,
|
|
138
126
|
replaceState,
|
|
139
|
-
replaceView,
|
|
140
127
|
view: view.current,
|
|
141
128
|
dispatch,
|
|
142
129
|
};
|
|
143
130
|
};
|
|
144
|
-
export default useEditor;
|
package/dist/es/views/keyword.js
CHANGED
|
@@ -13,13 +13,60 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { DeleteKeywordDialog, } from '../components/keywords/DeleteKeywordDialog';
|
|
17
|
+
import { getChangeClasses } from '../lib/track-changes-utils';
|
|
16
18
|
import { BaseNodeView } from './base_node_view';
|
|
17
19
|
import { createNodeView } from './creators';
|
|
20
|
+
import ReactSubView from './ReactSubView';
|
|
21
|
+
const icon = '<svg width="8px" height="8px" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg">\n' +
|
|
22
|
+
' <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\n' +
|
|
23
|
+
' <g fill="#6E6E6E">\n' +
|
|
24
|
+
' <rect id="Rectangle-23-Copy" transform="translate(13.000000, 13.000000) rotate(-45.000000) translate(-13.000000, -13.000000) " x="-3" y="11" width="32" height="4" rx="2"></rect>\n' +
|
|
25
|
+
' <rect id="Rectangle-23-Copy-2" transform="translate(13.000000, 13.000000) scale(1, -1) rotate(-45.000000) translate(-13.000000, -13.000000) " x="-3" y="11" width="32" height="4" rx="2"></rect>\n' +
|
|
26
|
+
' </g>\n' +
|
|
27
|
+
' </g>\n' +
|
|
28
|
+
'</svg>';
|
|
18
29
|
export class KeywordView extends BaseNodeView {
|
|
19
30
|
constructor() {
|
|
20
31
|
super(...arguments);
|
|
21
|
-
this.
|
|
22
|
-
|
|
32
|
+
this.initialise = () => {
|
|
33
|
+
this.createDOM();
|
|
34
|
+
this.updateContents();
|
|
35
|
+
};
|
|
36
|
+
this.createDOM = () => {
|
|
37
|
+
this.dom = document.createElement('span');
|
|
38
|
+
this.contentDOM = document.createElement('span');
|
|
39
|
+
};
|
|
40
|
+
this.updateContents = () => {
|
|
41
|
+
const keyword = document.createElement('span');
|
|
42
|
+
const classes = ['keyword', ...getChangeClasses(this.node)];
|
|
43
|
+
keyword.classList.add(...classes);
|
|
44
|
+
keyword.appendChild(this.contentDOM);
|
|
45
|
+
const can = this.props.getCapabilities();
|
|
46
|
+
if (can.editArticle) {
|
|
47
|
+
const svg = new DOMParser()
|
|
48
|
+
.parseFromString(icon, 'image/svg+xml')
|
|
49
|
+
.querySelector('svg');
|
|
50
|
+
svg.classList.add('delete-keyword');
|
|
51
|
+
svg.addEventListener('click', this.showConfirmationDialog);
|
|
52
|
+
keyword.appendChild(svg);
|
|
53
|
+
}
|
|
54
|
+
this.dom.innerHTML = '';
|
|
55
|
+
this.dom.appendChild(keyword);
|
|
56
|
+
};
|
|
57
|
+
this.showConfirmationDialog = () => {
|
|
58
|
+
var _a;
|
|
59
|
+
(_a = this.dialog) === null || _a === void 0 ? void 0 : _a.remove();
|
|
60
|
+
const keyword = this.node;
|
|
61
|
+
const componentProps = {
|
|
62
|
+
keyword: keyword.textContent,
|
|
63
|
+
handleDelete: () => this.deleteNode(keyword.attrs.id),
|
|
64
|
+
};
|
|
65
|
+
this.dialog = ReactSubView(this.props, DeleteKeywordDialog, componentProps, this.node, this.getPos, this.view, 'keywords-delete');
|
|
66
|
+
if (this.dialog) {
|
|
67
|
+
this.dom.appendChild(this.dialog);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
23
70
|
}
|
|
24
71
|
}
|
|
25
72
|
export default createNodeView(KeywordView);
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { AddKeywordInline } from '../components/keywords/AddKeywordInline';
|
|
17
|
-
import { DeleteKeyword } from '../components/keywords/DeleteKeyword';
|
|
18
17
|
import BlockView from './block_view';
|
|
19
18
|
import { createNodeView } from './creators';
|
|
20
19
|
import ReactSubView from './ReactSubView';
|
|
@@ -36,10 +35,6 @@ export class KeywordsElementView extends BlockView {
|
|
|
36
35
|
if (this.addingTools && this.props.getCapabilities().editArticle) {
|
|
37
36
|
this.element.appendChild(this.addingTools);
|
|
38
37
|
}
|
|
39
|
-
this.deleteTools = ReactSubView(this.props, DeleteKeyword, { getUpdatedNode: () => this.node }, this.node, this.getPos, this.view, 'keywords-delete');
|
|
40
|
-
if (this.deleteTools) {
|
|
41
|
-
this.element.appendChild(this.deleteTools);
|
|
42
|
-
}
|
|
43
38
|
};
|
|
44
39
|
}
|
|
45
40
|
}
|
|
@@ -19,11 +19,12 @@ import { Capabilities, FileAttachment, FileManagement } from '@manuscripts/style
|
|
|
19
19
|
import { Build, ManuscriptNode } from '@manuscripts/transform';
|
|
20
20
|
import { History } from 'history';
|
|
21
21
|
import { EditorState, Plugin } from 'prosemirror-state';
|
|
22
|
+
import { EditorView } from 'prosemirror-view';
|
|
22
23
|
import React from 'react';
|
|
23
24
|
import { DefaultTheme } from 'styled-components';
|
|
24
25
|
import { CollabProvider } from '../classes/collabProvider';
|
|
26
|
+
import { Dispatch } from '../commands';
|
|
25
27
|
import { PopperManager } from '../lib/popper';
|
|
26
|
-
import { CreateView } from '../useEditor';
|
|
27
28
|
export type CSLProps = {
|
|
28
29
|
style?: string;
|
|
29
30
|
locale?: string;
|
|
@@ -58,8 +59,5 @@ export interface EditorProps {
|
|
|
58
59
|
environment?: string;
|
|
59
60
|
collabProvider?: CollabProvider;
|
|
60
61
|
}
|
|
61
|
-
declare const
|
|
62
|
-
|
|
63
|
-
createView: (props: EditorProps) => CreateView;
|
|
64
|
-
};
|
|
65
|
-
export default _default;
|
|
62
|
+
export declare const createEditorState: (props: EditorProps) => EditorState;
|
|
63
|
+
export declare const createEditorView: (props: EditorProps, root: HTMLElement, state: EditorState, dispatch: Dispatch) => EditorView;
|
|
@@ -260,7 +260,7 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
|
|
|
260
260
|
footnotes_element: import("../types").NodeViewCreator<import("../views/footnotes_element").FootnotesElementView<any>>;
|
|
261
261
|
inline_equation: import("../types").NodeViewCreator<import("../views/inline_equation_editable").InlineEquationEditableView>;
|
|
262
262
|
inline_footnote: import("../types").NodeViewCreator<import("../views/inline_footnote").InlineFootnoteView<any>>;
|
|
263
|
-
keyword: import("../types").NodeViewCreator<import("../views/keyword").KeywordView
|
|
263
|
+
keyword: import("../types").NodeViewCreator<import("../views/keyword").KeywordView>;
|
|
264
264
|
keywords_element: import("../types").NodeViewCreator<import("../views/keywords_element").KeywordsElementView>;
|
|
265
265
|
link: import("../types").NodeViewCreator<import("../views/link_editable").LinkEditableView>;
|
|
266
266
|
listing: import("../types").NodeViewCreator<import("../views/listing_editable").ListingEditableView>;
|