2017-05-03 08:05:41 +08:00
|
|
|
import Storage from '/imports/ui/services/storage/session';
|
2017-06-17 10:32:41 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2020-04-07 04:34:08 +08:00
|
|
|
import { sendAnnotation, clearPreview } from '/imports/ui/components/whiteboard/service';
|
2019-07-18 08:30:28 +08:00
|
|
|
import { publishCursorUpdate } from '/imports/ui/components/cursor/service';
|
2017-09-21 05:05:17 +08:00
|
|
|
|
2018-05-12 00:01:24 +08:00
|
|
|
const DRAW_SETTINGS = 'drawSettings';
|
2017-05-02 05:34:24 +08:00
|
|
|
|
2017-05-03 08:05:41 +08:00
|
|
|
const getWhiteboardToolbarValues = () => {
|
2017-09-21 05:05:17 +08:00
|
|
|
const drawSettings = Storage.getItem(DRAW_SETTINGS);
|
|
|
|
if (!drawSettings) {
|
|
|
|
return {};
|
2017-06-03 07:40:52 +08:00
|
|
|
}
|
2017-09-21 05:05:17 +08:00
|
|
|
|
|
|
|
const {
|
|
|
|
whiteboardAnnotationTool,
|
|
|
|
whiteboardAnnotationThickness,
|
|
|
|
whiteboardAnnotationColor,
|
|
|
|
textFontSize,
|
|
|
|
textShape,
|
|
|
|
} = drawSettings;
|
|
|
|
|
|
|
|
return {
|
|
|
|
tool: whiteboardAnnotationTool,
|
|
|
|
thickness: whiteboardAnnotationThickness,
|
|
|
|
color: whiteboardAnnotationColor,
|
|
|
|
textFontSize,
|
|
|
|
textShapeValue: textShape.textShapeValue ? textShape.textShapeValue : '',
|
|
|
|
textShapeActiveId: textShape.textShapeActiveId ? textShape.textShapeActiveId : '',
|
|
|
|
};
|
2017-05-03 08:05:41 +08:00
|
|
|
};
|
|
|
|
|
2017-08-24 11:35:34 +08:00
|
|
|
const resetTextShapeSession = () => {
|
2017-09-21 05:05:17 +08:00
|
|
|
const drawSettings = Storage.getItem(DRAW_SETTINGS);
|
2017-08-19 10:47:31 +08:00
|
|
|
if (drawSettings) {
|
2017-06-17 10:32:41 +08:00
|
|
|
drawSettings.textShape.textShapeValue = '';
|
2017-08-24 11:35:34 +08:00
|
|
|
drawSettings.textShape.textShapeActiveId = '';
|
2017-09-21 05:05:17 +08:00
|
|
|
Storage.setItem(DRAW_SETTINGS, drawSettings);
|
2017-06-17 10:32:41 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const setTextShapeActiveId = (id) => {
|
2017-09-21 05:05:17 +08:00
|
|
|
const drawSettings = Storage.getItem(DRAW_SETTINGS);
|
2017-08-19 10:47:31 +08:00
|
|
|
if (drawSettings) {
|
2017-08-24 11:35:34 +08:00
|
|
|
drawSettings.textShape.textShapeActiveId = id;
|
2017-09-21 05:05:17 +08:00
|
|
|
Storage.setItem(DRAW_SETTINGS, drawSettings);
|
2017-06-17 10:32:41 +08:00
|
|
|
}
|
2017-06-11 10:21:37 +08:00
|
|
|
};
|
|
|
|
|
2017-08-19 10:47:31 +08:00
|
|
|
const getCurrentUserId = () => Auth.userID;
|
|
|
|
|
2018-07-24 05:25:06 +08:00
|
|
|
const contextMenuHandler = event => event.preventDefault();
|
2017-08-19 10:47:31 +08:00
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
const updateCursor = (payload) => {
|
|
|
|
publishCursorUpdate(payload);
|
|
|
|
};
|
|
|
|
|
2017-05-02 05:34:24 +08:00
|
|
|
export default {
|
|
|
|
sendAnnotation,
|
2017-05-03 08:05:41 +08:00
|
|
|
getWhiteboardToolbarValues,
|
2017-06-17 10:32:41 +08:00
|
|
|
setTextShapeActiveId,
|
2017-08-24 11:35:34 +08:00
|
|
|
resetTextShapeSession,
|
2017-08-19 10:47:31 +08:00
|
|
|
getCurrentUserId,
|
2018-07-24 05:25:06 +08:00
|
|
|
contextMenuHandler,
|
2019-07-18 08:30:28 +08:00
|
|
|
updateCursor,
|
2020-04-07 04:34:08 +08:00
|
|
|
clearPreview,
|
2017-05-02 05:34:24 +08:00
|
|
|
};
|