Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -869,11 +869,9 @@ So the idea is that we have a `uiCommands` object and at a point, there will be
- save: this function saves the given text, locale and caption type
- addLocale: this function sends a locale to be added to the available options

- presentation:
- upload: uploads a new presentation to BigBlueButton;

- presentation:
- upload: uploads a new presentation to BigBlueButton;
- presentation:
- upload: uploads a new presentation to BigBlueButton;
- insertPages: inserts pages into the current presentation at a given 1-based position (out-of-range values are clamped by the server: 1 prepends, totalPages + 1 appends). The content is the file to convert into pages; omitting it (or passing null) inserts a single blank page;

**Example usage:**

Expand Down Expand Up @@ -933,6 +931,15 @@ So the idea is that we have a `uiCommands` object and at a point, there will be
});
},
}),
new ActionButtonDropdownOption({
label: 'Insert pages',
icon: 'copy',
onClick: () => {
// Insert the pages of a PDF file at position 2 of the current presentation
// (pdfFile is a File object, e.g. taken from an input of type file)
pluginApi.serverCommands.presentation.insertPages(2, { file: pdfFile });
},
}),
]);
}, []);

Expand Down
3 changes: 3 additions & 0 deletions src/server-commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
export { CaptionCommandsEnum, CaptionsTypeEnum } from './caption/enum';
export { ChatCommandsEnum } from './chat/enum';
export { PresentationCommandsEnum } from './presentation/enum';
export {
UploadPresentationBase64Content,
UploadPresentationBlobContent,
UploadPresentationFileContent,
UploadPresentationDataUrlContent,
UploadPresentationContent,
UploadPresentationCommandArguments,
InsertPagesCommandArguments,
} from './presentation/types';
37 changes: 36 additions & 1 deletion src/server-commands/presentation/commands.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { PresentationCommandsEnum } from './enum';
import { UploadPresentationCommandArguments } from './types';
import {
InsertPagesCommandArguments,
UploadPresentationCommandArguments,
UploadPresentationContent,
} from './types';

export const presentation = {
/**
Expand All @@ -17,4 +21,35 @@ export const presentation = {
}),
);
},

/**
* Inserts pages into the current presentation at a given position (if presenter,
* ignores otherwise).
*
* @param position 1-based position where the pages are inserted. Out-of-range
* values are clamped by the server (1 prepends, totalPages + 1 appends).
* @param content The file to convert into pages. Pass `null` (or omit) to insert a
* single blank page.
* @param mimeType Optional mime type of the content (e.g. `application/pdf`).
* @param filename Optional original filename.
*/
insertPages: (
position: number,
content?: UploadPresentationContent | null,
mimeType?: string,
filename?: string,
) => {
window.dispatchEvent(
new CustomEvent<
InsertPagesCommandArguments
>(PresentationCommandsEnum.INSERT_PAGES, {
detail: {
position,
content: content ?? null,
mimeType,
filename,
},
}),
);
},
};
1 change: 1 addition & 0 deletions src/server-commands/presentation/enum.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export enum PresentationCommandsEnum {
UPLOAD = 'PRESENTATION_UPLOAD_COMMAND',
INSERT_PAGES = 'PRESENTATION_INSERT_PAGES_COMMAND',
}
16 changes: 16 additions & 0 deletions src/server-commands/presentation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ export interface UploadPresentationCommandArguments {
filename?: string;
}

export interface InsertPagesCommandArguments {
// 1-based position where the new pages are inserted. Out-of-range values are
// clamped by the server (1 -> prepend, totalPages + 1 -> append).
position: number;
// The file to convert into pages. `null` inserts a single blank page.
content: UploadPresentationContent | null;
mimeType?: string;
filename?: string;
}

export interface ServerCommandsPresentationObject {
upload: (uploadPresentationCommandArguments: UploadPresentationCommandArguments) => void;
insertPages: (
position: number,
content?: UploadPresentationContent | null,
mimeType?: string,
filename?: string,
) => void;
}
Loading