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)
|
## [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",
|
"name": "@hufe921/canvas-editor",
|
||||||
"author": "Hufe",
|
"author": "Hufe",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "0.9.85",
|
"version": "0.9.86",
|
||||||
"description": "rich text editor by canvas/svg",
|
"description": "rich text editor by canvas/svg",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "https://registry.npmjs.org/",
|
"registry": "https://registry.npmjs.org/",
|
||||||
|
|||||||
@@ -1179,37 +1179,23 @@ export class CommandAdapt {
|
|||||||
this.deleteTable()
|
this.deleteTable()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 跨列处理
|
// 缩小colspan或删除与当前列重叠的单元格
|
||||||
for (let t = 0; t < curTrList.length; t++) {
|
for (let t = 0; t < curTrList.length; t++) {
|
||||||
const tr = curTrList[t]
|
const tr = curTrList[t]
|
||||||
for (let d = 0; d < tr.tdList.length; d++) {
|
for (let d = 0; d < tr.tdList.length; d++) {
|
||||||
const td = tr.tdList[d]
|
const td = tr.tdList[d]
|
||||||
if (td.colspan > 1) {
|
|
||||||
const tdColIndex = td.colIndex!
|
|
||||||
// 交叉减去一列
|
|
||||||
if (
|
if (
|
||||||
tdColIndex <= curColIndex &&
|
td.colIndex! <= curColIndex &&
|
||||||
tdColIndex + td.colspan - 1 >= curColIndex
|
td.colIndex! + td.colspan > curColIndex
|
||||||
) {
|
) {
|
||||||
td.colspan -= 1
|
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)
|
element.colgroup?.splice(curColIndex, 1)
|
||||||
// 重新设置上下文
|
// 重新设置上下文
|
||||||
this.position.setPositionContext({
|
this.position.setPositionContext({
|
||||||
@@ -2467,20 +2453,14 @@ export class CommandAdapt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public setControlValue(payload: ISetControlValueOption) {
|
public setControlValue(payload: ISetControlValueOption) {
|
||||||
const isReadonly = this.draw.isReadonly()
|
|
||||||
if (isReadonly) return
|
|
||||||
this.draw.getControl().setValueByConceptId(payload)
|
this.draw.getControl().setValueByConceptId(payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
public setControlExtension(payload: ISetControlExtensionOption) {
|
public setControlExtension(payload: ISetControlExtensionOption) {
|
||||||
const isReadonly = this.draw.isReadonly()
|
|
||||||
if (isReadonly) return
|
|
||||||
this.draw.getControl().setExtensionByConceptId(payload)
|
this.draw.getControl().setExtensionByConceptId(payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
public setControlProperties(payload: ISetControlProperties) {
|
public setControlProperties(payload: ISetControlProperties) {
|
||||||
const isReadonly = this.draw.isReadonly()
|
|
||||||
if (isReadonly) return
|
|
||||||
this.draw.getControl().setPropertiesByConceptId(payload)
|
this.draw.getControl().setPropertiesByConceptId(payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1005,7 +1005,7 @@ export class Draw {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getValue(options: IGetValueOption = {}): IEditorResult {
|
public getValue(options: IGetValueOption = {}): IEditorResult {
|
||||||
const { pageNo } = options
|
const { pageNo, extraPickAttrs } = options
|
||||||
let mainElementList = this.elementList
|
let mainElementList = this.elementList
|
||||||
if (
|
if (
|
||||||
Number.isInteger(pageNo) &&
|
Number.isInteger(pageNo) &&
|
||||||
@@ -1017,9 +1017,15 @@ export class Draw {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
const data: IEditorData = {
|
const data: IEditorData = {
|
||||||
header: zipElementList(this.getHeaderElementList()),
|
header: zipElementList(this.getHeaderElementList(), {
|
||||||
main: zipElementList(mainElementList),
|
extraPickAttrs
|
||||||
footer: zipElementList(this.getFooterElementList())
|
}),
|
||||||
|
main: zipElementList(mainElementList, {
|
||||||
|
extraPickAttrs
|
||||||
|
}),
|
||||||
|
footer: zipElementList(this.getFooterElementList(), {
|
||||||
|
extraPickAttrs
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
version,
|
version,
|
||||||
|
|||||||
@@ -23,7 +23,13 @@ import { IEditorData, IEditorOption } from '../../../interface/Editor'
|
|||||||
import { IElement, IElementPosition } from '../../../interface/Element'
|
import { IElement, IElementPosition } from '../../../interface/Element'
|
||||||
import { EventBusMap } from '../../../interface/EventBus'
|
import { EventBusMap } from '../../../interface/EventBus'
|
||||||
import { IRange } from '../../../interface/Range'
|
import { IRange } from '../../../interface/Range'
|
||||||
import { deepClone, nextTick, omitObject, splitText } from '../../../utils'
|
import {
|
||||||
|
deepClone,
|
||||||
|
nextTick,
|
||||||
|
omitObject,
|
||||||
|
pickObject,
|
||||||
|
splitText
|
||||||
|
} from '../../../utils'
|
||||||
import {
|
import {
|
||||||
formatElementContext,
|
formatElementContext,
|
||||||
formatElementList,
|
formatElementList,
|
||||||
@@ -510,9 +516,12 @@ export class Control {
|
|||||||
const control = startElement.control!
|
const control = startElement.control!
|
||||||
if (!control.placeholder) return
|
if (!control.placeholder) return
|
||||||
const placeholderStrList = splitText(control.placeholder)
|
const placeholderStrList = splitText(control.placeholder)
|
||||||
|
// 优先使用默认控件样式
|
||||||
|
const anchorElementStyleAttr = pickObject(startElement, CONTROL_STYLE_ATTR)
|
||||||
for (let p = 0; p < placeholderStrList.length; p++) {
|
for (let p = 0; p < placeholderStrList.length; p++) {
|
||||||
const value = placeholderStrList[p]
|
const value = placeholderStrList[p]
|
||||||
const newElement: IElement = {
|
const newElement: IElement = {
|
||||||
|
...anchorElementStyleAttr,
|
||||||
value,
|
value,
|
||||||
controlId: startElement.controlId,
|
controlId: startElement.controlId,
|
||||||
type: ElementType.CONTROL,
|
type: ElementType.CONTROL,
|
||||||
@@ -638,8 +647,6 @@ export class Control {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public setValueByConceptId(payload: ISetControlValueOption) {
|
public setValueByConceptId(payload: ISetControlValueOption) {
|
||||||
const isReadonly = this.draw.isReadonly()
|
|
||||||
if (isReadonly) return
|
|
||||||
let isExistSet = false
|
let isExistSet = false
|
||||||
const { conceptId, value } = payload
|
const { conceptId, value } = payload
|
||||||
// 设置值
|
// 设置值
|
||||||
@@ -752,8 +759,6 @@ export class Control {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public setExtensionByConceptId(payload: ISetControlExtensionOption) {
|
public setExtensionByConceptId(payload: ISetControlExtensionOption) {
|
||||||
const isReadonly = this.draw.isReadonly()
|
|
||||||
if (isReadonly) return
|
|
||||||
const { conceptId, extension } = payload
|
const { conceptId, extension } = payload
|
||||||
const setExtension = (elementList: IElement[]) => {
|
const setExtension = (elementList: IElement[]) => {
|
||||||
let i = 0
|
let i = 0
|
||||||
@@ -794,8 +799,6 @@ export class Control {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public setPropertiesByConceptId(payload: ISetControlProperties) {
|
public setPropertiesByConceptId(payload: ISetControlProperties) {
|
||||||
const isReadonly = this.draw.isReadonly()
|
|
||||||
if (isReadonly) return
|
|
||||||
const { conceptId, properties } = payload
|
const { conceptId, properties } = payload
|
||||||
let isExistUpdate = false
|
let isExistUpdate = false
|
||||||
function setProperties(elementList: IElement[]) {
|
function setProperties(elementList: IElement[]) {
|
||||||
|
|||||||
@@ -511,11 +511,17 @@ export class Position {
|
|||||||
const headIndex = positionList.findIndex(
|
const headIndex = positionList.findIndex(
|
||||||
p => p.pageNo === positionNo && p.rowNo === rowNo
|
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 (~headIndex) {
|
||||||
if (positionList[headIndex].value === ZERO) {
|
if (headPosition.value === ZERO) {
|
||||||
curPositionIndex = headIndex
|
curPositionIndex = headIndex
|
||||||
} else {
|
} else {
|
||||||
curPositionIndex = headIndex - 1
|
curPositionIndex = headIndex - 1
|
||||||
@@ -526,10 +532,7 @@ export class Position {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 是否是复选框列表
|
// 是否是复选框列表
|
||||||
if (
|
if (headElement.listStyle === ListStyle.CHECKBOX && x < leftTop[0]) {
|
||||||
elementList[headIndex].listStyle === ListStyle.CHECKBOX &&
|
|
||||||
x < leftTop[0]
|
|
||||||
) {
|
|
||||||
return {
|
return {
|
||||||
index: headIndex,
|
index: headIndex,
|
||||||
isDirectHit: true,
|
isDirectHit: true,
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ export interface IPainterOption {
|
|||||||
|
|
||||||
export interface IGetValueOption {
|
export interface IGetValueOption {
|
||||||
pageNo?: number
|
pageNo?: number
|
||||||
|
extraPickAttrs?: Array<keyof IElement>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IAppendElementListOption {
|
export interface IAppendElementListOption {
|
||||||
|
|||||||
Reference in New Issue
Block a user