mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-13 02:30:29 +03:00
Fix editor bugs (#1281)
* focus editor on reply click * fix emoji and sticker img object-fit * fix cursor not moving with autocomplete * stop sanitizing sending plain text body * improve autocomplete query parsing * add escape to turn off active editor toolbar item
This commit is contained in:
parent
6d199244ef
commit
2883b4c35b
9 changed files with 69 additions and 22 deletions
|
|
@ -104,7 +104,7 @@ export function EmoticonAutocomplete({
|
|||
as="img"
|
||||
src={mx.mxcUrlToHttp(key) || key}
|
||||
alt={emoticon.shortcode}
|
||||
style={{ width: toRem(24), height: toRem(24) }}
|
||||
style={{ width: toRem(24), height: toRem(24), objectFit: 'contain' }}
|
||||
/>
|
||||
) : (
|
||||
<Box
|
||||
|
|
|
|||
|
|
@ -23,13 +23,14 @@ export const getAutocompletePrefix = <TPrefix extends string>(
|
|||
validPrefixes: readonly TPrefix[]
|
||||
): TPrefix | undefined => {
|
||||
const world = Editor.string(editor, queryRange);
|
||||
const prefix = world[0] as TPrefix | undefined;
|
||||
if (!prefix) return undefined;
|
||||
return validPrefixes.includes(prefix) ? prefix : undefined;
|
||||
return validPrefixes.find((p) => world.startsWith(p));
|
||||
};
|
||||
|
||||
export const getAutocompleteQueryText = (editor: Editor, queryRange: BaseRange): string =>
|
||||
Editor.string(editor, queryRange).slice(1);
|
||||
export const getAutocompleteQueryText = (
|
||||
editor: Editor,
|
||||
queryRange: BaseRange,
|
||||
prefix: string
|
||||
): string => Editor.string(editor, queryRange).slice(prefix.length);
|
||||
|
||||
export const getAutocompleteQuery = <TPrefix extends string>(
|
||||
editor: Editor,
|
||||
|
|
@ -41,6 +42,6 @@ export const getAutocompleteQuery = <TPrefix extends string>(
|
|||
return {
|
||||
range: queryRange,
|
||||
prefix,
|
||||
text: getAutocompleteQueryText(editor, queryRange),
|
||||
text: getAutocompleteQueryText(editor, queryRange, prefix),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue