Skip to content

Commit

Permalink
Iterate
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy committed Jan 2, 2025
1 parent 9773c15 commit f4ee383
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion platforms/web/lib/useComposerModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function useComposerModel(
modelContent.length,
);
}
} catch (e) {
} catch {
// if the initialisation fails, due to a parsing failure of the html, fallback to an empty composer
contentModel = new_composer_model();
}
Expand Down
45 changes: 23 additions & 22 deletions platforms/web/lib/useFormattingFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,43 +35,44 @@ export function useFormattingFunctions(
| SuggestionEvent['data']
| AtRoomSuggestionEvent['data'],
): void => {
editorRef.current &&
if (editorRef.current) {
sendWysiwygInputEvent(
editorRef.current,
blockType,
undefined,
data,
);
}
};

return {
bold: () => sendEvent('formatBold'),
italic: () => sendEvent('formatItalic'),
strikeThrough: () => sendEvent('formatStrikeThrough'),
underline: () => sendEvent('formatUnderline'),
undo: () => sendEvent('historyUndo'),
redo: () => sendEvent('historyRedo'),
orderedList: () => sendEvent('insertOrderedList'),
unorderedList: () => sendEvent('insertUnorderedList'),
inlineCode: () => sendEvent('formatInlineCode'),
clear: () => sendEvent('clear'),
insertText: (text: string) => sendEvent('insertText', text),
link: (url: string, text?: string) =>
bold: (): void => sendEvent('formatBold'),
italic: (): void => sendEvent('formatItalic'),
strikeThrough: (): void => sendEvent('formatStrikeThrough'),
underline: (): void => sendEvent('formatUnderline'),
undo: (): void => sendEvent('historyUndo'),
redo: (): void => sendEvent('historyRedo'),
orderedList: (): void => sendEvent('insertOrderedList'),
unorderedList: (): void => sendEvent('insertUnorderedList'),
inlineCode: (): void => sendEvent('formatInlineCode'),
clear: (): void => sendEvent('clear'),
insertText: (text: string): void => sendEvent('insertText', text),
link: (url: string, text?: string): void =>
sendEvent('insertLink', { url, text }),
removeLinks: () => sendEvent('removeLinks'),
getLink: () =>
removeLinks: (): void => sendEvent('removeLinks'),
getLink: (): string =>
composerModel?.get_link_action()?.edit_link?.url || '',
codeBlock: () => sendEvent('insertCodeBlock'),
quote: () => sendEvent('insertQuote'),
indent: () => sendEvent('formatIndent'),
unindent: () => sendEvent('formatOutdent'),
codeBlock: (): void => sendEvent('insertCodeBlock'),
quote: (): void => sendEvent('insertQuote'),
indent: (): void => sendEvent('formatIndent'),
unindent: (): void => sendEvent('formatOutdent'),
mention: (
url: string,
text: string,
attributes: AllowedMentionAttributes,
) => sendEvent('insertSuggestion', { url, text, attributes }),
command: (text: string) => sendEvent('insertCommand', text),
mentionAtRoom: (attributes: AllowedMentionAttributes) =>
): void => sendEvent('insertSuggestion', { url, text, attributes }),
command: (text: string): void => sendEvent('insertCommand', text),
mentionAtRoom: (attributes: AllowedMentionAttributes): void =>
sendEvent('insertAtRoomSuggestion', { attributes }),
};
}, [editorRef, composerModel]);
Expand Down
6 changes: 3 additions & 3 deletions platforms/web/lib/useListeners/useListeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export function useListeners(
plainTextContentRef.current =
composerModel.get_content_as_plain_text();
}
} catch (e) {
} catch {
onError(plainTextContentRef.current);
}
};
Expand Down Expand Up @@ -188,7 +188,7 @@ export function useListeners(
}
plainTextContentRef.current =
composerModel.get_content_as_plain_text();
} catch (e) {
} catch {
onError(plainTextContentRef.current);
}
};
Expand Down Expand Up @@ -216,7 +216,7 @@ export function useListeners(

setAreListenersReady(true);

return () => {
return (): void => {
setAreListenersReady(false);
editorNode.removeEventListener('input', onInput);
editorNode.removeEventListener('paste', onPaste);
Expand Down
3 changes: 1 addition & 2 deletions platforms/web/lib/useWysiwyg.undo-redo.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { fireEvent, render, screen, waitFor, act } from '@testing-library/react';

Check failure on line 9 in platforms/web/lib/useWysiwyg.undo-redo.test.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `·fireEvent,·render,·screen,·waitFor,·act·` with `⏎····fireEvent,⏎····render,⏎····screen,⏎····waitFor,⏎····act,⏎`
import userEvent from '@testing-library/user-event';
import { act } from 'react-dom/test-utils';

import { Editor } from './testUtils/Editor';

Expand Down

0 comments on commit f4ee383

Please sign in to comment.