mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: Support binding text to container via context menu (#4935)
* feat: Support binding text to closest container * Bind text to selected container * show bind action in canvas and selected container after binding * allow binding if container has no bound text * fix * move logic to show/hide bind actions to contextMenuPredicate * don't show bind action when clicking on bounding box and not elemnts
This commit is contained in:
parent
ceb43ed8fb
commit
625ecc64ed
9 changed files with 159 additions and 81 deletions
|
@ -27,6 +27,7 @@ import {
|
|||
actionToggleStats,
|
||||
actionToggleZenMode,
|
||||
actionUnbindText,
|
||||
actionBindText,
|
||||
actionUngroup,
|
||||
actionLink,
|
||||
} from "../actions";
|
||||
|
@ -5391,6 +5392,16 @@ class App extends React.Component<AppProps, AppState> {
|
|||
this.actionManager.getAppState(),
|
||||
);
|
||||
|
||||
const mayBeAllowUnbinding = actionUnbindText.contextItemPredicate(
|
||||
this.actionManager.getElementsIncludingDeleted(),
|
||||
this.actionManager.getAppState(),
|
||||
);
|
||||
|
||||
const mayBeAllowBinding = actionBindText.contextItemPredicate(
|
||||
this.actionManager.getElementsIncludingDeleted(),
|
||||
this.actionManager.getAppState(),
|
||||
);
|
||||
|
||||
const separator = "separator";
|
||||
|
||||
const elements = this.scene.getElements();
|
||||
|
@ -5467,10 +5478,6 @@ class App extends React.Component<AppProps, AppState> {
|
|||
});
|
||||
}
|
||||
} else if (type === "element") {
|
||||
const elementsWithUnbindedText = getSelectedElements(
|
||||
elements,
|
||||
this.state,
|
||||
).some((element) => !hasBoundTextElement(element));
|
||||
if (this.state.viewModeEnabled) {
|
||||
ContextMenu.push({
|
||||
options: [navigator.clipboard && actionCopy, ...options],
|
||||
|
@ -5504,7 +5511,8 @@ class App extends React.Component<AppProps, AppState> {
|
|||
actionPasteStyles,
|
||||
separator,
|
||||
maybeGroupAction && actionGroup,
|
||||
!elementsWithUnbindedText && actionUnbindText,
|
||||
mayBeAllowUnbinding && actionUnbindText,
|
||||
mayBeAllowBinding && actionBindText,
|
||||
maybeUngroupAction && actionUngroup,
|
||||
(maybeGroupAction || maybeUngroupAction) && separator,
|
||||
actionAddToLibrary,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue