mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-21 17:41:25 -08:00
fix #13 bio editor crashing with commet bios
This commit is contained in:
1 parent
6e03305442
commit
43cb5313be
3 files changed
+15
-7
No files matched your search
@@ -3,6 +3,7 @@
|
|||||||
## Version 1.1.4
|
## Version 1.1.4
|
||||||
|
|
||||||
- Various performance improvements
|
- Various performance improvements
|
||||||
|
- Fix bio editor crashing when faced with commet bio format.
|
||||||
|
|
||||||
## Version 1.1.3
|
## Version 1.1.3
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import { SettingTile } from '../../../components/setting-tile';
|
|||||||
import * as css from './BioEditor.css';
|
import * as css from './BioEditor.css';
|
||||||
|
|
||||||
type BioEditorProps = {
|
type BioEditorProps = {
|
||||||
value?: string;
|
value?: string | any;
|
||||||
isSaving?: boolean;
|
isSaving?: boolean;
|
||||||
imagePackRooms?: any[];
|
imagePackRooms?: any[];
|
||||||
onSave: (htmlContent: string) => void;
|
onSave: (htmlContent: string) => void;
|
||||||
@@ -67,15 +67,23 @@ export function BioEditor({ value, isSaving, imagePackRooms, onSave }: BioEditor
|
|||||||
|
|
||||||
if (valueChanged || isFirstValidLoad) {
|
if (valueChanged || isFirstValidLoad) {
|
||||||
prevValue.current = value;
|
prevValue.current = value;
|
||||||
const incomingPlainText = value ? toPlainText(htmlToEditorInput(value, isMarkdown), isMarkdown).trim() : '';
|
|
||||||
|
let normalizedValue = value;
|
||||||
|
if (typeof normalizedValue === 'object' && normalizedValue !== null && 'formatted_body' in normalizedValue) {
|
||||||
|
normalizedValue = normalizedValue.formatted_body;
|
||||||
|
}
|
||||||
|
|
||||||
|
const safeValue = typeof normalizedValue === 'string' ? normalizedValue : '';
|
||||||
|
|
||||||
|
const incomingPlainText = toPlainText(htmlToEditorInput(safeValue, isMarkdown), isMarkdown).trim();
|
||||||
const currentPlainText = toPlainText(editor.children, isMarkdown).trim();
|
const currentPlainText = toPlainText(editor.children, isMarkdown).trim();
|
||||||
|
|
||||||
if (currentPlainText === incomingPlainText && initialized.current) return;
|
if (currentPlainText === incomingPlainText && initialized.current) return;
|
||||||
|
|
||||||
const isLikelyHtml = value?.includes('<') || value?.includes('>');
|
const isLikelyHtml = safeValue.includes('<') || safeValue.includes('>');
|
||||||
const initialValue = isLikelyHtml
|
const initialValue = isLikelyHtml
|
||||||
? htmlToEditorInput(value!, isMarkdown)
|
? htmlToEditorInput(safeValue, isMarkdown)
|
||||||
: plainToEditorInput(value ?? '', isMarkdown);
|
: plainToEditorInput(safeValue, isMarkdown);
|
||||||
|
|
||||||
editor.children = initialValue;
|
editor.children = initialValue;
|
||||||
Editor.normalize(editor, { force: true });
|
Editor.normalize(editor, { force: true });
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import {
|
|||||||
Spinner,
|
Spinner,
|
||||||
} from 'folds';
|
} from 'folds';
|
||||||
import FocusTrap from 'focus-trap-react';
|
import FocusTrap from 'focus-trap-react';
|
||||||
import { MatrixClient } from 'matrix-js-sdk';
|
import { useSetAtom } from 'jotai';
|
||||||
import { SequenceCard } from '../../../components/sequence-card';
|
import { SequenceCard } from '../../../components/sequence-card';
|
||||||
import { SequenceCardStyle } from '../styles.css';
|
import { SequenceCardStyle } from '../styles.css';
|
||||||
import { SettingTile } from '../../../components/setting-tile';
|
import { SettingTile } from '../../../components/setting-tile';
|
||||||
@@ -48,7 +48,6 @@ import { TimezoneEditor } from './TimezoneEditor';
|
|||||||
import { PronounEditor } from './PronounEditor';
|
import { PronounEditor } from './PronounEditor';
|
||||||
import { BioEditor } from './BioEditor';
|
import { BioEditor } from './BioEditor';
|
||||||
import { NameColorEditor } from './NameColorEditor';
|
import { NameColorEditor } from './NameColorEditor';
|
||||||
import { useSetAtom } from 'jotai';
|
|
||||||
import { profilesCacheAtom } from '../../../state/userRoomProfile';
|
import { profilesCacheAtom } from '../../../state/userRoomProfile';
|
||||||
|
|
||||||
type PronounSet = {
|
type PronounSet = {
|
||||||
|
|||||||
Reference in new issue
Block a user