mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 09:01:17 -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
|
||||
|
||||
- Various performance improvements
|
||||
- Fix bio editor crashing when faced with commet bio format.
|
||||
|
||||
## Version 1.1.3
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import { SettingTile } from '../../../components/setting-tile';
|
||||
import * as css from './BioEditor.css';
|
||||
|
||||
type BioEditorProps = {
|
||||
value?: string;
|
||||
value?: string | any;
|
||||
isSaving?: boolean;
|
||||
imagePackRooms?: any[];
|
||||
onSave: (htmlContent: string) => void;
|
||||
@@ -67,15 +67,23 @@ export function BioEditor({ value, isSaving, imagePackRooms, onSave }: BioEditor
|
||||
|
||||
if (valueChanged || isFirstValidLoad) {
|
||||
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();
|
||||
|
||||
if (currentPlainText === incomingPlainText && initialized.current) return;
|
||||
|
||||
const isLikelyHtml = value?.includes('<') || value?.includes('>');
|
||||
const isLikelyHtml = safeValue.includes('<') || safeValue.includes('>');
|
||||
const initialValue = isLikelyHtml
|
||||
? htmlToEditorInput(value!, isMarkdown)
|
||||
: plainToEditorInput(value ?? '', isMarkdown);
|
||||
? htmlToEditorInput(safeValue, isMarkdown)
|
||||
: plainToEditorInput(safeValue, isMarkdown);
|
||||
|
||||
editor.children = initialValue;
|
||||
Editor.normalize(editor, { force: true });
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
Spinner,
|
||||
} from 'folds';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { MatrixClient } from 'matrix-js-sdk';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
import { SequenceCardStyle } from '../styles.css';
|
||||
import { SettingTile } from '../../../components/setting-tile';
|
||||
@@ -48,7 +48,6 @@ import { TimezoneEditor } from './TimezoneEditor';
|
||||
import { PronounEditor } from './PronounEditor';
|
||||
import { BioEditor } from './BioEditor';
|
||||
import { NameColorEditor } from './NameColorEditor';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { profilesCacheAtom } from '../../../state/userRoomProfile';
|
||||
|
||||
type PronounSet = {
|
||||
|
||||
Reference in new issue
Block a user