Merge branch 'Hufe921:main' into main
This commit is contained in:
@@ -1,3 +1,21 @@
|
||||
## [0.9.86](https://github.com/Hufe921/canvas-editor/compare/v0.9.85...v0.9.86) (2024-07-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add control placeholder boundary error #686 ([fac5c5c](https://github.com/Hufe921/canvas-editor/commit/fac5c5c045a30cb5e0c46ef027c83f21e07bcaa8)), closes [#686](https://github.com/Hufe921/canvas-editor/issues/686)
|
||||
* add control placeholder using default style #691 ([eb3ea5e](https://github.com/Hufe921/canvas-editor/commit/eb3ea5ed55cdedea0e281d45177c8661f674a280)), closes [#691](https://github.com/Hufe921/canvas-editor/issues/691)
|
||||
* delete table col boundary error #688 ([3f0a49f](https://github.com/Hufe921/canvas-editor/commit/3f0a49f56be7060d328a63c994f571b0a35a3521)), closes [#688](https://github.com/Hufe921/canvas-editor/issues/688)
|
||||
* refocus when cursor is not focused #685 ([0ac8ae7](https://github.com/Hufe921/canvas-editor/commit/0ac8ae7c4b0b47ee84a9c0f8c37ffde612849957)), closes [#685](https://github.com/Hufe921/canvas-editor/issues/685)
|
||||
* remove title and list properties from getControlList return value #683 ([b024050](https://github.com/Hufe921/canvas-editor/commit/b024050b3ef7f787079a74b062e5d83085be1a5f)), closes [#683](https://github.com/Hufe921/canvas-editor/issues/683)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add executeInsertControl api ([e5b3d05](https://github.com/Hufe921/canvas-editor/commit/e5b3d05991a26dc186cdf63962ca3c7b50a32572))
|
||||
|
||||
|
||||
|
||||
## [0.9.85](https://github.com/Hufe921/canvas-editor/compare/v0.9.84...v0.9.85) (2024-07-07)
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"name": "@hufe921/canvas-editor",
|
||||
"author": "Hufe",
|
||||
"license": "MIT",
|
||||
"version": "0.9.85",
|
||||
"version": "0.9.86",
|
||||
"description": "rich text editor by canvas/svg",
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/",
|
||||
|
||||
@@ -1179,37 +1179,23 @@ export class CommandAdapt {
|
||||
this.deleteTable()
|
||||
return
|
||||
}
|
||||
// 跨列处理
|
||||
// 缩小colspan或删除与当前列重叠的单元格
|
||||
for (let t = 0; t < curTrList.length; t++) {
|
||||
const tr = curTrList[t]
|
||||
for (let d = 0; d < tr.tdList.length; d++) {
|
||||
const td = tr.tdList[d]
|
||||
if (td.colspan > 1) {
|
||||
const tdColIndex = td.colIndex!
|
||||
// 交叉减去一列
|
||||
if (
|
||||
tdColIndex <= curColIndex &&
|
||||
tdColIndex + td.colspan - 1 >= curColIndex
|
||||
) {
|
||||
td.colspan -= 1
|
||||
if (
|
||||
td.colIndex! <= curColIndex &&
|
||||
td.colIndex! + td.colspan > curColIndex
|
||||
) {
|
||||
if (td.colspan > 1) {
|
||||
td.colspan--
|
||||
} else {
|
||||
tr.tdList.splice(d, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 删除当前列
|
||||
for (let t = 0; t < curTrList.length; t++) {
|
||||
const tr = curTrList[t]
|
||||
let start = -1
|
||||
for (let d = 0; d < tr.tdList.length; d++) {
|
||||
const td = tr.tdList[d]
|
||||
if (td.colIndex === curColIndex) {
|
||||
start = d
|
||||
}
|
||||
}
|
||||
if (~start) {
|
||||
tr.tdList.splice(start, 1)
|
||||
}
|
||||
}
|
||||
element.colgroup?.splice(curColIndex, 1)
|
||||
// 重新设置上下文
|
||||
this.position.setPositionContext({
|
||||
@@ -2467,20 +2453,14 @@ export class CommandAdapt {
|
||||
}
|
||||
|
||||
public setControlValue(payload: ISetControlValueOption) {
|
||||
const isReadonly = this.draw.isReadonly()
|
||||
if (isReadonly) return
|
||||
this.draw.getControl().setValueByConceptId(payload)
|
||||
}
|
||||
|
||||
public setControlExtension(payload: ISetControlExtensionOption) {
|
||||
const isReadonly = this.draw.isReadonly()
|
||||
if (isReadonly) return
|
||||
this.draw.getControl().setExtensionByConceptId(payload)
|
||||
}
|
||||
|
||||
public setControlProperties(payload: ISetControlProperties) {
|
||||
const isReadonly = this.draw.isReadonly()
|
||||
if (isReadonly) return
|
||||
this.draw.getControl().setPropertiesByConceptId(payload)
|
||||
}
|
||||
|
||||
|
||||
@@ -1005,7 +1005,7 @@ export class Draw {
|
||||
}
|
||||
|
||||
public getValue(options: IGetValueOption = {}): IEditorResult {
|
||||
const { pageNo } = options
|
||||
const { pageNo, extraPickAttrs } = options
|
||||
let mainElementList = this.elementList
|
||||
if (
|
||||
Number.isInteger(pageNo) &&
|
||||
@@ -1017,9 +1017,15 @@ export class Draw {
|
||||
)
|
||||
}
|
||||
const data: IEditorData = {
|
||||
header: zipElementList(this.getHeaderElementList()),
|
||||
main: zipElementList(mainElementList),
|
||||
footer: zipElementList(this.getFooterElementList())
|
||||
header: zipElementList(this.getHeaderElementList(), {
|
||||
extraPickAttrs
|
||||
}),
|
||||
main: zipElementList(mainElementList, {
|
||||
extraPickAttrs
|
||||
}),
|
||||
footer: zipElementList(this.getFooterElementList(), {
|
||||
extraPickAttrs
|
||||
})
|
||||
}
|
||||
return {
|
||||
version,
|
||||
|
||||
@@ -23,7 +23,13 @@ import { IEditorData, IEditorOption } from '../../../interface/Editor'
|
||||
import { IElement, IElementPosition } from '../../../interface/Element'
|
||||
import { EventBusMap } from '../../../interface/EventBus'
|
||||
import { IRange } from '../../../interface/Range'
|
||||
import { deepClone, nextTick, omitObject, splitText } from '../../../utils'
|
||||
import {
|
||||
deepClone,
|
||||
nextTick,
|
||||
omitObject,
|
||||
pickObject,
|
||||
splitText
|
||||
} from '../../../utils'
|
||||
import {
|
||||
formatElementContext,
|
||||
formatElementList,
|
||||
@@ -510,9 +516,12 @@ export class Control {
|
||||
const control = startElement.control!
|
||||
if (!control.placeholder) return
|
||||
const placeholderStrList = splitText(control.placeholder)
|
||||
// 优先使用默认控件样式
|
||||
const anchorElementStyleAttr = pickObject(startElement, CONTROL_STYLE_ATTR)
|
||||
for (let p = 0; p < placeholderStrList.length; p++) {
|
||||
const value = placeholderStrList[p]
|
||||
const newElement: IElement = {
|
||||
...anchorElementStyleAttr,
|
||||
value,
|
||||
controlId: startElement.controlId,
|
||||
type: ElementType.CONTROL,
|
||||
@@ -638,8 +647,6 @@ export class Control {
|
||||
}
|
||||
|
||||
public setValueByConceptId(payload: ISetControlValueOption) {
|
||||
const isReadonly = this.draw.isReadonly()
|
||||
if (isReadonly) return
|
||||
let isExistSet = false
|
||||
const { conceptId, value } = payload
|
||||
// 设置值
|
||||
@@ -752,8 +759,6 @@ export class Control {
|
||||
}
|
||||
|
||||
public setExtensionByConceptId(payload: ISetControlExtensionOption) {
|
||||
const isReadonly = this.draw.isReadonly()
|
||||
if (isReadonly) return
|
||||
const { conceptId, extension } = payload
|
||||
const setExtension = (elementList: IElement[]) => {
|
||||
let i = 0
|
||||
@@ -794,8 +799,6 @@ export class Control {
|
||||
}
|
||||
|
||||
public setPropertiesByConceptId(payload: ISetControlProperties) {
|
||||
const isReadonly = this.draw.isReadonly()
|
||||
if (isReadonly) return
|
||||
const { conceptId, properties } = payload
|
||||
let isExistUpdate = false
|
||||
function setProperties(elementList: IElement[]) {
|
||||
|
||||
@@ -511,11 +511,17 @@ export class Position {
|
||||
const headIndex = positionList.findIndex(
|
||||
p => p.pageNo === positionNo && p.rowNo === rowNo
|
||||
)
|
||||
const headElement = elementList[headIndex]
|
||||
const headPosition = positionList[headIndex]
|
||||
// 是否在头部
|
||||
if (x < this.options.margins[3]) {
|
||||
const headStartX =
|
||||
headElement.listStyle === ListStyle.CHECKBOX
|
||||
? this.options.margins[3]
|
||||
: headPosition.coordinate.leftTop[0]
|
||||
if (x < headStartX) {
|
||||
// 头部元素为空元素时无需选中
|
||||
if (~headIndex) {
|
||||
if (positionList[headIndex].value === ZERO) {
|
||||
if (headPosition.value === ZERO) {
|
||||
curPositionIndex = headIndex
|
||||
} else {
|
||||
curPositionIndex = headIndex - 1
|
||||
@@ -526,10 +532,7 @@ export class Position {
|
||||
}
|
||||
} else {
|
||||
// 是否是复选框列表
|
||||
if (
|
||||
elementList[headIndex].listStyle === ListStyle.CHECKBOX &&
|
||||
x < leftTop[0]
|
||||
) {
|
||||
if (headElement.listStyle === ListStyle.CHECKBOX && x < leftTop[0]) {
|
||||
return {
|
||||
index: headIndex,
|
||||
isDirectHit: true,
|
||||
|
||||
@@ -54,6 +54,7 @@ export interface IPainterOption {
|
||||
|
||||
export interface IGetValueOption {
|
||||
pageNo?: number
|
||||
extraPickAttrs?: Array<keyof IElement>
|
||||
}
|
||||
|
||||
export interface IAppendElementListOption {
|
||||
|
||||
Reference in New Issue
Block a user