fix:spell check
This commit is contained in:
@@ -205,23 +205,23 @@ export class Command {
|
||||
return Command.insertTableRightCol()
|
||||
}
|
||||
|
||||
public executDeleteTableRow() {
|
||||
public executeDeleteTableRow() {
|
||||
return Command.deleteTableRow()
|
||||
}
|
||||
|
||||
public executDeleteTableCol() {
|
||||
public executeDeleteTableCol() {
|
||||
return Command.deleteTableCol()
|
||||
}
|
||||
|
||||
public executDeleteTable() {
|
||||
public executeDeleteTable() {
|
||||
return Command.deleteTable()
|
||||
}
|
||||
|
||||
public executMergeTableCell() {
|
||||
public executeMergeTableCell() {
|
||||
return Command.mergeTableCell()
|
||||
}
|
||||
|
||||
public executCancelMergeTableCell() {
|
||||
public executeCancelMergeTableCell() {
|
||||
return Command.cancelMergeTableCell()
|
||||
}
|
||||
|
||||
|
||||
@@ -252,10 +252,10 @@ export class CommandAdapt {
|
||||
const elementList = this.draw.getElementList()
|
||||
// 当前选区所在行
|
||||
for (let p = 0; p < positionList.length; p++) {
|
||||
const postion = positionList[p]
|
||||
if (postion.pageNo !== pageNo) continue
|
||||
if (postion.rowNo > endRowNo) break
|
||||
if (postion.rowNo >= startRowNo && postion.rowNo <= endRowNo) {
|
||||
const position = positionList[p]
|
||||
if (position.pageNo !== pageNo) continue
|
||||
if (position.rowNo > endRowNo) break
|
||||
if (position.rowNo >= startRowNo && position.rowNo <= endRowNo) {
|
||||
elementList[p].rowFlex = payload
|
||||
}
|
||||
}
|
||||
@@ -276,10 +276,10 @@ export class CommandAdapt {
|
||||
const elementList = this.draw.getElementList()
|
||||
// 当前选区所在行
|
||||
for (let p = 0; p < positionList.length; p++) {
|
||||
const postion = positionList[p]
|
||||
if (postion.pageNo !== pageNo) continue
|
||||
if (postion.rowNo > endRowNo) break
|
||||
if (postion.rowNo >= startRowNo && postion.rowNo <= endRowNo) {
|
||||
const position = positionList[p]
|
||||
if (position.pageNo !== pageNo) continue
|
||||
if (position.rowNo > endRowNo) break
|
||||
if (position.rowNo >= startRowNo && position.rowNo <= endRowNo) {
|
||||
elementList[p].rowMargin = payload
|
||||
}
|
||||
}
|
||||
@@ -920,17 +920,17 @@ export class CommandAdapt {
|
||||
const originalElementList = this.draw.getOriginalElementList()
|
||||
const originalElementListLength = originalElementList.length
|
||||
// 查找表格所在位置
|
||||
const tabeleIndexList = []
|
||||
const tableIndexList = []
|
||||
for (let e = 0; e < originalElementListLength; e++) {
|
||||
const element = originalElementList[e]
|
||||
if (element.type === ElementType.TABLE) {
|
||||
tabeleIndexList.push(e)
|
||||
tableIndexList.push(e)
|
||||
}
|
||||
}
|
||||
let i = 0
|
||||
let elementIndex = 0
|
||||
while (elementIndex < originalElementListLength - 1) {
|
||||
const endIndex = tabeleIndexList.length ? tabeleIndexList[i] : originalElementListLength
|
||||
const endIndex = tableIndexList.length ? tableIndexList[i] : originalElementListLength
|
||||
const pageElement = originalElementList.slice(elementIndex, endIndex)
|
||||
if (pageElement.length) {
|
||||
elementListGroup.push({
|
||||
|
||||
@@ -11,7 +11,7 @@ interface IRenderPayload {
|
||||
contextMenuList: IRegisterContextMenu[];
|
||||
left: number;
|
||||
top: number;
|
||||
parentMenuConatiner?: HTMLDivElement;
|
||||
parentMenuContainer?: HTMLDivElement;
|
||||
}
|
||||
|
||||
export class ContextMenu {
|
||||
@@ -108,15 +108,15 @@ export class ContextMenu {
|
||||
}
|
||||
|
||||
private _render(payload: IRenderPayload): HTMLDivElement {
|
||||
const { contextMenuList, left, top, parentMenuConatiner } = payload
|
||||
const { contextMenuList, left, top, parentMenuContainer } = payload
|
||||
const contextMenuContainer = this._createContextMenuContainer()
|
||||
const contextMenuContent = document.createElement('div')
|
||||
contextMenuContent.classList.add('contextmenu-content')
|
||||
// 直接子菜单
|
||||
let childMenuContainer: HTMLDivElement | null = null
|
||||
// 父菜单添加子菜单映射关系
|
||||
if (parentMenuConatiner) {
|
||||
this.contextMenuRelationShip.set(parentMenuConatiner, contextMenuContainer)
|
||||
if (parentMenuContainer) {
|
||||
this.contextMenuRelationShip.set(parentMenuContainer, contextMenuContainer)
|
||||
}
|
||||
for (let c = 0; c < contextMenuList.length; c++) {
|
||||
const menu = contextMenuList[c]
|
||||
@@ -144,7 +144,7 @@ export class ContextMenu {
|
||||
contextMenuList: menu.childMenus!,
|
||||
left,
|
||||
top,
|
||||
parentMenuConatiner: contextMenuContainer
|
||||
parentMenuContainer: contextMenuContainer
|
||||
})
|
||||
}
|
||||
menuItem.onmouseleave = (evt) => {
|
||||
|
||||
@@ -58,7 +58,7 @@ export const tableMenus: IRegisterContextMenu[] = [
|
||||
icon: 'delete-row',
|
||||
when: () => true,
|
||||
callback: (command: Command) => {
|
||||
command.executDeleteTableRow()
|
||||
command.executeDeleteTableRow()
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -66,7 +66,7 @@ export const tableMenus: IRegisterContextMenu[] = [
|
||||
icon: 'delete-col',
|
||||
when: () => true,
|
||||
callback: (command: Command) => {
|
||||
command.executDeleteTableCol()
|
||||
command.executeDeleteTableCol()
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -74,7 +74,7 @@ export const tableMenus: IRegisterContextMenu[] = [
|
||||
icon: 'delete-table',
|
||||
when: () => true,
|
||||
callback: (command: Command) => {
|
||||
command.executDeleteTable()
|
||||
command.executeDeleteTable()
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -86,7 +86,7 @@ export const tableMenus: IRegisterContextMenu[] = [
|
||||
return payload.isCrossRowCol
|
||||
},
|
||||
callback: (command: Command) => {
|
||||
command.executMergeTableCell()
|
||||
command.executeMergeTableCell()
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -96,7 +96,7 @@ export const tableMenus: IRegisterContextMenu[] = [
|
||||
return payload.isInTable
|
||||
},
|
||||
callback: (command: Command) => {
|
||||
command.executCancelMergeTableCell()
|
||||
command.executeCancelMergeTableCell()
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -54,11 +54,11 @@ export class Cursor {
|
||||
// fillText位置 + 文字基线到底部距离 - 模拟光标偏移量
|
||||
const descent = metrics.boundingBoxDescent < 0 ? 0 : metrics.boundingBoxDescent
|
||||
const cursorTop = (leftTop[1] + ascent) + descent - (cursorHeight - offsetHeight) + preY
|
||||
const curosrleft = rightTop[0]
|
||||
agentCursorDom.style.left = `${curosrleft}px`
|
||||
const cursorLeft = rightTop[0]
|
||||
agentCursorDom.style.left = `${cursorLeft}px`
|
||||
agentCursorDom.style.top = `${cursorTop + cursorHeight - CURSOR_AGENT_HEIGHT * scale}px`
|
||||
// 模拟光标显示
|
||||
this.cursorDom.style.left = `${curosrleft}px`
|
||||
this.cursorDom.style.left = `${cursorLeft}px`
|
||||
this.cursorDom.style.top = `${cursorTop}px`
|
||||
this.cursorDom.style.display = 'block'
|
||||
this.cursorDom.style.height = `${cursorHeight}px`
|
||||
|
||||
@@ -238,28 +238,28 @@ export class CanvasEvent {
|
||||
const position = this.position.getPositionList()
|
||||
const { index } = cursorPosition
|
||||
const { startIndex, endIndex } = this.range.getRange()
|
||||
const isCollspace = startIndex === endIndex
|
||||
const isCollapsed = startIndex === endIndex
|
||||
if (evt.key === KeyMap.Backspace) {
|
||||
// 判断是否允许删除
|
||||
if (elementList[index].value === ZERO && index === 0) {
|
||||
evt.preventDefault()
|
||||
return
|
||||
}
|
||||
if (!isCollspace) {
|
||||
if (!isCollapsed) {
|
||||
elementList.splice(startIndex + 1, endIndex - startIndex)
|
||||
} else {
|
||||
elementList.splice(index, 1)
|
||||
}
|
||||
const curIndex = isCollspace ? index - 1 : startIndex
|
||||
const curIndex = isCollapsed ? index - 1 : startIndex
|
||||
this.range.setRange(curIndex, curIndex)
|
||||
this.draw.render({ curIndex })
|
||||
} else if (evt.key === KeyMap.Delete) {
|
||||
if (!isCollspace) {
|
||||
if (!isCollapsed) {
|
||||
elementList.splice(startIndex + 1, endIndex - startIndex)
|
||||
} else {
|
||||
elementList.splice(index + 1, 1)
|
||||
}
|
||||
const curIndex = isCollspace ? index : startIndex
|
||||
const curIndex = isCollapsed ? index : startIndex
|
||||
this.range.setRange(curIndex, curIndex)
|
||||
this.draw.render({ curIndex })
|
||||
} else if (evt.key === KeyMap.Enter) {
|
||||
@@ -274,7 +274,7 @@ export class CanvasEvent {
|
||||
value: ZERO,
|
||||
...restArg
|
||||
}
|
||||
if (isCollspace) {
|
||||
if (isCollapsed) {
|
||||
elementList.splice(index + 1, 0, enterText)
|
||||
} else {
|
||||
elementList.splice(startIndex + 1, endIndex - startIndex, enterText)
|
||||
@@ -375,7 +375,7 @@ export class CanvasEvent {
|
||||
agentDom.value = ''
|
||||
const { index } = cursorPosition
|
||||
const { startIndex, endIndex } = this.range.getRange()
|
||||
const isCollspace = startIndex === endIndex
|
||||
const isCollapsed = startIndex === endIndex
|
||||
// 表格需要上下文信息
|
||||
const positionContext = this.position.getPositionContext()
|
||||
let restArg = {}
|
||||
@@ -407,7 +407,7 @@ export class CanvasEvent {
|
||||
return newElement
|
||||
})
|
||||
let start = 0
|
||||
if (isCollspace) {
|
||||
if (isCollapsed) {
|
||||
start = index + 1
|
||||
} else {
|
||||
start = startIndex + 1
|
||||
@@ -417,7 +417,7 @@ export class CanvasEvent {
|
||||
for (let i = 0; i < inputData.length; i++) {
|
||||
elementList.splice(start + i, 0, inputData[i])
|
||||
}
|
||||
const curIndex = (isCollspace ? index : startIndex) + inputData.length
|
||||
const curIndex = (isCollapsed ? index : startIndex) + inputData.length
|
||||
this.range.setRange(curIndex, curIndex)
|
||||
this.draw.render({ curIndex })
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ export class Position {
|
||||
if (curPageNo !== pageNo) continue
|
||||
// 命中元素
|
||||
if (leftTop[0] <= x && rightTop[0] >= x && leftTop[1] <= y && leftBottom[1] >= y) {
|
||||
let curPostionIndex = j
|
||||
let curPositionIndex = j
|
||||
const element = elementList[j]
|
||||
// 表格被命中
|
||||
if (element.type === ElementType.TABLE) {
|
||||
@@ -110,21 +110,21 @@ export class Position {
|
||||
}
|
||||
// 图片区域均为命中
|
||||
if (element.type === ElementType.IMAGE) {
|
||||
return { index: curPostionIndex, isDirectHit: true, isImage: true }
|
||||
return { index: curPositionIndex, isDirectHit: true, isImage: true }
|
||||
}
|
||||
// 判断是否在文字中间前后
|
||||
if (elementList[index].value !== ZERO) {
|
||||
const valueWidth = rightTop[0] - leftTop[0]
|
||||
if (x < leftTop[0] + valueWidth / 2) {
|
||||
curPostionIndex = j - 1
|
||||
curPositionIndex = j - 1
|
||||
}
|
||||
}
|
||||
return { index: curPostionIndex }
|
||||
return { index: curPositionIndex }
|
||||
}
|
||||
}
|
||||
// 非命中区域
|
||||
let isLastArea = false
|
||||
let curPostionIndex = -1
|
||||
let curPositionIndex = -1
|
||||
// 判断是否在表格内
|
||||
if (isTable) {
|
||||
const { td, tablePosition } = payload
|
||||
@@ -135,7 +135,7 @@ export class Position {
|
||||
const tdWidth = td.width!
|
||||
const tdHeight = td.height!
|
||||
if (!(tdX < x && x < tdX + tdWidth && tdY < y && y < tdY + tdHeight)) {
|
||||
return { index: curPostionIndex }
|
||||
return { index: curPositionIndex }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,9 +149,9 @@ export class Position {
|
||||
// 是否在头部
|
||||
if (isHead) {
|
||||
const headIndex = positionList.findIndex(p => p.rowNo === firstLetterList[j].rowNo)
|
||||
curPostionIndex = ~headIndex ? headIndex : index
|
||||
curPositionIndex = ~headIndex ? headIndex : index
|
||||
} else {
|
||||
curPostionIndex = index
|
||||
curPositionIndex = index
|
||||
}
|
||||
isLastArea = true
|
||||
break
|
||||
@@ -161,7 +161,7 @@ export class Position {
|
||||
// 当前页最后一行
|
||||
return { index: firstLetterList[firstLetterList.length - 1]?.index || positionList.length - 1 }
|
||||
}
|
||||
return { index: curPostionIndex }
|
||||
return { index: curPositionIndex }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@ export interface IEditorOption {
|
||||
resizerSize?: number;
|
||||
marginIndicatorSize?: number;
|
||||
marginIndicatorColor?: string,
|
||||
margins?: [top: number, right: number, bootom: number, left: number],
|
||||
margins?: [top: number, right: number, bottom: number, left: number],
|
||||
tdPadding?: number;
|
||||
defaultTdHeight?: number;
|
||||
defaultHyperlinkColor?: string;
|
||||
@@ -38,6 +38,6 @@ export interface IEditorResult {
|
||||
version: string;
|
||||
width: number;
|
||||
height: number;
|
||||
margins: [top: number, right: number, bootom: number, left: number];
|
||||
margins: [top: number, right: number, bottom: number, left: number];
|
||||
data: IElement[];
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { ElementType } from ".."
|
||||
import { RowFlex } from "../dataset/enum/Row"
|
||||
import { IEditorResult } from "./Editor"
|
||||
|
||||
export interface IRangeStype {
|
||||
export interface IRangeStyle {
|
||||
type: ElementType | null;
|
||||
undo: boolean;
|
||||
redo: boolean;
|
||||
@@ -18,7 +18,7 @@ export interface IRangeStype {
|
||||
rowMargin: number;
|
||||
}
|
||||
|
||||
export type IRangeStyleChange = (payload: IRangeStype) => void
|
||||
export type IRangeStyleChange = (payload: IRangeStyle) => void
|
||||
|
||||
export type IVisiblePageNoListChange = (payload: number[]) => void
|
||||
|
||||
|
||||
Reference in New Issue
Block a user