Separate embeddable action

This commit is contained in:
Marcel Mraz 2025-03-13 13:40:25 +01:00
parent 54f5c0e156
commit ee66433a31
No known key found for this signature in database
GPG key ID: 4EBD6E62DC830CD2
3 changed files with 36 additions and 32 deletions

View file

@ -1,8 +1,5 @@
import { register } from "../actions/register";
import { FONT_FAMILY, VERTICAL_ALIGN } from "../constants";
import { setCursorForShape } from "../cursor";
import { CaptureUpdateAction } from "../store";
import { escapeDoubleQuotes, getFontString, updateActiveTool } from "../utils";
import { escapeDoubleQuotes, getFontString } from "../utils";
import { newTextElement } from "./newElement";
import { wrapText } from "./textWrapping";
@ -319,34 +316,6 @@ export const createPlaceholderEmbeddableLabel = (
});
};
export const actionSetEmbeddableAsActiveTool = register({
name: "setEmbeddableAsActiveTool",
trackEvent: { category: "toolbar" },
target: "Tool",
label: "toolBar.embeddable",
perform: (elements, appState, _, app) => {
const nextActiveTool = updateActiveTool(appState, {
type: "embeddable",
});
setCursorForShape(app.canvas, {
...appState,
activeTool: nextActiveTool,
});
return {
elements,
appState: {
...appState,
activeTool: updateActiveTool(appState, {
type: "embeddable",
}),
},
captureUpdate: CaptureUpdateAction.EVENTUALLY,
};
},
});
const matchHostname = (
url: string,
/** using a Set assumes it already contains normalized bare domains */

View file

@ -0,0 +1,33 @@
import { setCursorForShape } from "../cursor";
import { CaptureUpdateAction } from "../store";
import { updateActiveTool } from "../utils";
import { register } from "./register";
export const actionSetEmbeddableAsActiveTool = register({
name: "setEmbeddableAsActiveTool",
trackEvent: { category: "toolbar" },
target: "Tool",
label: "toolBar.embeddable",
perform: (elements, appState, _, app) => {
const nextActiveTool = updateActiveTool(appState, {
type: "embeddable",
});
setCursorForShape(app.canvas, {
...appState,
activeTool: nextActiveTool,
});
return {
elements,
appState: {
...appState,
activeTool: updateActiveTool(appState, {
type: "embeddable",
}),
},
captureUpdate: CaptureUpdateAction.EVENTUALLY,
};
},
});

View file

@ -30,6 +30,8 @@ export {
actionToggleTheme,
} from "./actionCanvas";
export { actionSetEmbeddableAsActiveTool } from "./actionEmbeddable";
export { actionFinalize } from "./actionFinalize";
export {