@manuscripts/article-editor 1.15.3-LEAN-3604.1 → 1.15.3
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/EditorApp.js +11 -3
- package/dist/cjs/EditorApp.js.map +1 -1
- package/dist/cjs/Main.js +2 -4
- package/dist/cjs/Main.js.map +1 -1
- package/dist/cjs/components/comments/CommentActions.js +59 -0
- package/dist/cjs/components/comments/CommentActions.js.map +1 -0
- package/dist/cjs/components/comments/CommentBody.js +97 -0
- package/dist/cjs/components/comments/CommentBody.js.map +1 -0
- package/dist/cjs/components/comments/CommentResolveButton.js +56 -0
- package/dist/cjs/components/comments/CommentResolveButton.js.map +1 -0
- package/dist/cjs/components/comments/CommentThread.js +122 -0
- package/dist/cjs/components/comments/CommentThread.js.map +1 -0
- package/dist/cjs/components/comments/CommentsPanel.js +134 -0
- package/dist/cjs/components/comments/CommentsPanel.js.map +1 -0
- package/dist/cjs/components/comments/CommentsPlaceholder.js +44 -0
- package/dist/cjs/components/comments/CommentsPlaceholder.js.map +1 -0
- package/dist/cjs/index.js +2 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/comments.js +29 -0
- package/dist/cjs/lib/comments.js.map +1 -0
- package/dist/cjs/postgres-data/PsSource.js +5 -3
- package/dist/cjs/postgres-data/PsSource.js.map +1 -1
- package/dist/cjs/postgres-data/buildUtilities.js +30 -13
- package/dist/cjs/postgres-data/buildUtilities.js.map +1 -1
- package/dist/cjs/store/StoreContext.js +4 -10
- package/dist/cjs/store/StoreContext.js.map +1 -1
- package/dist/es/EditorApp.js +11 -3
- package/dist/es/EditorApp.js.map +1 -1
- package/dist/es/Main.js +2 -4
- package/dist/es/Main.js.map +1 -1
- package/dist/es/components/comments/CommentActions.js +52 -0
- package/dist/es/components/comments/CommentActions.js.map +1 -0
- package/dist/es/components/comments/CommentBody.js +67 -0
- package/dist/es/components/comments/CommentBody.js.map +1 -0
- package/dist/es/components/comments/CommentResolveButton.js +49 -0
- package/dist/es/components/comments/CommentResolveButton.js.map +1 -0
- package/dist/es/components/comments/CommentThread.js +93 -0
- package/dist/es/components/comments/CommentThread.js.map +1 -0
- package/dist/es/components/comments/CommentsPanel.js +104 -0
- package/dist/es/components/comments/CommentsPanel.js.map +1 -0
- package/dist/es/components/comments/CommentsPlaceholder.js +37 -0
- package/dist/es/components/comments/CommentsPlaceholder.js.map +1 -0
- package/dist/es/index.js +2 -3
- package/dist/es/index.js.map +1 -1
- package/dist/es/lib/comments.js +23 -0
- package/dist/es/lib/comments.js.map +1 -0
- package/dist/es/postgres-data/PsSource.js +5 -3
- package/dist/es/postgres-data/PsSource.js.map +1 -1
- package/dist/es/postgres-data/buildUtilities.js +30 -13
- package/dist/es/postgres-data/buildUtilities.js.map +1 -1
- package/dist/es/store/StoreContext.js +4 -10
- package/dist/es/store/StoreContext.js.map +1 -1
- package/dist/types/EditorApp.d.ts +14 -5
- package/dist/types/Main.d.ts +2 -12
- package/dist/types/components/comments/CommentActions.d.ts +24 -0
- package/dist/types/components/comments/CommentBody.d.ts +21 -0
- package/dist/types/components/comments/CommentResolveButton.d.ts +18 -0
- package/dist/types/components/comments/CommentThread.d.ts +22 -0
- package/dist/types/components/comments/CommentsPanel.d.ts +2 -0
- package/dist/types/components/comments/CommentsPlaceholder.d.ts +14 -0
- package/dist/types/index.d.ts +3 -13
- package/dist/types/lib/comments.d.ts +21 -0
- package/dist/types/postgres-data/buildUtilities.d.ts +1 -1
- package/dist/types/store/StoreContext.d.ts +3 -3
- package/package.json +3 -3
package/dist/cjs/EditorApp.js
CHANGED
|
@@ -54,7 +54,7 @@ const PlaceholderWrapper = styled_components_1.default.div `
|
|
|
54
54
|
justify-content: center;
|
|
55
55
|
align-items: center;
|
|
56
56
|
`;
|
|
57
|
-
const EditorApp = ({
|
|
57
|
+
const EditorApp = ({ manuscriptID, projectID, permittedActions, fileManagement, files, authToken, observer, }) => {
|
|
58
58
|
const userID = (0, user_1.getCurrentUserId)();
|
|
59
59
|
const [store, setStore] = (0, react_1.useState)();
|
|
60
60
|
const loadDoc = (0, useLoadDoc_1.useLoadDoc)(authToken);
|
|
@@ -63,7 +63,7 @@ const EditorApp = ({ parentObserver, manuscriptID, projectID, permittedActions,
|
|
|
63
63
|
// implement remount for the store if component is retriggered
|
|
64
64
|
const basicSource = new store_1.BasicSource(fileManagement, projectID, manuscriptID, files, permittedActions, userID || '', authToken || '');
|
|
65
65
|
const mainSource = new PsSource_1.default(files);
|
|
66
|
-
(0, store_1.createStore)([basicSource, mainSource, quarterBackSource],
|
|
66
|
+
(0, store_1.createStore)([basicSource, mainSource, quarterBackSource], observer)
|
|
67
67
|
.then((store) => {
|
|
68
68
|
setStore(store);
|
|
69
69
|
})
|
|
@@ -71,11 +71,19 @@ const EditorApp = ({ parentObserver, manuscriptID, projectID, permittedActions,
|
|
|
71
71
|
console.error(e);
|
|
72
72
|
});
|
|
73
73
|
return () => {
|
|
74
|
-
parentObserver?.detach();
|
|
75
74
|
store?.unmount();
|
|
76
75
|
};
|
|
77
76
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
77
|
}, [manuscriptID, projectID]);
|
|
78
|
+
(0, react_1.useEffect)(() => {
|
|
79
|
+
if (!observer) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
observer.state.current = {
|
|
83
|
+
get: () => store?.getState(),
|
|
84
|
+
update: (state) => store?.setState(state),
|
|
85
|
+
};
|
|
86
|
+
}, [observer, store]);
|
|
79
87
|
return store ? (react_1.default.createElement(store_1.GenericStoreProvider, { store: store },
|
|
80
88
|
react_1.default.createElement(react_router_dom_1.BrowserRouter, null,
|
|
81
89
|
react_1.default.createElement(Page_1.Page, null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorApp.js","sourceRoot":"","sources":["../../src/EditorApp.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,+
|
|
1
|
+
{"version":3,"file":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,CAAC;aACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAClB,CAAC,CAAC,CAAA;QACJ,OAAO,GAAG,EAAE;YACV,KAAK,EAAE,OAAO,EAAE,CAAA;QAClB,CAAC,CAAA;QACD,uDAAuD;IACzD,CAAC,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAA;IAE7B,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,QAAQ,EAAE;YACb,OAAM;SACP;QACD,QAAQ,CAAC,KAAK,CAAC,OAAO,GAAG;YACvB,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE;YAC5B,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAc,CAAC;SACnD,CAAA;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAA;IAErB,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,8BAAC,4BAAoB,IAAC,KAAK,EAAE,KAAK;QAChC,8BAAC,gCAAM;YACL,8BAAC,WAAI;gBACH,8BAAC,OAAO;oBACN,8BAAC,iCAAuB,OAAG,CACnB,CACL,CACA,CACY,CACxB,CAAC,CAAC,CAAC,CACF,8BAAC,kBAAkB;QACjB,8BAAC,6CAAqB,OAAG,CACN,CACtB,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,SAAS,CAAA"}
|
package/dist/cjs/Main.js
CHANGED
|
@@ -19,10 +19,8 @@ const react_dnd_1 = require("react-dnd");
|
|
|
19
19
|
const react_dnd_html5_backend_1 = require("react-dnd-html5-backend");
|
|
20
20
|
const EditorApp_1 = __importDefault(require("./EditorApp"));
|
|
21
21
|
const theme_1 = require("./theme/theme");
|
|
22
|
-
|
|
23
|
-
// manuscriptID="MPManuscript:5F6D807F-CECF-45D0-B94C-5CF1361BDF05"
|
|
24
|
-
const Main = ({ fileManagement, files, parentObserver, manuscriptID, projectID, authToken, permittedActions, }) => (react_1.default.createElement(react_dnd_1.DndProvider, { backend: react_dnd_html5_backend_1.HTML5Backend },
|
|
22
|
+
const Main = ({ fileManagement, files, manuscriptID, projectID, authToken, permittedActions, observer, }) => (react_1.default.createElement(react_dnd_1.DndProvider, { backend: react_dnd_html5_backend_1.HTML5Backend },
|
|
25
23
|
react_1.default.createElement(theme_1.GlobalStyle, null),
|
|
26
|
-
react_1.default.createElement(EditorApp_1.default, { fileManagement: fileManagement, files: files,
|
|
24
|
+
react_1.default.createElement(EditorApp_1.default, { fileManagement: fileManagement, files: files, manuscriptID: manuscriptID, projectID: projectID, permittedActions: permittedActions, authToken: authToken, observer: observer })));
|
|
27
25
|
exports.default = Main;
|
|
28
26
|
//# sourceMappingURL=Main.js.map
|
package/dist/cjs/Main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Main.js","sourceRoot":"","sources":["../../src/Main.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;
|
|
1
|
+
{"version":3,"file":"Main.js","sourceRoot":"","sources":["../../src/Main.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;AAEH,kDAAyB;AACzB,yCAAuC;AACvC,qEAAsD;AAEtD,4DAAuD;AACvD,yCAA2C;AAE3C,MAAM,IAAI,GAA6B,CAAC,EACtC,cAAc,EACd,KAAK,EACL,YAAY,EACZ,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,QAAQ,GACT,EAAE,EAAE,CAAC,CACJ,8BAAC,uBAAW,IAAC,OAAO,EAAE,sCAAY;IAChC,8BAAC,mBAAW,OAAG;IACf,8BAAC,mBAAS,IACR,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,GAClB,CACU,CACf,CAAA;AAED,kBAAe,IAAI,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
|
|
4
|
+
*
|
|
5
|
+
* Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
|
|
6
|
+
*
|
|
7
|
+
* The Original Code is manuscripts-frontend.
|
|
8
|
+
*
|
|
9
|
+
* The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
|
|
10
|
+
*
|
|
11
|
+
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
|
|
12
|
+
*/
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.CommentActions = exports.CommentAction = exports.ActionsIcon = void 0;
|
|
18
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
19
|
+
const react_1 = __importDefault(require("react"));
|
|
20
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
21
|
+
const CommentResolveButton_1 = require("./CommentResolveButton");
|
|
22
|
+
exports.ActionsIcon = styled_components_1.default.button `
|
|
23
|
+
border: none;
|
|
24
|
+
background: transparent;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
padding: 0 8px;
|
|
27
|
+
margin-top: -8px;
|
|
28
|
+
&:focus {
|
|
29
|
+
outline: none;
|
|
30
|
+
}
|
|
31
|
+
&:hover svg circle {
|
|
32
|
+
fill: #1a9bc7;
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
exports.CommentAction = styled_components_1.default.div `
|
|
36
|
+
font-family: ${(props) => props.theme.font.family.Lato};
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
font-size: 16px;
|
|
39
|
+
line-height: 24px;
|
|
40
|
+
color: ${(props) => props.theme.colors.text.primary};
|
|
41
|
+
padding: 16px;
|
|
42
|
+
&:hover,
|
|
43
|
+
&:focus {
|
|
44
|
+
background: #f2fbfc;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
const CommentActions = ({ comment, isResolveEnabled, isActionsEnabled, onEdit, onDelete, toggleResolve, }) => {
|
|
48
|
+
const { isOpen, toggleOpen, wrapperRef } = (0, style_guide_1.useDropdown)();
|
|
49
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
50
|
+
isResolveEnabled && (react_1.default.createElement(CommentResolveButton_1.CommentResolveButton, { comment: comment, onClick: toggleResolve })),
|
|
51
|
+
isActionsEnabled && (react_1.default.createElement(style_guide_1.DropdownContainer, { ref: wrapperRef },
|
|
52
|
+
react_1.default.createElement(exports.ActionsIcon, { onClick: toggleOpen },
|
|
53
|
+
react_1.default.createElement(style_guide_1.DotsIcon, null)),
|
|
54
|
+
isOpen && (react_1.default.createElement(style_guide_1.DropdownList, { direction: 'right', width: 125, onClick: toggleOpen },
|
|
55
|
+
react_1.default.createElement(exports.CommentAction, { onClick: onEdit }, "Edit"),
|
|
56
|
+
react_1.default.createElement(exports.CommentAction, { onClick: onDelete }, "Delete")))))));
|
|
57
|
+
};
|
|
58
|
+
exports.CommentActions = CommentActions;
|
|
59
|
+
//# sourceMappingURL=CommentActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommentActions.js","sourceRoot":"","sources":["../../../../src/components/comments/CommentActions.tsx"],"names":[],"mappings":";AAAA;;;;;;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
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.CommentBody = void 0;
|
|
30
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
33
|
+
const CommentContent = styled_components_1.default.div `
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
`;
|
|
36
|
+
const CommentEditor = styled_components_1.default.textarea `
|
|
37
|
+
cursor: text;
|
|
38
|
+
font-family: ${(props) => props.theme.font.family.sans};
|
|
39
|
+
color: ${(props) => props.theme.colors.text.primary};
|
|
40
|
+
margin: ${(props) => props.theme.grid.unit * 2}px 0;
|
|
41
|
+
resize: none;
|
|
42
|
+
|
|
43
|
+
width: 100%;
|
|
44
|
+
outline: 0;
|
|
45
|
+
border: 1px solid #e2e2e2;
|
|
46
|
+
border-radius: 6px;
|
|
47
|
+
|
|
48
|
+
&:focus {
|
|
49
|
+
background: #f2fbfc;
|
|
50
|
+
border: 1px solid #bce7f6;
|
|
51
|
+
border-radius: 6px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
padding: 3px 16px 3px 16px;
|
|
56
|
+
font-style: normal;
|
|
57
|
+
font-weight: normal;
|
|
58
|
+
font-size: 14px;
|
|
59
|
+
line-height: 24px;
|
|
60
|
+
`;
|
|
61
|
+
const CommentViewer = styled_components_1.default.div `
|
|
62
|
+
flex: 1;
|
|
63
|
+
|
|
64
|
+
font-family: ${(props) => props.theme.font.family.sans};
|
|
65
|
+
line-height: 1.06;
|
|
66
|
+
letter-spacing: -0.2px;
|
|
67
|
+
color: ${(props) => props.theme.colors.text.primary};
|
|
68
|
+
margin: ${(props) => props.theme.grid.unit * 2}px 0;
|
|
69
|
+
`;
|
|
70
|
+
const EditorActions = (0, styled_components_1.default)(style_guide_1.ButtonGroup) `
|
|
71
|
+
& button:not(:last-of-type) {
|
|
72
|
+
margin-right: 4px;
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
const CommentBody = ({ comment, isEditing, onSave, onCancel, onSelect, }) => {
|
|
76
|
+
const editor = (0, react_1.useRef)(null);
|
|
77
|
+
const handleSave = () => {
|
|
78
|
+
if (editor.current) {
|
|
79
|
+
onSave(editor.current.value);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const ref = (0, react_1.useCallback)((e) => {
|
|
83
|
+
if (e && editor.current !== e) {
|
|
84
|
+
e.focus();
|
|
85
|
+
}
|
|
86
|
+
editor.current = e;
|
|
87
|
+
}, []);
|
|
88
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, isEditing ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
89
|
+
react_1.default.createElement(CommentEditor, { ref: ref, defaultValue: comment.node.attrs.contents }),
|
|
90
|
+
react_1.default.createElement(EditorActions, null,
|
|
91
|
+
react_1.default.createElement(style_guide_1.SecondaryButton, { onClick: onCancel }, "Cancel"),
|
|
92
|
+
react_1.default.createElement(style_guide_1.PrimaryButton, { onClick: handleSave }, "Save")))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
93
|
+
react_1.default.createElement(CommentContent, { onClick: onSelect },
|
|
94
|
+
react_1.default.createElement(CommentViewer, null, comment.node.attrs.contents))))));
|
|
95
|
+
};
|
|
96
|
+
exports.CommentBody = CommentBody;
|
|
97
|
+
//# sourceMappingURL=CommentBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommentBody.js","sourceRoot":"","sources":["../../../../src/components/comments/CommentBody.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,0DAIiC;AACjC,+CAAkD;AAClD,0EAAsC;AAEtC,MAAM,cAAc,GAAG,2BAAM,CAAC,GAAG,CAAA;;CAEhC,CAAA;AAED,MAAM,aAAa,GAAG,2BAAM,CAAC,QAAQ,CAAA;;iBAEpB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;WAC7C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;YACzC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;CAoB/C,CAAA;AAED,MAAM,aAAa,GAAG,2BAAM,CAAC,GAAG,CAAA;;;iBAG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ACJ,CAAC,CAAC,CAAC,CACF;QACE,8BAAC,cAAc,IAAC,OAAO,EAAE,QAAQ;YAC/B,8BAAC,aAAa,QAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAiB,CAC7C,CAChB,CACJ,CACA,CACJ,CAAA;AACH,CAAC,CAAA;AA5CY,QAAA,WAAW,eA4CvB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
|
|
4
|
+
*
|
|
5
|
+
* Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
|
|
6
|
+
*
|
|
7
|
+
* The Original Code is manuscripts-frontend.
|
|
8
|
+
*
|
|
9
|
+
* The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
|
|
10
|
+
*
|
|
11
|
+
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
|
|
12
|
+
*/
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.CommentResolveButton = void 0;
|
|
18
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
19
|
+
const react_1 = __importDefault(require("react"));
|
|
20
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
21
|
+
const Button = styled_components_1.default.button `
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
width: 24px;
|
|
25
|
+
height: 24px;
|
|
26
|
+
border-radius: 12px;
|
|
27
|
+
border: none;
|
|
28
|
+
background: #ffffff;
|
|
29
|
+
padding: 0;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
|
|
32
|
+
&.resolved {
|
|
33
|
+
background: #f2fbfc;
|
|
34
|
+
border: 1px solid #bce7f6;
|
|
35
|
+
path {
|
|
36
|
+
fill: #1a9bc7;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&:not([disabled]):hover,
|
|
41
|
+
&:not([disabled]):active {
|
|
42
|
+
path {
|
|
43
|
+
fill: #1a9bc7;
|
|
44
|
+
}
|
|
45
|
+
background: #f2fbfc;
|
|
46
|
+
border: 1px solid #c9c9c9;
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
const CommentResolveButton = ({ comment, onClick, }) => {
|
|
50
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
51
|
+
react_1.default.createElement(Button, { className: comment.node.attrs.resolved ? 'resolved' : '', "data-tooltip-id": comment.node.attrs.id, onClick: onClick },
|
|
52
|
+
react_1.default.createElement(style_guide_1.CommentResolveIcon, null)),
|
|
53
|
+
react_1.default.createElement(style_guide_1.Tooltip, { id: comment.node.attrs.id, place: "bottom" }, (comment.node.attrs.resolved && 'Unresolve') || 'Resolve')));
|
|
54
|
+
};
|
|
55
|
+
exports.CommentResolveButton = CommentResolveButton;
|
|
56
|
+
//# sourceMappingURL=CommentResolveButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommentResolveButton.js","sourceRoot":"","sources":["../../../../src/components/comments/CommentResolveButton.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;AAGH,0DAAsE;AACtE,kDAAyB;AACzB,0EAAsC;AAEtC,MAAM,MAAM,GAAG,2BAAM,CAAC,MAAM,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B3B,CAAA;AAOM,MAAM,oBAAoB,GAAwC,CAAC,EACxE,OAAO,EACP,OAAO,GACR,EAAE,EAAE;IACH,OAAO,CACL;QACE,8BAAC,MAAM,IACL,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,qBACvC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EACtC,OAAO,EAAE,OAAO;YAEhB,8BAAC,gCAAkB,OAAG,CACf;QACT,8BAAC,qBAAO,IAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,EAAC,QAAQ,IAC/C,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,WAAW,CAAC,IAAI,SAAS,CAClD,CACT,CACJ,CAAA;AACH,CAAC,CAAA;AAlBY,QAAA,oBAAoB,wBAkBhC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.CommentThread = void 0;
|
|
30
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
33
|
+
const comments_1 = require("../../lib/comments");
|
|
34
|
+
const store_1 = require("../../store");
|
|
35
|
+
const CommentActions_1 = require("./CommentActions");
|
|
36
|
+
const CommentBody_1 = require("./CommentBody");
|
|
37
|
+
const Container = styled_components_1.default.div `
|
|
38
|
+
padding: 16px;
|
|
39
|
+
background-color: ${(props) => (props.isSelected ? '#f2fbfc' : '#ffffff')};
|
|
40
|
+
border: 1px solid ${(props) => (props.isSelected ? '#bce7f6' : '#e2e2e2')};
|
|
41
|
+
border-left-width: 4px;
|
|
42
|
+
margin-bottom: 16px;
|
|
43
|
+
`;
|
|
44
|
+
const CommentHeader = styled_components_1.default.div `
|
|
45
|
+
display: flex;
|
|
46
|
+
margin-bottom: 16px;
|
|
47
|
+
`;
|
|
48
|
+
const CommentMetadata = styled_components_1.default.div `
|
|
49
|
+
flex: 1;
|
|
50
|
+
padding-left: 8px;
|
|
51
|
+
padding-right: 8px;
|
|
52
|
+
`;
|
|
53
|
+
const CommentAuthor = styled_components_1.default.div `
|
|
54
|
+
color: #353535;
|
|
55
|
+
font-weight: 400;
|
|
56
|
+
max-width: 200px;
|
|
57
|
+
white-space: nowrap;
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
text-overflow: ellipsis;
|
|
60
|
+
`;
|
|
61
|
+
const CommentTarget = styled_components_1.default.div `
|
|
62
|
+
font-size: 14px;
|
|
63
|
+
color: #353535;
|
|
64
|
+
background-color: #ffeebf;
|
|
65
|
+
padding: 4px 8px;
|
|
66
|
+
margin-top: 16px;
|
|
67
|
+
margin-bottom: 16px;
|
|
68
|
+
`;
|
|
69
|
+
const Timestamp = (0, styled_components_1.default)(style_guide_1.RelativeDate) `
|
|
70
|
+
font-size: 12px;
|
|
71
|
+
line-height: 16px;
|
|
72
|
+
font-weight: 400;
|
|
73
|
+
color: #6e6e6e;
|
|
74
|
+
`;
|
|
75
|
+
exports.CommentThread = (0, react_1.forwardRef)((props, ref) => {
|
|
76
|
+
const { tree, isSelected, onSelect, onSave, onDelete } = props;
|
|
77
|
+
const can = (0, style_guide_1.usePermissions)();
|
|
78
|
+
const [{ user, collaboratorsById }] = (0, store_1.useStore)((state) => ({
|
|
79
|
+
user: state.user,
|
|
80
|
+
collaboratorsById: state.collaboratorsById,
|
|
81
|
+
}));
|
|
82
|
+
const authorID = (0, comments_1.getAuthorID)(tree.comment);
|
|
83
|
+
const authorName = authorID
|
|
84
|
+
? (0, comments_1.buildAuthorName)(collaboratorsById.get(authorID))
|
|
85
|
+
: '';
|
|
86
|
+
const timestamp = tree.comment.node.attrs.contributions?.[0].timestamp;
|
|
87
|
+
const isOwn = authorID === user._id;
|
|
88
|
+
const isResolveEnabled = isOwn
|
|
89
|
+
? can.resolveOwnComment
|
|
90
|
+
: can.resolveOthersComment;
|
|
91
|
+
const isActionsEnabled = isOwn
|
|
92
|
+
? can.handleOwnComments
|
|
93
|
+
: can.handleOthersComments;
|
|
94
|
+
const [isEditing, setEditing] = (0, react_1.useState)(false);
|
|
95
|
+
const handleEdit = () => setEditing(true);
|
|
96
|
+
const handleSave = (contents) => {
|
|
97
|
+
onSave({
|
|
98
|
+
...tree.comment.node.attrs,
|
|
99
|
+
contents,
|
|
100
|
+
});
|
|
101
|
+
setEditing(false);
|
|
102
|
+
};
|
|
103
|
+
const handleCancel = () => {
|
|
104
|
+
setEditing(false);
|
|
105
|
+
};
|
|
106
|
+
const handleToggleResolve = () => {
|
|
107
|
+
onSave({
|
|
108
|
+
...tree.comment.node.attrs,
|
|
109
|
+
resolved: !tree.comment.node.attrs.resolved,
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
return (react_1.default.createElement(Container, { "data-cy": "comment", isSelected: isSelected, ref: ref },
|
|
113
|
+
react_1.default.createElement(CommentHeader, { "data-cy": "comment-header" },
|
|
114
|
+
authorName && react_1.default.createElement(style_guide_1.AvatarIcon, { width: 20, height: 20 }),
|
|
115
|
+
react_1.default.createElement(CommentMetadata, null,
|
|
116
|
+
react_1.default.createElement(CommentAuthor, null, authorName),
|
|
117
|
+
timestamp && react_1.default.createElement(Timestamp, { date: timestamp * 1000 })),
|
|
118
|
+
react_1.default.createElement(CommentActions_1.CommentActions, { comment: tree.comment, isResolveEnabled: isResolveEnabled, isActionsEnabled: isActionsEnabled, onDelete: () => onDelete(tree.comment.node.attrs.id), onEdit: handleEdit, toggleResolve: handleToggleResolve })),
|
|
119
|
+
tree.comment.node.attrs.originalText && (react_1.default.createElement(CommentTarget, null, tree.comment.node.attrs.originalText)),
|
|
120
|
+
react_1.default.createElement(CommentBody_1.CommentBody, { comment: tree.comment, isEditing: tree.isNew || isEditing, onSave: handleSave, onCancel: handleCancel, onSelect: onSelect })));
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=CommentThread.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommentThread.js","sourceRoot":"","sources":["../../../../src/components/comments/CommentThread.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,0DAIiC;AACjC,+CAAmD;AACnD,0EAAsC;AAEtC,iDAA8E;AAC9E,uCAAsC;AACtC,qDAAiD;AACjD,+CAA2C;AAE3C,MAAM,SAAS,GAAG,2B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AAG,EAAE,GAAG;QAC3D,8BAAC,aAAa,eAAS,gBAAgB;YACpC,UAAU,IAAI,8BAAC,wBAAU,IAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,GAAI;YACpD,8BAAC,eAAe;gBACd,8BAAC,aAAa,QAAE,UAAU,CAAiB;gBAC1C,SAAS,IAAI,8BAAC,SAAS,IAAC,IAAI,EAAE,SAAS,GAAG,IAAI,GAAI,CACnC;YAClB,8BAAC,+BAAc,IACb,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EACpD,MAAM,EAAE,UAAU,EAClB,aAAa,EAAE,mBAAmB,GAClC,CACY;QACf,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,CACvC,8BAAC,aAAa,QAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAiB,CACtE;QACD,8BAAC,yBAAW,IACV,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,SAAS,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS,EAClC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,QAAQ,GAClB,CACQ,CACb,CAAA;AACH,CAAC,CACF,CAAA"}
|
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.CommentsPanel = void 0;
|
|
30
|
+
/*!
|
|
31
|
+
* The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
|
|
32
|
+
*
|
|
33
|
+
* Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
|
|
34
|
+
*
|
|
35
|
+
* The Original Code is manuscripts-frontend.
|
|
36
|
+
*
|
|
37
|
+
* The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
|
|
38
|
+
*
|
|
39
|
+
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
|
|
40
|
+
*/
|
|
41
|
+
const body_editor_1 = require("@manuscripts/body-editor");
|
|
42
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
43
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
44
|
+
const react_1 = __importStar(require("react"));
|
|
45
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
46
|
+
const comments_1 = require("../../lib/comments");
|
|
47
|
+
const store_1 = require("../../store");
|
|
48
|
+
const CommentThread_1 = require("./CommentThread");
|
|
49
|
+
const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
|
|
50
|
+
const CommentsPlaceholder_1 = require("./CommentsPlaceholder");
|
|
51
|
+
const Header = styled_components_1.default.div `
|
|
52
|
+
display: flex;
|
|
53
|
+
justify-content: flex-end;
|
|
54
|
+
padding: 12px;
|
|
55
|
+
`;
|
|
56
|
+
const CheckboxLabelText = styled_components_1.default.div `
|
|
57
|
+
color: ${(props) => props.theme.colors.text.primary} !important;
|
|
58
|
+
`;
|
|
59
|
+
const scrollIntoView = (element) => {
|
|
60
|
+
const rect = element.getBoundingClientRect();
|
|
61
|
+
if (rect.bottom > window.innerHeight || rect.top < 150) {
|
|
62
|
+
element.scrollIntoView();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const CommentsPanel = () => {
|
|
66
|
+
const [{ view, newCommentID, selectedCommentKey }] = (0, store_1.useStore)((state) => ({
|
|
67
|
+
view: state.view,
|
|
68
|
+
newCommentID: state.newCommentID,
|
|
69
|
+
selectedCommentKey: state.selectedCommentKey,
|
|
70
|
+
}));
|
|
71
|
+
const [showResolved, setShowResolved] = (0, react_1.useState)(true);
|
|
72
|
+
const comments = (0, react_1.useMemo)(() => view?.state ? body_editor_1.commentsKey.getState(view.state)?.comments : undefined, [view?.state]);
|
|
73
|
+
const trees = (0, react_1.useMemo)(() => comments ? (0, comments_1.buildCommentTrees)([...comments.values()], newCommentID) : [], [comments, newCommentID]);
|
|
74
|
+
const selectedRef = (0, react_1.useCallback)((e) => {
|
|
75
|
+
if (e) {
|
|
76
|
+
scrollIntoView(e);
|
|
77
|
+
}
|
|
78
|
+
}, []);
|
|
79
|
+
const setSelectedComment = (comment) => {
|
|
80
|
+
if (!view) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const tr = view.state.tr;
|
|
84
|
+
(0, body_editor_1.setCommentSelection)(tr, comment.key, comment.node.attrs.id, false);
|
|
85
|
+
if ((0, body_editor_1.isNodeComment)(comment)) {
|
|
86
|
+
tr.setSelection(prosemirror_state_1.NodeSelection.create(view.state.doc, comment.target.pos));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const range = comment.range;
|
|
90
|
+
const from = range.pos;
|
|
91
|
+
const to = from + range.size;
|
|
92
|
+
tr.setSelection(prosemirror_state_1.TextSelection.create(view.state.doc, from, to));
|
|
93
|
+
}
|
|
94
|
+
tr.scrollIntoView();
|
|
95
|
+
view.focus();
|
|
96
|
+
view.dispatch(tr);
|
|
97
|
+
};
|
|
98
|
+
const handleSave = (attrs) => {
|
|
99
|
+
const comment = comments?.get(attrs.id);
|
|
100
|
+
if (!comment) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const tr = view.state.tr;
|
|
104
|
+
tr.setNodeMarkup(comment.pos, undefined, attrs);
|
|
105
|
+
(0, body_editor_1.clearCommentSelection)(tr);
|
|
106
|
+
view.dispatch((0, track_changes_plugin_1.skipTracking)(tr));
|
|
107
|
+
};
|
|
108
|
+
const handleDelete = (id) => {
|
|
109
|
+
const comment = comments?.get(id);
|
|
110
|
+
if (!comment) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const tr = view.state.tr;
|
|
114
|
+
tr.delete(comment.pos, comment.pos + comment.node.nodeSize);
|
|
115
|
+
(0, body_editor_1.clearCommentSelection)(tr);
|
|
116
|
+
view.dispatch((0, track_changes_plugin_1.skipTracking)(tr));
|
|
117
|
+
};
|
|
118
|
+
if (!view) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
if (!trees.length) {
|
|
122
|
+
return react_1.default.createElement(CommentsPlaceholder_1.CommentsPlaceholder, null);
|
|
123
|
+
}
|
|
124
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
125
|
+
react_1.default.createElement(Header, null,
|
|
126
|
+
react_1.default.createElement(style_guide_1.CheckboxLabel, null,
|
|
127
|
+
react_1.default.createElement(style_guide_1.CheckboxField, { name: 'show-resolved', checked: showResolved, onChange: (e) => setShowResolved(e.target.checked) }),
|
|
128
|
+
react_1.default.createElement(CheckboxLabelText, null, "See resolved"))),
|
|
129
|
+
trees
|
|
130
|
+
.filter((c) => showResolved || !c.comment.node.attrs.resolved)
|
|
131
|
+
.map((c) => (react_1.default.createElement(CommentThread_1.CommentThread, { key: c.comment.node.attrs.id, ref: selectedCommentKey === c.comment.key ? selectedRef : null, tree: c, isSelected: selectedCommentKey === c.comment.key, onSelect: () => setSelectedComment(c.comment), onSave: handleSave, onDelete: handleDelete })))));
|
|
132
|
+
};
|
|
133
|
+
exports.CommentsPanel = CommentsPanel;
|
|
134
|
+
//# sourceMappingURL=CommentsPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommentsPanel.js","sourceRoot":"","sources":["../../../../src/components/comments/CommentsPanel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;GAUG;AACH,0DAQiC;AACjC,0DAAuE;AACvE,yDAAgE;AAChE,+CAA6D;AAC7D,0EAAsC;AAEtC,iDAAsD;AACtD,uCAAsC;AACtC,mDAA+C;AAC/C,4EAA+D;AAC/D,+DAA0D;AAE1D,MAAM,MAAM,GAAG,2BAAM,CAAC,GAAG,CAAA;;;;CAIxB,CAAA;AAED,MAAM,iBAAiB,GAAG,2BAAM,CAAC,GAAG,CAA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