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