fix:split emoji and rare character #50

This commit is contained in:
黄云飞
2022-05-18 17:35:13 +08:00
parent 84209b719c
commit 7c37e84497
6 changed files with 25 additions and 16 deletions
+3 -4
View File
@@ -60,10 +60,9 @@ export class CursorAgent {
if (item.kind === 'string') {
if (item.type === 'text/plain' && !isHTML) {
item.getAsString(plainText => {
const elementList = plainText.split('').map(value => ({
value
}))
this.draw.insertElementList(elementList)
this.draw.insertElementList([{
value: plainText
}])
})
}
if (item.type === 'text/html' && isHTML) {
+2 -2
View File
@@ -3,7 +3,7 @@ import { ElementType } from '../../../dataset/enum/Element'
import { IControl, IControlInitOption, IControlInstance, IControlOption } from '../../../interface/Control'
import { IElement, IElementPosition } from '../../../interface/Element'
import { IRange } from '../../../interface/Range'
import { deepClone } from '../../../utils'
import { deepClone, splitText } from '../../../utils'
import { pickElementAttr, zipElementList } from '../../../utils/element'
import { Listener } from '../../listener/Listener'
import { RangeManager } from '../../range/RangeManager'
@@ -275,7 +275,7 @@ export class Control {
const startElement = elementList[startIndex]
const control = startElement.control!
if (!control.placeholder) return
const placeholderStrList = control.placeholder.split('')
const placeholderStrList = splitText(control.placeholder)
for (let p = 0; p < placeholderStrList.length; p++) {
const value = placeholderStrList[p]
elementList.splice(startIndex + p + 1, 0, {
@@ -4,6 +4,7 @@ import { EditorComponent } from '../../../../dataset/enum/Editor'
import { KeyMap } from '../../../../dataset/enum/Keymap'
import { IControlInstance } from '../../../../interface/Control'
import { IElement } from '../../../../interface/Element'
import { splitText } from '../../../../utils'
import { Control } from '../Control'
export class SelectControl implements IControlInstance {
@@ -185,7 +186,7 @@ export class SelectControl implements IControlInstance {
const elementList = this.control.getElementList()
const startElement = elementList[startIndex]
const start = startIndex + 1
const data = valueSet.value.split('')
const data = splitText(valueSet.value)
for (let i = 0; i < data.length; i++) {
elementList.splice(start + i, 0, {
...startElement,
+2 -1
View File
@@ -19,6 +19,7 @@ import { RangeManager } from '../range/RangeManager'
import { LETTER_REG, NUMBER_LIKE_REG } from '../../dataset/constant/Regular'
import { Control } from '../draw/control/Control'
import { CheckboxControl } from '../draw/control/checkbox/CheckboxControl'
import { splitText } from '../../utils'
export class CanvasEvent {
@@ -518,7 +519,7 @@ export class CanvasEvent {
restArg = { tdId, trId, tableId }
}
const element = elementList[endIndex]
const inputData: IElement[] = text.split('').map(value => {
const inputData: IElement[] = splitText(text).map(value => {
const newElement: IElement = {
value,
...restArg