@one2x/medeo-rte 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/index.js +1795 -1627
- package/dist/index.js.map +1 -1
- package/dist/style.css +15 -7
- package/dist/types/editor.d.ts +13 -10
- package/dist/types/editor.d.ts.map +1 -1
- package/dist/types/layout/engine.d.ts.map +1 -1
- package/dist/types/layout/measure.d.ts +3 -2
- package/dist/types/layout/measure.d.ts.map +1 -1
- package/dist/types/layout/types.d.ts +6 -0
- package/dist/types/layout/types.d.ts.map +1 -1
- package/dist/types/layout/wrap.d.ts +22 -0
- package/dist/types/layout/wrap.d.ts.map +1 -1
- package/dist/types/model/document.d.ts.map +1 -1
- package/dist/types/model/types.d.ts +2 -2
- package/dist/types/model/types.d.ts.map +1 -1
- package/dist/types/model/virtualBlock.d.ts +3 -1
- package/dist/types/model/virtualBlock.d.ts.map +1 -1
- package/dist/types/operations/harness.d.ts +1 -0
- package/dist/types/operations/harness.d.ts.map +1 -1
- package/dist/types/operations/index.d.ts +1 -1
- package/dist/types/operations/index.d.ts.map +1 -1
- package/dist/types/operations/virtualBlock.d.ts +5 -0
- package/dist/types/operations/virtualBlock.d.ts.map +1 -1
- package/dist/types/paint/canvasPainter.d.ts.map +1 -1
- package/dist/types/paint/htmlPainter.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,7 +75,7 @@ new Editor(el, { plugins: [...builtinEmbedPlugins, formulaPlugin] });
|
|
|
75
75
|
|
|
76
76
|
两种 kind:
|
|
77
77
|
|
|
78
|
-
- **`mark
|
|
78
|
+
- **`mark`**:纯样式叠层(高亮底色、边框、文字缺省色等)。点击落在字上,块内方向键逐字走。从外侧朝块内按方向键不会走进去,而是先进入选中态(高亮整段文字,焦点留在来的这一侧)。从内侧走到边界再往外按,同样先进入选中态,焦点留在要出去的这一侧。选中态再朝块内按一次,光标进入这一侧的内侧;朝外侧再按一次,才离开到这一侧的外面。拖选或 Shift 拉出的选区不是选中态,左右键仍收到选区两端。选中态打字按选区替换整段。上下键不参与选中态,按原来的方式换行。同一条边上有多块重叠时,从外往里撞上选范围最大的,从里往外离开选范围最小的。不参与嵌套(`parentId` 恒为 `null`),可与其他块任意叠放。光标停在左右边界时都分内外两侧:从块内走到边界或点在底色里是**内侧**,输入算区间内(背景跟着延伸,遇到换行就断);选中态再朝外侧按一次,或点在底色外,是**外侧**(光标画在底色外),输入的文字留在块外、同一行。其他方式落到边界(`setSelection`、撤销等)时,右边界默认内侧、左边界默认外侧。没有 `placeholder` 时,区间内文字删光后块自动移除;有 `placeholder` 时,只删这块里的字会收成零宽,灰字由 SDK 画出来,不进正文,方向键也不把它当成整段选中。选区比这块更大(含全选)再删除会把这块拆掉;已经是零宽灰字时,光标在它上面再按退格或删除也会拆掉。样式只需配 `chrome.background`、`chrome.radius`(圆角,默认 3;折行时首行的上两角和末行的下两角是圆角,倒数第二行右缘超出最后一行时它的右下角也圆,其余角为直角,单行自然四角全圆)、`chrome.paddingX`(水平内边距,不传按 4px,传 `0` 表示不留)、`chrome.hoverBackground`(鼠标悬停时整段含折行各行换成这个底色)和 `chrome.placeholderColor`(灰字颜色,不传是 `#c5ccd6`):
|
|
79
79
|
|
|
80
80
|
```ts
|
|
81
81
|
editor.insertVirtualBlock({
|
|
@@ -84,15 +84,15 @@ new Editor(el, { plugins: [...builtinEmbedPlugins, formulaPlugin] });
|
|
|
84
84
|
});
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
`paddingX`
|
|
87
|
+
`paddingX` 留在底色里面,每一行的字都按它缩进。mark 真正的起点前、终点后,这段空白还占排版宽度,前后文字和相邻 mark 不会压在底色上,光标在内外侧的位置也正好是下一个字落下的位置。还没写完的行,底色铺到内容区右缘。SDK 默认让画布和 `.mini-page-wrap` 左右各多出 5px(负 margin 抵消,文字位置不变),所以贴边的 `paddingX` 在 5px 以内开箱即用。**宿主若覆盖 `.mini-page-wrap` 的 `padding`,请保留 `padding-inline: 5px; margin-inline: -5px;`,否则文字会左移 5px、贴边的内边距会被裁**。不支持垂直内边距。
|
|
88
88
|
|
|
89
|
-
**空态。** `placeholder` 不是正文,复制、保存、`getContent()`
|
|
89
|
+
**空态。** `placeholder` 不是正文,复制、保存、`getContent()` 里都没有这段字。只删这块里的字,或 `replaceMarkText(id, '')`,块留在原下标,两种光标亲和打字都会写进块里。选区超出这块再删,或光标停在灰字上再按退格、删除,块会被拆掉。没传 `placeholder` 的 mark 不能建成零宽,删光即拆掉。
|
|
90
90
|
|
|
91
91
|
```ts
|
|
92
92
|
const id = editor.insertVirtualBlock({
|
|
93
93
|
kind: 'mark',
|
|
94
94
|
placeholder: 'Describe a scene',
|
|
95
|
-
chrome: { background: '#fff3bf', placeholderColor: '#
|
|
95
|
+
chrome: { background: '#fff3bf', placeholderColor: '#c5ccd6' }
|
|
96
96
|
});
|
|
97
97
|
// 光标在这块里(含空块、内侧边界)时:
|
|
98
98
|
editor.on('markenter', ({ id }) => {});
|
|
@@ -132,7 +132,7 @@ editor.insertSlice({
|
|
|
132
132
|
start: 19,
|
|
133
133
|
end: 33,
|
|
134
134
|
placeholder: 'a red bicycle',
|
|
135
|
-
chrome: { background: '#fff3bf', placeholderColor: '#
|
|
135
|
+
chrome: { background: '#fff3bf', placeholderColor: '#c5ccd6' }
|
|
136
136
|
}
|
|
137
137
|
]
|
|
138
138
|
});
|
|
@@ -147,7 +147,7 @@ editor.insertSlice({
|
|
|
147
147
|
editor.insertVirtualBlock({
|
|
148
148
|
kind: 'mark',
|
|
149
149
|
placeholder: 'Describe a scene',
|
|
150
|
-
chrome: { background: '#fff3bf', placeholderColor: '#
|
|
150
|
+
chrome: { background: '#fff3bf', placeholderColor: '#c5ccd6' }
|
|
151
151
|
});
|
|
152
152
|
|
|
153
153
|
// 也可显式下标
|