feat:add eslint and fix

This commit is contained in:
黄云飞
2022-03-22 14:48:10 +08:00
parent 764fd8bbad
commit c49b7b5978
59 changed files with 1117 additions and 317 deletions
+7 -6
View File
@@ -1,9 +1,10 @@
import { IElement } from "../.."
import { EditorMode } from "../../dataset/enum/Editor"
import { RowFlex } from "../../dataset/enum/Row"
import { IDrawImagePayload } from "../../interface/Draw"
import { IWatermark } from "../../interface/Watermark"
import { CommandAdapt } from "./CommandAdapt"
import { IElement } from '../..'
import { EditorMode } from '../../dataset/enum/Editor'
import { RowFlex } from '../../dataset/enum/Row'
import { IDrawImagePayload } from '../../interface/Draw'
import { IWatermark } from '../../interface/Watermark'
import { CommandAdapt } from './CommandAdapt'
export class Command {
+27 -26
View File
@@ -1,26 +1,27 @@
import { WRAP, ZERO } from "../../dataset/constant/Common"
import { EDITOR_ELEMENT_STYLE_ATTR } from "../../dataset/constant/Element"
import { defaultWatermarkOption } from "../../dataset/constant/Watermark"
import { EditorContext, EditorMode } from "../../dataset/enum/Editor"
import { ElementType } from "../../dataset/enum/Element"
import { ElementStyleKey } from "../../dataset/enum/ElementStyle"
import { RowFlex } from "../../dataset/enum/Row"
import { IDrawImagePayload } from "../../interface/Draw"
import { IEditorOption } from "../../interface/Editor"
import { IElement, IElementStyle } from "../../interface/Element"
import { IColgroup } from "../../interface/table/Colgroup"
import { ITd } from "../../interface/table/Td"
import { ITr } from "../../interface/table/Tr"
import { IWatermark } from "../../interface/Watermark"
import { getUUID } from "../../utils"
import { formatElementList } from "../../utils/element"
import { printImageBase64 } from "../../utils/print"
import { Draw } from "../draw/Draw"
import { TableTool } from "../draw/particle/table/TableTool"
import { CanvasEvent } from "../event/CanvasEvent"
import { HistoryManager } from "../history/HistoryManager"
import { Position } from "../position/Position"
import { RangeManager } from "../range/RangeManager"
import { WRAP, ZERO } from '../../dataset/constant/Common'
import { EDITOR_ELEMENT_STYLE_ATTR } from '../../dataset/constant/Element'
import { defaultWatermarkOption } from '../../dataset/constant/Watermark'
import { EditorContext, EditorMode } from '../../dataset/enum/Editor'
import { ElementType } from '../../dataset/enum/Element'
import { ElementStyleKey } from '../../dataset/enum/ElementStyle'
import { RowFlex } from '../../dataset/enum/Row'
import { IDrawImagePayload } from '../../interface/Draw'
import { IEditorOption } from '../../interface/Editor'
import { IElement, IElementStyle } from '../../interface/Element'
import { IColgroup } from '../../interface/table/Colgroup'
import { ITd } from '../../interface/table/Td'
import { ITr } from '../../interface/table/Tr'
import { IWatermark } from '../../interface/Watermark'
import { getUUID } from '../../utils'
import { formatElementList } from '../../utils/element'
import { printImageBase64 } from '../../utils/print'
import { Draw } from '../draw/Draw'
import { TableTool } from '../draw/particle/table/TableTool'
import { CanvasEvent } from '../event/CanvasEvent'
import { HistoryManager } from '../history/HistoryManager'
import { Position } from '../position/Position'
import { RangeManager } from '../range/RangeManager'
export class CommandAdapt {
@@ -822,7 +823,7 @@ export class CommandAdapt {
const startRowIndex = startTd.rowIndex!
const endRowIndex = endTd.rowIndex! + (endTd.rowspan - 1)
// 选区行列
let rowCol: ITd[][] = []
const rowCol: ITd[][] = []
for (let t = 0; t < curTrList.length; t++) {
const tr = curTrList[t]
const tdList: ITd[] = []
@@ -865,7 +866,7 @@ export class CommandAdapt {
}
}
// 合并单元格
let mergeTdIdList: string[] = []
const mergeTdIdList: string[] = []
const anchorTd = rowCol[0][0]
for (let t = 0; t < rowCol.length; t++) {
const tr = rowCol[t]
@@ -1234,7 +1235,7 @@ export class CommandAdapt {
formatElementList(payload, false)
const elementList = this.draw.getElementList()
const isCollapsed = startIndex === endIndex
let start = startIndex + 1
const start = startIndex + 1
if (!isCollapsed) {
elementList.splice(start, endIndex - startIndex)
}
+9 -9
View File
@@ -1,11 +1,11 @@
import { EDITOR_COMPONENT } from "../../dataset/constant/Editor"
import { EditorComponent } from "../../dataset/enum/Editor"
import { IContextMenuContext, IRegisterContextMenu } from "../../interface/contextmenu/ContextMenu"
import { findParent } from "../../utils"
import { Command } from "../command/Command"
import { Draw } from "../draw/Draw"
import { Position } from "../position/Position"
import { RangeManager } from "../range/RangeManager"
import { EDITOR_COMPONENT } from '../../dataset/constant/Editor'
import { EditorComponent } from '../../dataset/enum/Editor'
import { IContextMenuContext, IRegisterContextMenu } from '../../interface/contextmenu/ContextMenu'
import { findParent } from '../../utils'
import { Command } from '../command/Command'
import { Draw } from '../draw/Draw'
import { Position } from '../position/Position'
import { RangeManager } from '../range/RangeManager'
interface IRenderPayload {
contextMenuList: IRegisterContextMenu[];
@@ -42,7 +42,7 @@ export class ContextMenu {
private _proxyContextMenuEvent(evt: MouseEvent) {
const context = this._getContext()
let renderList: IRegisterContextMenu[] = []
const renderList: IRegisterContextMenu[] = []
let isRegisterContextMenu = false
for (let c = 0; c < this.contextMenuList.length; c++) {
const menu = this.contextMenuList[c]
@@ -1,5 +1,5 @@
import { IRegisterContextMenu } from "../../../interface/contextmenu/ContextMenu"
import { Command } from "../../command/Command"
import { IRegisterContextMenu } from '../../../interface/contextmenu/ContextMenu'
import { Command } from '../../command/Command'
export const globalMenus: IRegisterContextMenu[] = [
{
@@ -1,5 +1,5 @@
import { IRegisterContextMenu } from "../../../interface/contextmenu/ContextMenu"
import { Command } from "../../command/Command"
import { IRegisterContextMenu } from '../../../interface/contextmenu/ContextMenu'
import { Command } from '../../command/Command'
export const tableMenus: IRegisterContextMenu[] = [
{
+6 -6
View File
@@ -1,9 +1,9 @@
import { CURSOR_AGENT_HEIGHT } from "../../dataset/constant/Cursor"
import { IEditorOption } from "../../interface/Editor"
import { Draw } from "../draw/Draw"
import { CanvasEvent } from "../event/CanvasEvent"
import { Position } from "../position/Position"
import { CursorAgent } from "./CursorAgent"
import { CURSOR_AGENT_HEIGHT } from '../../dataset/constant/Cursor'
import { IEditorOption } from '../../interface/Editor'
import { Draw } from '../draw/Draw'
import { CanvasEvent } from '../event/CanvasEvent'
import { Position } from '../position/Position'
import { CursorAgent } from './CursorAgent'
export class Cursor {
+3 -3
View File
@@ -1,6 +1,6 @@
import { debounce } from "../../utils"
import { Draw } from "../draw/Draw"
import { CanvasEvent } from "../event/CanvasEvent"
import { debounce } from '../../utils'
import { Draw } from '../draw/Draw'
import { CanvasEvent } from '../event/CanvasEvent'
export class CursorAgent {
+42 -42
View File
@@ -1,38 +1,38 @@
import { ZERO } from "../../dataset/constant/Common"
import { RowFlex } from "../../dataset/enum/Row"
import { IDrawOption, IDrawRowPayload, IDrawRowResult } from "../../interface/Draw"
import { IEditorOption } from "../../interface/Editor"
import { IElement, IElementMetrics, IElementPosition, IElementFillRect, IElementStyle } from "../../interface/Element"
import { IRow, IRowElement } from "../../interface/Row"
import { deepClone, getUUID } from "../../utils"
import { Cursor } from "../cursor/Cursor"
import { CanvasEvent } from "../event/CanvasEvent"
import { GlobalEvent } from "../event/GlobalEvent"
import { HistoryManager } from "../history/HistoryManager"
import { Listener } from "../listener/Listener"
import { Position } from "../position/Position"
import { RangeManager } from "../range/RangeManager"
import { Background } from "./frame/Background"
import { Highlight } from "./richtext/Highlight"
import { Margin } from "./frame/Margin"
import { Search } from "./interactive/Search"
import { Strikeout } from "./richtext/Strikeout"
import { Underline } from "./richtext/Underline"
import { ElementType } from "../../dataset/enum/Element"
import { ImageParticle } from "./particle/ImageParticle"
import { TextParticle } from "./particle/TextParticle"
import { PageNumber } from "./frame/PageNumber"
import { GlobalObserver } from "../observer/GlobalObserver"
import { TableParticle } from "./particle/table/TableParticle"
import { TableTool } from "./particle/table/TableTool"
import { HyperlinkParticle } from "./particle/HyperlinkParticle"
import { Header } from "./frame/Header"
import { SuperscriptParticle } from "./particle/Superscript"
import { SubscriptParticle } from "./particle/Subscript"
import { SeparatorParticle } from "./particle/Separator"
import { PageBreakParticle } from "./particle/PageBreak"
import { Watermark } from "./frame/Watermark"
import { EditorMode } from "../../dataset/enum/Editor"
import { ZERO } from '../../dataset/constant/Common'
import { RowFlex } from '../../dataset/enum/Row'
import { IDrawOption, IDrawRowPayload, IDrawRowResult } from '../../interface/Draw'
import { IEditorOption } from '../../interface/Editor'
import { IElement, IElementMetrics, IElementPosition, IElementFillRect, IElementStyle } from '../../interface/Element'
import { IRow, IRowElement } from '../../interface/Row'
import { deepClone, getUUID } from '../../utils'
import { Cursor } from '../cursor/Cursor'
import { CanvasEvent } from '../event/CanvasEvent'
import { GlobalEvent } from '../event/GlobalEvent'
import { HistoryManager } from '../history/HistoryManager'
import { Listener } from '../listener/Listener'
import { Position } from '../position/Position'
import { RangeManager } from '../range/RangeManager'
import { Background } from './frame/Background'
import { Highlight } from './richtext/Highlight'
import { Margin } from './frame/Margin'
import { Search } from './interactive/Search'
import { Strikeout } from './richtext/Strikeout'
import { Underline } from './richtext/Underline'
import { ElementType } from '../../dataset/enum/Element'
import { ImageParticle } from './particle/ImageParticle'
import { TextParticle } from './particle/TextParticle'
import { PageNumber } from './frame/PageNumber'
import { GlobalObserver } from '../observer/GlobalObserver'
import { TableParticle } from './particle/table/TableParticle'
import { TableTool } from './particle/table/TableTool'
import { HyperlinkParticle } from './particle/HyperlinkParticle'
import { Header } from './frame/Header'
import { SuperscriptParticle } from './particle/Superscript'
import { SubscriptParticle } from './particle/Subscript'
import { SeparatorParticle } from './particle/Separator'
import { PageBreakParticle } from './particle/PageBreak'
import { Watermark } from './frame/Watermark'
import { EditorMode } from '../../dataset/enum/Editor'
export class Draw {
@@ -383,7 +383,7 @@ export class Draw {
this.ctxList.push(ctx)
}
private _getFont(el: IElement, scale: number = 1): string {
private _getFont(el: IElement, scale = 1): string {
const { defaultSize, defaultFont } = this.options
const font = el.font || defaultFont
const size = el.actualSize || el.size || defaultSize
@@ -410,7 +410,7 @@ export class Draw {
const curRow: IRow = rowList[rowList.length - 1]
const element = elementList[i]
const rowMargin = defaultBasicRowMarginHeight * (element.rowMargin || defaultRowMargin)
let metrics: IElementMetrics = {
const metrics: IElementMetrics = {
width: 0,
height: 0,
boundingBoxAscent: 0,
@@ -612,8 +612,8 @@ export class Draw {
}
}
// 当前td所在位置
let tablePreX = x
let tablePreY = y
const tablePreX = x
const tablePreY = y
// 选区绘制记录
const rangeRecord: IElementFillRect = {
x: 0,
@@ -794,12 +794,12 @@ export class Draw {
}
public render(payload?: IDrawOption) {
let {
curIndex,
const {
isSubmitHistory = true,
isSetCursor = true,
isComputeRowList = true
} = payload || {}
let { curIndex } = payload || {}
const height = this.getHeight()
const innerWidth = this.getInnerWidth()
// 计算行信息
@@ -818,7 +818,7 @@ export class Draw {
const marginHeight = margins[0] + margins[2]
let pageHeight = marginHeight
let pageNo = 0
let pageRowList: IRow[][] = [[]]
const pageRowList: IRow[][] = [[]]
for (let i = 0; i < this.rowList.length; i++) {
const row = this.rowList[i]
if (row.height + pageHeight > height || this.rowList[i - 1]?.isPageBreak) {
+2 -2
View File
@@ -1,5 +1,5 @@
import { IEditorOption } from "../../../interface/Editor"
import { Draw } from "../Draw"
import { IEditorOption } from '../../../interface/Editor'
import { Draw } from '../Draw'
export class Background {
+3 -3
View File
@@ -1,6 +1,6 @@
import { DeepRequired } from "../../../interface/Common"
import { IEditorOption } from "../../../interface/Editor"
import { Draw } from "../Draw"
import { DeepRequired } from '../../../interface/Common'
import { IEditorOption } from '../../../interface/Editor'
import { Draw } from '../Draw'
export class Header {
+2 -2
View File
@@ -1,5 +1,5 @@
import { IEditorOption } from "../../../interface/Editor"
import { Draw } from "../Draw"
import { IEditorOption } from '../../../interface/Editor'
import { Draw } from '../Draw'
export class Margin {
+2 -2
View File
@@ -1,5 +1,5 @@
import { IEditorOption } from "../../../interface/Editor"
import { Draw } from "../Draw"
import { IEditorOption } from '../../../interface/Editor'
import { Draw } from '../Draw'
export class PageNumber {
+3 -3
View File
@@ -1,6 +1,6 @@
import { IEditorOption } from "../../.."
import { DeepRequired } from "../../../interface/Common"
import { Draw } from "../Draw"
import { IEditorOption } from '../../..'
import { DeepRequired } from '../../../interface/Common'
import { Draw } from '../Draw'
export class Watermark {
+12 -12
View File
@@ -1,13 +1,13 @@
import { ZERO } from "../../../dataset/constant/Common"
import { TEXTLIKE_ELEMENT_TYPE } from "../../../dataset/constant/Element"
import { EditorContext } from "../../../dataset/enum/Editor"
import { ElementType } from "../../../dataset/enum/Element"
import { IEditorOption } from "../../../interface/Editor"
import { IElement, IElementPosition } from "../../../interface/Element"
import { ISearchResult, ISearchResultRestArgs } from "../../../interface/Search"
import { getUUID } from "../../../utils"
import { Position } from "../../position/Position"
import { Draw } from "../Draw"
import { ZERO } from '../../../dataset/constant/Common'
import { TEXTLIKE_ELEMENT_TYPE } from '../../../dataset/constant/Element'
import { EditorContext } from '../../../dataset/enum/Editor'
import { ElementType } from '../../../dataset/enum/Element'
import { IEditorOption } from '../../../interface/Editor'
import { IElement, IElementPosition } from '../../../interface/Element'
import { ISearchResult, ISearchResultRestArgs } from '../../../interface/Search'
import { getUUID } from '../../../utils'
import { Position } from '../../position/Position'
import { Draw } from '../Draw'
export class Search {
@@ -28,7 +28,7 @@ export class Search {
}
public compute(payload: string) {
let searchMatchList: ISearchResult[] = []
const searchMatchList: ISearchResult[] = []
// 分组
const elementListGroup: { type: EditorContext, elementList: IElement[], index: number }[] = []
const originalElementList = this.draw.getOriginalElementList()
@@ -129,7 +129,7 @@ export class Search {
let position: IElementPosition | null = null
if (searchMatch.type === EditorContext.TABLE) {
const { tableIndex, trIndex, tdIndex, index } = searchMatch
position = elementList[tableIndex!]?.trList![trIndex!].tdList[tdIndex!]!?.positionList![index]
position = elementList[tableIndex!]?.trList![trIndex!].tdList[tdIndex!]?.positionList![index]
} else {
position = positionList[searchMatch.index]
}
@@ -1,8 +1,8 @@
import { IElement } from "../../.."
import { IEditorOption } from "../../../interface/Editor"
import { IElementPosition } from "../../../interface/Element"
import { IRowElement } from "../../../interface/Row"
import { Draw } from "../Draw"
import { IElement } from '../../..'
import { IEditorOption } from '../../../interface/Editor'
import { IElementPosition } from '../../../interface/Element'
import { IRowElement } from '../../../interface/Row'
import { Draw } from '../Draw'
export class HyperlinkParticle {
@@ -1,7 +1,7 @@
import { IImageParticleCreateResult } from "../../../interface/Draw"
import { IEditorOption } from "../../../interface/Editor"
import { IElement, IElementPosition } from "../../../interface/Element"
import { Draw } from "../Draw"
import { IImageParticleCreateResult } from '../../../interface/Draw'
import { IEditorOption } from '../../../interface/Editor'
import { IElement, IElementPosition } from '../../../interface/Element'
import { Draw } from '../Draw'
export class ImageParticle {
@@ -93,7 +93,7 @@ export class ImageParticle {
document.body.style.cursor = cursor
this.canvas.style.cursor = cursor
// 拖拽图片镜像
this.resizerImage.src = this.curElement?.value!
this.resizerImage.src = this.curElement?.value || ''
this.resizerImageContainer.style.display = 'block'
const { coordinate: { leftTop: [left, top] } } = this.curPosition
const prePageHeight = this.draw.getPageNo() * (height + pageGap)
+3 -3
View File
@@ -1,6 +1,6 @@
import { IEditorOption } from "../../../interface/Editor"
import { IRowElement } from "../../../interface/Row"
import { Draw } from "../Draw"
import { IEditorOption } from '../../../interface/Editor'
import { IRowElement } from '../../../interface/Row'
import { Draw } from '../Draw'
export class PageBreakParticle {
+1 -1
View File
@@ -1,4 +1,4 @@
import { IRowElement } from "../../../interface/Row"
import { IRowElement } from '../../../interface/Row'
export class SeparatorParticle {
public render(ctx: CanvasRenderingContext2D, element: IRowElement, x: number, y: number) {
+1 -1
View File
@@ -1,4 +1,4 @@
import { IRowElement } from "../../../interface/Row"
import { IRowElement } from '../../../interface/Row'
export class SubscriptParticle {
+1 -1
View File
@@ -1,4 +1,4 @@
import { IRowElement } from "../../../interface/Row"
import { IRowElement } from '../../../interface/Row'
export class SuperscriptParticle {
@@ -1,6 +1,6 @@
import { IElement } from "../../.."
import { IRowElement } from "../../../interface/Row"
import { Draw } from "../Draw"
import { IElement } from '../../..'
import { IRowElement } from '../../../interface/Row'
import { Draw } from '../Draw'
export class TextParticle {
@@ -1,7 +1,7 @@
import { ElementType, IElement } from "../../../.."
import { IEditorOption } from "../../../../interface/Editor"
import { RangeManager } from "../../../range/RangeManager"
import { Draw } from "../../Draw"
import { ElementType, IElement } from '../../../..'
import { IEditorOption } from '../../../../interface/Editor'
import { RangeManager } from '../../../range/RangeManager'
import { Draw } from '../../Draw'
export class TableParticle {
@@ -1,9 +1,9 @@
import { IElement } from "../../../.."
import { TableOrder } from "../../../../dataset/enum/table/TableTool"
import { IEditorOption } from "../../../../interface/Editor"
import { IElementPosition } from "../../../../interface/Element"
import { Position } from "../../../position/Position"
import { Draw } from "../../Draw"
import { IElement } from '../../../..'
import { TableOrder } from '../../../../dataset/enum/table/TableTool'
import { IEditorOption } from '../../../../interface/Editor'
import { IElementPosition } from '../../../../interface/Element'
import { Position } from '../../../position/Position'
import { Draw } from '../../Draw'
interface IAnchorMouseDown {
evt: MouseEvent;
@@ -188,7 +188,7 @@ export class TableTool {
const innerWidth = this.draw.getInnerWidth()
const curColWidth = colgroup[index].width
// 最小移动距离计算
let moveColWidth = curColWidth + dx
const moveColWidth = curColWidth + dx
if (moveColWidth < this.minTdWidth) {
dx = this.minTdWidth - curColWidth
}
+2 -2
View File
@@ -1,5 +1,5 @@
import { IEditorOption } from "../../../interface/Editor"
import { Draw } from "../Draw"
import { IEditorOption } from '../../../interface/Editor'
import { Draw } from '../Draw'
export class Highlight {
+2 -2
View File
@@ -1,5 +1,5 @@
import { IEditorOption } from "../../../interface/Editor"
import { Draw } from "../Draw"
import { IEditorOption } from '../../../interface/Editor'
import { Draw } from '../Draw'
export class Strikeout {
+2 -2
View File
@@ -1,5 +1,5 @@
import { IEditorOption } from "../../../interface/Editor"
import { Draw } from "../Draw"
import { IEditorOption } from '../../../interface/Editor'
import { Draw } from '../Draw'
export class Underline {
+23 -23
View File
@@ -1,25 +1,25 @@
import { version } from "../../../../package.json"
import { ElementType } from "../.."
import { ZERO } from "../../dataset/constant/Common"
import { EDITOR_ELEMENT_COPY_ATTR } from "../../dataset/constant/Element"
import { ElementStyleKey } from "../../dataset/enum/ElementStyle"
import { MouseEventButton } from "../../dataset/enum/Event"
import { KeyMap } from "../../dataset/enum/Keymap"
import { IEditorResult } from "../../interface/Editor"
import { IElement } from "../../interface/Element"
import { ICurrentPosition } from "../../interface/Position"
import { writeTextByElementList } from "../../utils/clipboard"
import { zipElementList } from "../../utils/element"
import { Cursor } from "../cursor/Cursor"
import { Draw } from "../draw/Draw"
import { HyperlinkParticle } from "../draw/particle/HyperlinkParticle"
import { ImageParticle } from "../draw/particle/ImageParticle"
import { TableTool } from "../draw/particle/table/TableTool"
import { HistoryManager } from "../history/HistoryManager"
import { Listener } from "../listener/Listener"
import { Position } from "../position/Position"
import { RangeManager } from "../range/RangeManager"
import { LETTER_REG, NUMBER_LIKE_REG } from "../../dataset/constant/Regular"
import { version } from '../../../../package.json'
import { ElementType } from '../..'
import { ZERO } from '../../dataset/constant/Common'
import { EDITOR_ELEMENT_COPY_ATTR } from '../../dataset/constant/Element'
import { ElementStyleKey } from '../../dataset/enum/ElementStyle'
import { MouseEventButton } from '../../dataset/enum/Event'
import { KeyMap } from '../../dataset/enum/Keymap'
import { IEditorResult } from '../../interface/Editor'
import { IElement } from '../../interface/Element'
import { ICurrentPosition } from '../../interface/Position'
import { writeTextByElementList } from '../../utils/clipboard'
import { zipElementList } from '../../utils/element'
import { Cursor } from '../cursor/Cursor'
import { Draw } from '../draw/Draw'
import { HyperlinkParticle } from '../draw/particle/HyperlinkParticle'
import { ImageParticle } from '../draw/particle/ImageParticle'
import { TableTool } from '../draw/particle/table/TableTool'
import { HistoryManager } from '../history/HistoryManager'
import { Listener } from '../listener/Listener'
import { Position } from '../position/Position'
import { RangeManager } from '../range/RangeManager'
import { LETTER_REG, NUMBER_LIKE_REG } from '../../dataset/constant/Regular'
export class CanvasEvent {
@@ -119,7 +119,7 @@ export class CanvasEvent {
tdIndex: startTdIndex,
trIndex: startTrIndex
} = this.mouseDownStartPosition
let endIndex = isTable ? tdValueIndex! : index
const endIndex = isTable ? tdValueIndex! : index
// 判断是否是表格跨行/列
if (isTable && startIsTable && (tdIndex !== startTdIndex || trIndex !== startTrIndex)) {
this.range.setRange(
+10 -10
View File
@@ -1,13 +1,13 @@
import { EDITOR_COMPONENT } from "../../dataset/constant/Editor"
import { IEditorOption } from "../../interface/Editor"
import { findParent } from "../../utils"
import { Cursor } from "../cursor/Cursor"
import { Draw } from "../draw/Draw"
import { HyperlinkParticle } from "../draw/particle/HyperlinkParticle"
import { ImageParticle } from "../draw/particle/ImageParticle"
import { TableTool } from "../draw/particle/table/TableTool"
import { RangeManager } from "../range/RangeManager"
import { CanvasEvent } from "./CanvasEvent"
import { EDITOR_COMPONENT } from '../../dataset/constant/Editor'
import { IEditorOption } from '../../interface/Editor'
import { findParent } from '../../utils'
import { Cursor } from '../cursor/Cursor'
import { Draw } from '../draw/Draw'
import { HyperlinkParticle } from '../draw/particle/HyperlinkParticle'
import { ImageParticle } from '../draw/particle/ImageParticle'
import { TableTool } from '../draw/particle/table/TableTool'
import { RangeManager } from '../range/RangeManager'
import { CanvasEvent } from './CanvasEvent'
export class GlobalEvent {
+1 -1
View File
@@ -6,7 +6,7 @@ import {
IRangeStyleChange,
ISaved,
IVisiblePageNoListChange
} from "../../interface/Listener"
} from '../../interface/Listener'
export class Listener {
+6 -6
View File
@@ -1,6 +1,6 @@
import { IEditorOption } from "../../interface/Editor"
import { debounce } from "../../utils"
import { Draw } from "../draw/Draw"
import { IEditorOption } from '../../interface/Editor'
import { debounce } from '../../utils'
import { Draw } from '../draw/Draw'
export class GlobalObserver {
@@ -30,9 +30,9 @@ export class GlobalObserver {
const bottom = top + window.innerHeight
const pageList = this.draw.getPageList()
// 计算显示页
let visiblePageNoList: number[] = []
let intersectionPageNo: number = 0
let intersectionMaxHeight: number = 0
const visiblePageNoList: number[] = []
let intersectionPageNo = 0
let intersectionMaxHeight = 0
for (let i = 0; i < pageList.length; i++) {
const curTop = i * this.pageHeight
const curBottom = (i + 1) * this.pageHeight
+6 -6
View File
@@ -1,9 +1,9 @@
import { ElementType } from "../.."
import { ZERO } from "../../dataset/constant/Common"
import { IEditorOption } from "../../interface/Editor"
import { IElementPosition } from "../../interface/Element"
import { ICurrentPosition, IGetPositionByXYPayload, IPositionContext } from "../../interface/Position"
import { Draw } from "../draw/Draw"
import { ElementType } from '../..'
import { ZERO } from '../../dataset/constant/Common'
import { IEditorOption } from '../../interface/Editor'
import { IElementPosition } from '../../interface/Element'
import { ICurrentPosition, IGetPositionByXYPayload, IPositionContext } from '../../interface/Position'
import { Draw } from '../draw/Draw'
export class Position {
+11 -11
View File
@@ -1,10 +1,10 @@
import { ElementType } from "../.."
import { IEditorOption } from "../../interface/Editor"
import { IElement } from "../../interface/Element"
import { IRange } from "../../interface/Range"
import { Draw } from "../draw/Draw"
import { HistoryManager } from "../history/HistoryManager"
import { Listener } from "../listener/Listener"
import { ElementType } from '../..'
import { IEditorOption } from '../../interface/Editor'
import { IElement } from '../../interface/Element'
import { IRange } from '../../interface/Range'
import { Draw } from '../draw/Draw'
import { HistoryManager } from '../history/HistoryManager'
import { Listener } from '../listener/Listener'
export class RangeManager {
@@ -70,10 +70,10 @@ export class RangeManager {
const type = curElement.type || ElementType.TEXT
// 富文本
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)
let strikeout = !~curElementList.findIndex(el => !el.strikeout)
const bold = !~curElementList.findIndex(el => !el.bold)
const italic = !~curElementList.findIndex(el => !el.italic)
const underline = !~curElementList.findIndex(el => !el.underline)
const strikeout = !~curElementList.findIndex(el => !el.strikeout)
const color = curElement.color || null
const highlight = curElement.highlight || null
const rowFlex = curElement.rowFlex || null
+2 -2
View File
@@ -1,5 +1,5 @@
import { IRegisterContextMenu } from "../../interface/contextmenu/ContextMenu"
import { ContextMenu } from "../contextmenu/ContextMenu"
import { IRegisterContextMenu } from '../../interface/contextmenu/ContextMenu'
import { ContextMenu } from '../contextmenu/ContextMenu'
interface IRegisterPayload {
contextMenu: ContextMenu
+2 -2
View File
@@ -1,5 +1,5 @@
import { ElementType } from "../enum/Element"
import { IElement } from "../../interface/Element"
import { ElementType } from '../enum/Element'
import { IElement } from '../../interface/Element'
export const EDITOR_ELEMENT_STYLE_ATTR = [
'bold',
+1 -1
View File
@@ -1,4 +1,4 @@
import { IHeader } from "../../interface/Header"
import { IHeader } from '../../interface/Header'
export const defaultHeaderOption: Readonly<Required<IHeader>> = {
data: '',
+1 -1
View File
@@ -1,4 +1,4 @@
import { IWatermark } from "../../interface/Watermark"
import { IWatermark } from '../../interface/Watermark'
export const defaultWatermarkOption: Readonly<Required<IWatermark>> = {
data: '',
+11 -11
View File
@@ -1,15 +1,15 @@
export enum KeyMap {
Delete = 'Delete',
Backspace = 'Backspace',
Enter = "Enter",
Left = "ArrowLeft",
Right = "ArrowRight",
Up = "ArrowUp",
Down = "ArrowDown",
A = "a",
C = "c",
S = "s",
X = "x",
Y = "y",
Z = "z"
Enter = 'Enter',
Left = 'ArrowLeft',
Right = 'ArrowRight',
Up = 'ArrowUp',
Down = 'ArrowDown',
A = 'a',
C = 'c',
S = 's',
X = 'x',
Y = 'y',
Z = 'z'
}
+2 -2
View File
@@ -1,5 +1,5 @@
import { IElementPosition } from "./Element"
import { IRow } from "./Row"
import { IElementPosition } from './Element'
import { IRow } from './Row'
export interface IDrawOption {
curIndex?: number;
+4 -4
View File
@@ -1,7 +1,7 @@
import { IElement } from ".."
import { EditorMode } from "../dataset/enum/Editor"
import { IHeader } from "./Header"
import { IWatermark } from "./Watermark"
import { IElement } from '..'
import { EditorMode } from '../dataset/enum/Editor'
import { IHeader } from './Header'
import { IWatermark } from './Watermark'
export interface IEditorOption {
defaultMode?: EditorMode;
+4 -4
View File
@@ -1,7 +1,7 @@
import { ElementType } from "../dataset/enum/Element"
import { RowFlex } from "../dataset/enum/Row"
import { IColgroup } from "./table/Colgroup"
import { ITr } from "./table/Tr"
import { ElementType } from '../dataset/enum/Element'
import { RowFlex } from '../dataset/enum/Row'
import { IColgroup } from './table/Colgroup'
import { ITr } from './table/Tr'
export interface IElementBasic {
id?: string;
+3 -3
View File
@@ -1,6 +1,6 @@
import { ElementType } from ".."
import { RowFlex } from "../dataset/enum/Row"
import { IEditorResult } from "./Editor"
import { ElementType } from '..'
import { RowFlex } from '../dataset/enum/Row'
import { IEditorResult } from './Editor'
export interface IRangeStyle {
type: ElementType | null;
+3 -3
View File
@@ -1,6 +1,6 @@
import { IElement } from ".."
import { IElementPosition } from "./Element"
import { ITd } from "./table/Td"
import { IElement } from '..'
import { IElementPosition } from './Element'
import { ITd } from './table/Td'
export interface ICurrentPosition {
index: number;
+2 -2
View File
@@ -1,5 +1,5 @@
import { RowFlex } from "../dataset/enum/Row"
import { IElement, IElementMetrics } from "./Element"
import { RowFlex } from '../dataset/enum/Row'
import { IElement, IElementMetrics } from './Element'
export type IRowElement = IElement & {
metrics: IElementMetrics;
+1 -1
View File
@@ -1,4 +1,4 @@
import { EditorContext } from "../dataset/enum/Editor"
import { EditorContext } from '../dataset/enum/Editor'
export interface ISearchResultBasic {
type: EditorContext;
+2 -2
View File
@@ -1,5 +1,5 @@
import { IElement, IElementPosition } from "../Element"
import { IRow } from "../Row"
import { IElement, IElementPosition } from '../Element'
import { IRow } from '../Row'
export interface ITd {
id?: string;
+1 -1
View File
@@ -1,4 +1,4 @@
import { ITd } from "./Td"
import { ITd } from './Td'
export interface ITr {
id?: string;
+5 -5
View File
@@ -1,7 +1,7 @@
import { IElement } from ".."
import { HORIZON_TAB, WRAP, ZERO } from "../dataset/constant/Common"
import { TEXTLIKE_ELEMENT_TYPE } from "../dataset/constant/Element"
import { ElementType } from "../dataset/enum/Element"
import { IElement } from '..'
import { HORIZON_TAB, WRAP, ZERO } from '../dataset/constant/Common'
import { TEXTLIKE_ELEMENT_TYPE } from '../dataset/constant/Element'
import { ElementType } from '../dataset/enum/Element'
export function writeText(text: string) {
if (!text) return
@@ -9,7 +9,7 @@ export function writeText(text: string) {
}
export function writeTextByElementList(elementList: IElement[]) {
let text: string = ``
let text = ``
function pickTextFromElement(payload: IElement[]) {
for (let e = 0; e < payload.length; e++) {
const element = payload[e]
+4 -4
View File
@@ -1,7 +1,7 @@
import { deepClone, getUUID } from "."
import { ElementType, IElement } from ".."
import { ZERO } from "../dataset/constant/Common"
import { EDITOR_ELEMENT_ZIP_ATTR } from "../dataset/constant/Element"
import { deepClone, getUUID } from '.'
import { ElementType, IElement } from '..'
import { ZERO } from '../dataset/constant/Common'
import { EDITOR_ELEMENT_ZIP_ATTR } from '../dataset/constant/Element'
export function formatElementList(elementList: IElement[], isHandleFirstElement = true) {
if (isHandleFirstElement && elementList[0]?.value !== ZERO) {
+1 -1
View File
@@ -50,5 +50,5 @@ export function getUUID(): string {
function S4(): string {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
}
return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4())
return (S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4())
}
+2 -2
View File
@@ -1,6 +1,6 @@
import { data, options } from './mock'
import './style.css'
import prism from "prismjs"
import prism from 'prismjs'
import Editor, { EditorMode, ElementType, IElement } from './editor'
import { Dialog } from './components/dialog/Dialog'
import { formatPrismToken } from './utils/prism'
@@ -230,7 +230,7 @@ window.onload = function () {
imageFileDom.click()
}
imageFileDom.onchange = function () {
const file = imageFileDom.files?.[0]!
const file = imageFileDom.files![0]!
const fileReader = new FileReader()
fileReader.readAsDataURL(file)
fileReader.onload = function () {
+1 -1
View File
@@ -1,4 +1,4 @@
import { ElementType, IEditorOption, IElement, RowFlex } from "./editor"
import { ElementType, IEditorOption, IElement, RowFlex } from './editor'
const text = `人民医院门诊病历\n主诉:\n发热三天,咳嗽五天。\n现病史:\n患者于三天前无明显诱因,感冒后发现面部水肿,无皮疹,尿量减少,出现乏力,在外治疗无好转,现来我院就诊。\n既往史:\n有糖尿病10年,有高血压2年,有传染性疾病1年。没有报告其他既往疾病。\n流行病史:\n否认14天内接触过确诊患者、疑似患者、无症状感染者及其密切接触者;否认14天内去过以下场所:水产、肉类批发市场,农贸市场,集市,大型超市,夜市;否认14天内与以下场所工作人员密切接触:水产、肉类批发市场,农贸市场,集市,大型超市;否认14天内周围(如家庭、办公室)有2例以上聚集性发病;否认14天内接触过有发热或呼吸道症状的人员;否认14天内自身有发热或呼吸道症状;否认14天内接触过纳入隔离观察的人员及其他可能与新冠肺炎关联的情形;陪同家属{有无选择代码}有以上情况。\n体格检查:\nT39.5℃,P80bpmR20次/分,BP120/80mmHg\n辅助检查:\n2020年6月10日,普放:血细胞比容36.50%(偏低)40~50;单核细胞绝对值0.75*10/L(偏高)参考值:0.10.6\n门诊诊断:\n1.高血压\n2.糖尿病\n3.病毒性感冒\n4.过敏性鼻炎\n5.过敏性鼻息肉\n处置治疗:\n1.超声引导下甲状腺细针穿刺术;\n2.乙型肝炎表面抗体测定;\n3.膜式病变细胞采集术、后颈皮下肤层;\n电子签名:【】\n其他记录:`
+40 -40
View File
@@ -7,48 +7,48 @@ interface IPrismKindStyle {
export function getPrismKindStyle(payload: string): IPrismKindStyle | null {
switch (payload) {
case "comment":
case "prolog":
case "doctype":
case "cdata":
return { color: "#008000", italic: true }
case "namespace":
case 'comment':
case 'prolog':
case 'doctype':
case 'cdata':
return { color: '#008000', italic: true }
case 'namespace':
return { opacity: 0.7 }
case "string":
return { color: "#A31515" }
case "punctuation":
case "operator":
return { color: "#393A34" }
case "url":
case "symbol":
case "number":
case "boolean":
case "variable":
case "constant":
case "inserted":
return { color: "#36acaa" }
case "atrule":
case "keyword":
case "attr-value":
return { color: "#0000ff" }
case "function":
return { color: "#b9a40a" }
case "deleted":
case "tag":
return { color: "#9a050f" }
case "selector":
return { color: "#00009f" }
case "important":
return { color: "#e90", bold: true }
case "italic":
case 'string':
return { color: '#A31515' }
case 'punctuation':
case 'operator':
return { color: '#393A34' }
case 'url':
case 'symbol':
case 'number':
case 'boolean':
case 'variable':
case 'constant':
case 'inserted':
return { color: '#36acaa' }
case 'atrule':
case 'keyword':
case 'attr-value':
return { color: '#0000ff' }
case 'function':
return { color: '#b9a40a' }
case 'deleted':
case 'tag':
return { color: '#9a050f' }
case 'selector':
return { color: '#00009f' }
case 'important':
return { color: '#e90', bold: true }
case 'italic':
return { italic: true }
case "class-name":
case "property":
return { color: "#2B91AF" }
case "attr-name":
case "regex":
case "entity":
return { color: "#ff0000" }
case 'class-name':
case 'property':
return { color: '#2B91AF' }
case 'attr-name':
case 'regex':
case 'entity':
return { color: '#ff0000' }
default:
return null
}