2021-10-20 04:35:39 +08:00
|
|
|
import Users from '/imports/api/users';
|
2018-05-12 00:01:24 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2021-03-05 06:26:25 +08:00
|
|
|
import WhiteboardMultiUser from '/imports/api/whiteboard-multi-user';
|
2018-05-12 00:01:24 +08:00
|
|
|
import addAnnotationQuery from '/imports/api/annotations/addAnnotation';
|
2021-03-05 06:26:25 +08:00
|
|
|
import { Slides } from '/imports/api/slides';
|
2019-02-14 00:15:09 +08:00
|
|
|
import { makeCall } from '/imports/ui/services/api';
|
2021-04-12 22:06:43 +08:00
|
|
|
import PresentationService from '/imports/ui/components/presentation/service';
|
2022-06-01 21:47:28 +08:00
|
|
|
import PollService from '/imports/ui/components/poll/service';
|
2020-10-21 22:50:06 +08:00
|
|
|
import logger from '/imports/startup/client/logger';
|
2022-10-21 22:05:31 +08:00
|
|
|
import { defineMessages } from 'react-intl';
|
|
|
|
import { notify } from '/imports/ui/services/notification';
|
2023-01-06 00:40:03 +08:00
|
|
|
import caseInsensitiveReducer from '/imports/utils/caseInsensitiveReducer';
|
2023-03-17 02:55:56 +08:00
|
|
|
import { getTextSize } from './utils';
|
2018-05-12 00:01:24 +08:00
|
|
|
|
|
|
|
const Annotations = new Mongo.Collection(null);
|
2022-04-26 21:55:05 +08:00
|
|
|
|
2022-10-21 22:05:31 +08:00
|
|
|
const intlMessages = defineMessages({
|
|
|
|
notifyNotAllowedChange: {
|
|
|
|
id: 'app.whiteboard.annotations.notAllowed',
|
|
|
|
description: 'Label shown in toast when the user make a change on a shape he doesnt have permission',
|
|
|
|
},
|
2023-02-03 03:47:16 +08:00
|
|
|
shapeNumberExceeded: {
|
|
|
|
id: 'app.whiteboard.annotations.numberExceeded',
|
|
|
|
description: 'Label shown in toast when the user tries to add more shapes than the limit',
|
|
|
|
},
|
2022-10-21 22:05:31 +08:00
|
|
|
});
|
|
|
|
|
2019-10-23 09:26:25 +08:00
|
|
|
let annotationsStreamListener = null;
|
|
|
|
|
2023-03-08 21:32:24 +08:00
|
|
|
async function handleAddedAnnotation({
|
2022-04-05 22:49:13 +08:00
|
|
|
meetingId,
|
|
|
|
whiteboardId,
|
|
|
|
userId,
|
|
|
|
annotation,
|
2018-05-12 00:01:24 +08:00
|
|
|
}) {
|
2023-03-08 21:32:24 +08:00
|
|
|
const query = await addAnnotationQuery(meetingId, whiteboardId, userId, annotation, Annotations);
|
2018-05-12 00:01:24 +08:00
|
|
|
|
2020-04-07 04:34:08 +08:00
|
|
|
Annotations.upsert(query.selector, query.modifier);
|
2018-05-12 00:01:24 +08:00
|
|
|
}
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
function handleRemovedAnnotation({
|
|
|
|
meetingId, whiteboardId, userId, shapeId,
|
|
|
|
}) {
|
2018-05-12 00:01:24 +08:00
|
|
|
const query = { meetingId, whiteboardId };
|
|
|
|
|
|
|
|
if (userId) {
|
|
|
|
query.userId = userId;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shapeId) {
|
2020-04-07 04:34:08 +08:00
|
|
|
query.id = shapeId;
|
2018-05-12 00:01:24 +08:00
|
|
|
}
|
2023-03-10 19:30:46 +08:00
|
|
|
Annotations.remove(query);
|
2018-05-12 00:01:24 +08:00
|
|
|
}
|
|
|
|
|
2019-10-23 09:26:25 +08:00
|
|
|
export function initAnnotationsStreamListener() {
|
2022-04-05 22:49:13 +08:00
|
|
|
logger.info(
|
2023-03-10 19:30:46 +08:00
|
|
|
{ logCode: 'init_annotations_stream_listener' },
|
|
|
|
'initAnnotationsStreamListener called',
|
2022-04-05 22:49:13 +08:00
|
|
|
);
|
2020-01-13 20:34:54 +08:00
|
|
|
/**
|
|
|
|
* We create a promise to add the handlers after a ddp subscription stop.
|
|
|
|
* The problem was caused because we add handlers to stream before the onStop event happens,
|
|
|
|
* which set the handlers to undefined.
|
|
|
|
*/
|
2022-04-05 22:49:13 +08:00
|
|
|
annotationsStreamListener = new Meteor.Streamer(
|
|
|
|
`annotations-${Auth.meetingID}`,
|
2023-03-10 19:30:46 +08:00
|
|
|
{ retransmit: false },
|
2022-04-05 22:49:13 +08:00
|
|
|
);
|
2020-01-13 20:34:54 +08:00
|
|
|
|
|
|
|
const startStreamHandlersPromise = new Promise((resolve) => {
|
|
|
|
const checkStreamHandlersInterval = setInterval(() => {
|
2022-04-05 22:49:13 +08:00
|
|
|
const streamHandlersSize = Object.values(
|
|
|
|
Meteor.StreamerCentral.instances[`annotations-${Auth.meetingID}`]
|
2023-03-10 19:30:46 +08:00
|
|
|
.handlers,
|
2022-04-05 22:49:13 +08:00
|
|
|
).filter((el) => el !== undefined).length;
|
2020-01-13 20:34:54 +08:00
|
|
|
|
2020-01-14 00:43:31 +08:00
|
|
|
if (!streamHandlersSize) {
|
2020-01-13 20:34:54 +08:00
|
|
|
resolve(clearInterval(checkStreamHandlersInterval));
|
|
|
|
}
|
|
|
|
}, 250);
|
|
|
|
});
|
2019-10-23 09:26:25 +08:00
|
|
|
|
2020-01-13 20:34:54 +08:00
|
|
|
startStreamHandlersPromise.then(() => {
|
2022-04-05 22:49:13 +08:00
|
|
|
logger.debug(
|
2023-03-10 19:30:46 +08:00
|
|
|
{ logCode: 'annotations_stream_handler_attach' },
|
|
|
|
'Attaching handlers for annotations stream',
|
2022-04-05 22:49:13 +08:00
|
|
|
);
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
annotationsStreamListener.on('removed', handleRemovedAnnotation);
|
2022-04-05 22:49:13 +08:00
|
|
|
|
2023-05-04 00:46:54 +08:00
|
|
|
annotationsStreamListener.on('added', async ({ annotations }) => {
|
|
|
|
await Promise.all(annotations.map(async (annotation) => {
|
|
|
|
const addedHandeler = await handleAddedAnnotation(annotation);
|
|
|
|
return addedHandeler;
|
2023-05-04 00:56:47 +08:00
|
|
|
}));
|
2019-10-23 09:26:25 +08:00
|
|
|
});
|
2020-01-13 20:34:54 +08:00
|
|
|
});
|
2019-10-23 09:26:25 +08:00
|
|
|
}
|
2018-05-12 00:01:24 +08:00
|
|
|
|
2019-02-14 00:15:09 +08:00
|
|
|
const annotationsQueue = [];
|
2018-05-12 00:01:24 +08:00
|
|
|
// How many packets we need to have to use annotationsBufferTimeMax
|
|
|
|
const annotationsMaxDelayQueueSize = 60;
|
|
|
|
// Minimum bufferTime
|
|
|
|
const annotationsBufferTimeMin = 30;
|
|
|
|
// Maximum bufferTime
|
|
|
|
const annotationsBufferTimeMax = 200;
|
2021-03-25 20:47:57 +08:00
|
|
|
// Time before running 'sendBulkAnnotations' again if user is offline
|
|
|
|
const annotationsRetryDelay = 1000;
|
|
|
|
|
2018-05-12 00:01:24 +08:00
|
|
|
let annotationsSenderIsRunning = false;
|
|
|
|
|
2019-02-14 00:15:09 +08:00
|
|
|
const proccessAnnotationsQueue = async () => {
|
2018-05-12 00:01:24 +08:00
|
|
|
annotationsSenderIsRunning = true;
|
|
|
|
const queueSize = annotationsQueue.length;
|
|
|
|
|
|
|
|
if (!queueSize) {
|
|
|
|
annotationsSenderIsRunning = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-02-14 00:15:09 +08:00
|
|
|
const annotations = annotationsQueue.splice(0, queueSize);
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
const isAnnotationSent = await makeCall('sendBulkAnnotations', annotations);
|
2021-03-25 20:47:57 +08:00
|
|
|
|
|
|
|
if (!isAnnotationSent) {
|
|
|
|
// undo splice
|
|
|
|
annotationsQueue.splice(0, 0, ...annotations);
|
|
|
|
setTimeout(proccessAnnotationsQueue, annotationsRetryDelay);
|
|
|
|
} else {
|
|
|
|
// ask tiago
|
2023-03-10 19:30:46 +08:00
|
|
|
const delayPerc = Math.min(
|
|
|
|
annotationsMaxDelayQueueSize, queueSize,
|
|
|
|
) / annotationsMaxDelayQueueSize;
|
2021-03-25 20:47:57 +08:00
|
|
|
const delayDelta = annotationsBufferTimeMax - annotationsBufferTimeMin;
|
2022-04-05 22:49:13 +08:00
|
|
|
const delayTime = annotationsBufferTimeMin + delayDelta * delayPerc;
|
2021-03-25 20:47:57 +08:00
|
|
|
setTimeout(proccessAnnotationsQueue, delayTime);
|
|
|
|
}
|
2018-05-12 00:01:24 +08:00
|
|
|
};
|
|
|
|
|
2020-04-07 04:34:08 +08:00
|
|
|
const sendAnnotation = (annotation) => {
|
2018-06-26 21:28:58 +08:00
|
|
|
// Prevent sending annotations while disconnected
|
2020-04-07 04:34:08 +08:00
|
|
|
// TODO: Change this to add the annotation, but delay the send until we're
|
|
|
|
// reconnected. With this it will miss things
|
2018-06-26 21:28:58 +08:00
|
|
|
if (!Meteor.status().connected) return;
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
const index = annotationsQueue.findIndex((ann) => ann.id === annotation.id);
|
2022-09-03 03:26:26 +08:00
|
|
|
if (index !== -1) {
|
|
|
|
annotationsQueue[index] = annotation;
|
|
|
|
} else {
|
|
|
|
annotationsQueue.push(annotation);
|
|
|
|
}
|
2022-03-09 04:37:37 +08:00
|
|
|
if (!annotationsSenderIsRunning) setTimeout(proccessAnnotationsQueue, annotationsBufferTimeMin);
|
|
|
|
};
|
|
|
|
|
2021-03-05 06:26:25 +08:00
|
|
|
const getMultiUser = (whiteboardId) => {
|
|
|
|
const data = WhiteboardMultiUser.findOne(
|
|
|
|
{
|
|
|
|
meetingId: Auth.meetingID,
|
|
|
|
whiteboardId,
|
2022-04-05 22:49:13 +08:00
|
|
|
},
|
2023-03-10 19:30:46 +08:00
|
|
|
{ fields: { multiUser: 1 } },
|
2021-03-05 06:26:25 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
if (!data || !data.multiUser || !Array.isArray(data.multiUser)) return [];
|
|
|
|
|
|
|
|
return data.multiUser;
|
|
|
|
};
|
|
|
|
|
|
|
|
const getMultiUserSize = (whiteboardId) => {
|
|
|
|
const multiUser = getMultiUser(whiteboardId);
|
|
|
|
|
|
|
|
if (multiUser.length === 0) return 0;
|
|
|
|
|
|
|
|
// Individual whiteboard access is controlled by an array of userIds.
|
|
|
|
// When an user leaves the meeting or the presenter role moves from an
|
|
|
|
// user to another we applying a filter at the whiteboard collection.
|
|
|
|
// Ideally this should change to something more cohese but this would
|
|
|
|
// require extra changes at multiple backend modules.
|
|
|
|
const multiUserSize = Users.find(
|
|
|
|
{
|
|
|
|
meetingId: Auth.meetingID,
|
2022-08-12 02:44:16 +08:00
|
|
|
$or: [
|
|
|
|
{
|
|
|
|
userId: { $in: multiUser },
|
|
|
|
presenter: false,
|
|
|
|
},
|
|
|
|
{ presenter: true },
|
|
|
|
],
|
2022-04-05 22:49:13 +08:00
|
|
|
},
|
2023-03-10 19:30:46 +08:00
|
|
|
{ fields: { userId: 1 } },
|
2021-03-05 06:26:25 +08:00
|
|
|
).fetch();
|
|
|
|
|
|
|
|
return multiUserSize.length;
|
|
|
|
};
|
|
|
|
|
|
|
|
const getCurrentWhiteboardId = () => {
|
2023-03-10 19:30:46 +08:00
|
|
|
const podId = 'DEFAULT_PRESENTATION_POD';
|
2021-04-12 22:06:43 +08:00
|
|
|
const currentPresentation = PresentationService.getCurrentPresentation(podId);
|
|
|
|
|
|
|
|
if (!currentPresentation) return null;
|
|
|
|
|
|
|
|
const currentSlide = Slides.findOne(
|
|
|
|
{
|
|
|
|
podId,
|
|
|
|
presentationId: currentPresentation.id,
|
2021-03-05 06:26:25 +08:00
|
|
|
current: true,
|
2022-04-05 22:49:13 +08:00
|
|
|
},
|
2023-03-10 19:30:46 +08:00
|
|
|
{ fields: { id: 1 } },
|
2021-03-05 06:26:25 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
return currentSlide && currentSlide.id;
|
2022-04-05 22:49:13 +08:00
|
|
|
};
|
2021-03-05 06:26:25 +08:00
|
|
|
|
2023-05-12 05:06:48 +08:00
|
|
|
const hasAnnotations = (presentationId) => {
|
|
|
|
const ann = Annotations.findOne(
|
|
|
|
{ whiteboardId: { $regex: `^${presentationId}` } },
|
|
|
|
);
|
|
|
|
return ann !== undefined;
|
|
|
|
};
|
|
|
|
|
2021-03-05 06:26:25 +08:00
|
|
|
const isMultiUserActive = (whiteboardId) => {
|
|
|
|
const multiUser = getMultiUser(whiteboardId);
|
|
|
|
|
|
|
|
return multiUser.length !== 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
const hasMultiUserAccess = (whiteboardId, userId) => {
|
|
|
|
const multiUser = getMultiUser(whiteboardId);
|
|
|
|
|
|
|
|
return multiUser.includes(userId);
|
|
|
|
};
|
|
|
|
|
|
|
|
const addGlobalAccess = (whiteboardId) => {
|
2023-03-10 19:30:46 +08:00
|
|
|
makeCall('addGlobalAccess', whiteboardId);
|
2021-03-05 06:26:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const addIndividualAccess = (whiteboardId, userId) => {
|
2023-03-10 19:30:46 +08:00
|
|
|
makeCall('addIndividualAccess', whiteboardId, userId);
|
2021-03-05 06:26:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const removeGlobalAccess = (whiteboardId) => {
|
2023-03-10 19:30:46 +08:00
|
|
|
makeCall('removeGlobalAccess', whiteboardId);
|
2021-03-05 06:26:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const removeIndividualAccess = (whiteboardId, userId) => {
|
2023-03-10 19:30:46 +08:00
|
|
|
makeCall('removeIndividualAccess', whiteboardId, userId);
|
|
|
|
};
|
|
|
|
|
|
|
|
const changeWhiteboardAccess = (userId, access) => {
|
|
|
|
const whiteboardId = getCurrentWhiteboardId();
|
|
|
|
|
|
|
|
if (!whiteboardId) return;
|
|
|
|
|
|
|
|
if (access) {
|
|
|
|
addIndividualAccess(whiteboardId, userId);
|
|
|
|
} else {
|
|
|
|
removeIndividualAccess(whiteboardId, userId);
|
|
|
|
}
|
2022-04-05 22:49:13 +08:00
|
|
|
};
|
|
|
|
|
2023-06-06 04:02:06 +08:00
|
|
|
const persistShape = (shape, whiteboardId, isModerator) => {
|
2022-05-04 20:40:56 +08:00
|
|
|
const annotation = {
|
|
|
|
id: shape.id,
|
2023-06-06 04:02:06 +08:00
|
|
|
annotationInfo: { ...shape, isModerator },
|
2022-05-04 20:40:56 +08:00
|
|
|
wbId: whiteboardId,
|
2022-10-21 22:05:31 +08:00
|
|
|
userId: Auth.userID,
|
2022-05-04 20:40:56 +08:00
|
|
|
};
|
|
|
|
|
2022-05-13 22:51:41 +08:00
|
|
|
sendAnnotation(annotation);
|
2022-04-05 22:49:13 +08:00
|
|
|
};
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
const removeShapes = (shapes, whiteboardId) => makeCall('deleteAnnotations', shapes, whiteboardId);
|
2022-04-05 22:49:13 +08:00
|
|
|
|
2022-04-26 21:55:05 +08:00
|
|
|
const changeCurrentSlide = (s) => {
|
2023-03-10 19:30:46 +08:00
|
|
|
makeCall('changeCurrentSlide', s);
|
|
|
|
};
|
2022-05-04 20:40:56 +08:00
|
|
|
|
2023-06-06 04:02:06 +08:00
|
|
|
const getShapes = (whiteboardId, curPageId, intl, isLocked) => {
|
|
|
|
const unlockedSelector = { whiteboardId };
|
|
|
|
const lockedSelector = {
|
|
|
|
whiteboardId,
|
|
|
|
$or: [
|
|
|
|
{ 'annotationInfo.isModerator': true },
|
|
|
|
{ 'annotationInfo.userId': Auth.userID },
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
const annotations = Annotations.find(
|
2023-06-06 04:02:06 +08:00
|
|
|
isLocked ? lockedSelector : unlockedSelector,
|
2022-05-04 20:40:56 +08:00
|
|
|
{
|
2023-03-10 19:30:46 +08:00
|
|
|
fields: { annotationInfo: 1, userId: 1 },
|
2022-05-04 20:40:56 +08:00
|
|
|
},
|
|
|
|
).fetch();
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
const result = {};
|
2022-05-19 03:35:42 +08:00
|
|
|
|
|
|
|
annotations.forEach((annotation) => {
|
2022-06-01 03:40:31 +08:00
|
|
|
if (annotation.annotationInfo.questionType) {
|
2023-03-10 19:30:46 +08:00
|
|
|
const modAnnotation = annotation;
|
2022-06-01 03:40:31 +08:00
|
|
|
// poll result, convert it to text and create tldraw shape
|
2023-03-10 19:30:46 +08:00
|
|
|
modAnnotation.annotationInfo.answers = annotation.annotationInfo.answers.reduce(
|
|
|
|
caseInsensitiveReducer, [],
|
|
|
|
);
|
2023-03-15 02:02:02 +08:00
|
|
|
let pollResult = PollService.getPollResultString(annotation.annotationInfo, intl)
|
2023-03-10 19:30:46 +08:00
|
|
|
.split('<br/>').join('\n').replace(/(<([^>]+)>)/ig, '');
|
2023-03-15 02:02:02 +08:00
|
|
|
|
|
|
|
const lines = pollResult.split('\n');
|
|
|
|
const longestLine = lines.reduce((a, b) => a.length > b.length ? a : b, '').length;
|
|
|
|
|
|
|
|
// add empty spaces before first | in each of the lines to make them all the same length
|
|
|
|
pollResult = lines.map((line) => {
|
|
|
|
if (!line.includes('|') || line.length === longestLine) return line;
|
|
|
|
|
|
|
|
const splitLine = line.split(' |');
|
|
|
|
const spaces = ' '.repeat(longestLine - line.length);
|
|
|
|
return `${splitLine[0]} ${spaces}|${splitLine[1]}`;
|
|
|
|
}).join('\n');
|
|
|
|
|
2023-03-17 02:55:56 +08:00
|
|
|
const style = {
|
|
|
|
color: 'white',
|
|
|
|
dash: 'solid',
|
|
|
|
font: 'mono',
|
|
|
|
isFilled: true,
|
|
|
|
size: 'small',
|
|
|
|
scale: 1,
|
|
|
|
};
|
2023-03-15 02:02:02 +08:00
|
|
|
|
2023-03-17 02:55:56 +08:00
|
|
|
const textSize = getTextSize(pollResult, style, padding = 20);
|
2023-03-15 02:02:02 +08:00
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
modAnnotation.annotationInfo = {
|
2023-03-15 02:02:02 +08:00
|
|
|
childIndex: 0,
|
2022-06-01 03:40:31 +08:00
|
|
|
id: annotation.annotationInfo.id,
|
|
|
|
name: `poll-result-${annotation.annotationInfo.id}`,
|
2023-03-15 02:02:02 +08:00
|
|
|
type: 'rectangle',
|
|
|
|
label: pollResult,
|
|
|
|
labelPoint: [0.5, 0.5],
|
2022-06-01 03:40:31 +08:00
|
|
|
parentId: `${curPageId}`,
|
|
|
|
point: [0, 0],
|
2023-03-17 02:55:56 +08:00
|
|
|
size: textSize,
|
|
|
|
style,
|
2023-03-10 19:30:46 +08:00
|
|
|
};
|
|
|
|
modAnnotation.annotationInfo.questionType = false;
|
2022-06-01 03:40:31 +08:00
|
|
|
}
|
2022-05-19 03:35:42 +08:00
|
|
|
result[annotation.annotationInfo.id] = annotation.annotationInfo;
|
|
|
|
});
|
2022-05-04 20:40:56 +08:00
|
|
|
return result;
|
2022-04-05 22:49:13 +08:00
|
|
|
};
|
|
|
|
|
2022-04-26 21:55:05 +08:00
|
|
|
const getCurrentPres = () => {
|
2023-03-10 19:30:46 +08:00
|
|
|
const podId = 'DEFAULT_PRESENTATION_POD';
|
|
|
|
return PresentationService.getCurrentPresentation(podId);
|
|
|
|
};
|
2022-04-26 21:55:05 +08:00
|
|
|
|
|
|
|
const initDefaultPages = (count = 1) => {
|
2022-04-05 22:49:13 +08:00
|
|
|
const pages = {};
|
|
|
|
const pageStates = {};
|
2023-02-28 00:05:29 +08:00
|
|
|
let i = 0;
|
2022-04-26 21:55:05 +08:00
|
|
|
while (i < count + 1) {
|
2022-04-05 22:49:13 +08:00
|
|
|
pages[`${i}`] = {
|
|
|
|
id: `${i}`,
|
|
|
|
name: `Slide ${i}`,
|
|
|
|
shapes: {},
|
|
|
|
bindings: {},
|
|
|
|
};
|
|
|
|
pageStates[`${i}`] = {
|
|
|
|
id: `${i}`,
|
|
|
|
selectedIds: [],
|
|
|
|
camera: {
|
|
|
|
point: [0, 0],
|
|
|
|
zoom: 1,
|
|
|
|
},
|
|
|
|
};
|
2023-03-10 19:30:46 +08:00
|
|
|
i += 1;
|
2022-04-05 22:49:13 +08:00
|
|
|
}
|
|
|
|
return { pages, pageStates };
|
2021-03-05 06:26:25 +08:00
|
|
|
};
|
|
|
|
|
2022-10-21 22:05:31 +08:00
|
|
|
const notifyNotAllowedChange = (intl) => {
|
|
|
|
if (intl) notify(intl.formatMessage(intlMessages.notifyNotAllowedChange), 'warning', 'whiteboard');
|
|
|
|
};
|
|
|
|
|
2023-02-03 03:47:16 +08:00
|
|
|
const notifyShapeNumberExceeded = (intl, limit) => {
|
|
|
|
if (intl) notify(intl.formatMessage(intlMessages.shapeNumberExceeded, { 0: limit }), 'warning', 'whiteboard');
|
|
|
|
};
|
|
|
|
|
2023-04-14 23:27:37 +08:00
|
|
|
const toggleToolsAnimations = (activeAnim, anim, time) => {
|
2023-08-16 22:32:23 +08:00
|
|
|
const tdTools = document.querySelector('#TD-Tools');
|
|
|
|
const topToolbar = document.getElementById('TD-Styles')?.parentElement;
|
|
|
|
const optionsDropdown = document.getElementById('WhiteboardOptionButton');
|
2023-03-27 06:08:09 +08:00
|
|
|
if (tdTools && topToolbar) {
|
|
|
|
tdTools.classList.remove(activeAnim);
|
|
|
|
topToolbar.classList.remove(activeAnim);
|
|
|
|
topToolbar.style.transition = `opacity ${time} ease-in-out`;
|
|
|
|
tdTools.style.transition = `opacity ${time} ease-in-out`;
|
|
|
|
tdTools?.classList?.add(anim);
|
|
|
|
topToolbar?.classList?.add(anim);
|
|
|
|
}
|
2023-08-16 22:32:23 +08:00
|
|
|
if (optionsDropdown) {
|
|
|
|
optionsDropdown.classList.remove(activeAnim);
|
|
|
|
optionsDropdown.style.transition = `opacity ${time} ease-in-out`;
|
|
|
|
optionsDropdown?.classList?.add(anim);
|
|
|
|
}
|
2023-03-27 06:08:09 +08:00
|
|
|
}
|
|
|
|
|
2020-04-07 04:34:08 +08:00
|
|
|
export {
|
2022-04-05 22:49:13 +08:00
|
|
|
initDefaultPages,
|
2020-04-07 04:34:08 +08:00
|
|
|
Annotations,
|
|
|
|
sendAnnotation,
|
2021-03-05 06:26:25 +08:00
|
|
|
getMultiUser,
|
|
|
|
getMultiUserSize,
|
|
|
|
getCurrentWhiteboardId,
|
|
|
|
isMultiUserActive,
|
|
|
|
hasMultiUserAccess,
|
|
|
|
changeWhiteboardAccess,
|
|
|
|
addGlobalAccess,
|
|
|
|
addIndividualAccess,
|
|
|
|
removeGlobalAccess,
|
|
|
|
removeIndividualAccess,
|
2022-04-05 22:49:13 +08:00
|
|
|
persistShape,
|
|
|
|
getShapes,
|
2022-04-26 21:55:05 +08:00
|
|
|
getCurrentPres,
|
2022-05-04 20:40:56 +08:00
|
|
|
removeShapes,
|
2022-04-26 21:55:05 +08:00
|
|
|
changeCurrentSlide,
|
2022-10-21 22:05:31 +08:00
|
|
|
notifyNotAllowedChange,
|
2023-02-03 03:47:16 +08:00
|
|
|
notifyShapeNumberExceeded,
|
2023-05-12 05:06:48 +08:00
|
|
|
hasAnnotations,
|
2023-03-27 06:08:09 +08:00
|
|
|
toggleToolsAnimations,
|
2020-04-07 04:34:08 +08:00
|
|
|
};
|