添加画布粘贴外部文字和图片

This commit is contained in:
李志鹏
2025-11-11 17:35:00 +08:00
parent 9c6dd126e0
commit e5fc07e5e3
9 changed files with 84 additions and 19 deletions

View File

@@ -321,6 +321,7 @@ export class CreateTextCommand extends Command {
this.x = options.x;
this.y = options.y;
this.textOptions = options.textOptions || {};
this.options = options;
// 生成唯一ID
this.textId = options?.textId || generateId("text_");
this.layerId = options?.layerId || generateId("text_layer_");
@@ -331,7 +332,7 @@ export class CreateTextCommand extends Command {
// 默认文本属性
this.defaultOptions = {
text: t('Canvas.DoubleClickText'),
text: options.text || t('Canvas.DoubleClickText'),
fontFamily: "Arial",
fontSize: 24,
fontWeight: "normal",
@@ -373,8 +374,8 @@ export class CreateTextCommand extends Command {
originY: "center",
});
// 创建文本图层
const layerName = this.textOptions.layerName || "文本图层";
// 创建文本图层 取15
const layerName = this.options.text?.substring(0, 25) || t('Canvas.TextLayer');
const layer = createLayer({
id: this.layerId,
name: layerName,