From 73d815c4c57db7d2b4b3ec5f92ce2e235653eda6 Mon Sep 17 00:00:00 2001 From: caiwuu <37742475+caiwuu@users.noreply.github.com> Date: Wed, 10 Jan 2024 09:36:50 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20=20@=205f66f?= =?UTF-8?q?fc6ae4464a178eb17d713b49c470489b4b2=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Caret.html | 2 +- Component.html | 2 +- Content.html | 2 +- Formater.html | 2 +- Measure.html | 2 +- Path.html | 2 +- Path_Path.html | 2 +- Range.html | 2 +- Selection.html | 2 +- core_defaultActions_caretMove.js.html | 4 ++-- core_defaultActions_delete.js.html | 4 ++-- core_initCore.js.html | 4 ++-- core_model_content.js.html | 4 ++-- core_model_formater.js.html | 4 ++-- core_model_path.js.html | 4 ++-- core_selection_index.js.html | 4 ++-- core_selection_range_index.js.html | 4 ++-- core_utils.js.html | 4 ++-- core_view_component.js.html | 4 ++-- core_view_vdom_createRef.js.html | 4 ++-- core_view_vdom_createVnode.js.html | 4 ++-- core_view_vdom_enqueueSetState.js.html | 4 ++-- core_view_vdom_patch.js.html | 4 ++-- dist/index.html | 2 +- dist/index.js | 2 +- editor_mount.js.html | 4 ++-- global.html | 2 +- index.html | 4 ++-- platform_web_caret.js.html | 4 ++-- platform_web_updateProps_index.js.html | 4 ++-- 30 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Caret.html b/Caret.html index b9f4c04..bbd0d1d 100644 --- a/Caret.html +++ b/Caret.html @@ -1,3 +1,3 @@ Class: Caret
On this page

Caret

new Caret()

光标类

Members

defaultStyle

默认样式

dom

光标dom

rect

光标坐标

style

当前样式

Methods

draw()

绘制光标

hidden()

光标隐藏

remove()

光标移除

setStyle(styleopt)

设置光标样式
Parameters:
NameTypeAttributesDefaultDescription
style*<optional>
{}

show()

光标显示

update(drawCaretopt)

光标更新
Parameters:
NameTypeAttributesDefaultDescription
drawCaretboolean<optional>
true
Typex-Document
\ No newline at end of file +
On this page

Caret

new Caret()

光标类

Members

defaultStyle

默认样式

dom

光标dom

rect

光标坐标

style

当前样式

Methods

draw()

绘制光标

hidden()

光标隐藏

remove()

光标移除

setStyle(styleopt)

设置光标样式
Parameters:
NameTypeAttributesDefaultDescription
style*<optional>
{}

show()

光标显示

update(drawCaretopt)

光标更新
Parameters:
NameTypeAttributesDefaultDescription
drawCaretboolean<optional>
true
Typex-Document
\ No newline at end of file diff --git a/Component.html b/Component.html index f97970d..b196a51 100644 --- a/Component.html +++ b/Component.html @@ -1,3 +1,3 @@ Class: Component
On this page

Component

new Component()

组件类

Members

$nextTick

nextTick

(readonly) isComponent

是否是组件

state

状态

(static) isComponent

是否是组件

Methods

render(h)

渲染函数
Parameters:
NameTypeDescription
h*

setState(partialStateopt) → {*}

设置状态,异步更新
Parameters:
NameTypeAttributesDefaultDescription
partialState*<optional>
{}
Returns:
Type: 
*

shouldComponentUpdate() → {*}

控制组件是否需要更新
Returns:
Type: 
*
Typex-Document
\ No newline at end of file +
On this page

Component

new Component()

组件类

Members

$nextTick

nextTick

(readonly) isComponent

是否是组件

state

状态

(static) isComponent

是否是组件

Methods

render(h)

渲染函数
Parameters:
NameTypeDescription
h*

setState(partialStateopt) → {*}

设置状态,异步更新
Parameters:
NameTypeAttributesDefaultDescription
partialState*<optional>
{}
Returns:
Type: 
*

shouldComponentUpdate() → {*}

控制组件是否需要更新
Returns:
Type: 
*
Typex-Document
\ No newline at end of file diff --git a/Content.html b/Content.html index 298c3aa..58fe69d 100644 --- a/Content.html +++ b/Content.html @@ -1,3 +1,3 @@ Class: Content
On this page

Content

new Content()

内容管理类

Extends

Members

(readonly) $editor

编辑器实例

$nextTick

nextTick
Inherited From

(readonly) $path

对应路径

(readonly) contentLength

内容长度

(readonly) displayType

类型

(readonly) isComponent

是否是组件
Inherited From

state

状态
Inherited From

Methods

_updatePoints(container, position, distance, newContainer)

range端点更新
Parameters:
NameTypeDescription
container*
position*
distance*
newContainer*

enterPath(path, range, direction) → {*}

光标进入
Parameters:
NameTypeDescription
path*
range*
direction*
Returns:
Type: 
*

isCaretShouldLeavePath(path, range, direction) → {Boolean}

检测光标是否要离开当前path
Parameters:
NameTypeDescription
pathPath路径
rangeRange选取范围
direction'left' | 'right'方向
Returns:
Type: 
Boolean

leavePath(path, range, direction) → {*}

光标离开
Parameters:
NameTypeDescription
path*
range*
direction*从哪个方向离开
Returns:
Type: 
*

onCaretMove(direction, range, event) → {*}

光标移动处理
Parameters:
NameTypeDescription
direction*
range*
event*
Returns:
Type: 
*

onKeydownArrowDown(range, event)

键盘下箭头处理
Parameters:
NameTypeDescription
range*
event*

onKeydownArrowLeft(range, event)

键盘左箭头处理
Parameters:
NameTypeDescription
range*
event*

onKeydownArrowRight(range, event)

键盘右箭头处理
Parameters:
NameTypeDescription
range*
event*

onKeydownArrowUp(range, event)

键盘上箭头处理
Parameters:
NameTypeDescription
range*
event*

onKeydownBackspace(range)

键盘空格处理
Parameters:
NameTypeDescription
range*

onKeydownEnter(range, event)

键盘回车处理
Parameters:
NameTypeDescription
range*
event*

render(h)

渲染函数
Parameters:
NameTypeDescription
h*
Inherited From

setFormat(range, callback)

格式设置
Parameters:
NameTypeDescription
range*
callbackfunction格式处理回调

setState(partialStateopt) → {*}

设置状态,异步更新
Parameters:
NameTypeAttributesDefaultDescription
partialState*<optional>
{}
Inherited From
Returns:
Type: 
*

shouldComponentUpdate() → {*}

控制组件是否需要更新
Returns:
Type: 
*

update(path, range) → {*}

更新状态
Parameters:
NameTypeDescription
path*
range*
Returns:
Type: 
*

(static) onBeforeRender()

render前调用hook

(static) onInsert({) → {*}

内容插入处理
Parameters:
NameTypeDescription
{*data, type, range }
Returns:
Type: 
*

(static) onLinefeed(range, eventopt)

换行
Parameters:
NameTypeAttributesDefaultDescription
rangeRange
eventevent<optional>
null
Typex-Document
\ No newline at end of file +
On this page

Content

new Content()

内容管理类

Extends

Members

(readonly) $editor

编辑器实例

$nextTick

nextTick
Inherited From

(readonly) $path

对应路径

(readonly) contentLength

内容长度

(readonly) displayType

类型

(readonly) isComponent

是否是组件
Inherited From

state

状态
Inherited From

Methods

_updatePoints(container, position, distance, newContainer)

range端点更新
Parameters:
NameTypeDescription
container*
position*
distance*
newContainer*

enterPath(path, range, direction) → {*}

光标进入
Parameters:
NameTypeDescription
path*
range*
direction*
Returns:
Type: 
*

isCaretShouldLeavePath(path, range, direction) → {Boolean}

检测光标是否要离开当前path
Parameters:
NameTypeDescription
pathPath路径
rangeRange选取范围
direction'left' | 'right'方向
Returns:
Type: 
Boolean

leavePath(path, range, direction) → {*}

光标离开
Parameters:
NameTypeDescription
path*
range*
direction*从哪个方向离开
Returns:
Type: 
*

onCaretMove(direction, range, event) → {*}

光标移动处理
Parameters:
NameTypeDescription
direction*
range*
event*
Returns:
Type: 
*

onKeydownArrowDown(range, event)

键盘下箭头处理
Parameters:
NameTypeDescription
range*
event*

onKeydownArrowLeft(range, event)

键盘左箭头处理
Parameters:
NameTypeDescription
range*
event*

onKeydownArrowRight(range, event)

键盘右箭头处理
Parameters:
NameTypeDescription
range*
event*

onKeydownArrowUp(range, event)

键盘上箭头处理
Parameters:
NameTypeDescription
range*
event*

onKeydownBackspace(range)

键盘空格处理
Parameters:
NameTypeDescription
range*

onKeydownEnter(range, event)

键盘回车处理
Parameters:
NameTypeDescription
range*
event*

render(h)

渲染函数
Parameters:
NameTypeDescription
h*
Inherited From

setFormat(range, callback)

格式设置
Parameters:
NameTypeDescription
range*
callbackfunction格式处理回调

setState(partialStateopt) → {*}

设置状态,异步更新
Parameters:
NameTypeAttributesDefaultDescription
partialState*<optional>
{}
Inherited From
Returns:
Type: 
*

shouldComponentUpdate() → {*}

控制组件是否需要更新
Returns:
Type: 
*

update(path, range) → {*}

更新状态
Parameters:
NameTypeDescription
path*
range*
Returns:
Type: 
*

(static) onBeforeRender()

render前调用hook

(static) onInsert({) → {*}

内容插入处理
Parameters:
NameTypeDescription
{*data, type, range }
Returns:
Type: 
*

(static) onLinefeed(range, eventopt)

换行
Parameters:
NameTypeAttributesDefaultDescription
rangeRange
eventevent<optional>
null
Typex-Document
\ No newline at end of file diff --git a/Formater.html b/Formater.html index 2465067..8d3a8d0 100644 --- a/Formater.html +++ b/Formater.html @@ -1,3 +1,3 @@ Class: Formater
On this page

Formater

new Formater()

格式管理类

Members

(readonly) types

获取格式类型list

Methods

_generateGroups(gs, isEmptyBlock) → {*}

格式分组
Parameters:
NameTypeDescription
gs*
isEmptyBlock*
Returns:
Type: 
*

_invokeRender(vn, current) → {*}

渲染调用
Parameters:
NameTypeDescription
vn*
current*
Returns:
Type: 
*

get(key) → {*}

根据格式名获取格式
Parameters:
NameTypeDescription
key*
Returns:
Type: 
*

inject(propName, prop)

依赖注入
Parameters:
NameTypeDescription
propName*
prop*

register(formats)

注册格式
Parameters:
NameTypeDescription
formats*

render(path) → {*}

path 渲染
Parameters:
NameTypeDescription
path*
Returns:
Type: 
*

(static) exports.mergePointsContainer(path, basePath)

合并选区断点容器
Parameters:
NameTypeDescription
path*
basePath*

(static) exports.mergeTextPath(paths) → {*}

文本路径合并
Parameters:
NameTypeDescription
paths*
Returns:
Type: 
*
Typex-Document
\ No newline at end of file +
On this page

Formater

new Formater()

格式管理类

Members

(readonly) types

获取格式类型list

Methods

_generateGroups(gs, isEmptyBlock) → {*}

格式分组
Parameters:
NameTypeDescription
gs*
isEmptyBlock*
Returns:
Type: 
*

_invokeRender(vn, current) → {*}

渲染调用
Parameters:
NameTypeDescription
vn*
current*
Returns:
Type: 
*

get(key) → {*}

根据格式名获取格式
Parameters:
NameTypeDescription
key*
Returns:
Type: 
*

inject(propName, prop)

依赖注入
Parameters:
NameTypeDescription
propName*
prop*

register(formats)

注册格式
Parameters:
NameTypeDescription
formats*

render(path) → {*}

path 渲染
Parameters:
NameTypeDescription
path*
Returns:
Type: 
*

(static) exports.mergePointsContainer(path, basePath)

合并选区断点容器
Parameters:
NameTypeDescription
path*
basePath*

(static) exports.mergeTextPath(paths) → {*}

文本路径合并
Parameters:
NameTypeDescription
paths*
Returns:
Type: 
*
Typex-Document
\ No newline at end of file diff --git a/Measure.html b/Measure.html index 2e48283..d73598e 100644 --- a/Measure.html +++ b/Measure.html @@ -1,3 +1,3 @@ Class: Measure
On this page

Measure

Typex-Document
\ No newline at end of file +
On this page

Measure

Typex-Document
\ No newline at end of file diff --git a/Path.html b/Path.html index 54be44b..08da820 100644 --- a/Path.html +++ b/Path.html @@ -1,3 +1,3 @@ Class: Path
On this page

Path

new Path()

路径类

Classes

Path

Members

(readonly) block

path所属的块级组件实例

(readonly) component

path所属组件的实例

(readonly) dataType

数据类型

(readonly) elm

path对应的真实dom

(readonly) firstLeaf

第一个叶子节点

(readonly) isLeaf

是否是叶子节点

(readonly) lastLeaf

最后一个叶子节点

(readonly) length

path内容长度

(readonly) nextLeaf

下一个叶子节点

(readonly) pathType

路径类型

(readonly) position

绝对路径

(readonly) prevLeaf

上一个叶子节点

(readonly) vn

path对应的虚拟dom

(static) children :Array.<Path>

子级path
Type:

(static) index :Number

同级相对索引
Type:
  • Number

(static) nextSibling :Path

后一个兄弟path
Type:

(static) node :Object

原始数据节点
Type:
  • Object

(static) parent :Path

父path
Type:

(static) prevSibling :Path

前一个兄弟path
Type:

(protected, static) rebuildFlag

重建标记 0:无操作 ;1:删除

Methods

clearFormat()

清除格式

clone() → {Path}

标记克隆
Returns:
Type: 
Path

delete()

path删除

deleteBetween(startPath, endPath)

删除两个节点之间的所有节点 不包含开始结束节点
Parameters:
NameTypeDescription
startPathPath开始节点
endPathPath结束节点

insertAfter(path)

插入到path后面
Parameters:
NameTypeDescription
pathPath

insertBefore(path)

插入到path前面
Parameters:
NameTypeDescription
pathPath

moveTo(path)

移动到path的children
Parameters:
NameTypeDescription
pathPath

originOf(path) → {Boolean}

是否源于 xxx
Parameters:
NameTypeDescription
pathPath
Returns:
Type: 
Boolean

pop() → {*}

从尾部弹出元素
Returns:
Type: 
*

positionCompare(path) → {Number}

- 位置比较
Parameters:
NameTypeDescription
pathPath
Returns:
Type: 
Number
Example
res = a.positionCompare(b),
res=-1: a<b;
res=0: a===b;
res=1: a>b

push(…paths)

尾部插入children
Parameters:
NameTypeAttributesDescription
paths*<repeatable>

rebuild()

重构链表树

setFormat(formats)

设置格式(只会merge格式,不会强制覆盖其他格式)
Parameters:
NameTypeDescription
formatsObject格式

setNode({ dataopt)

设置节点
Parameters:
NameTypeAttributesDefaultDescription
{ data*<optional>
'', formats = {} }={}

shift() → {*}

从头部弹出元素
Returns:
Type: 
*

splice(start, deleteCount, …additems) → {deleteItems}

通过移除或者替换已存在的元素和/或添加新元素就地改变一个数组的内容
Parameters:
NameTypeAttributesDescription
start*
deleteCount*
additems*<repeatable>
Returns:
Type: 
deleteItems

split(index) → {Array.<Path>}

path分割
Parameters:
NameTypeDescription
indexNumber分隔位置
Returns:
path列表
Type: 
Array.<Path>

textDelete(offset, count)

内容删除
Parameters:
NameTypeDescription
offsetNumber偏移量,开始删除的位置
countNumber删除的字符数量

textInsert(pos, data)

文本插入
Parameters:
NameTypeDescription
posString从偏移量,开始删除的位置
dataString插入字符

unshift(…paths)

从头部插入children
Parameters:
NameTypeAttributesDescription
paths*<repeatable>
Typex-Document
\ No newline at end of file +
On this page

Path

new Path()

路径类

Classes

Path

Members

(readonly) block

path所属的块级组件实例

(readonly) component

path所属组件的实例

(readonly) dataType

数据类型

(readonly) elm

path对应的真实dom

(readonly) firstLeaf

第一个叶子节点

(readonly) isLeaf

是否是叶子节点

(readonly) lastLeaf

最后一个叶子节点

(readonly) length

path内容长度

(readonly) nextLeaf

下一个叶子节点

(readonly) pathType

路径类型

(readonly) position

绝对路径

(readonly) prevLeaf

上一个叶子节点

(readonly) vn

path对应的虚拟dom

(static) children :Array.<Path>

子级path
Type:

(static) index :Number

同级相对索引
Type:
  • Number

(static) nextSibling :Path

后一个兄弟path
Type:

(static) node :Object

原始数据节点
Type:
  • Object

(static) parent :Path

父path
Type:

(static) prevSibling :Path

前一个兄弟path
Type:

(protected, static) rebuildFlag

重建标记 0:无操作 ;1:删除

Methods

clearFormat()

清除格式

clone() → {Path}

标记克隆
Returns:
Type: 
Path

delete()

path删除

deleteBetween(startPath, endPath)

删除两个节点之间的所有节点 不包含开始结束节点
Parameters:
NameTypeDescription
startPathPath开始节点
endPathPath结束节点

insertAfter(path)

插入到path后面
Parameters:
NameTypeDescription
pathPath

insertBefore(path)

插入到path前面
Parameters:
NameTypeDescription
pathPath

moveTo(path)

移动到path的children
Parameters:
NameTypeDescription
pathPath

originOf(path) → {Boolean}

是否源于 xxx
Parameters:
NameTypeDescription
pathPath
Returns:
Type: 
Boolean

pop() → {*}

从尾部弹出元素
Returns:
Type: 
*

positionCompare(path) → {Number}

- 位置比较
Parameters:
NameTypeDescription
pathPath
Returns:
Type: 
Number
Example
res = a.positionCompare(b),
res=-1: a<b;
res=0: a===b;
res=1: a>b

push(…paths)

尾部插入children
Parameters:
NameTypeAttributesDescription
paths*<repeatable>

rebuild()

重构链表树

setFormat(formats)

设置格式(只会merge格式,不会强制覆盖其他格式)
Parameters:
NameTypeDescription
formatsObject格式

setNode({ dataopt)

设置节点
Parameters:
NameTypeAttributesDefaultDescription
{ data*<optional>
'', formats = {} }={}

shift() → {*}

从头部弹出元素
Returns:
Type: 
*

splice(start, deleteCount, …additems) → {deleteItems}

通过移除或者替换已存在的元素和/或添加新元素就地改变一个数组的内容
Parameters:
NameTypeAttributesDescription
start*
deleteCount*
additems*<repeatable>
Returns:
Type: 
deleteItems

split(index) → {Array.<Path>}

path分割
Parameters:
NameTypeDescription
indexNumber分隔位置
Returns:
path列表
Type: 
Array.<Path>

textDelete(offset, count)

内容删除
Parameters:
NameTypeDescription
offsetNumber偏移量,开始删除的位置
countNumber删除的字符数量

textInsert(pos, data)

文本插入
Parameters:
NameTypeDescription
posString从偏移量,开始删除的位置
dataString插入字符

unshift(…paths)

从头部插入children
Parameters:
NameTypeAttributesDescription
paths*<repeatable>
Typex-Document
\ No newline at end of file diff --git a/Path_Path.html b/Path_Path.html index 26a88c2..4fe8665 100644 --- a/Path_Path.html +++ b/Path_Path.html @@ -1,3 +1,3 @@ Class: Path
On this page

Path# Path

new Path(options)

Creates an instance of Path.
Parameters:
NameTypeDescription
optionsObjectThe options object.
Properties
NameTypeDescription
nodeObject原始数据节点.
parentPath父path.
indexnumber同级相对索引.
prevSiblingPath前一个兄弟path.
nextSiblingPath后一个兄弟path.
childrenArray.<Path>子级path.
Typex-Document
\ No newline at end of file +
On this page

Path# Path

new Path(options)

Creates an instance of Path.
Parameters:
NameTypeDescription
optionsObjectThe options object.
Properties
NameTypeDescription
nodeObject原始数据节点.
parentPath父path.
indexnumber同级相对索引.
prevSiblingPath前一个兄弟path.
nextSiblingPath后一个兄弟path.
childrenArray.<Path>子级path.
Typex-Document
\ No newline at end of file diff --git a/Range.html b/Range.html index 8c87a1b..66b8ab4 100644 --- a/Range.html +++ b/Range.html @@ -1,3 +1,3 @@ Class: Range
On this page

Range

new Range()

选区范围类

Members

(readonly) collapsed

是否折叠

container

容器

container

设置容器

get:offset

偏移量

set:offset :number

设置偏移量
Type:
  • number

(static) d

标识range方向

(static, readonly) snapshot

range快照

Methods

collapse(toStart)

折叠选区范围
Parameters:
NameTypeDefaultDescription
toStart*true

remove()

删除选区范围

set(container, offset)

设置容器和偏移量
Parameters:
NameTypeDescription
container*
offset*

setEnd(endContainer, endOffset)

设置结束端点
Parameters:
NameTypeDescription
endContainer*
endOffset*

setStart(startContainer, startOffset)

设置开始端点
Parameters:
NameTypeDescription
startContainer*
startOffset*

updateCaret(drawCaretopt)

更新光标
Parameters:
NameTypeAttributesDefaultDescription
drawCaretboolean<optional>
true
Typex-Document
\ No newline at end of file +
On this page

Range

new Range()

选区范围类

Members

(readonly) collapsed

是否折叠

container

容器

container

设置容器

get:offset

偏移量

set:offset :number

设置偏移量
Type:
  • number

(static) d

标识range方向

(static, readonly) snapshot

range快照

Methods

collapse(toStart)

折叠选区范围
Parameters:
NameTypeDefaultDescription
toStart*true

remove()

删除选区范围

set(container, offset)

设置容器和偏移量
Parameters:
NameTypeDescription
container*
offset*

setEnd(endContainer, endOffset)

设置结束端点
Parameters:
NameTypeDescription
endContainer*
endOffset*

setStart(startContainer, startOffset)

设置开始端点
Parameters:
NameTypeDescription
startContainer*
startOffset*

updateCaret(drawCaretopt)

更新光标
Parameters:
NameTypeAttributesDefaultDescription
drawCaretboolean<optional>
true
Typex-Document
\ No newline at end of file diff --git a/Selection.html b/Selection.html index ecccfa8..bdb692f 100644 --- a/Selection.html +++ b/Selection.html @@ -1,3 +1,3 @@ Class: Selection
On this page

Selection

new Selection()

选区类

Members

(readonly) collapsed

选区是否折叠

(readonly) rangeCount

选区范围数量

(readonly) rangePoints

选区端点list

Methods

addRange(range)

增加range
Parameters:
NameTypeDescription
range*

clearRanges()

清除范围选区

collapse(parentNode, offset)

折叠选区
Parameters:
NameTypeDescription
parentNode*
offset*

createNativeRange({) → {*}

创建原生range
Parameters:
NameTypeDescription
{*startContainer, startOffset, endContainer, endOffset }
Returns:
Type: 
*

createRange(ops) → {*}

创建range
Parameters:
NameTypeDescription
ops*
Returns:
Type: 
*

createRangeFromNativeRange(nativeRange) → {*}

从原生range创建range
Parameters:
NameTypeDescription
nativeRange*
Returns:
Type: 
*

drawRangeBg(range)

默认以第一个range同步到native来绘制拖蓝
Parameters:
NameTypeDescription
range*

getRangeAt(indexopt) → {*}

获取第index个range
Parameters:
NameTypeAttributesDefaultDescription
indexnumber<optional>
0
Returns:
Type: 
*

getSeletedPath() → {Iterator}

获取选中的叶子节点迭代器
Returns:
迭代器
Type: 
Iterator

removeAllRanges()

移除range并且清除原生range

updateCaret(drawCaretopt)

光标视图更新
Parameters:
NameTypeAttributesDefaultDescription
drawCaretboolean<optional>
true

updatePoints(container, position, distance, newContainer)

在指定容器指定位置发生内容平移,该位置右侧的range锚点需要跟随平移
Parameters:
NameTypeDescription
container*目标容器
position*位置
distance*平移距离,负左正右
newContainer*设置新容器

updateRangesFromNative(multiple)

range更新 追加ranges或者重新设置ranges
Parameters:
NameTypeDescription
multiple*
Typex-Document
\ No newline at end of file +
On this page

Selection

new Selection()

选区类

Members

(readonly) collapsed

选区是否折叠

(readonly) rangeCount

选区范围数量

(readonly) rangePoints

选区端点list

Methods

addRange(range)

增加range
Parameters:
NameTypeDescription
range*

clearRanges()

清除范围选区

collapse(parentNode, offset)

折叠选区
Parameters:
NameTypeDescription
parentNode*
offset*

createNativeRange({) → {*}

创建原生range
Parameters:
NameTypeDescription
{*startContainer, startOffset, endContainer, endOffset }
Returns:
Type: 
*

createRange(ops) → {*}

创建range
Parameters:
NameTypeDescription
ops*
Returns:
Type: 
*

createRangeFromNativeRange(nativeRange) → {*}

从原生range创建range
Parameters:
NameTypeDescription
nativeRange*
Returns:
Type: 
*

drawRangeBg(range)

默认以第一个range同步到native来绘制拖蓝
Parameters:
NameTypeDescription
range*

getRangeAt(indexopt) → {*}

获取第index个range
Parameters:
NameTypeAttributesDefaultDescription
indexnumber<optional>
0
Returns:
Type: 
*

getSeletedPath() → {Iterator}

获取选中的叶子节点迭代器
Returns:
迭代器
Type: 
Iterator

removeAllRanges()

移除range并且清除原生range

updateCaret(drawCaretopt)

光标视图更新
Parameters:
NameTypeAttributesDefaultDescription
drawCaretboolean<optional>
true

updatePoints(container, position, distance, newContainer)

在指定容器指定位置发生内容平移,该位置右侧的range锚点需要跟随平移
Parameters:
NameTypeDescription
container*目标容器
position*位置
distance*平移距离,负左正右
newContainer*设置新容器

updateRangesFromNative(multiple)

range更新 追加ranges或者重新设置ranges
Parameters:
NameTypeDescription
multiple*
Typex-Document
\ No newline at end of file diff --git a/core_defaultActions_caretMove.js.html b/core_defaultActions_caretMove.js.html index 9a96ecd..b10f21b 100644 --- a/core_defaultActions_caretMove.js.html +++ b/core_defaultActions_caretMove.js.html @@ -1,6 +1,6 @@ Source: core/defaultActions/caretMove.js
On this page

core_defaultActions_caretMove.js

/*
+    
On this page

core_defaultActions_caretMove.js

/*
  * @Author: caiwu
  * @Description: 光标移动功能
  * @CreateDate:
@@ -116,4 +116,4 @@
   }
   return loop(range, direction, initialCaretInfo, currCaretInfo, lineChanged, event)
 }
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex-Document
\ No newline at end of file diff --git a/core_defaultActions_delete.js.html b/core_defaultActions_delete.js.html index f577ec8..3e27318 100644 --- a/core_defaultActions_delete.js.html +++ b/core_defaultActions_delete.js.html @@ -1,6 +1,6 @@ Source: core/defaultActions/delete.js
On this page

core_defaultActions_delete.js

/*
+    
On this page

core_defaultActions_delete.js

/*
  * @Author: caiwu
  * @Description:
  * @CreateDate:
@@ -22,4 +22,4 @@
   const component = commonPath.component
   component.onContentDelete(commonPath, range)
 }
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex-Document
\ No newline at end of file diff --git a/core_initCore.js.html b/core_initCore.js.html index 991eb8b..4ec57f6 100644 --- a/core_initCore.js.html +++ b/core_initCore.js.html @@ -1,6 +1,6 @@ Source: core/initCore.js
On this page

core_initCore.js

import pluginContext from './pluginContext'
+    
On this page

core_initCore.js

import pluginContext from './pluginContext'
 import emit from 'mitt'
 import Selection from './selection'
 import { usePlugin } from './pluginContext'
@@ -181,4 +181,4 @@
     e.target.value = ''
   }
 }
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex-Document
\ No newline at end of file diff --git a/core_model_content.js.html b/core_model_content.js.html index 619a103..0826fe7 100644 --- a/core_model_content.js.html +++ b/core_model_content.js.html @@ -1,6 +1,6 @@ Source: core/model/content.js
On this page

core_model_content.js

import Component from '../view/component'
+    
On this page

core_model_content.js

import Component from '../view/component'
 import { horizontalMove, verticalMove } from '../defaultActions/caretMove'
 import { del } from '../defaultActions/delete'
 import { createPath } from './path'
@@ -468,4 +468,4 @@
     })
   }
 }
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex-Document
\ No newline at end of file diff --git a/core_model_formater.js.html b/core_model_formater.js.html index a606433..5451849 100644 --- a/core_model_formater.js.html +++ b/core_model_formater.js.html @@ -1,6 +1,6 @@ Source: core/model/formater.js
On this page

core_model_formater.js

import { default as h } from '../view/vdom/createVnode'
+    
On this page

core_model_formater.js

import { default as h } from '../view/vdom/createVnode'
 import { setVdomOrPath } from '../mappings'
 import { mergeTextPath } from '../utils'
 
@@ -316,4 +316,4 @@
   }
 }
 export default Formater
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex-Document
\ No newline at end of file diff --git a/core_model_path.js.html b/core_model_path.js.html index 3e8675c..6d92469 100644 --- a/core_model_path.js.html +++ b/core_model_path.js.html @@ -1,6 +1,6 @@ Source: core/model/path.js
On this page

core_model_path.js

import { getVdomOrElm, getVdomOrPath } from '../mappings'
+    
On this page

core_model_path.js

import { getVdomOrElm, getVdomOrPath } from '../mappings'
 import { computeLen, typeOf, positionCompare, isPrimitive, uuid } from '../utils'
 
 /**
@@ -633,4 +633,4 @@
     return prev.children[index]
   }, rootPath)
 }
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex-Document
\ No newline at end of file diff --git a/core_selection_index.js.html b/core_selection_index.js.html index 176f9d9..f981b56 100644 --- a/core_selection_index.js.html +++ b/core_selection_index.js.html @@ -1,6 +1,6 @@ Source: core/selection/index.js
On this page

core_selection_index.js

import pluginContext from '@/core/pluginContext'
+    
On this page

core_selection_index.js

import pluginContext from '@/core/pluginContext'
 import Range from './range'
 
 /**
@@ -449,4 +449,4 @@
     this.updateCaret()
   }
 }
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex-Document
\ No newline at end of file diff --git a/core_selection_range_index.js.html b/core_selection_range_index.js.html index 8cc5664..954a0f0 100644 --- a/core_selection_range_index.js.html +++ b/core_selection_range_index.js.html @@ -1,6 +1,6 @@ Source: core/selection/range/index.js
On this page

core_selection_range_index.js

/*
+    
On this page

core_selection_range_index.js

/*
  * @Author: caiwu
  * @Description:
  * @CreateDate:
@@ -191,4 +191,4 @@
     this.editor.selection.ranges.splice(index, 1)
   }
 }
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex-Document
\ No newline at end of file diff --git a/core_utils.js.html b/core_utils.js.html index aefce27..d8fd3a7 100644 --- a/core_utils.js.html +++ b/core_utils.js.html @@ -1,6 +1,6 @@ Source: core/utils.js
On this page

core_utils.js

/*
+    
On this page

core_utils.js

/*
  * @Author: caiwu
  * @Description:
  * @CreateDate:
@@ -215,4 +215,4 @@
 export function isFunction (v) {
   if (typeof v !== 'function') return false
   return /^function\s/.test(Function.prototype.toString.call(v))
-}
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +}
Typex-Document
\ No newline at end of file diff --git a/core_view_component.js.html b/core_view_component.js.html index 311faf6..32a4884 100644 --- a/core_view_component.js.html +++ b/core_view_component.js.html @@ -1,6 +1,6 @@ Source: core/view/component.js
On this page

core_view_component.js

/*
+    
On this page

core_view_component.js

/*
  * @Author: caiwu
  * @Description:
  * @CreateDate:
@@ -109,4 +109,4 @@
     return true
   }
 }
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex-Document
\ No newline at end of file diff --git a/core_view_vdom_createRef.js.html b/core_view_vdom_createRef.js.html index e92da1f..9baeff8 100644 --- a/core_view_vdom_createRef.js.html +++ b/core_view_vdom_createRef.js.html @@ -1,6 +1,6 @@ Source: core/view/vdom/createRef.js
On this page

core_view_vdom_createRef.js


+    
On this page

core_view_vdom_createRef.js


 /**
  * @description 创建ref
  * @export
@@ -9,4 +9,4 @@
 export default function createRef () {
   return { current: null }
 }
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex-Document
\ No newline at end of file diff --git a/core_view_vdom_createVnode.js.html b/core_view_vdom_createVnode.js.html index ffb1e8c..353713f 100644 --- a/core_view_vdom_createVnode.js.html +++ b/core_view_vdom_createVnode.js.html @@ -1,6 +1,6 @@ Source: core/view/vdom/createVnode.js
On this page

core_view_vdom_createVnode.js

import { isPrimitive, isUndef, styleToObj, uuid, mergeObj, isClass, isFunction } from '../../utils'
+    
On this page

core_view_vdom_createVnode.js

import { isPrimitive, isUndef, styleToObj, uuid, mergeObj, isClass, isFunction } from '../../utils'
 const BUILTINPROPSKEY = ['ref', 'key', 'ns'] //不包含在props中的属性
 const INHERITPROPSKEY = ['ns'] // 需要继承的属性
 
@@ -96,4 +96,4 @@
   }
   return element
 }
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex-Document
\ No newline at end of file diff --git a/core_view_vdom_enqueueSetState.js.html b/core_view_vdom_enqueueSetState.js.html index 0169df1..f9e8032 100644 --- a/core_view_vdom_enqueueSetState.js.html +++ b/core_view_vdom_enqueueSetState.js.html @@ -1,6 +1,6 @@ Source: core/view/vdom/enqueueSetState.js
On this page

core_view_vdom_enqueueSetState.js

const queue = []
+    
On this page

core_view_vdom_enqueueSetState.js

const queue = []
 const componentQueue = []
 
 /**
@@ -62,4 +62,4 @@
 function defer(fn) {
   return Promise.resolve().then(fn)
 }
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex-Document
\ No newline at end of file diff --git a/core_view_vdom_patch.js.html b/core_view_vdom_patch.js.html index f522b30..836f6cd 100644 --- a/core_view_vdom_patch.js.html +++ b/core_view_vdom_patch.js.html @@ -1,6 +1,6 @@ Source: core/view/vdom/patch.js
On this page

core_view_vdom_patch.js

/*
+    
On this page

core_view_vdom_patch.js

/*
  * @Author: caiwu
  * @Description:
  * @CreateDate:
@@ -340,4 +340,4 @@
   if (typeof ins[hookName] !== 'function') return
   ins[hookName]()
 }
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex-Document
\ No newline at end of file diff --git a/dist/index.html b/dist/index.html index b071cba..67c8dab 100644 --- a/dist/index.html +++ b/dist/index.html @@ -1,3 +1,3 @@ Document
渲染器测试demo:
\ No newline at end of file + }
\ No newline at end of file diff --git a/dist/index.js b/dist/index.js index ffb88aa..defd2c3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -(()=>{var t={705:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",o=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),o&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),o&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,o,r,i){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(o)for(var a=0;a0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=i),n&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=n):d[2]=n),r&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=r):d[4]="".concat(r)),e.push(d))}},e}},742:t=>{"use strict";t.exports=function(t,e){return e||(e={}),t?(t=String(t.__esModule?t.default:t),/^['"].*['"]$/.test(t)&&(t=t.slice(1,-1)),e.hash&&(t+=e.hash),/["'() \t\n]|(%20)/.test(t)||e.needQuotes?'"'.concat(t.replace(/"/g,'\\"').replace(/\n/g,"\\n"),'"'):t):t}},738:t=>{"use strict";t.exports=function(t){return t[1]}},22:()=>{window._iconfont_svg_string_3243125='',function(t){var e,n=(e=(e=document.getElementsByTagName("script"))[e.length-1]).getAttribute("data-injectcss");if(!(e=e.getAttribute("data-disable-injectsvg"))){var o,r,i,s,a;if(n&&!t.__iconfont__svg__cssinject__){t.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(e){console&&console.log(e)}}o=function(){var e,n=document.createElement("div");n.innerHTML=t._iconfont_svg_string_3243125,(n=n.getElementsByTagName("svg")[0])&&(n.setAttribute("aria-hidden","true"),n.style.position="absolute",n.style.width=0,n.style.height=0,n.style.overflow="hidden",n=n,(e=document.body).firstChild?function(t,e){e.parentNode.insertBefore(t,e)}(n,e.firstChild):e.appendChild(n))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(o,0):(r=function(){document.removeEventListener("DOMContentLoaded",r,!1),o()},document.addEventListener("DOMContentLoaded",r,!1)):document.attachEvent&&(i=o,s=t.document,a=!1,function t(){try{s.documentElement.doScroll("left")}catch(e){return void setTimeout(t,50)}l()}(),s.onreadystatechange=function(){"complete"==s.readyState&&(s.onreadystatechange=null,l())})}function l(){a||(a=!0,i())}}(window)},259:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var o=n(738),r=n.n(o),i=n(705),s=n.n(i)()(r());s.push([t.id,".editor-tool-bar{border:solid 1px #eee;background:#282828;padding:6px}.editor-tool-bar .icon{width:1.2em;height:1.2em;vertical-align:-.15em;fill:currentColor;overflow:hidden}.editor-tool-bar .editor-tool-bar-item{padding:4px 10px;display:inline-block;border-radius:4px;cursor:pointer;user-select:none}.editor-tool-bar #editor-content{padding:16px;min-height:200px}.editor-tool-bar .editor-tooltip{position:relative;display:inline-block}.editor-tool-bar .editor-tooltip .tooltiptext{opacity:0;width:60px;font-size:12px;background-color:#000;color:#fff;text-align:center;border-radius:6px;padding:5px 0;position:absolute;z-index:1;top:140%;left:50%;margin-left:-30px;transition:opacity 600ms ease-out}.editor-tool-bar .editor-tooltip .tooltiptext::after{content:'';position:absolute;left:50%;margin-left:-5px;border-width:5px;border-style:solid}.editor-tool-bar .editor-tooltip:hover .tooltiptext{opacity:1}.editor-tool-bar .editor-tooltip .tooltiptext.bottom{top:140%}.editor-tool-bar .editor-tooltip .tooltiptext.bottom::after{bottom:100%;border-color:transparent transparent #000 transparent}.editor-tool-bar .editor-tooltip .tooltiptext.top{top:-140%}.editor-tool-bar .editor-tooltip .tooltiptext.top::after{top:100%;border-color:#000 transparent transparent transparent}.editor-tool-bar #colorPicker{width:200px;padding:10px;background-color:#fff;border:1px solid #ccc;box-shadow:0 0 10px rgba(0,0,0,0.1);border-radius:5px;text-align:center}.editor-tool-bar #colorDisplay{width:100%;height:50px;margin-bottom:10px}.editor-tool-bar #colorInput{width:100%;padding:5px;border:1px solid #ccc;border-radius:3px}.editor-tool-bar #alphaInput{width:100%;padding:5px;border:1px solid #ccc;border-radius:3px;margin-top:5px}",""]);const a=s},706:(t,e,n)=>{"use strict";n.d(e,{Z:()=>p});var o=n(738),r=n.n(o),i=n(705),s=n.n(i),a=n(742),l=n.n(a),c=new URL(n(363),n.b),d=s()(r()),h=l()(c);d.push([t.id,".picker{display:flex;justify-content:space-between;margin-top:4px}.left .hue{font-size:0;height:10px;width:200px;background:linear-gradient(to left,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00)}.left .hue .hue-picker{display:inline-block;position:relative;width:6px;height:12px;transform:translate(-6px,-1px);background-color:#f8f8f8;box-shadow:rgba(0,0,0,0.37) 0 1px 4px 0}.left .transparency{position:relative;font-size:0;height:10px;width:200px;background:url("+h+") left center}.left .transparency .transparency-picker-bg{height:100%}.left .transparency .transparency-picker{display:inline-block;position:relative;width:6px;height:12px;transform:translate(-6px,-1px);background-color:#f8f8f8;box-shadow:rgba(0,0,0,0.37) 0 1px 4px 0}.right{position:relative;cursor:pointer}.right .color-block{width:24px;height:24px;position:absolute;top:0}.right .color-block-bg{width:24px;height:24px;background:url("+h+") left center}.palette{width:228px;height:150px;overflow:hidden;border:#eee solid 1px}.palette .palette-picker{pointer-events:none;display:inline-block;position:relative;width:12px;height:12px;border-radius:50%;box-shadow:#fff 0 0 0 1px inset;transform:translate(-6px,-6px)}",""]);const p=d},815:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var o=n(738),r=n.n(o),i=n(705),s=n.n(i)()(r());s.push([t.id,"#editor-content:focus,.custom-input:focus{outline:none}#editor-content{word-break:break-all;padding:15px}#editor-content .custom-input-iframe{top:-100px;left:0;background:transparent;color:transparent;width:0;height:0;pointer-events:none;border:none;caret-color:transparent;position:absolute}#editor-content .custom-caret{top:-100px;left:0;pointer-events:none;position:absolute;width:2px;border:none;padding:0;display:block;animation:caret 1s infinite .5s steps(1,start)}#editor-content .editor-disabled{user-select:none}#editor-content ::selection{background:#bad2fa}#editor-content table td,#editor-content td{background-color:#fff}#editor-content table td,#editor-content th,#editor-content td{display:table-cell;margin:0;padding:0;text-align:left;vertical-align:middle}@-moz-keyframes static-caret{0%{opacity:1}100%{opacity:1}}@-webkit-keyframes static-caret{0%{opacity:1}100%{opacity:1}}@-o-keyframes static-caret{0%{opacity:1}100%{opacity:1}}@keyframes static-caret{0%{opacity:1}100%{opacity:1}}@-moz-keyframes caret{0%{opacity:1}50%{opacity:0}100%{opacity:1}}@-webkit-keyframes caret{0%{opacity:1}50%{opacity:0}100%{opacity:1}}@-o-keyframes caret{0%{opacity:1}50%{opacity:0}100%{opacity:1}}@keyframes caret{0%{opacity:1}50%{opacity:0}100%{opacity:1}}",""]);const a=s},379:t=>{"use strict";var e=[];function n(t){for(var n=-1,o=0;o{"use strict";var e={};t.exports=function(t,n){var o=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},565:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},795:t=>{"use strict";t.exports=function(t){var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var o="";n.supports&&(o+="@supports (".concat(n.supports,") {")),n.media&&(o+="@media ".concat(n.media," {"));var r=void 0!==n.layer;r&&(o+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),o+=n.css,r&&(o+="}"),n.media&&(o+="}"),n.supports&&(o+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleTagTransform(o,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},589:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},363:t=>{"use strict";t.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAADFJREFUOE9jZGBgEGHAD97gk2YcNYBhmIQBgWSAP52AwoAQwJvQRg1gACckQoC2gQgAIF8IscwEtKYAAAAASUVORK5CYII="}},e={};function n(o){var r=e[o];if(void 0!==r)return r.exports;var i=e[o]={id:o,exports:{}};return t[o](i,i.exports,n),i.exports}n.m=t,n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.b=document.baseURI||self.location.href,(()=>{"use strict";var t={};n.r(t),n.d(t,{classCheck:()=>q,computeLen:()=>T,debounce:()=>N,isClass:()=>X,isDef:()=>M,isFunction:()=>Y,isPrimitive:()=>P,isUndef:()=>A,mergeObj:()=>D,mergePointsContainer:()=>G,mergeTextPath:()=>Z,multiplication:()=>F,positionCompare:()=>K,setStyle:()=>_,stringify:()=>H,styleToObj:()=>V,throttle:()=>$,times:()=>j,toRawType:()=>z,typeOf:()=>U,uuid:()=>I});var e={};n.r(e),n.d(e,{Caret:()=>ge,appendChild:()=>Ie,createElm:()=>Pe,domToVNode:()=>je,initIntercept:()=>Be,insertBefore:()=>He,nativeDocument:()=>ze,nativeSelection:()=>Fe,nativeWindow:()=>_e,removeChild:()=>De,replaceChild:()=>Ve,updateProps:()=>Me});var o=n(379),r=n.n(o),i=n(795),s=n.n(i),a=n(569),l=n.n(a),c=n(565),d=n.n(c),h=n(216),p=n.n(h),u=n(589),f=n.n(u),m=n(706),g={};g.styleTagTransform=f(),g.setAttributes=d(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=p(),r()(m.Z,g),m.Z&&m.Z.locals&&m.Z.locals;const y=new WeakMap,v=new WeakMap,b=new WeakMap,x=new WeakMap;function w(t){return b.get(t)}function C(t){if(t.vnodeType){const e=x.get(t);if(e)return e;if(3===t.vnodeType)return null;const n=w(t),o=S(n);return 1===n.vnodeType?x.get(n):x.get(o)}{const e=x.get(t);if(!e)return;return e}}function S(t){return v.get(t)}function k(t){return 1===t.vnodeType?y.get(b.get(t)):2===t.vnodeType?y.get(b.get(v.get(t))):y.get(t)}function O(t,e){y.set(e,t).set(t,e)}function E(t,e){v.set(e,t).set(t,e)}function R(t,e){x.set(t,e).set(e,t)}function L(t,e){return b.set(e,t).set(t,e)}function A(t){return null==t}function M(t){return null!=t}function P(t){return"string"==typeof t||"number"==typeof t||"symbol"==typeof t||"boolean"==typeof t}function T(t){return P(t.node.data)?t.node.data.length:t.children.length?t.children.reduce(((t,e)=>t+T(e)),0):0}function $(t,e,n=!0){let o,r,i;return function(){const s=this,a=arguments;o?(clearTimeout(r),r=setTimeout((function(){Date.now()-i>=e&&(t.apply(s,a),i=Date.now())}),Math.max(e-(Date.now()-i),0))):(n&&t.apply(s,a),i=Date.now(),o=!0)}}function N(t,e=0){let n;return function(...o){clearTimeout(n),n=setTimeout((()=>t.apply(this,o)),e)}}window.aa={setVdomOrElm:O,setVnodeOrIns:E,setVdomOrPath:R,getVdomOrElm:k,getVdomOrPath:C,getVnodeOrIns:S};const B=Object.prototype.toString;function z(t){return B.call(t).slice(8,-1).toLowerCase()}function _(t,e){for(const n in e)t.style[n]=e[n]}function F(t,e){return t.replace(/(\d*).*/,(function(t,n){return n*e}))}function H(t){let e=[],n=JSON.stringify(t,((t,n)=>{if("object"==typeof n&&null!==n){if(-1!==e.indexOf(n))return"Circular reference";e.push(n)}return n}));return e=null,n}function V(t){return(t=t.trim()).split(";").filter((t=>t)).reduce(((t,e)=>{const n=e.split(":");return t[n[0].trim()]=n[1].trim(),t}),{})}function I(){return([1e3]+-1e3+-4e3+-8e3).replace(/[018]/g,(t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)))}function D(t,e){for(let n in e)e.hasOwnProperty(n)&&A(t[n])&&!A(e[n])&&(t[n]=e[n])}function j(t,e,n,...o){let r=0;for(;r++r)return 1;if(e{if(!t.prototype.hasOwnProperty(e))throw new Error(`please overwrite ${e} method`)}))}function G(t,e,n){n.selection.rangePoints.filter((e=>e.container===t)).forEach((t=>{"start"===t.pointName?t.range.setStart(e,e.length+t.offset):t.range.setEnd(e,e.length+t.offset)}))}function Z(t,e){const n=t[0],o=t.length;if(1===o)return n;for(let t=0;t{t.moveTo(e)})),e.insertAfter(this),[this,e]}}clone(t=!1){let e;return e=t?P(this.node.data)?this.node.data:JSON.parse(JSON.stringify(this.node.data)):P(this.node.data)?"":this.node.data?[]:{},Q({data:e,formats:{...this.node.formats}})}positionCompare(t){return K(this,t)}originOf(t){return this.position.includes(t.position+"-")}insertBefore(t){this.delete(),t.parent.splice(t.index,0,this)}insertAfter(t){this.delete(),t.parent.splice(t.index+1,0,this)}moveTo(t){this.delete(),t.push(this)}delete(){this.parent&&(this.rebuildFlag=1,this.parent.rebuild(),this.parent.component.update())}push(...t){t.forEach((t=>t.rebuildFlag=0)),this.children.push(...t),this.rebuild(),this.component.update()}pop(){const t=this.children[this.children.length-1];return t.rebuildFlag=1,this.rebuild(),this.component.update(),t}unshift(...t){t.forEach((t=>t.rebuildFlag=0)),this.children.unshift(...t),this.rebuild(),this.component.update()}shift(){const t=this.children[0];return t.rebuildFlag=1,this.rebuild(),this.component.update(),t}splice(t,e,...n){const o=[];if(n.length&&(n.forEach((t=>t.rebuildFlag=0)),this.children.splice(t,0,...n)),e>0)for(let n=0;n{for(var i=0;it.rebuild()))}rebuild(t=!1){if("Array"!==this.dataType)return;let e=null;this.children=this.children.filter((t=>1!==t.rebuildFlag)),this.node.data.length=0,this.children.forEach(((t,n)=>{t.parent=this,this.node.data.push(t.node),t.prevSibling=e,e&&(e.nextSibling=t),t.nextSibling=null,e=t,t.index=n}))}}function Q(t,e=null,n=null,o=null,r=0){t.formats||(t.formats={});const i=new J({node:t,parent:e,index:r,prevSibling:n,nextSibling:o,children:[]});if(t.data){let e=null;t.data.reduce?.(((t,n,o)=>(e=Q(n,i,t,null,o),t&&(t.nextSibling=e),e.prevSibling=t,i.children.push(e),e)),null)}return i}function W(t,e){if(t===e)return t;if("0"===t.position)return t;if("0"===e.position)return e;const n=function(t){for(;t.parent;)t=t.parent;return t}(t),o=t.position.split("-"),r=e.position.split("-"),i=Math.min(o.length,r.length);let s;for(s=0;st.children[e]),e)}const ot=["ref","key","ns"],rt=["ns"];function it(t,e,n=[]){e=e||{};const o={},r={};for(let t of ot)r[t]=e[t]||null;for(let t in e)ot.includes(t)||("style"===t&&P(e[t])?o[t]=V(e[t]):o[t]=e[t]);return function(t,e,n,o){let r;if("text"===t)r={_uuid:I(),vnodeType:3,type:"text",children:o.join("")};else{r={_uuid:I(),vnodeType:X(t)?2:Y(t)?1:4,type:t,...e,props:n};const i={};for(let t of rt)i[t]=r[t];1===r.vnodeType||2===r.vnodeType?r.props.children=st(o,i):r.children=st(o,i)}return r}(t,r,o,n.flat())}const st=(t,e)=>t.filter((t=>!!t)).map((t=>P(t)||A(t)?{_uuid:I(),type:"text",vnodeType:3,children:t}:(D(t,e),t))),at=class{formatMap=new Map;register(t){t.forEach((t=>{this.formatMap.set(t.name,t)}))}inject(t,e){this[t]=e}renderRoot(t){return this.render({children:[t]})}render(t){const e=this._group({paths:t.children,restFormats:this.types},0);return this._generateGroups(e,t.isBlock&&0===t.length)}_invokeRender(t,e){return e.fmt.render(t,e.value,it)}_generateGroups(t,e){return t.map((t=>{let n;const o=this._getFormats(t.commonFormats);if(0===t.commonFormats.length){if(-1!==t.children.findIndex((t=>"object"==typeof t.node.data)))throw"格式标记不合法,文本格式不可用于标记非文本的结构";const n=Z(t.children,this.editor);let o=null;return e?(o=it("br"),R(n,n.parent.vn),n.clearFormat()):(""===n.node.data&&console.warn("非法空标签:",n),o=it("text",{},[n.node.data]),R(n,o)),o}if((n=o.filter((t=>"component"===t.fmt.type))).length){const e=t.children[0],o=n[0].fmt.render(null,{path:e,editor:this.editor},n[0].value,it);return R(e,o),o}{let n=null,r=null;const i=[];for(let t=0;t"object"==typeof t.data)))throw"格式标记不合法,文本格式不可用于标记非文本的结构";const n=Z(t.children,this.editor);let o=null;e?(o=it("br"),R(n,r),n.clearFormat()):(""===n.node.data&&console.warn("非法空标签:",n),o=it("text",{},[n.node.data]),R(n,o)),r.children=[o]}return n}})).filter((t=>t))}get types(){return[...this.formatMap.keys()]}_getFormats(t){return t.map((t=>{const e=Object.keys(t)[0];return{fmt:this.formatMap.get(e),value:t[e]}}))}get(t){return this.formatMap.get(t)||{}}_canAdd(t,e,n){return!!t.node.formats[n]&&(!e.node.formats[n]||e.node.formats[n]===t.node.formats[n]||void 0)}_group(t,e,n=[]){const o={commonFormats:[],children:[]};let r=[],i=null,s={},a=0;for(;e{i?this._canAdd(l,i,t)&&s[t]++:(s[t]=0,l.node.formats[t]&&s[t]++)}));const c=Math.max(...Object.values(s));if(i&&Object.keys(l.node.formats).some((t=>"component"===this.get(t).type))){i=null;break}if(i&&Object.keys(i.node.formats).some((t=>"component"===this.get(t).type))){i=null;break}if(i&&0===a&&c>a){s=n;break}if(i&&c===a&&0!==c){s=n;break}o.children.push(l),o.commonFormats=Object.entries(s).filter((t=>t[1]&&t[1]===c)).map((n=>({[n[0]]:t.paths[e].node.formats[n[0]]}))),r=t.restFormats.filter((t=>!o.commonFormats.some((e=>e[t])))),a=c,i=l}return o.commonFormats.length>0&&o.children.length>1&&(o.children=this._group({paths:o.children,restFormats:r},0)),n.push(o),e{"function"==typeof t.onUnmounted&&t.onUnmounted()})),n=null}}}(t,n,a,c)}(n,r,o)}}function ft(t,e){if(e!==t){if(!t){const t=S(e),n=w(t),o=t.generateVdom(it);return L(t,o),ut(o,n),k(o)}if(A(e))return Bt.platform.createElm(t);if(M(e.nodeType)&&O(e,e=Bt.platform.domToVNode(e)),lt(t,e))ut(t,e);else{let n=k([1,2].includes(e.vnodeType)?pt(e):e);const o=Bt.platform.createElm(t);mt(e,"onUnmounted"),Bt.platform.replaceChild(n.parentNode,o,n),mt(t,"onMounted")}return k([1,2].includes(t.vnodeType)?pt(t):t)}}function mt(t,e){const n=t.vnodeType?S(t):t;n&&"function"==typeof n[e]&&n[e]()}const gt=[],yt=[];function vt(){let t,e;for(;t=gt.shift();){const{partialState:e,component:n}=t;n.prevState||(n.prevState=Object.assign({},n.state)),"function"==typeof e?Object.assign(n.state,e(n.prevState,n.props)):Object.assign(n.state,e),n.prevState=n.state}for(;e=yt.shift();)e.shouldComponentUpdate()&&e.syncUpdate()}class bt{static isComponent=!0;get isComponent(){return!0}state={};$nextTick=t=>Promise.resolve().then(t);constructor(t){this.props=Object.freeze({...t})}render(t){throw Error('Component does not implement a required interface "render"')}generateVdom(t){return"function"==typeof this.onBeforeRender&&this.onBeforeRender(),this.render(t)}setState(t={}){return function(t,e){let n=null;var o;return 0===gt.length&&(o=vt,n=Promise.resolve().then(o)),gt.push({partialState:t,component:e}),yt.some((t=>t===e))||yt.push(e),n||Promise.resolve()}(t,this)}syncUpdate(){ft(null,S(this))}shouldComponentUpdate(){return!0}}function xt(t,e,n){if(e.inputState.isComposing)return;if(!e.collapsed&&!n.shiftKey)return void e.collapse("left"===t);const{shiftKey:o}=n;if(e.collapsed||o)return e.container.component.onCaretMove(t,e,n);e.collapse("left"===t)}function wt(t,e,n){e.inputState.isComposing||(e.collapsed||n.shiftKey?St(e,"up"===t?"left":"right",{...e.caret.rect,block:e.container.block},{...e.caret.rect,block:e.container.block},!1,n):e.collapse("up"===t))}function Ct(t,e,n,o){if(n.block!==e.block)return!1;let r=!0;return("left"===o&&n.x>e.x||"right"===o&&n.xt===this));this.caret.remove(),this.editor.selection.ranges.splice(t,1)}}class Pt{ranges=[];nativeSelection=Bt.platform.nativeSelection;constructor(t){this.editor=t}get collapsed(){return this.ranges.every((t=>t.collapsed))}get rangeCount(){return this.ranges.length}get rangePoints(){const t=[];return this.ranges.forEach((e=>{t.push({container:e.startContainer,offset:e.startOffset,range:e,pointName:"start"},{container:e.endContainer,offset:e.endOffset,range:e,pointName:"end"})})),t}get rangesSnapshot(){return this.ranges.map((t=>t.snapshot))}clearRanges(){for(;this.ranges.length;)this.ranges.pop().caret.remove()}createRange(t){return new Mt(t,this.editor)}createRangeFromNativeRange(t){const{startContainer:e,endContainer:n,startOffset:o,endOffset:r,collapsed:i}=t,{focusNode:s,focusOffset:a}=this.nativeSelection;let l=0;return l=i?0:s===n&&a===r?1:-1,this.createRange({startContainer:this.amendPathOffset(e).path,endContainer:this.amendPathOffset(n).path,startOffset:o,endOffset:r,d:l})}addRange(t){this.ranges.push(t)}collapse(t,e){this.nativeSelection.collapse(t,e),this._resetRangesFromNative()}amendPathOffset(t,e){const n=this.editor.queryPath(t);return n?n.isLeaf&&3!==n.pathType?this.amendPathOffset(n.elm.parentNode,n.index+1):{path:n,offset:e}:this.amendPathOffset(t.parentNode,e)}amendRange(t){const{startContainer:e,endContainer:n,startOffset:o,endOffset:r}=t,i=this.amendPathOffset(e,o),s=this.amendPathOffset(n,r);return t.setStart(i.path.elm,i.offset),t.setEnd(s.path.elm,s.offset),t}_resetRangesFromNative(){this.clearRanges();const t=this.nativeSelection.rangeCount;for(let e=0;e0){const e=this.amendRange(this.nativeSelection.getRangeAt(t-1));if(!e)return;let n=!1;if(this.ranges.forEach((t=>{t.endContainer===e.endContainer&&t.startOffset===e.startOffset&&(n=!0,t.remove())})),n)return;this.addRange(this.createRangeFromNativeRange(e))}}getRangeAt(t=0){return this.ranges[t]}removeAllRanges(){this.nativeSelection.removeAllRanges(),this.clearRanges()}createNativeRange({startContainer:t,startOffset:e,endContainer:n,endOffset:o}){const r=document.createRange();return r.setStart(t,e),r.setEnd(n,o),r}updatePoints(t,e,n,o){this.rangePoints.forEach((r=>{r.container===t&&e<=r.offset&&(r.range[r.pointName+"Offset"]+=n,o&&(r.range[r.pointName+"Container"]=o))}))}updateRangesFromNative(t){setTimeout((()=>{t?this._extendRangesFromNative():this._resetRangesFromNative(),this.updateCaret()}))}updateCaret(t=!0){this.ranges.forEach((e=>e.updateCaret(t))),this.rangeCount>1&&this._distinct(),t&&this.drawRangeBg()}_isCoverd(t,e){return t.y=e.y+e.height:e.y+e.height>=t.y+t.height}_distinct(){let t={},e=this.ranges.length;if(!(e<2)){for(let n=0;no.caret.rect.x===t[1].caret.rect.x));0===i.length?t[r]=o:this._isCoverd(o.caret.rect,i[0][1].caret.rect)?(o.caret.remove(),this.ranges.splice(n,1),e--,n--):t[r]=o}}t=null}}drawRangeBg(t){const e=t||this.getRangeAt(0);if(!e)return;const{startContainer:n,startOffset:o,endContainer:r,endOffset:i}=e;this.nativeSelection.removeAllRanges();const s={startContainer:n.elm,endContainer:r.elm,startOffset:o,endOffset:i};this.nativeSelection.addRange(this.createNativeRange(s))}getSeletedPath(){if(this.collapsed)return[];const t=this.ranges[0];let e,n,o,r=!1;if(t.collapsed)r=!0;else{if(0===t.startOffset)e=t.startContainer;else if(t.startOffset===t.startContainer.length)e=t.startContainer.nextLeaf;else{const n=t.startContainer.split(t.startOffset);this.updatePoints(t.startContainer,t.startOffset,-t.startOffset,n[1]),e=n[1]}if(0===t.endOffset)n=t.endContainer.prevLeaf;else if(t.endOffset===t.endContainer.length)n=t.endContainer;else{const e=t.endContainer.split(t.endOffset);this.updatePoints(t.endContainer,t.endOffset+1,-t.endOffset,e[1]),n=e[0]}}return o=e,{length:0,next:function(){if(r)return{value:void 0,done:r};{const t={value:o,done:r};return r=o===n,o=o.nextLeaf,this.length++,t}},[Symbol.iterator]:function(){return this}}}recoverRangesFromSnapshot(t){this.removeAllRanges(),this.ranges=t.map((t=>this.createRange({startContainer:this.editor.queryPath(t.startContainer),endContainer:this.editor.queryPath(t.endContainer),startOffset:t.startOffset,endOffset:t.endOffset,d:t.d}))),this.updateCaret()}}class Tt{steps=[];startRanges=[];endRanges=[];commited=!1;constructor(t){this.editor=t,this.startRanges=this.editor.selection.rangesSnapshot}get commitPath(){return this.editor.queryPath(this.commitPathPosition)}addAndApplyStep(t){return this.steps.push(t),t.apply(this.editor)}addStep(...t){this.steps.push(...t)}commit(){0!==this.steps.length&&(this.endRanges=this.editor.selection.rangesSnapshot,this.editor.history.push(this),this.commited=!0)}apply(){for(let t=0;t{this.editor.selection.recoverRangesFromSnapshot(this.endRanges)}))}rollback(){for(let t=this.steps.length;t>0;t--)this.steps[t-1].invert(this.editor);setTimeout((()=>{this.editor.selection.recoverRangesFromSnapshot(this.startRanges)}))}}const $t={createPath:Q,queryCommonPath:W,queryPath:tt,Formater:at,Content:class extends bt{uuid=I();get renderContent(){return this.$editor.formater.render(this.$path)}get displayType(){return"inline"}constructor(t){super(t)}get contentLength(){return this.$path.length}get $path(){return this.props.path}get $editor(){return this.props.editor}shouldComponentUpdate(){return 1!==this.$path.rebuildFlag}onBeforeRender(){this.$path._$component=this}update(t,e){return this.onBeforeUpdate&&this.onBeforeUpdate({path:t||this.$path,range:e}),this.setState().then((()=>{this.$editor.selection.drawRangeBg(),this.onAfterUpdate&&this.onAfterUpdate({range:e,path:t})}))}onInsert({data:t,type:e,range:n}){if("text"===e){const e=new At({range:n,data:t});return e.apply(),this.update().then((()=>{n.collapse(!1),n.updateCaret()})),e}}onContentDelete(t,e){console.log("删除");const{endContainer:n,endOffset:o,startContainer:r,startOffset:i,collapsed:s}=e;if(s){const t=r.prevLeaf;if(o>0)r.textDelete(o,1),0===r.block.contentLength?(e.setStart(r,0).collapse(),r.block.$path.parent.component.update()):0===r.length?(r.delete(),t.block===r.block&&t?e.setStart(t,t.length).collapse():e.setStart(r.nextLeaf,0).collapse()):(this._updatePoints(n,o,-1),t?.block===r.block&&1===o&&e.setStart(t,t.length).collapse());else if(0===r.block.contentLength)r.block.$path.delete(),e.setStart(t,t.length).collapse();else if(0===r.length)r.delete();else if(r.block!==t.block){const n=r.parent;0===t.length?(t.parent.pop(),t.parent.push(...r.parent.children),n.delete(),e.setStart(r,0)):(t.parent.splice(t.index+1,0,...r.parent.children),n.delete(),e.setStart(r,0).collapse())}else e.setStart(t,t.length).collapse(),this.onContentDelete(e.startContainer,e)}else r===n?(r.textDelete(o,o-i),0===r.length&&(r.delete(),e.setStart(r.prevLeaf,r.prevLeaf.length).collapse()),e.collapse(!0)):(r.textDelete(r.length,r.length-i),n.textDelete(o,o),t.deleteBetween(r,n),r.block!==n.block&&(n.parent.delete(),r.parent.splice(r.index+1,0,...n.parent.children.filter((t=>t.length)))),e.collapse(!0),console.log(e.startOffset,e.endOffset,e));t.component.update(t,e).then((()=>{e.updateCaret()}))}enterPath(t,e){let n=null;if("left"===e){const e=t.endContainer;if(n=e.nextLeaf,!n)return null;const o=e.block===n.block;t.set(n,o?1:0)}else{if(n=t.startContainer.prevLeaf,!n)return null;t.set(n,n.length)}return{path:n,range:t}}leavePath(t,e){if("left"===e){const e=t.startContainer;let n=e.prevLeaf;return n&&e?(t.set(e,e.length),n.component.enterPath(t,"right")):null}{let e=t.endContainer.nextLeaf;return e?e.component.enterPath(t,"left"):null}}onCaretMove(t,e,n){const o=e.container,{shiftKey:r}=n;let i={path:o,range:e};return 0===e.d&&(e.d="left"===t?-1:1),this.isCaretShouldLeavePath(o,e,t)?i=this.leavePath(e,t):"left"===t?e.offset>0&&(e.offset-=1):e.offset{t.moveTo(n)})),e.set(n.children[0],0)}else n=e.container.parent.clone(!0),n.insertAfter(e.container.parent),e.set(n.children[0],0);n.parent.component.update().then((()=>{e.collapse(!0),e.updateCaret()}))}onKeydownArrowLeft(t,e){xt("left",e,t),this.$editor.selection.updateCaret()}onKeydownArrowRight(t,e){xt("right",e,t),this.$editor.selection.updateCaret()}onKeydownArrowUp(t,e){wt("up",e,t),this.$editor.selection.updateCaret()}onKeydownArrowDown(t,e){wt("down",e,t),this.$editor.selection.updateCaret()}onKeydownBackspace(t,e){kt(e,!1)}onKeydownEnter(t,e){this.onLinefeed(t,e)}isCaretShouldLeavePath(t,e,n){if("left"===n&&e.offset<=1){let n=t.prevLeaf;return!!n&&(0===e.offset||t.block===n.block)}return"right"===n&&e.offset===t.length}_updatePoints(t,e,n,o){this.$editor.selection.updatePoints(t,e,n,o)}setFormat(t,e){const n=this.$editor.queryCommonPath(t.startContainer,t.endContainer),o=this.$editor.selection.getSeletedPath();for(const t of o)e(t);n.component.update().then((()=>{t.updateCaret(),this.$editor.selection.drawRangeBg()}))}},Path:J,Selection:Pt,createRef:function(){return{current:null}},createVnode:it,patch:ft,Component:bt,utils:t,setVdomOrElm:O,setVnodeOrIns:E,setVdomOrPath:R,getVdomOrElm:k,getVdomOrPath:C,getVnodeOrIns:S,setVdomOrIns:L,getVdomOrIns:w,SplitText:Et};window.setFormat=function(t,e){const n=new Tt(t);t.selection.ranges.forEach((o=>{const r=t.queryCommonPath(o.startContainer,o.endContainer),i=function(t,e,n){if(t.collapsed)return[];let o,r,i,s=!1;if(t.collapsed)s=!0;else{if(0===t.startOffset)o=t.startContainer;else if(t.startOffset===t.startContainer.length)o=t.startContainer.nextLeaf;else{const e=new Et(t.startContainer,t.startOffset);o=n.addAndApplyStep(e)[1]}if(0===t.endOffset)r=t.endContainer.prevLeaf;else if(t.endOffset===t.endContainer.length)r=t.endContainer;else{const e=new Et(t.endContainer,t.endOffset),o=n.addAndApplyStep(e);r=o[0]}}return i=o,{length:0,next:function(){if(s)return{value:void 0,done:s};{const t={value:i,done:s};return s=i===r,i=i.nextLeaf,this.length++,t}},[Symbol.iterator]:function(){return this}}}(o,0,n);for(const t of i){const o=new Rt(t,0,e);n.addAndApplyStep(o)}n.commit(r),r.component.update()}))},window.deleteText=function(t,e){const n=new Tt(t);t.selection.ranges.forEach((t=>{const o=new Lt(t.container,t.offset,e);n.addAndApplyStep(o),n.commit(t.container.parent),t.container.parent.component.update()}))};const Nt={},Bt=Nt;class zt{size=50;queue=[];idx=-1;editor=null;constructor({size:t,editor:e}){this.size=t||50,this.editor=e}get current(){return this.queue[this.idx]}push(t){this.current!==t&&(this.queue.length===this.size?this.queue.shift():this.idx++,this.queue.splice(this.idx,this.size,t))}redo(){return this.idx!==this.queue.length-1&&(this.idx++,this.current.apply())}undo(){if(-1===this.idx)return!1;{const t=this.current.rollback();return this.idx--,t}}}const _t={value:"",isComposing:!1};function Ft(t){return t.replace(/( |^)[a-z]/g,(t=>t.toUpperCase()))}const Ht=["mount"];class Vt{contentRef={current:null};renderContent(){return(0,arguments[arguments.length-1])("div",{id:"editor-content",style:"position:relative",ref:this.contentRef},[this.renderPath()])}constructor(t){q(new.target,Vt,Ht),this.$path=t.path,t.path._editor=this,function({editor:t,formats:e,plugins:n}){const o=new at;var r;o.register(e),t.$eventBus={all:r=r||new Map,on:function(t,e){var n=r.get(t);n?n.push(e):r.set(t,[e])},off:function(t,e){var n=r.get(t);n&&(e?n.splice(n.indexOf(e)>>>0,1):r.set(t,[]))},emit:function(t,e){var n=r.get(t);n&&n.slice().map((function(t){t(e)})),(n=r.get("*"))&&n.slice().map((function(n){n(t,e)}))}},o.inject("editor",t),t.formater=o,t.history=new zt({editor:t}),(t=>{for(let e=0;e{Bt.platform.initIntercept(t)})),function(t){let e,n=null;t.on("mouseEvents",(e=>{if(!e.shiftKey&&0===e.button){const n=Bt.platform.nativeSelection.rangeCount;for(let t=0;t{if(function(t){return t.type.startsWith("composition")||"input"===t.type}(o)){if(null===o.data)return;n&&!n.commited||(n=new Tt(t)),function(t,e){const{data:n,type:o}=t;if("input"===o){let t=" "===n?" ":n||"";if(!_t.isComposing&&n)e({data:t,type:"input"});else{const n=_t.value.length;_t.value=t,e({data:t,type:"compositioning",prevDataLength:n})}}else"compositionstart"===o?(_t.value="",_t.isComposing=!0):"compositionend"===o&&(setTimeout((()=>{e({data:_t.value,type:"compositionend"}),_t.value="",_t.isComposing=!1})),t.target.value="")}(o,(({data:r,prevDataLength:i,type:s})=>{t.selection.ranges.forEach((a=>{a.collapsed||kt(a,!0),i&&j(i,kt,t,a,!0);const l=a.container;if("input"!==s&&"compositioning"!==s||(e=l.component.onInsert({type:"text",data:r,range:a,ts:n})),"input"===s||"compositionend"===s){n.addStep(e);const t=l.component.onInput;"function"==typeof t&&t.call(l.component,o,a,n)}})),n.commit()}))}else{const e=o.key?`${o.type}${o.key}`:null,n=`${o.type}`;t.selection.ranges.forEach((t=>{const r=t.container,i=e?r.component[`on${Ft(e)}`]:null,s=r.component[`on${Ft(n)}`];"function"==typeof i&&i.call(r.component,o,t),"function"==typeof s&&s.call(r.component,o,t)})),t.emit(e,o),t.emit(n,o)}})),t.on("selectionchange-origin",(()=>{const e=Bt.platform.nativeSelection,{startContainer:n,startOffset:o,endContainer:r,endOffset:i}=t.selection.ranges[0]||{};t.emit("selectionchange",{startContainer:n,startOffset:o,endContainer:r,endOffset:i}),e&&!e.isCollapsed&&t.selection.ranges.forEach((t=>{t.caret.hidden()}))})),t.on("keydownz",(e=>{e.ctrlKey&&t.history.undo()})),t.on("keydownZ",(e=>{e.ctrlKey&&t.history.redo()}))}(t)}({editor:this,formats:t.formats,plugins:t.plugins})}renderPath(){return this.formater.render({children:[this.$path]})}on(t,e){this.$eventBus.on(t,e)}emit(t,e){this.$eventBus.emit(t,e)}focus(t){this.$eventBus.emit("focus",t)}destroy(){this.$eventBus.emit("destroy")}queryPath(t){return tt(t,this.$path)}queryCommonPath(t,e){return W(this.queryPath(t),this.queryPath(e))}}const It=$t.createPath,Dt=$t.Content,jt=$t.createRef,Kt=$t.createVnode,Ut=$t.patch,qt=$t.Component,Gt=$t.utils;function Zt(t,e,n){n/=100;const o=e=>(e+t/30)%12,r=(e/=100)*Math.min(n,1-n),i=t=>n-r*Math.max(-1,Math.min(o(t)-3,Math.min(9-o(t),1)));return[255*i(0),255*i(8),255*i(4)].map((t=>Xt(t)))}function Xt(t,e=0){return Number(`${Math.round(`${t}e${e}`)}e-${e}`)}function Yt(t,e,n){const[o,r,i]=Zt(t,100,50),s=((255-r)*e+r)*n,a=((255-i)*e+i)*n;return[Xt(((255-o)*e+o)*n),Xt(s),Xt(a)]}function Jt(t){return t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.cancelBubble=!0,t.returnValue=!1,!1}class Qt extends qt{constructor(t){super(t)}render(){return(0,arguments[arguments.length-1])("div",{style:"font-size:20px"},[this.props.children,this.props.color])}}class Wt extends qt{constructor(t){super(t),this.state={hue:0,x:228,y:0,px:1,py:1},this.containerRef=jt()}render(){const t=arguments[arguments.length-1];return t("div",{style:`background: linear-gradient(to top, rgba(0, 0, 0, 1), transparent), linear-gradient(to left, hsla(${this.state.hue}, 100%, 50%, 1), rgba(255, 255, 255, 1))`,onMousedown:this.handleMouseDown,class:"palette",ref:this.containerRef},[t("span",{style:`top:${this.state.y}px;left:${this.state.x}px;`,class:"palette-picker"},[]),t(Qt,{color:this.state.hue},[t("span",{},["hue:"])])])}handleChange=$((t=>{Jt(t);const e="number"==typeof t.pageX?t.pageX:t.touches[0].pageX,n="number"==typeof t.pageY?t.pageY:t.touches[0].pageY,o=e-(this.containerRef.current.getBoundingClientRect().left+window.pageXOffset),r=n-(this.containerRef.current.getBoundingClientRect().top+window.pageYOffset),i=(228-o)/228,s=(150-r)/150;this.setState({x:o>=228?228:o<=0?0:o,y:r>=150?150:r<=0?0:r,px:i,py:s});const[a,l,c]=Yt(this.state.hue,i,s);this.props.hue.current.color=`rgba(${a},${l},${c},${this.props.hue.current.state.A})`,this.props.hue.current.setState({R:a,G:l,B:c})}),32);handleMouseDown=t=>{Jt(t),this.handleChange(t),window.addEventListener("mousemove",this.handleChange),window.addEventListener("mouseup",this.handleMouseUp)};handleMouseUp=t=>{Jt(t),this.unbindEventListeners()};unbindEventListeners=()=>{window.removeEventListener("mousemove",this.handleChange),window.removeEventListener("mouseup",this.handleMouseUp)};setPalette(t,e,n,o){if(M(o)){const[r,i]=function(t,e,n,o){const r={R:e,G:n,B:o},[i,s,a]=Zt(t,100,50);let l,c,d,h;return[i,s,a].forEach(((t,e)=>{255===t&&(c=["R","G","B"][e]),0===t&&(l=["R","G","B"][e])})),h=r[c]/255,d=0===r[l]?0:r[l]/h/255,[Xt(d,2),Xt(h,2)]}(t,e,n,o);this.setState({x:228*(1-r),y:150*(1-i),px:r,py:i})}this.setState({hue:t})}}const{throttle:te,isDef:ee}=Gt;function ne(t){return t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.cancelBubble=!0,t.returnValue=!1,!1}class oe extends qt{constructor(t){super(t),this.color=this.props.color,this.state={x:200,x2:200,R:255,G:0,B:0,A:1},this.colorBlock=jt(),this.hueContainer=jt(),this.transparencyContainer=jt()}render(){const t=arguments[arguments.length-1];return t("div",{class:"picker"},[t("div",{class:"left"},[t("div",{ref:this.hueContainer,onMousedown:this.handleHueMouseDown,class:"hue"},[t("div",{style:`left:${this.state.x}px`,class:"hue-picker"},[])]),t("div",{onMousedown:this.handleTransparencyMouseDown,class:"transparency",style:"margin-top:4px"},[t("div",{class:"transparency-picker-bg",style:`background: linear-gradient(to right, rgba(${this.state.R},${this.state.G},${this.state.B},0) 0%, rgba(${this.state.R},${this.state.G},${this.state.B},1)`},[]),t("div",{ref:this.transparencyContainer,style:"position:absolute;top:0"},[t("div",{style:`left:${this.state.x2}px;`,class:"transparency-picker"},[])])])]),t("div",{class:"right"},[t("div",{class:"color-block-bg"},[]),t("div",{style:`background:${this.color};`,ref:this.colorBlock,class:"color-block"},[])])])}onMounted(){let[t,e,n,o]=getComputedStyle(this.colorBlock.current).backgroundColor.match(/[\d||\.]+/g).map(Number);const[r]=function(t,e,n){t/=255,e/=255,n/=255;const o=Math.max(t,e,n),r=o-Math.min(t,e,n),i=r?o===t?(e-n)/r:o===e?2+(n-t)/r:4+(t-e)/r:0;return[60*i<0?60*i+360:60*i,100*(r?o<=.5?r/(2*o-r):r/(2-(2*o-r)):0),100*(2*o-r)/2].map((t=>Xt(t)))}(t,e,n);o=ee(o)?o:1,this.props.paletteRef.current.setPalette(r,t,e,n);const i=200-5*r/9;this.setState({A:o,x2:200*o<=6?6:200*o,x:i<=6?6:i,R:t,G:e,B:n})}handleHueChange=te((t=>{ne(t);let e=("number"==typeof t.pageX?t.pageX:t.touches[0].pageX)-(this.hueContainer.current.getBoundingClientRect().left+window.pageXOffset);e=e>=200?200:e<=0?0:e;const n=360*(1-e/200),[o,r,i]=Yt(n,this.props.paletteRef.current.state.px,this.props.paletteRef.current.state.py);this.color=`rgba(${o},${r},${i},${this.state.A})`,this.setState({x:e<=6?6:e,R:o,G:r,B:i}),this.props.paletteRef.current.setPalette(n)}),32);handleHueMouseDown=t=>{ne(t),this.handleHueChange(t),window.addEventListener("mousemove",this.handleHueChange),window.addEventListener("mouseup",this.handleMouseUp)};handleTransparencyChange=te((t=>{ne(t);let e=("number"==typeof t.pageX?t.pageX:t.touches[0].pageX)-(this.transparencyContainer.current.getBoundingClientRect().left+window.pageXOffset);e=e>=200?200:e<=0?0:e;const n=e/200;this.color=`rgba(${this.state.R},${this.state.G},${this.state.B},${n})`,this.setState({x2:e<=6?6:e,A:n})}),32);handleTransparencyMouseDown=t=>{ne(t),this.handleTransparencyChange(t),window.addEventListener("mousemove",this.handleTransparencyChange),window.addEventListener("mouseup",this.handleMouseUp)};handleMouseUp=t=>{ne(t),this.unbindEventListeners()};unbindEventListeners(){window.removeEventListener("mousemove",this.handleHueChange),window.removeEventListener("mousemove",this.handleTransparencyChange),window.removeEventListener("mouseup",this.handleMouseUp)}}class re extends qt{constructor(t){super(t),this.paletteRef=jt(),this.hueRef=jt()}render(){const t=arguments[arguments.length-1];return t("div",{style:"font-size:0;width:228px;"},[t(Wt,{ref:this.paletteRef,hue:this.hueRef},[]),t(oe,{ref:this.hueRef,color:this.props.color,paletteRef:this.paletteRef},[])])}onMounted(){console.log("ColorPicker")}}setTimeout((()=>{Ut(function(){const t=arguments[arguments.length-1];return t(re,{color:"red"},[])}(Kt),document.getElementById("components-test"))}),500),n(22);var ie=n(259),se={};se.styleTagTransform=f(),se.setAttributes=d(),se.insert=l().bind(null,"head"),se.domAPI=s(),se.insertStyleElement=p(),r()(ie.Z,se),ie.Z&&ie.Z.locals&&ie.Z.locals;class ae extends qt{constructor(t){super(t),this.state={visiable:!1},this.dialogRef=jt()}render(){const t=arguments[arguments.length-1];return t("div",{ref:this.dialogRef,onClick:t=>t.stopPropagation()},[this.state.visiable?t("div",{style:"background:#ddd;height:200px;position:absolute;top:35px;width:300px;z-index:1"},[this.props.children.length?this.props.children:"dialog"]):""])}outClickHandle=t=>{this.setState({visiable:!1}),document.removeEventListener("click",this.outClickHandle)};toggle(){this.state.visiable||(console.log("==toggle==="),document.addEventListener("click",this.outClickHandle)),this.setState({visiable:!this.state.visiable})}}class le extends qt{render(){const t=arguments[arguments.length-1];return t("div",{class:"editor-tooltip"},[this.props.children.length?this.props.children:"",t("span",{class:"tooltiptext top",style:`width:${this.props.width}px;margin-left:-${this.props.width/2}px;`},[this.props.content||"content"])])}}const ce={fontColor:(t,e)=>t("div",{id:"colorPicker"},[t("div",{id:"colorDisplay"},[]),t("input",{type:"color",id:"colorInput"},[]),t("label",{for:"alphaInput"},["Alpha:"]),t("input",{type:"range",id:"alphaInput",min:"0",max:"1",step:"0.01",value:"1"},[])])};class de extends qt{constructor(t){super(t)}render(t){return ce[this.props.name]?.(t,this)}}class he extends qt{toolBarItems=[];constructor(t){super(t),this.props.editor.on("selectionchange",(t=>{const{startContainer:e,endContainer:n}=t,o=[];let r=e;for(;o.push(r),r!==n;)r=r.nextLeaf;const i=function(t){if(0===t.length)return{};const e={};for(const n in t[0]){const o=t[0][n];t.every((t=>t[n]===o))&&(e[n]=o)}return e}(o.map((t=>t.node.formats)));this.notice(i)}))}notice(t){this.toolBarItems.forEach((e=>e.onNotice(t)))}render(){const t=arguments[arguments.length-1],{tools:e}=this.props;return t("div",{class:"editor-tool-bar"},[e.map((e=>t(le,{width:"64",content:e.tooltip},[t(pe,{...{...e,onCommand:this.onCommand,toolBarItems:this.toolBarItems}},[])])))])}onCommand=(t,...e)=>{this.props.onCommand(t,...e)}}class pe extends qt{constructor(t){super(t),this.state={active:!1},this.props.toolBarItems.push(this),this.dialogRef=jt()}onNotice(t){t[this.props.commandName]!==this.state.active&&this.setState({active:t[this.props.commandName]})}render(){const t=arguments[arguments.length-1];return t("span",{onClick:this.clickHandle,class:"editor-tool-bar-item",style:`color: ${this.state.active?"rgb(42 201 249)":"rgb(227 227 227);"};`},[t("svg",{class:"icon","aria-hidden":!0,ns:"http://www.w3.org/2000/svg"},[t("use",{"xlink:href":this.props.icon},[])]),this.props.options?t(ae,{ref:this.dialogRef},[t(de,{name:this.props.commandName,options:this.props.options},[])]):""])}emitComand=()=>{this.props.editor.command(this.props.commandName)};clickHandle=t=>{t.stopPropagation(),this.setState({active:!this.state.active}),this.dialogRef.current?this.dialogRef.current.toggle():this.emitComand()}}function ue(t){return document.getElementById(t).appendChild(Ut(function(t){const e=arguments[arguments.length-1];return e("div",{class:"editor-wrappe"},[e(he,{tools:[...t.toolBarOption],editor:t},[]),t.renderContent(e)])}(this,Kt))),this}function fe(t,e){return t.replace(/(\d*).*/,(function(t,n){return n*e}))}let me;me=Range.prototype.getClientRects?t=>{const e=document.createRange();let n;3!==t.container.elm.nodeType?0===t.offset?(e.setStart(t.container.elm,t.offset),e.setEnd(t.container.elm,t.offset+1),n=e.getClientRects()[0]):(e.setStart(t.container.elm,t.offset-1),e.setEnd(t.container.elm,t.offset),n=e.getClientRects()[0],n.x+=n.width):(e.setStart(t.container.elm,t.offset),n=e.getClientRects()[0]),e.setStart(t.container.elm,t.offset);const o=be(t.editor.contentRef.current),r=ve(t.editor.contentRef.current);return{x:n.x+o.x-r.x,y:n.y+o.y-r.y,height:n.height}}:t=>(new ye).measure(t.container.elm,t.offset);class ge{dom=null;rect=null;defaultStyle={};style={};constructor(t){this.range=t,this.dom=document.createElement("span"),this.dom.classList.add("custom-caret"),this.setStyle(this.dom)}setStyle(t={}){Object.assign(this.style,this.defaultStyle,t)}remove(){this.dom.remove()}hidden(){"none"!==this.style.display&&(this.setStyle({display:"none"}),this.draw())}show(){"inline-block"!==this.style.display&&(this.setStyle({display:"inline-block"}),this.draw())}update(t=!0){if(this.rect=me(this.range),!t)return;this.range.editor.contentRef.current.appendChild(this.dom);let e=this.range.startContainer.elm;if(!e)return;e instanceof Element||(e=e.parentNode);const n=getComputedStyle(e),o={top:this.rect.y+"px",left:this.rect.x-1+"px",height:this.rect.height+"px",fontSize:n.fontSize,background:n.color,display:this.range.collapsed?"inline-block":"none"};this.setStyle(o),this.draw()}draw(){((t,e)=>{for(const n in e)t.style[n]=e[n]})(this.dom,this.style)}}class ye{dom=null;instance=null;constructor(){if(ye.instance)return ye.instance;this.dom=document.createElement("text"),ye.instance=this}measure(t,e){let n;return 3===t.nodeType?e?(n=t.splitText(e),t.parentNode.insertBefore(this.dom,n)):t.parentNode.insertBefore(this.dom,t):t.childNodes[e-1]&&"BR"===t.childNodes[e-1].nodeName?t.insertBefore(this.dom,t.childNodes[e-1]):t.childNodes[e]?t.insertBefore(this.dom,t.childNodes[e]):t.appendChild(this.dom),this._getRect(t,e,n)}_getRect(t,e,n){let o=t;t instanceof Element||(o=t.parentNode);const r=fe(getComputedStyle(o).fontSize,1.3)/1,i={x:this.dom.offsetLeft,y:this.dom.offsetTop,height:r||this.dom.offsetHeight};return this.dom.remove(),3===t.nodeType&&e&&(!t.data&&t.nextSibling?t.nextSibling.remove():(t.data+=n.data,n.remove())),i}}function ve(t,e={x:0,y:0}){return e.height=e.height??t.offsetHeight,e.x+=t.offsetLeft,e.y+=t.offsetTop,t.offsetParent&&"HTML"!==t.offsetParent.tagName?ve(t.offsetParent,e):e}function be(t,e={x:0,y:0}){return e.x+=t.scrollLeft||0,e.y+=t.scrollTop||0,t.parentNode?be(t.parentNode,e):e}const xe={};function we(t,e,n){let o,r=n?.props,i=e.props;if((r||i)&&r!==i){for(o in r=r||{},i=i||{},i){if(/^on[A-Z]|class|style/.test(o))continue;const e=i[o];r[o]!==e&&(!0===e?t.setAttribute(o,""):!1===e?t.removeAttribute(o):120!==o.charCodeAt(0)?t.setAttribute(o,e):58===o.charCodeAt(3)?t.setAttributeNS("http://www.w3.org/XML/1998/namespace",o,e):58===o.charCodeAt(5)?t.setAttributeNS("http://www.w3.org/1999/xlink",o,e):t.setAttribute(o,e))}for(o in r)o in i||t.removeAttribute(o)}}const Ce={create:we,update:we};function Se(t,e,n){let o=new Map,r=new Map;e&&Object.keys(e.props).forEach((t=>{/^on[A-Z]/.test(t)&&r.set(t.replace(/^on/,"").toLowerCase(),e.props[t])})),n&&Object.keys(n.props).forEach((t=>{/^on[A-Z]/.test(t)&&o.set(t.replace(/^on/,"").toLowerCase(),e.props[t])})),(o.size||r.size)&&(r.forEach(((e,n)=>{o.has(n)||t.addEventListener(n,e,!1)})),o.forEach(((e,n)=>{r.has(n)||t.removeEventListener(n,e,!1)})))}const ke={create:Se,update:Se};function Oe(t,e,n){const o=(e?.props.class||"").trim();let r,i;o&&t.setAttribute("class",o);const s=(n?.props.class||"").trim(),a=(e?.props.class||"").trim();(s||a)&&s!==a&&(r=new Set(s?s.split(/\s+/g):[]),i=new Set(a?a.split(/\s+/g):[]),i.forEach((e=>{r.has(e)||t.classList.add(e)})),r.forEach((e=>{i.has(e)||t.classList.remove(key)})))}const Ee={create:Oe,update:Oe},Re={};function Le(t,e,n){let o=n?.props.style,r=e?.props.style;(o||r)&&o!==r&&(o=o||Re,r=r||Re,Object.keys(o).forEach((e=>{r[e]||t.style.removeProperty(e.replace(/([A-Z])/g,"-$1").toLowerCase())})),Object.assign(t.style,r))}const Ae={create:Le,update:Le};function Me(t,e){if("function"==typeof t.type)return;const n=xe.core.getVdomOrElm(t);"text"===t.type?t.children!==e.children&&(n.data=t.children):(Ae.update(n,t,e),Ee.update(n,t,e),ke.update(n,t,e),Ce.update(n,t,e))}function Pe(t){let e;if(1===t.vnodeType){const n=t.type(xe.core.createVnode,t.props);e=Pe(n),t.ref&&(t.ref.current=e),xe.core.setVdomOrIns(n,t),xe.core.setVdomOrElm(e,n),Me(n)}else if(2===t.vnodeType){const n=new t.type(t.props),o=n.generateVdom(xe.core.createVnode);e=Pe(o),"function"==typeof n.onCreated&&n.onCreated(),t.ref&&(t.ref.current=n),xe.core.setVdomOrIns(o,n),xe.core.setVnodeOrIns(n,t),xe.core.setVdomOrElm(e,o),Me(o)}else{if(3===t.vnodeType)return e=document.createTextNode(t.children),xe.core.setVdomOrElm(e,t),e;e=t.ns?document.createElementNS(t.ns,t.type):document.createElement(t.type),t.ref&&(t.ref.current=e),xe.core.setVdomOrElm(e,t),Me(t)}if(1===t.children?.length)e.appendChild(Pe(t.children[0]));else if(t.children?.length>1){const n=document.createDocumentFragment();for(let e=0;et.apply(this,o)),e)}}((()=>{const t=window.getSelection(),e=this.editor.contentRef.current;if(t.anchorNode&&t.focusNode){const n=t.anchorNode.parentElement,o=t.focusNode.parentElement;(n===e||o===e||e.contains(n)||e.contains(o))&&this.editor.emit("selectionchange-origin")}}),200);handMousedown(t){if(this.editor.emit("mouseEvents",t),!t.shiftKey&&0===t.button){const e=$e.rangeCount;for(let t=0;te.focus(t))),t.on("destroy",(()=>{e.destroy(),n.destroy()}))}const ze=document,_e=window,Fe=document.getSelection();function He(t,e,n){return t.insertBefore(e,n)}function Ve(t,e,n){return t.replaceChild(e,n)}function Ie(t,e){return t.appendChild(e)}function De(t,e){return console.log(e),t.removeChild(e)}function je(t){const e=t.tagName.toLowerCase()||"text";if("text"===e)return xe.core.createVnode(e);const n={},o=[],r=t.attributes,i=t.childNodes;for(let t=0,e=r.length;t(xe.core=n,t.platform=e,Ke.initIntercept);const Ue=Ke;class qe extends Dt{state={initProp:null};render(){const t=arguments[arguments.length-1];return t("div",{style:"display:inline-block"},["我是image的一部分",t("div",{onMousedown:this.onMousedown,onClick:this.sizeChange,style:"display:inline-block;height:15px;width:15px;background:red;user-select:none"},[]),t("img",{onMousedown:this.onMousedown,onClick:this.sizeChange,...this.$path.node.data},[])])}onMousedown=t=>{t.preventDefault(),t.stopPropagation()};sizeChange=t=>{this.state.initProp||(this.state.initProp={...this.$path.node.data}),this.$path.node.data.width===this.state.initProp.width?(this.$path.node.data.width="100px",this.$path.node.data.height="100px"):(this.$path.node.data.width=this.state.initProp.width,this.$path.node.data.height=this.state.initProp.height),this.update()};onAfterUpdate(){this.$editor.selection.updateCaret()}onContentDelete(t,e){const{endOffset:n,collapsed:o}=e;if(o)if(n>0){const n=this.$path.parent.component;t.delete(),n.update(),n.onCaretEnterPath(this.$path.parent,e,!1)}else{const n=this.getPrevLeafPath(t);n&&n.component.onCaretEnterPath(n,e,!1)}}onCaretEnterPath(t,e,n){return e.set(t,"left"===n?0:1),{path:t,range:e}}get contentLength(){return 1}}class Ge extends Dt{get displayType(){return"block"}onKeydownb(t,e){t?.ctrlKey&&(t?.preventDefault?.(),this.setFormat(e,(t=>{t.node.formats.bold=!t.node.formats.bold})))}onKeydownd(t,e){t?.ctrlKey&&(t?.preventDefault?.(),this.setFormat(e,(t=>{t.node.formats.deleteline=!t.node.formats.deleteline})))}onKeydowns(t,e){t?.ctrlKey&&(t?.preventDefault?.(),this.setFormat(e,(e=>{t.shiftKey?e.node.formats.sub=!e.node.formats.sub:e.node.formats.sup=!e.node.formats.sup})))}onKeydownu(t,e){t?.ctrlKey&&(t?.preventDefault?.(),this.setFormat(e,(t=>{t.node.formats.underline=!t.node.formats.underline})))}}class Ze extends Ge{render(){const t=arguments[arguments.length-1];return t("div",{},[this.$path.children.length?this.$path.render():this.state.placeholder(t)])}}class Xe extends Ge{render(){return(0,arguments[arguments.length-1])("p",{},[this.$path.render()])}}class Ye extends Ge{render(t){return t(`h${this.props.level}`,null,this.$path.render())}}class Je extends Ge{render(){return(0,arguments[arguments.length-1])("table",{border:"1",style:"border-collapse:collapse;width:600px"},[this.$path.render()])}}class Qe extends Ge{render(){return(0,arguments[arguments.length-1])("tr",{},[this.$path.render()])}}class We extends Ge{constructor(t){super(t),this.state._$root=jt()}render(){return(0,arguments[arguments.length-1])("td",{ref:this.state._$root,style:"text-align:center;width:50%"},[this.$path.render()])}}const tn=[{name:"root",type:"component",render(t,e){return(0,arguments[arguments.length-1])(Ze,{...e},[])}},{name:"bold",type:"tag",render(t){const e=(0,arguments[arguments.length-1])("strong",{},[]);return t&&t.children.push(e),e}},{name:"image",type:"component",render(t,e){const n=(0,arguments[arguments.length-1])(qe,{...e},[]);return t&&t.children.push(n),n}},{name:"underline",type:"tag",render(t){const e=(0,arguments[arguments.length-1])("u",{},[]);return t&&t.children.push(e),e}},{name:"fontSize",type:"attribute",render(t,e){if(!t)return(0,arguments[arguments.length-1])("span",{style:{fontSize:e}},[]);t.props.style||(t.props.style={}),t.props.style.fontSize=e}},{name:"color",type:"attribute",render(t,e){if(!t)return(0,arguments[arguments.length-1])("span",{style:{color:e}},[]);t.props.style||(t.props.style={}),t.props.style.color=e}},{name:"paragraph",type:"component",render(t,e){const n=(0,arguments[arguments.length-1])(Xe,{...e,key:e.path._uuid},[]);return t&&t.children.push(n),n}},{name:"deleteline",type:"tag",render(t){const e=(0,arguments[arguments.length-1])("del",{},[]);return t&&t.children.push(e),e}},{name:"sup",type:"tag",render(t){const e=(0,arguments[arguments.length-1])("sup",{},[]);return t&&t.children.push(e),e}},{name:"sub",type:"tag",render(t){const e=(0,arguments[arguments.length-1])("sub",{},[]);return t&&t.children.push(e),e}},{name:"table",type:"component",render(t,e){const n=(0,arguments[arguments.length-1])(Je,{...e},[]);return t&&t.children.push(n),n}},{name:"row",type:"component",render(t,e){const n=(0,arguments[arguments.length-1])(Qe,{...e},[]);return t&&t.children.push(n),n}},{name:"col",type:"component",render(t,e){const n=(0,arguments[arguments.length-1])(We,{...e},[]);return t&&t.children.push(n),n}},{name:"background",type:"attribute",render(t,e){if(!t)return(0,arguments[arguments.length-1])("span",{style:{background:e}},[]);t.props.style||(t.props.style={}),t.props.style.background=e}},{name:"header",type:"component",render(t,e,n){const o=arguments[arguments.length-1];console.log(t,e);const r=o(Ye,{...e,level:n,key:e.path._uuid},[]);return t&&t.children.push(r),r}}],en={data:[{data:[{data:"这是一个基于Typex编写的简单富文本编辑器demo",formats:{color:"#666",bold:!0,fontSize:"20px"}}],formats:{paragraph:!0}},{data:[{data:"这是一个基于Typex编写的简单富文本编辑器demo"}],formats:{header:4}},{data:[{data:"Typex",formats:{color:"#ff9999"}},{data:"是一款全新架构的编辑器内核,该内核不依赖contenteditable;自主实现了光标、模拟输入、模拟选区;数据驱动,组件化,插件化,支持多光标,跨平台的设计。优秀的格式排版系统避免了脏标签的产生(打开控制台你会发现它的标签非常简洁)。多光标:按住alt+左键;加粗/取消加粗:ctrl+b;删除线/取消删除线:ctrl+d;上标/取消上标:ctrl+s ....",formats:{color:"#999"}}],formats:{paragraph:!0}},{data:[{data:"红色删除线",formats:{deleteline:!0,color:"red"}},{data:"上标示例",formats:{sup:!0,color:"green",fontSize:"12px"}},{data:"绿色加粗下划线",formats:{underline:!0,color:"green",bold:!0}},{data:"下标示例",formats:{sub:!0,color:"red",fontSize:"12px"}},{data:"背景示例",formats:{sub:!0,color:"white",fontSize:"16px",background:"orange"}}],formats:{paragraph:!0}},{data:[{data:"带静态内容的行内图片示例",formats:{color:"#ff9999",fontSize:"24px"}},{data:{src:"https://img2.baidu.com/it/u=3979034437,2878656671&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=333",alt:"test image",width:"60px",height:"60px"},formats:{image:!0}},{data:{src:"https://img2.baidu.com/it/u=3979034437,2878656671&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=333",alt:"test image",width:"50px",height:"50px"},formats:{image:!0}}],formats:{paragraph:!0}},{data:[{data:"表格示例:",formats:{color:"#666",bold:!0}}],formats:{paragraph:!0}},{data:[{data:[{data:[{data:[{data:"表格内容1",formats:{color:"green"}}],formats:{paragraph:!0}},{data:[{data:"表格内容2",formats:{color:"red",fontSize:"12px"}}],formats:{paragraph:!0}}],formats:{col:!0}},{data:[{data:[{data:"表格内容2",formats:{color:"Orange",fontSize:"20px",background:"#ddd"}}],formats:{paragraph:!0}}],formats:{col:!0}}],formats:{row:!0}}],formats:{table:!0}}],formats:{root:!0}};console.log(tn);class nn extends Vt{conamndHandles={};toolBarOption=[];constructor(t){super({formats:tn,plugins:[Ue],...t}),this.on("command",this.command)}mount(t){return ue.call(this,t),this}setToolBar(t){return this.toolBarOption=t,t.forEach((t=>{t.editor=this,this.conamndHandles[t.commandName]=t.commandHandle})),this}command(t,e){const n=this.conamndHandles[t];console.log(n),"function"==typeof n&&n(this,e)}}var on=n(815),rn={};function sn(t,e){t.selection.ranges.forEach((t=>{t.container.component.setFormat(t,e)}))}rn.styleTagTransform=f(),rn.setAttributes=d(),rn.insert=l().bind(null,"head"),rn.domAPI=s(),rn.insertStyleElement=p(),r()(on.Z,rn),on.Z&&on.Z.locals&&on.Z.locals;const an=[{tooltip:"撤销",commandName:"undo",icon:"#icon-undo",commandHandle:t=>{t.history.undo()}},{tooltip:"重做",commandName:"redo",icon:"#icon-todo",commandHandle:t=>{t.history.redo()}},{tooltip:"标题",commandName:"header",icon:"#icon-header"},{tooltip:"字体大小",commandName:"fontSize",icon:"#icon-font-size",options:{}},{tooltip:"字体颜色",commandName:"fontColor",icon:"#icon-color",options:{componentName:"fontColor"}},{tooltip:"加粗",commandName:"bold",icon:"#icon-bold",commandHandle:t=>sn(t,(t=>t.node.formats.bold=!t.node.formats.bold))},{tooltip:"下划线",commandName:"underline",icon:"#icon-underline",commandHandle:t=>sn(t,(t=>t.node.formats.underline=!t.node.formats.underline))},{tooltip:"删除线",commandName:"deleteline",icon:"#icon-del",commandHandle:t=>sn(t,(t=>t.node.formats.deleteline=!t.node.formats.deleteline))},{tooltip:"背景填充",commandName:"background",icon:"#icon-fill",options:{}},{tooltip:"左对齐",commandName:"leftAligned",icon:"#icon-align-left"},{tooltip:"居中",commandName:"middleAligned",icon:"#icon-align-middle"},{tooltip:"右对齐",commandName:"rightAligned",icon:"#icon-align-right"},{tooltip:"超链接",commandName:"link",icon:"#icon-link"},{tooltip:"图片",commandName:"img",icon:"#icon-img"},{tooltip:"代码段",commandName:"code",icon:"#icon-code"},{tooltip:"markdown",commandName:"markdown",icon:"#icon-markdown"},{tooltip:"视频",commandName:"radio",icon:"#icon-radio"},{tooltip:"清除样式",commandName:"clearStyle",icon:"#icon-clear-style",commandHandle:t=>sn(t,(t=>t.node.formats={}))}];setTimeout((()=>{window.editor=function(t={}){const e=It(en);return new nn({path:e})}({data:"hello world"}).setToolBar(an).mount("editor-root")}),0)})()})(); \ No newline at end of file +(()=>{var t={705:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",o=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),o&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),o&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,o,r,i){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(o)for(var a=0;a0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=i),n&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=n):d[2]=n),r&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=r):d[4]="".concat(r)),e.push(d))}},e}},742:t=>{"use strict";t.exports=function(t,e){return e||(e={}),t?(t=String(t.__esModule?t.default:t),/^['"].*['"]$/.test(t)&&(t=t.slice(1,-1)),e.hash&&(t+=e.hash),/["'() \t\n]|(%20)/.test(t)||e.needQuotes?'"'.concat(t.replace(/"/g,'\\"').replace(/\n/g,"\\n"),'"'):t):t}},738:t=>{"use strict";t.exports=function(t){return t[1]}},22:()=>{window._iconfont_svg_string_3243125='',function(t){var e,n=(e=(e=document.getElementsByTagName("script"))[e.length-1]).getAttribute("data-injectcss");if(!(e=e.getAttribute("data-disable-injectsvg"))){var o,r,i,s,a;if(n&&!t.__iconfont__svg__cssinject__){t.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(e){console&&console.log(e)}}o=function(){var e,n=document.createElement("div");n.innerHTML=t._iconfont_svg_string_3243125,(n=n.getElementsByTagName("svg")[0])&&(n.setAttribute("aria-hidden","true"),n.style.position="absolute",n.style.width=0,n.style.height=0,n.style.overflow="hidden",n=n,(e=document.body).firstChild?function(t,e){e.parentNode.insertBefore(t,e)}(n,e.firstChild):e.appendChild(n))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(o,0):(r=function(){document.removeEventListener("DOMContentLoaded",r,!1),o()},document.addEventListener("DOMContentLoaded",r,!1)):document.attachEvent&&(i=o,s=t.document,a=!1,function t(){try{s.documentElement.doScroll("left")}catch(e){return void setTimeout(t,50)}l()}(),s.onreadystatechange=function(){"complete"==s.readyState&&(s.onreadystatechange=null,l())})}function l(){a||(a=!0,i())}}(window)},259:(t,e,n)=>{"use strict";n.d(e,{Z:()=>p});var o=n(738),r=n.n(o),i=n(705),s=n.n(i),a=n(742),l=n.n(a),c=new URL(n(363),n.b),d=s()(r()),h=l()(c);d.push([t.id,".editor-tool-bar{border:solid 1px #eee;background:#282828;padding:6px}.editor-tool-bar .icon{width:1.2em;height:1.2em;vertical-align:-.15em;fill:currentColor;overflow:hidden}.editor-tool-bar .editor-tool-bar-item{padding:4px 10px;display:inline-block;border-radius:4px;cursor:pointer;user-select:none}.editor-tool-bar #editor-content{padding:16px;min-height:200px}.editor-tool-bar .editor-tooltip{position:relative;display:inline-block}.editor-tool-bar .editor-tooltip .tooltiptext{opacity:0;width:60px;font-size:12px;background-color:#000;color:#fff;text-align:center;border-radius:6px;padding:5px 0;position:absolute;z-index:1;top:140%;left:50%;margin-left:-30px;transition:opacity 600ms ease-out}.editor-tool-bar .editor-tooltip .tooltiptext::after{content:'';position:absolute;left:50%;margin-left:-5px;border-width:5px;border-style:solid}.editor-tool-bar .editor-tooltip:hover .tooltiptext{opacity:1}.editor-tool-bar .editor-tooltip .tooltiptext.bottom{top:140%}.editor-tool-bar .editor-tooltip .tooltiptext.bottom::after{bottom:100%;border-color:transparent transparent #000 transparent}.editor-tool-bar .editor-tooltip .tooltiptext.top{top:-140%}.editor-tool-bar .editor-tooltip .tooltiptext.top::after{top:100%;border-color:#000 transparent transparent transparent}.editor-tool-bar .picker{display:flex;justify-content:space-between;margin-top:4px}.editor-tool-bar .left,.editor-tool-bar .hue{font-size:0;height:10px;width:200px;background:linear-gradient(to left,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00)}.editor-tool-bar .left .hue-picker,.editor-tool-bar .hue .hue-picker{display:inline-block;position:relative;width:6px;height:12px;transform:translate(-6px,-1px);background-color:#f8f8f8;box-shadow:rgba(0,0,0,0.37) 0 1px 4px 0}.editor-tool-bar .transparency{position:relative;font-size:0;height:10px;width:200px;background:url("+h+") left center}.editor-tool-bar .transparency-picker-bg{height:100%}.editor-tool-bar .transparency-picker{display:inline-block;position:relative;width:6px;height:12px;transform:translate(-6px,-1px);background-color:#f8f8f8;box-shadow:rgba(0,0,0,0.37) 0 1px 4px 0}.editor-tool-bar .right{position:relative;cursor:pointer}.editor-tool-bar .color-block{width:24px;height:24px;position:absolute;top:0}.editor-tool-bar .color-block-bg{width:24px;height:24px;background:url("+h+") left center}.editor-tool-bar .palette{width:228px;height:150px;overflow:hidden;border:#eee solid 1px}.editor-tool-bar .palette-picker{pointer-events:none;display:inline-block;position:relative;width:12px;height:12px;border-radius:50%;box-shadow:#fff 0 0 0 1px inset;transform:translate(-6px,-6px)}",""]);const p=d},815:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var o=n(738),r=n.n(o),i=n(705),s=n.n(i)()(r());s.push([t.id,"#editor-content:focus,.custom-input:focus{outline:none}#editor-content{word-break:break-all;padding:15px}#editor-content .custom-input-iframe{top:-100px;left:0;background:transparent;color:transparent;width:0;height:0;pointer-events:none;border:none;caret-color:transparent;position:absolute}#editor-content .custom-caret{top:-100px;left:0;pointer-events:none;position:absolute;width:2px;border:none;padding:0;display:block;animation:caret 1s infinite .5s steps(1,start)}#editor-content .editor-disabled{user-select:none}#editor-content ::selection{background:#bad2fa}#editor-content table td,#editor-content td{background-color:#fff}#editor-content table td,#editor-content th,#editor-content td{display:table-cell;margin:0;padding:0;text-align:left;vertical-align:middle}@-moz-keyframes static-caret{0%{opacity:1}100%{opacity:1}}@-webkit-keyframes static-caret{0%{opacity:1}100%{opacity:1}}@-o-keyframes static-caret{0%{opacity:1}100%{opacity:1}}@keyframes static-caret{0%{opacity:1}100%{opacity:1}}@-moz-keyframes caret{0%{opacity:1}50%{opacity:0}100%{opacity:1}}@-webkit-keyframes caret{0%{opacity:1}50%{opacity:0}100%{opacity:1}}@-o-keyframes caret{0%{opacity:1}50%{opacity:0}100%{opacity:1}}@keyframes caret{0%{opacity:1}50%{opacity:0}100%{opacity:1}}",""]);const a=s},379:t=>{"use strict";var e=[];function n(t){for(var n=-1,o=0;o{"use strict";var e={};t.exports=function(t,n){var o=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},565:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},795:t=>{"use strict";t.exports=function(t){var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var o="";n.supports&&(o+="@supports (".concat(n.supports,") {")),n.media&&(o+="@media ".concat(n.media," {"));var r=void 0!==n.layer;r&&(o+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),o+=n.css,r&&(o+="}"),n.media&&(o+="}"),n.supports&&(o+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleTagTransform(o,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},589:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},363:t=>{"use strict";t.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAADFJREFUOE9jZGBgEGHAD97gk2YcNYBhmIQBgWSAP52AwoAQwJvQRg1gACckQoC2gQgAIF8IscwEtKYAAAAASUVORK5CYII="}},e={};function n(o){var r=e[o];if(void 0!==r)return r.exports;var i=e[o]={id:o,exports:{}};return t[o](i,i.exports,n),i.exports}n.m=t,n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.b=document.baseURI||self.location.href,(()=>{"use strict";var t={};n.r(t),n.d(t,{classCheck:()=>$,computeLen:()=>v,debounce:()=>x,isClass:()=>B,isDef:()=>g,isFunction:()=>z,isPrimitive:()=>y,isUndef:()=>m,mergeObj:()=>L,mergePointsContainer:()=>T,mergeTextPath:()=>N,multiplication:()=>k,positionCompare:()=>M,setStyle:()=>S,stringify:()=>O,styleToObj:()=>E,throttle:()=>b,times:()=>A,toRawType:()=>C,typeOf:()=>P,uuid:()=>R});var e={};n.r(e),n.d(e,{Caret:()=>ge,appendChild:()=>De,createElm:()=>Pe,domToVNode:()=>je,initIntercept:()=>Be,insertBefore:()=>He,nativeDocument:()=>ze,nativeSelection:()=>Fe,nativeWindow:()=>_e,removeChild:()=>Ie,replaceChild:()=>Ve,updateProps:()=>Me});const o=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap;function a(t){return i.get(t)}function l(t){if(t.vnodeType){const e=s.get(t);if(e)return e;if(3===t.vnodeType)return null;const n=a(t),o=c(n);return 1===n.vnodeType?s.get(n):s.get(o)}{const e=s.get(t);if(!e)return;return e}}function c(t){return r.get(t)}function d(t){return 1===t.vnodeType?o.get(i.get(t)):2===t.vnodeType?o.get(i.get(r.get(t))):o.get(t)}function h(t,e){o.set(e,t).set(t,e)}function p(t,e){r.set(e,t).set(t,e)}function u(t,e){s.set(t,e).set(e,t)}function f(t,e){return i.set(e,t).set(t,e)}function m(t){return null==t}function g(t){return null!=t}function y(t){return"string"==typeof t||"number"==typeof t||"symbol"==typeof t||"boolean"==typeof t}function v(t){return y(t.node.data)?t.node.data.length:t.children.length?t.children.reduce(((t,e)=>t+v(e)),0):0}function b(t,e,n=!0){let o,r,i;return function(){const s=this,a=arguments;o?(clearTimeout(r),r=setTimeout((function(){Date.now()-i>=e&&(t.apply(s,a),i=Date.now())}),Math.max(e-(Date.now()-i),0))):(n&&t.apply(s,a),i=Date.now(),o=!0)}}function x(t,e=0){let n;return function(...o){clearTimeout(n),n=setTimeout((()=>t.apply(this,o)),e)}}window.aa={setVdomOrElm:h,setVnodeOrIns:p,setVdomOrPath:u,getVdomOrElm:d,getVdomOrPath:l,getVnodeOrIns:c};const w=Object.prototype.toString;function C(t){return w.call(t).slice(8,-1).toLowerCase()}function S(t,e){for(const n in e)t.style[n]=e[n]}function k(t,e){return t.replace(/(\d*).*/,(function(t,n){return n*e}))}function O(t){let e=[],n=JSON.stringify(t,((t,n)=>{if("object"==typeof n&&null!==n){if(-1!==e.indexOf(n))return"Circular reference";e.push(n)}return n}));return e=null,n}function E(t){return(t=t.trim()).split(";").filter((t=>t)).reduce(((t,e)=>{const n=e.split(":");return t[n[0].trim()]=n[1].trim(),t}),{})}function R(){return([1e3]+-1e3+-4e3+-8e3).replace(/[018]/g,(t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)))}function L(t,e){for(let n in e)e.hasOwnProperty(n)&&m(t[n])&&!m(e[n])&&(t[n]=e[n])}function A(t,e,n,...o){let r=0;for(;r++r)return 1;if(e{if(!t.prototype.hasOwnProperty(e))throw new Error(`please overwrite ${e} method`)}))}function T(t,e,n){n.selection.rangePoints.filter((e=>e.container===t)).forEach((t=>{"start"===t.pointName?t.range.setStart(e,e.length+t.offset):t.range.setEnd(e,e.length+t.offset)}))}function N(t,e){const n=t[0],o=t.length;if(1===o)return n;for(let t=0;t{t.moveTo(e)})),e.insertAfter(this),[this,e]}}clone(t=!1){let e;return e=t?y(this.node.data)?this.node.data:JSON.parse(JSON.stringify(this.node.data)):y(this.node.data)?"":this.node.data?[]:{},F({data:e,formats:{...this.node.formats}})}positionCompare(t){return M(this,t)}originOf(t){return this.position.includes(t.position+"-")}insertBefore(t){this.delete(),t.parent.splice(t.index,0,this)}insertAfter(t){this.delete(),t.parent.splice(t.index+1,0,this)}moveTo(t){this.delete(),t.push(this)}delete(){this.parent&&(this.rebuildFlag=1,this.parent.rebuild(),this.parent.component.update())}push(...t){t.forEach((t=>t.rebuildFlag=0)),this.children.push(...t),this.rebuild(),this.component.update()}pop(){const t=this.children[this.children.length-1];return t.rebuildFlag=1,this.rebuild(),this.component.update(),t}unshift(...t){t.forEach((t=>t.rebuildFlag=0)),this.children.unshift(...t),this.rebuild(),this.component.update()}shift(){const t=this.children[0];return t.rebuildFlag=1,this.rebuild(),this.component.update(),t}splice(t,e,...n){const o=[];if(n.length&&(n.forEach((t=>t.rebuildFlag=0)),this.children.splice(t,0,...n)),e>0)for(let n=0;n{for(var i=0;it.rebuild()))}rebuild(t=!1){if("Array"!==this.dataType)return;let e=null;this.children=this.children.filter((t=>1!==t.rebuildFlag)),this.node.data.length=0,this.children.forEach(((t,n)=>{t.parent=this,this.node.data.push(t.node),t.prevSibling=e,e&&(e.nextSibling=t),t.nextSibling=null,e=t,t.index=n}))}}function F(t,e=null,n=null,o=null,r=0){t.formats||(t.formats={});const i=new _({node:t,parent:e,index:r,prevSibling:n,nextSibling:o,children:[]});if(t.data){let e=null;t.data.reduce?.(((t,n,o)=>(e=F(n,i,t,null,o),t&&(t.nextSibling=e),e.prevSibling=t,i.children.push(e),e)),null)}return i}function H(t,e){if(t===e)return t;if("0"===t.position)return t;if("0"===e.position)return e;const n=function(t){for(;t.parent;)t=t.parent;return t}(t),o=t.position.split("-"),r=e.position.split("-"),i=Math.min(o.length,r.length);let s;for(s=0;st.children[e]),e)}const j=["ref","key","ns"],K=["ns"];function U(t,e,n=[]){e=e||{};const o={},r={};for(let t of j)r[t]=e[t]||null;for(let t in e)j.includes(t)||("style"===t&&y(e[t])?o[t]=E(e[t]):o[t]=e[t]);return function(t,e,n,o){let r;if("text"===t)r={_uuid:R(),vnodeType:3,type:"text",children:o.join("")};else{r={_uuid:R(),vnodeType:B(t)?2:z(t)?1:4,type:t,...e,props:n};const i={};for(let t of K)i[t]=r[t];1===r.vnodeType||2===r.vnodeType?r.props.children=q(o,i):r.children=q(o,i)}return r}(t,r,o,n.flat())}const q=(t,e)=>t.filter((t=>!!t)).map((t=>y(t)||m(t)?{_uuid:R(),type:"text",vnodeType:3,children:t}:(L(t,e),t))),G=class{formatMap=new Map;register(t){t.forEach((t=>{this.formatMap.set(t.name,t)}))}inject(t,e){this[t]=e}renderRoot(t){return this.render({children:[t]})}render(t){const e=this._group({paths:t.children,restFormats:this.types},0);return this._generateGroups(e,t.isBlock&&0===t.length)}_invokeRender(t,e){return e.fmt.render(t,e.value,U)}_generateGroups(t,e){return t.map((t=>{let n;const o=this._getFormats(t.commonFormats);if(0===t.commonFormats.length){if(-1!==t.children.findIndex((t=>"object"==typeof t.node.data)))throw"格式标记不合法,文本格式不可用于标记非文本的结构";const n=N(t.children,this.editor);let o=null;return e?(o=U("br"),u(n,n.parent.vn),n.clearFormat()):(""===n.node.data&&console.warn("非法空标签:",n),o=U("text",{},[n.node.data]),u(n,o)),o}if((n=o.filter((t=>"component"===t.fmt.type))).length){const e=t.children[0],o=n[0].fmt.render(null,{path:e,editor:this.editor},n[0].value,U);return u(e,o),o}{let n=null,r=null;const i=[];for(let t=0;t"object"==typeof t.data)))throw"格式标记不合法,文本格式不可用于标记非文本的结构";const n=N(t.children,this.editor);let o=null;e?(o=U("br"),u(n,r),n.clearFormat()):(""===n.node.data&&console.warn("非法空标签:",n),o=U("text",{},[n.node.data]),u(n,o)),r.children=[o]}return n}})).filter((t=>t))}get types(){return[...this.formatMap.keys()]}_getFormats(t){return t.map((t=>{const e=Object.keys(t)[0];return{fmt:this.formatMap.get(e),value:t[e]}}))}get(t){return this.formatMap.get(t)||{}}_canAdd(t,e,n){return!!t.node.formats[n]&&(!e.node.formats[n]||e.node.formats[n]===t.node.formats[n]||void 0)}_group(t,e,n=[]){const o={commonFormats:[],children:[]};let r=[],i=null,s={},a=0;for(;e{i?this._canAdd(l,i,t)&&s[t]++:(s[t]=0,l.node.formats[t]&&s[t]++)}));const c=Math.max(...Object.values(s));if(i&&Object.keys(l.node.formats).some((t=>"component"===this.get(t).type))){i=null;break}if(i&&Object.keys(i.node.formats).some((t=>"component"===this.get(t).type))){i=null;break}if(i&&0===a&&c>a){s=n;break}if(i&&c===a&&0!==c){s=n;break}o.children.push(l),o.commonFormats=Object.entries(s).filter((t=>t[1]&&t[1]===c)).map((n=>({[n[0]]:t.paths[e].node.formats[n[0]]}))),r=t.restFormats.filter((t=>!o.commonFormats.some((e=>e[t])))),a=c,i=l}return o.commonFormats.length>0&&o.children.length>1&&(o.children=this._group({paths:o.children,restFormats:r},0)),n.push(o),e{"function"==typeof t.onUnmounted&&t.onUnmounted()})),n=null}}}(t,n,a,c)}(n,r,o)}}function tt(t,e){if(e!==t){if(!t){const t=c(e),n=a(t),o=t.generateVdom(U);return f(t,o),W(o,n),d(o)}if(m(e))return wt.platform.createElm(t);if(g(e.nodeType)&&h(e,e=wt.platform.domToVNode(e)),Z(t,e))W(t,e);else{let n=d([1,2].includes(e.vnodeType)?Q(e):e);const o=wt.platform.createElm(t);et(e,"onUnmounted"),wt.platform.replaceChild(n.parentNode,o,n),et(t,"onMounted")}return d([1,2].includes(t.vnodeType)?Q(t):t)}}function et(t,e){const n=t.vnodeType?c(t):t;n&&"function"==typeof n[e]&&n[e]()}const nt=[],ot=[];function rt(){let t,e;for(;t=nt.shift();){const{partialState:e,component:n}=t;n.prevState||(n.prevState=Object.assign({},n.state)),"function"==typeof e?Object.assign(n.state,e(n.prevState,n.props)):Object.assign(n.state,e),n.prevState=n.state}for(;e=ot.shift();)e.shouldComponentUpdate()&&e.syncUpdate()}class it{static isComponent=!0;get isComponent(){return!0}state={};$nextTick=t=>Promise.resolve().then(t);constructor(t){this.props=Object.freeze({...t})}render(t){throw Error('Component does not implement a required interface "render"')}generateVdom(t){return"function"==typeof this.onBeforeRender&&this.onBeforeRender(),this.render(t)}setState(t={}){return function(t,e){let n=null;var o;return 0===nt.length&&(o=rt,n=Promise.resolve().then(o)),nt.push({partialState:t,component:e}),ot.some((t=>t===e))||ot.push(e),n||Promise.resolve()}(t,this)}syncUpdate(){tt(null,c(this))}shouldComponentUpdate(){return!0}}function st(t,e,n){if(e.inputState.isComposing)return;if(!e.collapsed&&!n.shiftKey)return void e.collapse("left"===t);const{shiftKey:o}=n;if(e.collapsed||o)return e.container.component.onCaretMove(t,e,n);e.collapse("left"===t)}function at(t,e,n){e.inputState.isComposing||(e.collapsed||n.shiftKey?ct(e,"up"===t?"left":"right",{...e.caret.rect,block:e.container.block},{...e.caret.rect,block:e.container.block},!1,n):e.collapse("up"===t))}function lt(t,e,n,o){if(n.block!==e.block)return!1;let r=!0;return("left"===o&&n.x>e.x||"right"===o&&n.xt===this));this.caret.remove(),this.editor.selection.ranges.splice(t,1)}}class yt{ranges=[];nativeSelection=wt.platform.nativeSelection;constructor(t){this.editor=t}get collapsed(){return this.ranges.every((t=>t.collapsed))}get rangeCount(){return this.ranges.length}get rangePoints(){const t=[];return this.ranges.forEach((e=>{t.push({container:e.startContainer,offset:e.startOffset,range:e,pointName:"start"},{container:e.endContainer,offset:e.endOffset,range:e,pointName:"end"})})),t}get rangesSnapshot(){return this.ranges.map((t=>t.snapshot))}clearRanges(){for(;this.ranges.length;)this.ranges.pop().caret.remove()}createRange(t){return new gt(t,this.editor)}createRangeFromNativeRange(t){const{startContainer:e,endContainer:n,startOffset:o,endOffset:r,collapsed:i}=t,{focusNode:s,focusOffset:a}=this.nativeSelection;let l=0;return l=i?0:s===n&&a===r?1:-1,this.createRange({startContainer:this.amendPathOffset(e).path,endContainer:this.amendPathOffset(n).path,startOffset:o,endOffset:r,d:l})}addRange(t){this.ranges.push(t)}collapse(t,e){this.nativeSelection.collapse(t,e),this._resetRangesFromNative()}amendPathOffset(t,e){const n=this.editor.queryPath(t);return n?n.isLeaf&&3!==n.pathType?this.amendPathOffset(n.elm.parentNode,n.index+1):{path:n,offset:e}:this.amendPathOffset(t.parentNode,e)}amendRange(t){const{startContainer:e,endContainer:n,startOffset:o,endOffset:r}=t,i=this.amendPathOffset(e,o),s=this.amendPathOffset(n,r);return t.setStart(i.path.elm,i.offset),t.setEnd(s.path.elm,s.offset),t}_resetRangesFromNative(){this.clearRanges();const t=this.nativeSelection.rangeCount;for(let e=0;e0){const e=this.amendRange(this.nativeSelection.getRangeAt(t-1));if(!e)return;let n=!1;if(this.ranges.forEach((t=>{t.endContainer===e.endContainer&&t.startOffset===e.startOffset&&(n=!0,t.remove())})),n)return;this.addRange(this.createRangeFromNativeRange(e))}}getRangeAt(t=0){return this.ranges[t]}removeAllRanges(){this.nativeSelection.removeAllRanges(),this.clearRanges()}createNativeRange({startContainer:t,startOffset:e,endContainer:n,endOffset:o}){const r=document.createRange();return r.setStart(t,e),r.setEnd(n,o),r}updatePoints(t,e,n,o){this.rangePoints.forEach((r=>{r.container===t&&e<=r.offset&&(r.range[r.pointName+"Offset"]+=n,o&&(r.range[r.pointName+"Container"]=o))}))}updateRangesFromNative(t){setTimeout((()=>{t?this._extendRangesFromNative():this._resetRangesFromNative(),this.updateCaret()}))}updateCaret(t=!0){this.ranges.forEach((e=>e.updateCaret(t))),this.rangeCount>1&&this._distinct(),t&&this.drawRangeBg()}_isCoverd(t,e){return t.y=e.y+e.height:e.y+e.height>=t.y+t.height}_distinct(){let t={},e=this.ranges.length;if(!(e<2)){for(let n=0;no.caret.rect.x===t[1].caret.rect.x));0===i.length?t[r]=o:this._isCoverd(o.caret.rect,i[0][1].caret.rect)?(o.caret.remove(),this.ranges.splice(n,1),e--,n--):t[r]=o}}t=null}}drawRangeBg(t){const e=t||this.getRangeAt(0);if(!e)return;const{startContainer:n,startOffset:o,endContainer:r,endOffset:i}=e;this.nativeSelection.removeAllRanges();const s={startContainer:n.elm,endContainer:r.elm,startOffset:o,endOffset:i};this.nativeSelection.addRange(this.createNativeRange(s))}getSeletedPath(){if(this.collapsed)return[];const t=this.ranges[0];let e,n,o,r=!1;if(t.collapsed)r=!0;else{if(0===t.startOffset)e=t.startContainer;else if(t.startOffset===t.startContainer.length)e=t.startContainer.nextLeaf;else{const n=t.startContainer.split(t.startOffset);this.updatePoints(t.startContainer,t.startOffset,-t.startOffset,n[1]),e=n[1]}if(0===t.endOffset)n=t.endContainer.prevLeaf;else if(t.endOffset===t.endContainer.length)n=t.endContainer;else{const e=t.endContainer.split(t.endOffset);this.updatePoints(t.endContainer,t.endOffset+1,-t.endOffset,e[1]),n=e[0]}}return o=e,{length:0,next:function(){if(r)return{value:void 0,done:r};{const t={value:o,done:r};return r=o===n,o=o.nextLeaf,this.length++,t}},[Symbol.iterator]:function(){return this}}}recoverRangesFromSnapshot(t){this.removeAllRanges(),this.ranges=t.map((t=>this.createRange({startContainer:this.editor.queryPath(t.startContainer),endContainer:this.editor.queryPath(t.endContainer),startOffset:t.startOffset,endOffset:t.endOffset,d:t.d}))),this.updateCaret()}}class vt{steps=[];startRanges=[];endRanges=[];commited=!1;constructor(t){this.editor=t,this.startRanges=this.editor.selection.rangesSnapshot}get commitPath(){return this.editor.queryPath(this.commitPathPosition)}addAndApplyStep(t){return this.steps.push(t),t.apply(this.editor)}addStep(...t){this.steps.push(...t)}commit(){0!==this.steps.length&&(this.endRanges=this.editor.selection.rangesSnapshot,this.editor.history.push(this),this.commited=!0)}apply(){for(let t=0;t{this.editor.selection.recoverRangesFromSnapshot(this.endRanges)}))}rollback(){for(let t=this.steps.length;t>0;t--)this.steps[t-1].invert(this.editor);setTimeout((()=>{this.editor.selection.recoverRangesFromSnapshot(this.startRanges)}))}}const bt={createPath:F,queryCommonPath:H,queryPath:V,Formater:G,Content:class extends it{uuid=R();get renderContent(){return this.$editor.formater.render(this.$path)}get displayType(){return"inline"}constructor(t){super(t)}get contentLength(){return this.$path.length}get $path(){return this.props.path}get $editor(){return this.props.editor}shouldComponentUpdate(){return 1!==this.$path.rebuildFlag}onBeforeRender(){this.$path._$component=this}update(t,e){return this.onBeforeUpdate&&this.onBeforeUpdate({path:t||this.$path,range:e}),this.setState().then((()=>{this.$editor.selection.drawRangeBg(),this.onAfterUpdate&&this.onAfterUpdate({range:e,path:t})}))}onInsert({data:t,type:e,range:n}){if("text"===e){const e=new mt({range:n,data:t});return e.apply(),this.update().then((()=>{n.collapse(!1),n.updateCaret()})),e}}onContentDelete(t,e){console.log("删除");const{endContainer:n,endOffset:o,startContainer:r,startOffset:i,collapsed:s}=e;if(s){const t=r.prevLeaf;if(o>0)r.textDelete(o,1),0===r.block.contentLength?(e.setStart(r,0).collapse(),r.block.$path.parent.component.update()):0===r.length?(r.delete(),t.block===r.block&&t?e.setStart(t,t.length).collapse():e.setStart(r.nextLeaf,0).collapse()):(this._updatePoints(n,o,-1),t?.block===r.block&&1===o&&e.setStart(t,t.length).collapse());else if(0===r.block.contentLength)r.block.$path.delete(),e.setStart(t,t.length).collapse();else if(0===r.length)r.delete();else if(r.block!==t.block){const n=r.parent;0===t.length?(t.parent.pop(),t.parent.push(...r.parent.children),n.delete(),e.setStart(r,0)):(t.parent.splice(t.index+1,0,...r.parent.children),n.delete(),e.setStart(r,0).collapse())}else e.setStart(t,t.length).collapse(),this.onContentDelete(e.startContainer,e)}else r===n?(r.textDelete(o,o-i),0===r.length&&(r.delete(),e.setStart(r.prevLeaf,r.prevLeaf.length).collapse()),e.collapse(!0)):(r.textDelete(r.length,r.length-i),n.textDelete(o,o),t.deleteBetween(r,n),r.block!==n.block&&(n.parent.delete(),r.parent.splice(r.index+1,0,...n.parent.children.filter((t=>t.length)))),e.collapse(!0),console.log(e.startOffset,e.endOffset,e));t.component.update(t,e).then((()=>{e.updateCaret()}))}enterPath(t,e){let n=null;if("left"===e){const e=t.endContainer;if(n=e.nextLeaf,!n)return null;const o=e.block===n.block;t.set(n,o?1:0)}else{if(n=t.startContainer.prevLeaf,!n)return null;t.set(n,n.length)}return{path:n,range:t}}leavePath(t,e){if("left"===e){const e=t.startContainer;let n=e.prevLeaf;return n&&e?(t.set(e,e.length),n.component.enterPath(t,"right")):null}{let e=t.endContainer.nextLeaf;return e?e.component.enterPath(t,"left"):null}}onCaretMove(t,e,n){const o=e.container,{shiftKey:r}=n;let i={path:o,range:e};return 0===e.d&&(e.d="left"===t?-1:1),this.isCaretShouldLeavePath(o,e,t)?i=this.leavePath(e,t):"left"===t?e.offset>0&&(e.offset-=1):e.offset{t.moveTo(n)})),e.set(n.children[0],0)}else n=e.container.parent.clone(!0),n.insertAfter(e.container.parent),e.set(n.children[0],0);n.parent.component.update().then((()=>{e.collapse(!0),e.updateCaret()}))}onKeydownArrowLeft(t,e){st("left",e,t),this.$editor.selection.updateCaret()}onKeydownArrowRight(t,e){st("right",e,t),this.$editor.selection.updateCaret()}onKeydownArrowUp(t,e){at("up",e,t),this.$editor.selection.updateCaret()}onKeydownArrowDown(t,e){at("down",e,t),this.$editor.selection.updateCaret()}onKeydownBackspace(t,e){dt(e,!1)}onKeydownEnter(t,e){this.onLinefeed(t,e)}isCaretShouldLeavePath(t,e,n){if("left"===n&&e.offset<=1){let n=t.prevLeaf;return!!n&&(0===e.offset||t.block===n.block)}return"right"===n&&e.offset===t.length}_updatePoints(t,e,n,o){this.$editor.selection.updatePoints(t,e,n,o)}setFormat(t,e){const n=this.$editor.queryCommonPath(t.startContainer,t.endContainer),o=this.$editor.selection.getSeletedPath();for(const t of o)e(t);n.component.update().then((()=>{t.updateCaret(),this.$editor.selection.drawRangeBg()}))}},Path:_,Selection:yt,createRef:function(){return{current:null}},createVnode:U,patch:tt,Component:it,utils:t,setVdomOrElm:h,setVnodeOrIns:p,setVdomOrPath:u,getVdomOrElm:d,getVdomOrPath:l,getVnodeOrIns:c,setVdomOrIns:f,getVdomOrIns:a,SplitText:pt};window.setFormat=function(t,e){const n=new vt(t);t.selection.ranges.forEach((o=>{const r=t.queryCommonPath(o.startContainer,o.endContainer),i=function(t,e,n){if(t.collapsed)return[];let o,r,i,s=!1;if(t.collapsed)s=!0;else{if(0===t.startOffset)o=t.startContainer;else if(t.startOffset===t.startContainer.length)o=t.startContainer.nextLeaf;else{const e=new pt(t.startContainer,t.startOffset);o=n.addAndApplyStep(e)[1]}if(0===t.endOffset)r=t.endContainer.prevLeaf;else if(t.endOffset===t.endContainer.length)r=t.endContainer;else{const e=new pt(t.endContainer,t.endOffset),o=n.addAndApplyStep(e);r=o[0]}}return i=o,{length:0,next:function(){if(s)return{value:void 0,done:s};{const t={value:i,done:s};return s=i===r,i=i.nextLeaf,this.length++,t}},[Symbol.iterator]:function(){return this}}}(o,0,n);for(const t of i){const o=new ut(t,0,e);n.addAndApplyStep(o)}n.commit(r),r.component.update()}))},window.deleteText=function(t,e){const n=new vt(t);t.selection.ranges.forEach((t=>{const o=new ft(t.container,t.offset,e);n.addAndApplyStep(o),n.commit(t.container.parent),t.container.parent.component.update()}))};const xt={},wt=xt;class Ct{size=50;queue=[];idx=-1;editor=null;constructor({size:t,editor:e}){this.size=t||50,this.editor=e}get current(){return this.queue[this.idx]}push(t){this.current!==t&&(this.queue.length===this.size?this.queue.shift():this.idx++,this.queue.splice(this.idx,this.size,t))}redo(){return this.idx!==this.queue.length-1&&(this.idx++,this.current.apply())}undo(){if(-1===this.idx)return!1;{const t=this.current.rollback();return this.idx--,t}}}const St={value:"",isComposing:!1};function kt(t){return t.replace(/( |^)[a-z]/g,(t=>t.toUpperCase()))}const Ot=["mount"];class Et{contentRef={current:null};renderContent(){return(0,arguments[arguments.length-1])("div",{id:"editor-content",style:"position:relative",ref:this.contentRef},[this.renderPath()])}constructor(t){$(new.target,Et,Ot),this.$path=t.path,t.path._editor=this,function({editor:t,formats:e,plugins:n}){const o=new G;var r;o.register(e),t.$eventBus={all:r=r||new Map,on:function(t,e){var n=r.get(t);n?n.push(e):r.set(t,[e])},off:function(t,e){var n=r.get(t);n&&(e?n.splice(n.indexOf(e)>>>0,1):r.set(t,[]))},emit:function(t,e){var n=r.get(t);n&&n.slice().map((function(t){t(e)})),(n=r.get("*"))&&n.slice().map((function(n){n(t,e)}))}},o.inject("editor",t),t.formater=o,t.history=new Ct({editor:t}),(t=>{for(let e=0;e{wt.platform.initIntercept(t)})),function(t){let e,n=null;t.on("mouseEvents",(e=>{if(!e.shiftKey&&0===e.button){const n=wt.platform.nativeSelection.rangeCount;for(let t=0;t{if(function(t){return t.type.startsWith("composition")||"input"===t.type}(o)){if(null===o.data)return;n&&!n.commited||(n=new vt(t)),function(t,e){const{data:n,type:o}=t;if("input"===o){let t=" "===n?" ":n||"";if(!St.isComposing&&n)e({data:t,type:"input"});else{const n=St.value.length;St.value=t,e({data:t,type:"compositioning",prevDataLength:n})}}else"compositionstart"===o?(St.value="",St.isComposing=!0):"compositionend"===o&&(setTimeout((()=>{e({data:St.value,type:"compositionend"}),St.value="",St.isComposing=!1})),t.target.value="")}(o,(({data:r,prevDataLength:i,type:s})=>{t.selection.ranges.forEach((a=>{a.collapsed||dt(a,!0),i&&A(i,dt,t,a,!0);const l=a.container;if("input"!==s&&"compositioning"!==s||(e=l.component.onInsert({type:"text",data:r,range:a,ts:n})),"input"===s||"compositionend"===s){n.addStep(e);const t=l.component.onInput;"function"==typeof t&&t.call(l.component,o,a,n)}})),n.commit()}))}else{const e=o.key?`${o.type}${o.key}`:null,n=`${o.type}`;t.selection.ranges.forEach((t=>{const r=t.container,i=e?r.component[`on${kt(e)}`]:null,s=r.component[`on${kt(n)}`];"function"==typeof i&&i.call(r.component,o,t),"function"==typeof s&&s.call(r.component,o,t)})),t.emit(e,o),t.emit(n,o)}})),t.on("selectionchange-origin",(()=>{const e=wt.platform.nativeSelection,{startContainer:n,startOffset:o,endContainer:r,endOffset:i}=t.selection.ranges[0]||{};t.emit("selectionchange",{startContainer:n,startOffset:o,endContainer:r,endOffset:i}),e&&!e.isCollapsed&&t.selection.ranges.forEach((t=>{t.caret.hidden()}))})),t.on("keydownz",(e=>{e.ctrlKey&&t.history.undo()})),t.on("keydownZ",(e=>{e.ctrlKey&&t.history.redo()}))}(t)}({editor:this,formats:t.formats,plugins:t.plugins})}renderPath(){return this.formater.render({children:[this.$path]})}on(t,e){this.$eventBus.on(t,e)}emit(t,e){this.$eventBus.emit(t,e)}focus(t){this.$eventBus.emit("focus",t)}destroy(){this.$eventBus.emit("destroy")}queryPath(t){return V(t,this.$path)}queryCommonPath(t,e){return H(this.queryPath(t),this.queryPath(e))}}const Rt=bt.createPath,Lt=bt.Content,At=bt.createRef,Mt=bt.createVnode,Pt=bt.patch,$t=bt.Component,Tt=bt.utils;n(22);var Nt=n(379),Bt=n.n(Nt),zt=n(795),_t=n.n(zt),Ft=n(569),Ht=n.n(Ft),Vt=n(565),Dt=n.n(Vt),It=n(216),jt=n.n(It),Kt=n(589),Ut=n.n(Kt),qt=n(259),Gt={};Gt.styleTagTransform=Ut(),Gt.setAttributes=Dt(),Gt.insert=Ht().bind(null,"head"),Gt.domAPI=_t(),Gt.insertStyleElement=jt(),Bt()(qt.Z,Gt),qt.Z&&qt.Z.locals&&qt.Z.locals;class Zt extends $t{constructor(t){super(t),this.state={visiable:!1},this.dialogRef=At()}render(){const t=arguments[arguments.length-1];return t("div",{ref:this.dialogRef,onClick:t=>t.stopPropagation()},[this.state.visiable?t("div",{style:"background:#ddd;position:absolute;top:35px;z-index:1"},[this.props.children.length?this.props.children:"dialog"]):""])}outClickHandle=t=>{this.setState({visiable:!1}),document.removeEventListener("click",this.outClickHandle)};toggle(){this.state.visiable||(console.log("==toggle==="),document.addEventListener("click",this.outClickHandle)),this.setState({visiable:!this.state.visiable})}}class Xt extends $t{render(){const t=arguments[arguments.length-1];return t("div",{class:"editor-tooltip"},[this.props.children.length?this.props.children:"",t("span",{class:"tooltiptext top",style:`width:${this.props.width}px;margin-left:-${this.props.width/2}px;`},[this.props.content||"content"])])}}function Yt(t,e,n){n/=100;const o=e=>(e+t/30)%12,r=(e/=100)*Math.min(n,1-n),i=t=>n-r*Math.max(-1,Math.min(o(t)-3,Math.min(9-o(t),1)));return[255*i(0),255*i(8),255*i(4)].map((t=>Jt(t)))}function Jt(t,e=0){return Number(`${Math.round(`${t}e${e}`)}e-${e}`)}function Qt(t,e,n){const[o,r,i]=Yt(t,100,50),s=((255-r)*e+r)*n,a=((255-i)*e+i)*n;return[Jt(((255-o)*e+o)*n),Jt(s),Jt(a)]}const{throttle:Wt,isDef:te}=Tt;function ee(t){return t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.cancelBubble=!0,t.returnValue=!1,!1}class ne extends $t{constructor(t){super(t)}render(){return(0,arguments[arguments.length-1])("div",{style:"font-size:20px"},[this.props.children,this.props.color])}}class oe extends $t{constructor(t){super(t),this.state={hue:0,x:228,y:0,px:1,py:1},this.containerRef=At()}render(){const t=arguments[arguments.length-1];return t("div",{style:`background: linear-gradient(to top, rgba(0, 0, 0, 1), transparent), linear-gradient(to left, hsla(${this.state.hue}, 100%, 50%, 1), rgba(255, 255, 255, 1))`,onMousedown:this.handleMouseDown,class:"palette",ref:this.containerRef},[t("span",{style:`top:${this.state.y}px;left:${this.state.x}px;`,class:"palette-picker"},[]),t(ne,{color:this.state.hue},[t("span",{},["hue:"])])])}handleChange=Wt((t=>{ee(t);const e="number"==typeof t.pageX?t.pageX:t.touches[0].pageX,n="number"==typeof t.pageY?t.pageY:t.touches[0].pageY,o=e-(this.containerRef.current.getBoundingClientRect().left+window.pageXOffset),r=n-(this.containerRef.current.getBoundingClientRect().top+window.pageYOffset),i=(228-o)/228,s=(150-r)/150;this.setState({x:o>=228?228:o<=0?0:o,y:r>=150?150:r<=0?0:r,px:i,py:s});const[a,l,c]=Qt(this.state.hue,i,s);this.props.hue.current.color=`rgba(${a},${l},${c},${this.props.hue.current.state.A})`,this.props.hue.current.setState({R:a,G:l,B:c})}),32);handleMouseDown=t=>{ee(t),this.handleChange(t),window.addEventListener("mousemove",this.handleChange),window.addEventListener("mouseup",this.handleMouseUp)};handleMouseUp=t=>{ee(t),this.unbindEventListeners()};unbindEventListeners=()=>{window.removeEventListener("mousemove",this.handleChange),window.removeEventListener("mouseup",this.handleMouseUp)};setPalette(t,e,n,o){if(te(o)){const[r,i]=function(t,e,n,o){const r={R:e,G:n,B:o},[i,s,a]=Yt(t,100,50);let l,c,d,h;return[i,s,a].forEach(((t,e)=>{255===t&&(c=["R","G","B"][e]),0===t&&(l=["R","G","B"][e])})),h=r[c]/255,d=0===r[l]?0:r[l]/h/255,[Jt(d,2),Jt(h,2)]}(t,e,n,o);this.setState({x:228*(1-r),y:150*(1-i),px:r,py:i})}this.setState({hue:t})}}const{throttle:re,isDef:ie}=Tt;function se(t){return t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.cancelBubble=!0,t.returnValue=!1,!1}class ae extends $t{constructor(t){super(t),this.color=this.props.color,this.state={x:200,x2:200,R:255,G:0,B:0,A:1},this.colorBlock=At(),this.hueContainer=At(),this.transparencyContainer=At()}render(){const t=arguments[arguments.length-1];return t("div",{class:"picker"},[t("div",{class:"left"},[t("div",{ref:this.hueContainer,onMousedown:this.handleHueMouseDown,class:"hue"},[t("div",{style:`left:${this.state.x}px`,class:"hue-picker"},[])]),t("div",{onMousedown:this.handleTransparencyMouseDown,class:"transparency",style:"margin-top:4px"},[t("div",{class:"transparency-picker-bg",style:`background: linear-gradient(to right, rgba(${this.state.R},${this.state.G},${this.state.B},0) 0%, rgba(${this.state.R},${this.state.G},${this.state.B},1)`},[]),t("div",{ref:this.transparencyContainer,style:"position:absolute;top:0"},[t("div",{style:`left:${this.state.x2}px;`,class:"transparency-picker"},[])])])]),t("div",{class:"right"},[t("div",{class:"color-block-bg"},[]),t("div",{style:`background:${this.color};`,ref:this.colorBlock,class:"color-block"},[])])])}onMounted(){let[t,e,n,o]=getComputedStyle(this.colorBlock.current).backgroundColor.match(/[\d||\.]+/g).map(Number);const[r]=function(t,e,n){t/=255,e/=255,n/=255;const o=Math.max(t,e,n),r=o-Math.min(t,e,n),i=r?o===t?(e-n)/r:o===e?2+(n-t)/r:4+(t-e)/r:0;return[60*i<0?60*i+360:60*i,100*(r?o<=.5?r/(2*o-r):r/(2-(2*o-r)):0),100*(2*o-r)/2].map((t=>Jt(t)))}(t,e,n);o=ie(o)?o:1,this.props.paletteRef.current.setPalette(r,t,e,n);const i=200-5*r/9;this.setState({A:o,x2:200*o<=6?6:200*o,x:i<=6?6:i,R:t,G:e,B:n})}handleHueChange=re((t=>{se(t);let e=("number"==typeof t.pageX?t.pageX:t.touches[0].pageX)-(this.hueContainer.current.getBoundingClientRect().left+window.pageXOffset);e=e>=200?200:e<=0?0:e;const n=360*(1-e/200),[o,r,i]=Qt(n,this.props.paletteRef.current.state.px,this.props.paletteRef.current.state.py);this.color=`rgba(${o},${r},${i},${this.state.A})`,this.setState({x:e<=6?6:e,R:o,G:r,B:i}),this.props.paletteRef.current.setPalette(n)}),32);handleHueMouseDown=t=>{se(t),this.handleHueChange(t),window.addEventListener("mousemove",this.handleHueChange),window.addEventListener("mouseup",this.handleMouseUp)};handleTransparencyChange=re((t=>{se(t);let e=("number"==typeof t.pageX?t.pageX:t.touches[0].pageX)-(this.transparencyContainer.current.getBoundingClientRect().left+window.pageXOffset);e=e>=200?200:e<=0?0:e;const n=e/200;this.color=`rgba(${this.state.R},${this.state.G},${this.state.B},${n})`,this.setState({x2:e<=6?6:e,A:n})}),32);handleTransparencyMouseDown=t=>{se(t),this.handleTransparencyChange(t),window.addEventListener("mousemove",this.handleTransparencyChange),window.addEventListener("mouseup",this.handleMouseUp)};handleMouseUp=t=>{se(t),this.unbindEventListeners()};unbindEventListeners(){window.removeEventListener("mousemove",this.handleHueChange),window.removeEventListener("mousemove",this.handleTransparencyChange),window.removeEventListener("mouseup",this.handleMouseUp)}}class le extends $t{constructor(t){super(t),this.paletteRef=At(),this.hueRef=At()}render(){const t=arguments[arguments.length-1];return t("div",{style:"font-size:0;width:228px;"},[t(oe,{ref:this.paletteRef,hue:this.hueRef},[]),t(ae,{ref:this.hueRef,color:this.props.color,paletteRef:this.paletteRef},[])])}onMounted(){console.log("ColorPicker")}}const ce={fontColor:(t,e)=>t("div",{id:"colorPicker"},[t(le,{color:"#666600"},[])])};class de extends $t{constructor(t){super(t)}render(t){return ce[this.props.name]?.(t,this)}}class he extends $t{toolBarItems=[];constructor(t){super(t),this.props.editor.on("selectionchange",(t=>{const{startContainer:e,endContainer:n}=t,o=[];let r=e;for(;o.push(r),r!==n;)r=r.nextLeaf;const i=function(t){if(0===t.length)return{};const e={};for(const n in t[0]){const o=t[0][n];t.every((t=>t[n]===o))&&(e[n]=o)}return e}(o.map((t=>t.node.formats)));this.notice(i)}))}notice(t){this.toolBarItems.forEach((e=>e.onNotice(t)))}render(){const t=arguments[arguments.length-1],{tools:e}=this.props;return t("div",{class:"editor-tool-bar"},[e.map((e=>t(Xt,{width:"64",content:e.tooltip},[t(pe,{...{...e,onCommand:this.onCommand,toolBarItems:this.toolBarItems}},[])])))])}onCommand=(t,...e)=>{this.props.onCommand(t,...e)}}class pe extends $t{constructor(t){super(t),this.state={active:!1},this.props.toolBarItems.push(this),this.dialogRef=At()}onNotice(t){t[this.props.commandName]!==this.state.active&&this.setState({active:t[this.props.commandName]})}render(){const t=arguments[arguments.length-1];return t("span",{onClick:this.clickHandle,class:"editor-tool-bar-item",style:`color: ${this.state.active?"rgb(42 201 249)":"rgb(227 227 227);"};`},[t("svg",{class:"icon","aria-hidden":!0,ns:"http://www.w3.org/2000/svg"},[t("use",{"xlink:href":this.props.icon},[])]),this.props.options?t(Zt,{ref:this.dialogRef},[t(de,{name:this.props.commandName,options:this.props.options},[])]):""])}emitComand=()=>{this.props.editor.command(this.props.commandName)};clickHandle=t=>{t.stopPropagation(),this.setState({active:!this.state.active}),this.dialogRef.current?this.dialogRef.current.toggle():this.emitComand()}}function ue(t){return document.getElementById(t).appendChild(Pt(function(t){const e=arguments[arguments.length-1];return e("div",{class:"editor-wrappe"},[e(he,{tools:[...t.toolBarOption],editor:t},[]),t.renderContent(e)])}(this,Mt))),this}function fe(t,e){return t.replace(/(\d*).*/,(function(t,n){return n*e}))}let me;me=Range.prototype.getClientRects?t=>{const e=document.createRange();let n;3!==t.container.elm.nodeType?0===t.offset?(e.setStart(t.container.elm,t.offset),e.setEnd(t.container.elm,t.offset+1),n=e.getClientRects()[0]):(e.setStart(t.container.elm,t.offset-1),e.setEnd(t.container.elm,t.offset),n=e.getClientRects()[0],n.x+=n.width):(e.setStart(t.container.elm,t.offset),n=e.getClientRects()[0]),e.setStart(t.container.elm,t.offset);const o=be(t.editor.contentRef.current),r=ve(t.editor.contentRef.current);return{x:n.x+o.x-r.x,y:n.y+o.y-r.y,height:n.height}}:t=>(new ye).measure(t.container.elm,t.offset);class ge{dom=null;rect=null;defaultStyle={};style={};constructor(t){this.range=t,this.dom=document.createElement("span"),this.dom.classList.add("custom-caret"),this.setStyle(this.dom)}setStyle(t={}){Object.assign(this.style,this.defaultStyle,t)}remove(){this.dom.remove()}hidden(){"none"!==this.style.display&&(this.setStyle({display:"none"}),this.draw())}show(){"inline-block"!==this.style.display&&(this.setStyle({display:"inline-block"}),this.draw())}update(t=!0){if(this.rect=me(this.range),!t)return;this.range.editor.contentRef.current.appendChild(this.dom);let e=this.range.startContainer.elm;if(!e)return;e instanceof Element||(e=e.parentNode);const n=getComputedStyle(e),o={top:this.rect.y+"px",left:this.rect.x-1+"px",height:this.rect.height+"px",fontSize:n.fontSize,background:n.color,display:this.range.collapsed?"inline-block":"none"};this.setStyle(o),this.draw()}draw(){((t,e)=>{for(const n in e)t.style[n]=e[n]})(this.dom,this.style)}}class ye{dom=null;instance=null;constructor(){if(ye.instance)return ye.instance;this.dom=document.createElement("text"),ye.instance=this}measure(t,e){let n;return 3===t.nodeType?e?(n=t.splitText(e),t.parentNode.insertBefore(this.dom,n)):t.parentNode.insertBefore(this.dom,t):t.childNodes[e-1]&&"BR"===t.childNodes[e-1].nodeName?t.insertBefore(this.dom,t.childNodes[e-1]):t.childNodes[e]?t.insertBefore(this.dom,t.childNodes[e]):t.appendChild(this.dom),this._getRect(t,e,n)}_getRect(t,e,n){let o=t;t instanceof Element||(o=t.parentNode);const r=fe(getComputedStyle(o).fontSize,1.3)/1,i={x:this.dom.offsetLeft,y:this.dom.offsetTop,height:r||this.dom.offsetHeight};return this.dom.remove(),3===t.nodeType&&e&&(!t.data&&t.nextSibling?t.nextSibling.remove():(t.data+=n.data,n.remove())),i}}function ve(t,e={x:0,y:0}){return e.height=e.height??t.offsetHeight,e.x+=t.offsetLeft,e.y+=t.offsetTop,t.offsetParent&&"HTML"!==t.offsetParent.tagName?ve(t.offsetParent,e):e}function be(t,e={x:0,y:0}){return e.x+=t.scrollLeft||0,e.y+=t.scrollTop||0,t.parentNode?be(t.parentNode,e):e}const xe={};function we(t,e,n){let o,r=n?.props,i=e.props;if((r||i)&&r!==i){for(o in r=r||{},i=i||{},i){if(/^on[A-Z]|class|style/.test(o))continue;const e=i[o];r[o]!==e&&(!0===e?t.setAttribute(o,""):!1===e?t.removeAttribute(o):120!==o.charCodeAt(0)?t.setAttribute(o,e):58===o.charCodeAt(3)?t.setAttributeNS("http://www.w3.org/XML/1998/namespace",o,e):58===o.charCodeAt(5)?t.setAttributeNS("http://www.w3.org/1999/xlink",o,e):t.setAttribute(o,e))}for(o in r)o in i||t.removeAttribute(o)}}const Ce={create:we,update:we};function Se(t,e,n){let o=new Map,r=new Map;e&&Object.keys(e.props).forEach((t=>{/^on[A-Z]/.test(t)&&r.set(t.replace(/^on/,"").toLowerCase(),e.props[t])})),n&&Object.keys(n.props).forEach((t=>{/^on[A-Z]/.test(t)&&o.set(t.replace(/^on/,"").toLowerCase(),e.props[t])})),(o.size||r.size)&&(r.forEach(((e,n)=>{o.has(n)||t.addEventListener(n,e,!1)})),o.forEach(((e,n)=>{r.has(n)||t.removeEventListener(n,e,!1)})))}const ke={create:Se,update:Se};function Oe(t,e,n){const o=(e?.props.class||"").trim();let r,i;o&&t.setAttribute("class",o);const s=(n?.props.class||"").trim(),a=(e?.props.class||"").trim();(s||a)&&s!==a&&(r=new Set(s?s.split(/\s+/g):[]),i=new Set(a?a.split(/\s+/g):[]),i.forEach((e=>{r.has(e)||t.classList.add(e)})),r.forEach((e=>{i.has(e)||t.classList.remove(key)})))}const Ee={create:Oe,update:Oe},Re={};function Le(t,e,n){let o=n?.props.style,r=e?.props.style;(o||r)&&o!==r&&(o=o||Re,r=r||Re,Object.keys(o).forEach((e=>{r[e]||t.style.removeProperty(e.replace(/([A-Z])/g,"-$1").toLowerCase())})),Object.assign(t.style,r))}const Ae={create:Le,update:Le};function Me(t,e){if("function"==typeof t.type)return;const n=xe.core.getVdomOrElm(t);"text"===t.type?t.children!==e.children&&(n.data=t.children):(Ae.update(n,t,e),Ee.update(n,t,e),ke.update(n,t,e),Ce.update(n,t,e))}function Pe(t){let e;if(1===t.vnodeType){const n=t.type(xe.core.createVnode,t.props);e=Pe(n),t.ref&&(t.ref.current=e),xe.core.setVdomOrIns(n,t),xe.core.setVdomOrElm(e,n),Me(n)}else if(2===t.vnodeType){const n=new t.type(t.props),o=n.generateVdom(xe.core.createVnode);e=Pe(o),"function"==typeof n.onCreated&&n.onCreated(),t.ref&&(t.ref.current=n),xe.core.setVdomOrIns(o,n),xe.core.setVnodeOrIns(n,t),xe.core.setVdomOrElm(e,o),Me(o)}else{if(3===t.vnodeType)return e=document.createTextNode(t.children),xe.core.setVdomOrElm(e,t),e;e=t.ns?document.createElementNS(t.ns,t.type):document.createElement(t.type),t.ref&&(t.ref.current=e),xe.core.setVdomOrElm(e,t),Me(t)}if(1===t.children?.length)e.appendChild(Pe(t.children[0]));else if(t.children?.length>1){const n=document.createDocumentFragment();for(let e=0;et.apply(this,o)),e)}}((()=>{const t=window.getSelection(),e=this.editor.contentRef.current;if(t.anchorNode&&t.focusNode){const n=t.anchorNode.parentElement,o=t.focusNode.parentElement;(n===e||o===e||e.contains(n)||e.contains(o))&&this.editor.emit("selectionchange-origin")}}),200);handMousedown(t){if(this.editor.emit("mouseEvents",t),!t.shiftKey&&0===t.button){const e=Te.rangeCount;for(let t=0;te.focus(t))),t.on("destroy",(()=>{e.destroy(),n.destroy()}))}const ze=document,_e=window,Fe=document.getSelection();function He(t,e,n){return t.insertBefore(e,n)}function Ve(t,e,n){return t.replaceChild(e,n)}function De(t,e){return t.appendChild(e)}function Ie(t,e){return console.log(e),t.removeChild(e)}function je(t){const e=t.tagName.toLowerCase()||"text";if("text"===e)return xe.core.createVnode(e);const n={},o=[],r=t.attributes,i=t.childNodes;for(let t=0,e=r.length;t(xe.core=n,t.platform=e,Ke.initIntercept);const Ue=Ke;class qe extends Lt{state={initProp:null};render(){const t=arguments[arguments.length-1];return t("div",{style:"display:inline-block"},["我是image的一部分",t("div",{onMousedown:this.onMousedown,onClick:this.sizeChange,style:"display:inline-block;height:15px;width:15px;background:red;user-select:none"},[]),t("img",{onMousedown:this.onMousedown,onClick:this.sizeChange,...this.$path.node.data},[])])}onMousedown=t=>{t.preventDefault(),t.stopPropagation()};sizeChange=t=>{this.state.initProp||(this.state.initProp={...this.$path.node.data}),this.$path.node.data.width===this.state.initProp.width?(this.$path.node.data.width="100px",this.$path.node.data.height="100px"):(this.$path.node.data.width=this.state.initProp.width,this.$path.node.data.height=this.state.initProp.height),this.update()};onAfterUpdate(){this.$editor.selection.updateCaret()}onContentDelete(t,e){const{endOffset:n,collapsed:o}=e;if(o)if(n>0){const n=this.$path.parent.component;t.delete(),n.update(),n.onCaretEnterPath(this.$path.parent,e,!1)}else{const n=this.getPrevLeafPath(t);n&&n.component.onCaretEnterPath(n,e,!1)}}onCaretEnterPath(t,e,n){return e.set(t,"left"===n?0:1),{path:t,range:e}}get contentLength(){return 1}}class Ge extends Lt{get displayType(){return"block"}onKeydownb(t,e){t?.ctrlKey&&(t?.preventDefault?.(),this.setFormat(e,(t=>{t.node.formats.bold=!t.node.formats.bold})))}onKeydownd(t,e){t?.ctrlKey&&(t?.preventDefault?.(),this.setFormat(e,(t=>{t.node.formats.deleteline=!t.node.formats.deleteline})))}onKeydowns(t,e){t?.ctrlKey&&(t?.preventDefault?.(),this.setFormat(e,(e=>{t.shiftKey?e.node.formats.sub=!e.node.formats.sub:e.node.formats.sup=!e.node.formats.sup})))}onKeydownu(t,e){t?.ctrlKey&&(t?.preventDefault?.(),this.setFormat(e,(t=>{t.node.formats.underline=!t.node.formats.underline})))}}class Ze extends Ge{render(){const t=arguments[arguments.length-1];return t("div",{},[this.$path.children.length?this.$path.render():this.state.placeholder(t)])}}class Xe extends Ge{render(){return(0,arguments[arguments.length-1])("p",{},[this.$path.render()])}}class Ye extends Ge{render(t){return t(`h${this.props.level}`,null,this.$path.render())}}class Je extends Ge{render(){return(0,arguments[arguments.length-1])("table",{border:"1",style:"border-collapse:collapse;width:600px"},[this.$path.render()])}}class Qe extends Ge{render(){return(0,arguments[arguments.length-1])("tr",{},[this.$path.render()])}}class We extends Ge{constructor(t){super(t),this.state._$root=At()}render(){return(0,arguments[arguments.length-1])("td",{ref:this.state._$root,style:"text-align:center;width:50%"},[this.$path.render()])}}const tn=[{name:"root",type:"component",render(t,e){return(0,arguments[arguments.length-1])(Ze,{...e},[])}},{name:"bold",type:"tag",render(t){const e=(0,arguments[arguments.length-1])("strong",{},[]);return t&&t.children.push(e),e}},{name:"image",type:"component",render(t,e){const n=(0,arguments[arguments.length-1])(qe,{...e},[]);return t&&t.children.push(n),n}},{name:"underline",type:"tag",render(t){const e=(0,arguments[arguments.length-1])("u",{},[]);return t&&t.children.push(e),e}},{name:"fontSize",type:"attribute",render(t,e){if(!t)return(0,arguments[arguments.length-1])("span",{style:{fontSize:e}},[]);t.props.style||(t.props.style={}),t.props.style.fontSize=e}},{name:"color",type:"attribute",render(t,e){if(!t)return(0,arguments[arguments.length-1])("span",{style:{color:e}},[]);t.props.style||(t.props.style={}),t.props.style.color=e}},{name:"paragraph",type:"component",render(t,e){const n=(0,arguments[arguments.length-1])(Xe,{...e,key:e.path._uuid},[]);return t&&t.children.push(n),n}},{name:"deleteline",type:"tag",render(t){const e=(0,arguments[arguments.length-1])("del",{},[]);return t&&t.children.push(e),e}},{name:"sup",type:"tag",render(t){const e=(0,arguments[arguments.length-1])("sup",{},[]);return t&&t.children.push(e),e}},{name:"sub",type:"tag",render(t){const e=(0,arguments[arguments.length-1])("sub",{},[]);return t&&t.children.push(e),e}},{name:"table",type:"component",render(t,e){const n=(0,arguments[arguments.length-1])(Je,{...e},[]);return t&&t.children.push(n),n}},{name:"row",type:"component",render(t,e){const n=(0,arguments[arguments.length-1])(Qe,{...e},[]);return t&&t.children.push(n),n}},{name:"col",type:"component",render(t,e){const n=(0,arguments[arguments.length-1])(We,{...e},[]);return t&&t.children.push(n),n}},{name:"background",type:"attribute",render(t,e){if(!t)return(0,arguments[arguments.length-1])("span",{style:{background:e}},[]);t.props.style||(t.props.style={}),t.props.style.background=e}},{name:"header",type:"component",render(t,e,n){const o=arguments[arguments.length-1];console.log(t,e);const r=o(Ye,{...e,level:n,key:e.path._uuid},[]);return t&&t.children.push(r),r}}],en={data:[{data:[{data:"这是一个基于Typex编写的简单富文本编辑器demo",formats:{color:"#666",bold:!0,fontSize:"20px"}}],formats:{paragraph:!0}},{data:[{data:"这是一个基于Typex编写的简单富文本编辑器demo"}],formats:{header:4}},{data:[{data:"Typex",formats:{color:"#ff9999"}},{data:"是一款全新架构的编辑器内核,该内核不依赖contenteditable;自主实现了光标、模拟输入、模拟选区;数据驱动,组件化,插件化,支持多光标,跨平台的设计。优秀的格式排版系统避免了脏标签的产生(打开控制台你会发现它的标签非常简洁)。多光标:按住alt+左键;加粗/取消加粗:ctrl+b;删除线/取消删除线:ctrl+d;上标/取消上标:ctrl+s ....",formats:{color:"#999"}}],formats:{paragraph:!0}},{data:[{data:"红色删除线",formats:{deleteline:!0,color:"red"}},{data:"上标示例",formats:{sup:!0,color:"green",fontSize:"12px"}},{data:"绿色加粗下划线",formats:{underline:!0,color:"green",bold:!0}},{data:"下标示例",formats:{sub:!0,color:"red",fontSize:"12px"}},{data:"背景示例",formats:{sub:!0,color:"white",fontSize:"16px",background:"orange"}}],formats:{paragraph:!0}},{data:[{data:"带静态内容的行内图片示例",formats:{color:"#ff9999",fontSize:"24px"}},{data:{src:"https://img2.baidu.com/it/u=3979034437,2878656671&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=333",alt:"test image",width:"60px",height:"60px"},formats:{image:!0}},{data:{src:"https://img2.baidu.com/it/u=3979034437,2878656671&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=333",alt:"test image",width:"50px",height:"50px"},formats:{image:!0}}],formats:{paragraph:!0}},{data:[{data:"表格示例:",formats:{color:"#666",bold:!0}}],formats:{paragraph:!0}},{data:[{data:[{data:[{data:[{data:"表格内容1",formats:{color:"green"}}],formats:{paragraph:!0}},{data:[{data:"表格内容2",formats:{color:"red",fontSize:"12px"}}],formats:{paragraph:!0}}],formats:{col:!0}},{data:[{data:[{data:"表格内容2",formats:{color:"Orange",fontSize:"20px",background:"#ddd"}}],formats:{paragraph:!0}}],formats:{col:!0}}],formats:{row:!0}}],formats:{table:!0}}],formats:{root:!0}};console.log(tn);class nn extends Et{conamndHandles={};toolBarOption=[];constructor(t){super({formats:tn,plugins:[Ue],...t}),this.on("command",this.command)}mount(t){return ue.call(this,t),this}setToolBar(t){return this.toolBarOption=t,t.forEach((t=>{t.editor=this,this.conamndHandles[t.commandName]=t.commandHandle})),this}command(t,e){const n=this.conamndHandles[t];console.log(n),"function"==typeof n&&n(this,e)}}var on=n(815),rn={};function sn(t,e){t.selection.ranges.forEach((t=>{t.container.component.setFormat(t,e)}))}rn.styleTagTransform=Ut(),rn.setAttributes=Dt(),rn.insert=Ht().bind(null,"head"),rn.domAPI=_t(),rn.insertStyleElement=jt(),Bt()(on.Z,rn),on.Z&&on.Z.locals&&on.Z.locals;const an=[{tooltip:"撤销",commandName:"undo",icon:"#icon-undo",commandHandle:t=>{t.history.undo()}},{tooltip:"重做",commandName:"redo",icon:"#icon-todo",commandHandle:t=>{t.history.redo()}},{tooltip:"标题",commandName:"header",icon:"#icon-header"},{tooltip:"字体大小",commandName:"fontSize",icon:"#icon-font-size",options:{}},{tooltip:"字体颜色",commandName:"fontColor",icon:"#icon-color",options:{componentName:"fontColor"}},{tooltip:"加粗",commandName:"bold",icon:"#icon-bold",commandHandle:t=>sn(t,(t=>t.node.formats.bold=!t.node.formats.bold))},{tooltip:"下划线",commandName:"underline",icon:"#icon-underline",commandHandle:t=>sn(t,(t=>t.node.formats.underline=!t.node.formats.underline))},{tooltip:"删除线",commandName:"deleteline",icon:"#icon-del",commandHandle:t=>sn(t,(t=>t.node.formats.deleteline=!t.node.formats.deleteline))},{tooltip:"背景填充",commandName:"background",icon:"#icon-fill",options:{}},{tooltip:"左对齐",commandName:"leftAligned",icon:"#icon-align-left"},{tooltip:"居中",commandName:"middleAligned",icon:"#icon-align-middle"},{tooltip:"右对齐",commandName:"rightAligned",icon:"#icon-align-right"},{tooltip:"超链接",commandName:"link",icon:"#icon-link"},{tooltip:"图片",commandName:"img",icon:"#icon-img"},{tooltip:"代码段",commandName:"code",icon:"#icon-code"},{tooltip:"markdown",commandName:"markdown",icon:"#icon-markdown"},{tooltip:"视频",commandName:"radio",icon:"#icon-radio"},{tooltip:"清除样式",commandName:"clearStyle",icon:"#icon-clear-style",commandHandle:t=>sn(t,(t=>t.node.formats={}))}];setTimeout((()=>{window.editor=function(t={}){const e=Rt(en);return new nn({path:e})}({data:"hello world"}).setToolBar(an).mount("editor-root")}),0)})()})(); \ No newline at end of file diff --git a/editor_mount.js.html b/editor_mount.js.html index 9cbc6b7..93214da 100644 --- a/editor_mount.js.html +++ b/editor_mount.js.html @@ -1,6 +1,6 @@ Source: editor/mount.js
On this page

editor_mount.js

/*
+    
On this page

editor_mount.js

/*
  * @Author: caiwu
  * @Description:
  * @CreateDate:
@@ -32,4 +32,4 @@
   document.getElementById(id).appendChild(patch(renderRoot(this, h)))
   return this
 }
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file diff --git a/global.html b/global.html index 4815829..4a96af7 100644 --- a/global.html +++ b/global.html @@ -1,3 +1,3 @@ Global
On this page

Members

getRect :function

Type:
  • function

Methods

Element(type, builtinProps, props, children) → {*}

虚拟节点工厂函数
Parameters:
NameTypeDescription
type*
builtinProps*
props*
children*
Returns:
Type: 
*

addVnodes(parentElm, beforeopt, vnodes, startIdx, endIdx)

增加节点
Parameters:
NameTypeAttributesDefaultDescription
parentElm*
before*<optional>
null
vnodes*
startIdx*
endIdx*

computeOffset(dom, resopt) → {*}

累计偏移量计算
Parameters:
NameTypeAttributesDefaultDescription
dom*
res*<optional>
{ x: 0, y: 0 }
Returns:
Type: 
*

computeScroll(dom, resopt) → {*}

累计滚动距离计算
Parameters:
NameTypeAttributesDefaultDescription
dom*
res*<optional>
{ x: 0, y: 0 }
Returns:
Type: 
*

createKeyToOldIdx(children, beginIdx, endIdx) → {*}

生成id映射
Parameters:
NameTypeDescription
children*
beginIdx*
endIdx*
Returns:
Type: 
*

createPath(node, parentopt, prevSiblingopt, nextSiblingopt, indexopt) → {Path}

创建path
Parameters:
NameTypeAttributesDefaultDescription
nodeObject标记
Properties
NameTypeDescription
dataString | Object
formatsObject
parentPath<optional>
null
prevSiblingPath<optional>
null
nextSiblingPath<optional>
null
indexNumber<optional>
0
Returns:
Type: 
Path

defer(fn) → {*}

defer
Parameters:
NameTypeDescription
fnfunction
Returns:
Type: 
*

del(range, forceopt)

删除操作
Parameters:
NameTypeAttributesDefaultDescription
range*
forceboolean<optional>
false

findIdxInOld(node, oldCh, start, end) → {*}

在老节点中查找id
Parameters:
NameTypeDescription
node*
oldCh*
start*
end*
Returns:
Type: 
*

flush()

调度执行

horizontalMove(direction, range, event) → {*}

水平移动
Parameters:
NameTypeDescription
direction*
range*
event*
Returns:
Type: 
*

initDispatcher(editor)

事件拦截到对应的组件
Parameters:
NameTypeDescription
editor*

invokeDestroyHook(vnode, destoryQueue)

销毁钩子调用
Parameters:
NameTypeDescription
vnode*
destoryQueue*

isSameLine(initialCaretInfo, prevCaretInfo, currCaretInfo, editor) → {Boolean}

光标跨行判断
Parameters:
NameTypeDescription
initialCaretInfo*
prevCaretInfo*
currCaretInfo*
editor*
Returns:
Type: 
Boolean

loop(range, direction, initialCaretInfo, prevCaretInfo, lineChanged, shiftKey) → {*}

循环执行函数
Parameters:
NameTypeDefaultDescription
range*
direction*
initialCaretInfo*
prevCaretInfo*
lineChanged*false
shiftKey*
Returns:
Type: 
*

patchVnode(vnode, oldVnode)

节点比对
Parameters:
NameTypeDescription
vnode*
oldVnode*

positionCompare(a, b) → {*}

Parameters:
NameTypeDescription
a*
b*
Returns:
0 a===b;-1 ab
Type: 
*

queryCommonPath(target, path) → {path}

Parameters:
NameTypeDescription
targetelm | vn | position
pathpath
Returns:
Type: 
path

queryPath(target, path) → {path}

Parameters:
NameTypeDescription
targetelm | vn | position
pathpath
Returns:
Type: 
path

queryPathByElm(elm) → {*}

根据dom查询path
Parameters:
NameTypeDescription
elm*
Returns:
Type: 
*

queryPathByPosition(position, rootPath) → {*}

根据坐标查询path
Parameters:
NameTypeDescription
position*
rootPath*
Returns:
Type: 
*

queryPathByVn(vn) → {*}

根据虚拟dom查询path
Parameters:
NameTypeDescription
vn*
Returns:
Type: 
*

queryRootPath(path) → {*}

查询根路径
Parameters:
NameTypeDescription
path*
Returns:
Type: 
*

removeVnodes(parentElm, oldCh, startIdx, endIdx)

节点删除
Parameters:
NameTypeDescription
parentElm*
oldCh*
startIdx*
endIdx*

renderRoot(h) → {*}

Parameters:
NameTypeDescription
h*
Returns:
Type: 
*

sameVnode(vnode, oldVnode) → {*}

判断是否相同节点
Parameters:
NameTypeDescription
vnode*
oldVnode*
Returns:
Type: 
*

setStyle(dom, style)

设置光标的样式
Parameters:
NameTypeDescription
dom*
style*

updateChildren(parentElm, newCh, oldCh)

children更新函数
Parameters:
NameTypeDescription
parentElm*
newCh*
oldCh*

verticalMove(range, direction, shiftKey)

垂直移动 垂直移动等效于水平移动N步的结果,关键点在于确定N 这里通过光标位置回溯法,计算出最合适的N
Parameters:
NameTypeDescription
range*
direction*
shiftKey*
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
On this page

Members

getRect :function

Type:
  • function

Methods

Element(type, builtinProps, props, children) → {*}

虚拟节点工厂函数
Parameters:
NameTypeDescription
type*
builtinProps*
props*
children*
Returns:
Type: 
*

addVnodes(parentElm, beforeopt, vnodes, startIdx, endIdx)

增加节点
Parameters:
NameTypeAttributesDefaultDescription
parentElm*
before*<optional>
null
vnodes*
startIdx*
endIdx*

computeOffset(dom, resopt) → {*}

累计偏移量计算
Parameters:
NameTypeAttributesDefaultDescription
dom*
res*<optional>
{ x: 0, y: 0 }
Returns:
Type: 
*

computeScroll(dom, resopt) → {*}

累计滚动距离计算
Parameters:
NameTypeAttributesDefaultDescription
dom*
res*<optional>
{ x: 0, y: 0 }
Returns:
Type: 
*

createKeyToOldIdx(children, beginIdx, endIdx) → {*}

生成id映射
Parameters:
NameTypeDescription
children*
beginIdx*
endIdx*
Returns:
Type: 
*

createPath(node, parentopt, prevSiblingopt, nextSiblingopt, indexopt) → {Path}

创建path
Parameters:
NameTypeAttributesDefaultDescription
nodeObject标记
Properties
NameTypeDescription
dataString | Object
formatsObject
parentPath<optional>
null
prevSiblingPath<optional>
null
nextSiblingPath<optional>
null
indexNumber<optional>
0
Returns:
Type: 
Path

defer(fn) → {*}

defer
Parameters:
NameTypeDescription
fnfunction
Returns:
Type: 
*

del(range, forceopt)

删除操作
Parameters:
NameTypeAttributesDefaultDescription
range*
forceboolean<optional>
false

findIdxInOld(node, oldCh, start, end) → {*}

在老节点中查找id
Parameters:
NameTypeDescription
node*
oldCh*
start*
end*
Returns:
Type: 
*

flush()

调度执行

horizontalMove(direction, range, event) → {*}

水平移动
Parameters:
NameTypeDescription
direction*
range*
event*
Returns:
Type: 
*

initDispatcher(editor)

事件拦截到对应的组件
Parameters:
NameTypeDescription
editor*

invokeDestroyHook(vnode, destoryQueue)

销毁钩子调用
Parameters:
NameTypeDescription
vnode*
destoryQueue*

isSameLine(initialCaretInfo, prevCaretInfo, currCaretInfo, editor) → {Boolean}

光标跨行判断
Parameters:
NameTypeDescription
initialCaretInfo*
prevCaretInfo*
currCaretInfo*
editor*
Returns:
Type: 
Boolean

loop(range, direction, initialCaretInfo, prevCaretInfo, lineChanged, shiftKey) → {*}

循环执行函数
Parameters:
NameTypeDefaultDescription
range*
direction*
initialCaretInfo*
prevCaretInfo*
lineChanged*false
shiftKey*
Returns:
Type: 
*

patchVnode(vnode, oldVnode)

节点比对
Parameters:
NameTypeDescription
vnode*
oldVnode*

positionCompare(a, b) → {*}

Parameters:
NameTypeDescription
a*
b*
Returns:
0 a===b;-1 ab
Type: 
*

queryCommonPath(target, path) → {path}

Parameters:
NameTypeDescription
targetelm | vn | position
pathpath
Returns:
Type: 
path

queryPath(target, path) → {path}

Parameters:
NameTypeDescription
targetelm | vn | position
pathpath
Returns:
Type: 
path

queryPathByElm(elm) → {*}

根据dom查询path
Parameters:
NameTypeDescription
elm*
Returns:
Type: 
*

queryPathByPosition(position, rootPath) → {*}

根据坐标查询path
Parameters:
NameTypeDescription
position*
rootPath*
Returns:
Type: 
*

queryPathByVn(vn) → {*}

根据虚拟dom查询path
Parameters:
NameTypeDescription
vn*
Returns:
Type: 
*

queryRootPath(path) → {*}

查询根路径
Parameters:
NameTypeDescription
path*
Returns:
Type: 
*

removeVnodes(parentElm, oldCh, startIdx, endIdx)

节点删除
Parameters:
NameTypeDescription
parentElm*
oldCh*
startIdx*
endIdx*

renderRoot(h) → {*}

Parameters:
NameTypeDescription
h*
Returns:
Type: 
*

sameVnode(vnode, oldVnode) → {*}

判断是否相同节点
Parameters:
NameTypeDescription
vnode*
oldVnode*
Returns:
Type: 
*

setStyle(dom, style)

设置光标的样式
Parameters:
NameTypeDescription
dom*
style*

updateChildren(parentElm, newCh, oldCh)

children更新函数
Parameters:
NameTypeDescription
parentElm*
newCh*
oldCh*

verticalMove(range, direction, shiftKey)

垂直移动 垂直移动等效于水平移动N步的结果,关键点在于确定N 这里通过光标位置回溯法,计算出最合适的N
Parameters:
NameTypeDescription
range*
direction*
shiftKey*
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file diff --git a/index.html b/index.html index 6421390..e50a1c5 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,6 @@ Home
On this page

演示/API文档地址👉[https://caiwuu.github.io/Typex/]


特点

  • 不依赖contentEditable;不依赖document.execCommand
  • 自绘光标、模拟输入,支持多光标;可自定义各个组件的光标和输入行为
  • 组件化、状态驱动、自建数据模型;高性能、高拓展性、高可控
  • 跨平台设计:内核和平台相关代码分离,通过平台插件注入

目录结构

src
+    
On this page

演示/API文档地址👉[https://caiwuu.github.io/Typex/]


特点

  • 不依赖contentEditable;不依赖document.execCommand
  • 自绘光标、模拟输入,支持多光标;可自定义各个组件的光标和输入行为
  • 组件化、状态驱动、自建数据模型;高性能、高拓展性、高可控
  • 跨平台设计:内核和平台相关代码分离,通过平台插件注入

目录结构

src
 ├─index.js
 ├─style.styl
 ├─platform 平台插件
@@ -75,4 +75,4 @@
 |  |       ├─caretMove.js
 |  |       ├─delete.js
 |  |       └input.js
-

TODO

  • 协同编辑
  • 历史记录
  • 复制粘贴
  • API 优化
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +

TODO

  • 协同编辑
  • 历史记录
  • 复制粘贴
  • API 优化
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file diff --git a/platform_web_caret.js.html b/platform_web_caret.js.html index 57a6419..071fc2e 100644 --- a/platform_web_caret.js.html +++ b/platform_web_caret.js.html @@ -1,6 +1,6 @@ Source: platform/web/caret.js
On this page

platform_web_caret.js

import { multiplication } from './utils'
+    
On this page

platform_web_caret.js

import { multiplication } from './utils'
 
 /** @type {Function} */
 let getRect
@@ -288,4 +288,4 @@
   }
   return res
 }
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file diff --git a/platform_web_updateProps_index.js.html b/platform_web_updateProps_index.js.html index 45913f3..ae63874 100644 --- a/platform_web_updateProps_index.js.html +++ b/platform_web_updateProps_index.js.html @@ -1,6 +1,6 @@ Source: platform/web/updateProps/index.js
On this page

platform_web_updateProps_index.js

import { attributesModule } from './modules/attributes'
+    
On this page

platform_web_updateProps_index.js

import { attributesModule } from './modules/attributes'
 import { listenersModule } from './modules/listeners'
 import { classesModule } from './modules/classes'
 import { stylesModule } from './modules/styles'
@@ -25,4 +25,4 @@
     attributesModule.update(elm, vnode, oldVnode)
   }
 }
-
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file +
Typex 欢迎各位对编辑器感兴趣的同学加入 QQ群:616405713
\ No newline at end of file