mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: support collaboration in bound text (#4573)
* fix: support collaboration in bounded text * align implementation irrespective of collab/submit * don't wrap when submitted * fix * tests: exit editor via ESCAPE instead to remove async hacks * simplify and remove dead comment * remove mutating coords in submit since its taken care in updateWysiwygStyle Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
parent
0850ab0dd0
commit
24bf4cb5fb
6 changed files with 56 additions and 82 deletions
|
@ -476,7 +476,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
zenModeEnabled={zenModeEnabled}
|
||||
toggleZenMode={this.toggleZenMode}
|
||||
langCode={getLanguage().code}
|
||||
isCollaborating={this.props.isCollaborating || false}
|
||||
isCollaborating={this.props.isCollaborating}
|
||||
renderTopRightUI={renderTopRightUI}
|
||||
renderCustomFooter={renderFooter}
|
||||
viewModeEnabled={viewModeEnabled}
|
||||
|
@ -1912,20 +1912,15 @@ class App extends React.Component<AppProps, AppState> {
|
|||
text: string,
|
||||
originalText: string,
|
||||
isDeleted: boolean,
|
||||
isSubmit: boolean,
|
||||
) => {
|
||||
this.scene.replaceAllElements([
|
||||
...this.scene.getElementsIncludingDeleted().map((_element) => {
|
||||
if (_element.id === element.id && isTextElement(_element)) {
|
||||
return updateTextElement(
|
||||
_element,
|
||||
{
|
||||
text,
|
||||
isDeleted,
|
||||
originalText,
|
||||
},
|
||||
isSubmit,
|
||||
);
|
||||
return updateTextElement(_element, {
|
||||
text,
|
||||
isDeleted,
|
||||
originalText,
|
||||
});
|
||||
}
|
||||
return _element;
|
||||
}),
|
||||
|
@ -1950,14 +1945,14 @@ class App extends React.Component<AppProps, AppState> {
|
|||
];
|
||||
},
|
||||
onChange: withBatchedUpdates((text) => {
|
||||
updateElement(text, text, false, false);
|
||||
updateElement(text, text, false);
|
||||
if (isNonDeletedElement(element)) {
|
||||
updateBoundElements(element);
|
||||
}
|
||||
}),
|
||||
onSubmit: withBatchedUpdates(({ text, viaKeyboard, originalText }) => {
|
||||
const isDeleted = !text.trim();
|
||||
updateElement(text, originalText, isDeleted, true);
|
||||
updateElement(text, originalText, isDeleted);
|
||||
// select the created text element only if submitting via keyboard
|
||||
// (when submitting via click it should act as signal to deselect)
|
||||
if (!isDeleted && viaKeyboard) {
|
||||
|
@ -1997,7 +1992,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
|
||||
// do an initial update to re-initialize element position since we were
|
||||
// modifying element's x/y for sake of editor (case: syncing to remote)
|
||||
updateElement(element.text, element.originalText, false, false);
|
||||
updateElement(element.text, element.originalText, false);
|
||||
}
|
||||
|
||||
private deselectElements() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue