bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/whiteboard/whiteboard-overlay/service.js

67 lines
1.8 KiB
JavaScript
Raw Normal View History

import Storage from '/imports/ui/services/storage/session';
import Auth from '/imports/ui/services/auth';
2020-04-07 04:34:08 +08:00
import { sendAnnotation, clearPreview } from '/imports/ui/components/whiteboard/service';
import { publishCursorUpdate } from '/imports/ui/components/cursor/service';
2017-09-21 05:05:17 +08:00
const DRAW_SETTINGS = 'drawSettings';
const getWhiteboardToolbarValues = () => {
2017-09-21 05:05:17 +08:00
const drawSettings = Storage.getItem(DRAW_SETTINGS);
if (!drawSettings) {
return {};
}
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 : '',
};
};
const resetTextShapeSession = () => {
2017-09-21 05:05:17 +08:00
const drawSettings = Storage.getItem(DRAW_SETTINGS);
if (drawSettings) {
drawSettings.textShape.textShapeValue = '';
drawSettings.textShape.textShapeActiveId = '';
2017-09-21 05:05:17 +08:00
Storage.setItem(DRAW_SETTINGS, drawSettings);
}
};
const setTextShapeActiveId = (id) => {
2017-09-21 05:05:17 +08:00
const drawSettings = Storage.getItem(DRAW_SETTINGS);
if (drawSettings) {
drawSettings.textShape.textShapeActiveId = id;
2017-09-21 05:05:17 +08:00
Storage.setItem(DRAW_SETTINGS, drawSettings);
}
};
const getCurrentUserId = () => Auth.userID;
const contextMenuHandler = event => event.preventDefault();
const updateCursor = (payload) => {
publishCursorUpdate(payload);
};
export default {
sendAnnotation,
getWhiteboardToolbarValues,
setTextShapeActiveId,
resetTextShapeSession,
getCurrentUserId,
contextMenuHandler,
updateCursor,
2020-04-07 04:34:08 +08:00
clearPreview,
};