Skip to content
Open
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
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"requiredSdkVersion": "~0.0.59",
"requiredSdkVersion": "0.1.x",
"name": "TypedCaptions",
"javascriptEntrypointUrl": "TypedCaptions.js",
"localesBaseUrl": "locales",
Expand Down
16 changes: 12 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"@types/react": "^18.2.13",
"@types/react-dom": "^18.2.6",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"bigbluebutton-html-plugin-sdk": "0.0.84",
"bigbluebutton-html-plugin-sdk": "0.1.10",
"path": "^0.12.7",
"react-intl": "^6.6.8",
"react": "^18.2.0",
"react-chat-elements": "^12.0.14",
"react-dom": "^18.2.0",
"react-intl": "^6.6.8",
"react-modal": "^3.16.1",
"react-select": "^5.7.3",
"react-textarea-autosize": "^8.5.3",
Expand Down Expand Up @@ -50,6 +50,7 @@
"@types/react-dom": "^18.2.7",
"@types/react-modal": "^3.16.0",
"@types/styled-components": "^5.1.26",
"@types/webpack-env": "^1.18.8",
"@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^6.2.0",
"babel-loader": "^9.1.2",
Expand Down
83 changes: 19 additions & 64 deletions src/components/main/component.tsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,26 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom/client';
import { createIntl, defineMessages } from 'react-intl';

import {
ActionButtonDropdownOption,
ActionButtonDropdownSeparator,
BbbPluginSdk,
MediaAreaOption,
MediaAreaSeparator,
DataChannelTypes,
GenericContentSidekickArea,
PluginApi,
} from 'bigbluebutton-html-plugin-sdk';

import { TypedCaptionsProps } from './types';
import { TypedCaptionsModal } from '../modal/component';
import { CaptionMenu } from '../../common/types';
import { TypedCaptionsSidekickArea } from '../typed-captions-sidekick-content/component';
import { TypedCaptionsProps } from './types';
import { intlMessages } from '../../intlMessages';

const intlMessages = defineMessages({
writeCC: {
id: 'plugin.actionButtonDropdown.write',
description: 'action button dropdown label to start writing',
},
stopCC: {
id: 'plugin.actionButtonDropdown.remove',
description: 'action button dropdown label to start writing',
},
sectionName: {
id: 'plugin.actionButtonDropdown.sidekickComponent.sectionName',
description: 'name of the sidekick component section',
},
menuTitle: {
id: 'plugin.actionButtonDropdown.sidekickComponent.menuTitle',
description: 'title of the sidekick component menu (internal part)',
},
});

function TypedCaptions(
{ pluginUuid: uuid }: TypedCaptionsProps,
): React.ReactElement {
BbbPluginSdk.initialize(uuid);

const pluginApi: PluginApi = BbbPluginSdk.getPluginApi(uuid);

function TypedCaptions({ intl, pluginApi, uuid }: TypedCaptionsProps): React.ReactElement {
const {
data: captionMenusResponseFromDataChannel,
pushEntry: pushCaptionMenuResponseFromDataChannel,
deleteEntry: excludeCaptionMenuResponseFromDataChannel,
} = pluginApi.useDataChannel<CaptionMenu>('typed-captions-data-channel', DataChannelTypes.ALL_ITEMS, 'caption-menus');

const {
messages,
currentLocale,
loading: localeMessagesLoading,
} = pluginApi.useLocaleMessages({
headers: {
'ngrok-skip-browser-warning': 'any',
},
});

const intl = (!localeMessagesLoading && messages) ? createIntl({
locale: currentLocale,
messages,
fallbackOnEmptyString: true,
}) : null;

const [captionLocale, setCaptionLocale] = React.useState('');

const currentUserResponse = pluginApi.useCurrentUser();
Expand All @@ -76,7 +33,7 @@ function TypedCaptions(

/// contentFunction, name, section, buttonIcon
React.useEffect(() => {
if (!localeMessagesLoading && captionMenusResponseFromDataChannel?.data && currentUserResponse?.data?.role === 'MODERATOR') {
if (captionMenusResponseFromDataChannel?.data && currentUserResponse?.data?.role === 'MODERATOR') {
const sectionName = intl.formatMessage(intlMessages.sectionName);
const sidekickMenuComponentList = captionMenusResponseFromDataChannel?.data
.map((menu) => new GenericContentSidekickArea({
Expand All @@ -102,7 +59,7 @@ function TypedCaptions(
}));
pluginApi.setGenericContentItems(sidekickMenuComponentList);
}
}, [captionMenusResponseFromDataChannel, localeMessagesLoading, messages]);
}, [captionMenusResponseFromDataChannel]);

React.useEffect(() => {
if (currentUserResponse?.data?.role === 'MODERATOR') {
Expand Down Expand Up @@ -131,23 +88,21 @@ function TypedCaptions(
};
} else actionButtonDropdownLabel = intl.formatMessage(intlMessages.stopCC);
}
if (!localeMessagesLoading) {
pluginApi.setActionButtonDropdownItems([
new ActionButtonDropdownSeparator(),
new ActionButtonDropdownOption({
icon: 'closed_caption',
label: actionButtonDropdownLabel,
tooltip: 'this is a button injected by plugin',
allowed: true,
onClick: actionButtonDropdownOnClick,
}),
]);
}
pluginApi.setMediaAreaItems([
new MediaAreaSeparator({}),
new MediaAreaOption({
icon: 'closed_caption',
label: actionButtonDropdownLabel,
tooltip: 'this is a button injected by plugin',
allowed: true,
onClick: actionButtonDropdownOnClick,
}),
]);
} else {
pluginApi.setActionButtonDropdownItems([]);
pluginApi.setMediaAreaItems([]);
pluginApi.setGenericContentItems([]);
}
}, [currentUserResponse, captionMenusResponseFromDataChannel, localeMessagesLoading, messages]);
}, [currentUserResponse, captionMenusResponseFromDataChannel]);

return (
<TypedCaptionsModal
Expand Down
8 changes: 6 additions & 2 deletions src/components/main/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { IntlShape } from 'react-intl';
import { PluginApi } from 'bigbluebutton-html-plugin-sdk';

interface TypedCaptionsProps {
pluginName: string,
pluginUuid: string,
intl: IntlShape;
pluginApi: PluginApi;
uuid: string;
}

interface ExternalVideoMeetingSubscription {
Expand Down
18 changes: 2 additions & 16 deletions src/components/modal/component.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as BbbPluginSdk from 'bigbluebutton-html-plugin-sdk';
import { defineMessages, IntlShape } from 'react-intl';
import { IntlShape } from 'react-intl';
import * as React from 'react';
import Styled from './styles';
import LocalesDropdown from './locales-dropdown/component';
import './styles.css';
import { AVAILABLE_LOCALES, CAPTIONS_CONFIG_LANGUAGES } from './constants';
import { AvailableLocaleObject, CaptionMenu } from '../../common/types';
import { intlMessages } from '../../intlMessages';

interface TypedCaptionsModalProps {
isOpen: boolean;
Expand All @@ -21,21 +22,6 @@

const TIMEOUT_RENDER_ERROR = 3000;

const intlMessages = defineMessages({
selectorLabel: {
id: 'plugin.actionButtonDropdown.modal.selectorLabel',
description: 'action button dropdown label to start writing',
},
selectPlaceholder: {
id: 'plugin.actionButtonDropdown.modal.selectPlaceHolder',
description: 'placeholder of the selector',
},
startButtonLabel: {
id: 'plugin.actionButtonDropdown.modal.start',
description: 'start button label',
},
});

function TypedCaptionsModal(props: TypedCaptionsModalProps) {
const {
isOpen,
Expand All @@ -53,7 +39,7 @@
const [errorMessage, setErrorMessage] = React.useState('');

React.useEffect(() => {
const filteredLocales = AVAILABLE_LOCALES.filter(l => CAPTIONS_CONFIG_LANGUAGES.includes(l?.locale));

Check failure on line 42 in src/components/modal/component.tsx

View workflow job for this annotation

GitHub Actions / ts-code-validation

Expected parentheses around arrow function argument

Check failure on line 42 in src/components/modal/component.tsx

View workflow job for this annotation

GitHub Actions / ts-code-validation

This line has a length of 105. Maximum allowed is 100
setAvailableLocales(filteredLocales as AvailableLocaleObject[]);

return () => {
Expand Down
46 changes: 2 additions & 44 deletions src/components/modal/locales-dropdown/component.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { defineMessages, IntlShape } from 'react-intl';
import { IntlShape } from 'react-intl';
import { AvailableLocaleObject, WindowWithSettings } from '../../../common/types';
import { intlMessages } from '../../../intlMessages';

const DEFAULT_VALUE = 'select';
const DEFAULT_KEY = -1;
Expand All @@ -14,49 +15,6 @@ interface LocalesDropdownProps {
selectMessage: string;
}

const intlMessages = defineMessages({
'en-US': {
id: 'plugin.actionButtonDropdown.modal.dropdown.en-US',
description: 'English language',
},
'de-DE': {
id: 'plugin.actionButtonDropdown.modal.dropdown.de-DE',
description: 'English language',
},
'es-ES': {
id: 'plugin.actionButtonDropdown.modal.dropdown.es-ES',
description: 'English language',
},
'fr-FR': {
id: 'plugin.actionButtonDropdown.modal.dropdown.fr-FR',
description: 'English language',
},
'hi-ID': {
id: 'plugin.actionButtonDropdown.modal.dropdown.hi-ID',
description: 'English language',
},
'it-IT': {
id: 'plugin.actionButtonDropdown.modal.dropdown.it-IT',
description: 'English language',
},
'ja-JP': {
id: 'plugin.actionButtonDropdown.modal.dropdown.ja-JP',
description: 'English language',
},
'pt-BR': {
id: 'plugin.actionButtonDropdown.modal.dropdown.pt-BR',
description: 'English language',
},
'ru-RU': {
id: 'plugin.actionButtonDropdown.modal.dropdown.ru-RU',
description: 'English language',
},
'zh-CN': {
id: 'plugin.actionButtonDropdown.modal.dropdown.zh-CN',
description: 'English language',
},
});

declare const window: WindowWithSettings;

function LocalesDropdown(props: LocalesDropdownProps) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const Content = styled.div`
align-items: center;
display: flex;
flex-direction: column;
padding: .3rem 0 0.5rem 0;
gap: 1rem;
`;

const CloseButton = styled.button`
Expand Down
10 changes: 2 additions & 8 deletions src/components/typed-captions-sidekick-content/component.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
import { BbbPluginSdk, DataChannelTypes, PluginApi } from 'bigbluebutton-html-plugin-sdk';
import { defineMessages, IntlShape } from 'react-intl';
import { IntlShape } from 'react-intl';
import * as React from 'react';

import Styled from './styles';
import { TypedCaptionsInput } from './input-captions/component';
import { CaptionMessage } from '../../common/types';
import { CaptionMessagesList } from './caption-messages-list/component';
import { intlMessages } from '../../intlMessages';

interface GenericContentExampleProps {
uuid: string;
intl: IntlShape;
captionLocale: string;
}

const intlMessages = defineMessages({
inputPlaceholder: {
id: 'plugin.actionButtonDropdown.sidekickComponent.inputPlaceholder',
description: 'Placeholder of the sidekick component input',
},
});

export function TypedCaptionsSidekickArea(props: GenericContentExampleProps) {
const {
uuid,
Expand Down
15 changes: 11 additions & 4 deletions src/components/typed-captions-sidekick-content/styles.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import styled from 'styled-components';
import { mdPaddingY } from '../modal/styles';
import { mdPaddingX, mdPaddingY, smallOnly } from '../modal/styles';

const CaptionsWrapper = styled.div`
height: 100%;
width: 100%;
display: flex;
flex-grow: 1;
flex-direction: column;
justify-content: space-between;
overflow-x: hidden;
overflow-y: auto;
height: 100%;
box-sizing: border-box;
padding: ${mdPaddingX};

@media ${smallOnly} {
transform: none !important;
}
`;

const HeaderWrapper = styled.div`
Expand Down
Loading
Loading