添加字体设置菜单

This commit is contained in:
麦香缘
2025-02-18 11:24:31 +08:00
parent 7c78fb9e1a
commit 3a35cc45a5
10 changed files with 523 additions and 2 deletions
+31
View File
@@ -7,11 +7,17 @@ import { UAIEditorEventListener, UAIEditorOptions } from "../../../core/UAIEdito
import menuIcon from "../../../assets/icons/menu.svg";
import { ScrollableDiv } from "./ScrollableDiv";
import { FontSizeIncrease } from "../common/FontSizeIncrease.ts";
import { FontSizeDecrease } from "../common/FontSizeDecrease.ts";
import { Redo } from "./base/Redo";
import { Undo } from "./base/Undo";
import { FormatPainter } from "./base/FormatPainter";
import { ClearFormat } from "./base/ClearFormat";
import { FontFamily } from "./base/FontFamily";
import { FontSize } from "./base/FontSize";
/**
* 传统菜单栏
*/
@@ -33,6 +39,11 @@ export class Classic extends HTMLElement implements UAIEditorEventListener {
baseMenuFormatPainter!: FormatPainter;
baseMenuClearFormat!: ClearFormat;
baseMenuFontFamily!: FontFamily;
baseMenuFontSize!: FontSize;
baseMenuFontSizeIncrease!: FontSizeIncrease;
baseMenuFontSizeDecrease!: FontSizeDecrease;
constructor(defaultToolbarMenus: Record<string, any>[]) {
super();
this.defaultToolbarMenus = defaultToolbarMenus;
@@ -118,6 +129,18 @@ export class Classic extends HTMLElement implements UAIEditorEventListener {
this.baseMenuClearFormat = new ClearFormat({ menuType: "button", enable: true });
this.eventComponents.push(this.baseMenuClearFormat);
this.baseMenuFontFamily = new FontFamily({ menuType: "select", enable: true });
this.eventComponents.push(this.baseMenuFontFamily);
this.baseMenuFontSize = new FontSize({ menuType: "select", enable: true });
this.eventComponents.push(this.baseMenuFontSize);
this.baseMenuFontSizeIncrease = new FontSizeIncrease({ menuType: "button", enable: true });
this.eventComponents.push(this.baseMenuFontSizeIncrease);
this.baseMenuFontSizeDecrease = new FontSizeDecrease({ menuType: "button", enable: true });
this.eventComponents.push(this.baseMenuFontSizeDecrease);
}
/**
* 创建基础菜单
@@ -139,5 +162,13 @@ export class Classic extends HTMLElement implements UAIEditorEventListener {
group1.appendChild(this.baseMenuRedo);
group1.appendChild(this.baseMenuFormatPainter);
group1.appendChild(this.baseMenuClearFormat);
const group2 = document.createElement("div");
group2.classList.add("uai-classic-virtual-group");
this.classicMenuBaseGroup.appendChild(group2);
group2.appendChild(this.baseMenuFontFamily);
group2.appendChild(this.baseMenuFontSize);
group2.appendChild(this.baseMenuFontSizeIncrease);
group2.appendChild(this.baseMenuFontSizeDecrease);
}
}