mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-10 14:35:56 +09:00
prevent editing text inside of a component that is not text editable
This commit is contained in:
1 parent
d078ab2b91
commit
2cddf59606
2 files changed
+9
-1
No files matched your search
@@ -8,6 +8,7 @@ import {
|
||||
useRootInstance,
|
||||
useTextEditingInstanceId,
|
||||
} from "~/shared/nano-states";
|
||||
import { primitives } from "~/shared/canvas-components";
|
||||
|
||||
const inputTags = ["INPUT", "SELECT", "TEXTAREA"] as const;
|
||||
|
||||
@@ -99,6 +100,8 @@ export const useShortcuts = () => {
|
||||
"enter",
|
||||
(event) => {
|
||||
if (selectedInstance === undefined) return;
|
||||
const { isContentEditable } = primitives[selectedInstance.component];
|
||||
if (isContentEditable === false) return;
|
||||
// Prevents inserting a newline when entering text-editing mode
|
||||
event.preventDefault();
|
||||
setEditingInstanceId(selectedInstance.id);
|
||||
|
||||
@@ -86,7 +86,12 @@ export const useTrackSelectedElement = () => {
|
||||
if (component === undefined || component in primitives === false) {
|
||||
return;
|
||||
}
|
||||
const { isInlineOnly } = primitives[component];
|
||||
const { isInlineOnly, isContentEditable } = primitives[component];
|
||||
|
||||
if (isContentEditable === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
// When user double clicks on an inline instance, we need to select the parent instance and put it indo text editing mode.
|
||||
// Inline instances are not directly, only through parent instance.
|
||||
if (isInlineOnly) {
|
||||
|
||||
Reference in new issue
Block a user