feat:字体选择
This commit is contained in:
@@ -6,6 +6,7 @@ export class Command {
|
||||
private static redo: Function
|
||||
private static painter: Function
|
||||
private static format: Function
|
||||
private static font: Function
|
||||
private static sizeAdd: Function
|
||||
private static sizeMinus: Function
|
||||
private static bold: Function
|
||||
@@ -22,6 +23,7 @@ export class Command {
|
||||
Command.redo = adapt.redo.bind(adapt)
|
||||
Command.painter = adapt.painter.bind(adapt)
|
||||
Command.format = adapt.format.bind(adapt)
|
||||
Command.font = adapt.font.bind(adapt)
|
||||
Command.sizeAdd = adapt.sizeAdd.bind(adapt)
|
||||
Command.sizeMinus = adapt.sizeMinus.bind(adapt)
|
||||
Command.bold = adapt.bold.bind(adapt)
|
||||
@@ -51,7 +53,11 @@ export class Command {
|
||||
return Command.format()
|
||||
}
|
||||
|
||||
// 字体变大、字体变小、加粗、斜体、下划线、删除线、字体颜色、背景色
|
||||
// 字体、字体变大、字体变小、加粗、斜体、下划线、删除线、字体颜色、背景色
|
||||
public executeFont(payload: string) {
|
||||
return Command.font(payload)
|
||||
}
|
||||
|
||||
public executeSizeAdd() {
|
||||
return Command.sizeAdd()
|
||||
}
|
||||
|
||||
@@ -58,6 +58,15 @@ export class CommandAdapt {
|
||||
this.draw.render({ isSetCursor: false })
|
||||
}
|
||||
|
||||
public font(payload: string) {
|
||||
const selection = this.range.getSelection()
|
||||
if (!selection) return
|
||||
selection.forEach(el => {
|
||||
el.font = payload
|
||||
})
|
||||
this.draw.render({ isSetCursor: false })
|
||||
}
|
||||
|
||||
public sizeAdd() {
|
||||
const selection = this.range.getSelection()
|
||||
if (!selection) return
|
||||
|
||||
@@ -52,6 +52,7 @@ export class RangeManager {
|
||||
}
|
||||
const curElement = curElementList[curElementList.length - 1]
|
||||
// 富文本
|
||||
const font = curElement.font || this.options.defaultFont
|
||||
let bold = !~curElementList.findIndex(el => !el.bold)
|
||||
let italic = !~curElementList.findIndex(el => !el.italic)
|
||||
let underline = !~curElementList.findIndex(el => !el.underline)
|
||||
@@ -66,6 +67,7 @@ export class RangeManager {
|
||||
undo,
|
||||
redo,
|
||||
painter,
|
||||
font,
|
||||
bold,
|
||||
italic,
|
||||
underline,
|
||||
@@ -77,6 +79,7 @@ export class RangeManager {
|
||||
|
||||
public recoveryRangeStyle() {
|
||||
if (!this.listener.rangeStyleChange) return
|
||||
const font = this.options.defaultFont
|
||||
const painter = !!this.draw.getPainterStyle()
|
||||
const undo = this.historyManager.isCanUndo()
|
||||
const redo = this.historyManager.isCanRedo()
|
||||
@@ -84,6 +87,7 @@ export class RangeManager {
|
||||
undo,
|
||||
redo,
|
||||
painter,
|
||||
font,
|
||||
bold: false,
|
||||
italic: false,
|
||||
underline: false,
|
||||
|
||||
@@ -2,6 +2,7 @@ export interface IRangeStype {
|
||||
undo: boolean;
|
||||
redo: boolean;
|
||||
painter: boolean;
|
||||
font: string;
|
||||
bold: boolean;
|
||||
italic: boolean;
|
||||
underline: boolean;
|
||||
|
||||
Reference in New Issue
Block a user