@one2x/medeo-rte 0.4.2 → 0.4.3

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 CHANGED
@@ -75,7 +75,7 @@ new Editor(el, { plugins: [...builtinEmbedPlugins, formulaPlugin] });
75
75
 
76
76
  两种 kind:
77
77
 
78
- - **`mark`**:纯样式叠层(高亮底色、边框、文字缺省色等)。点击落在字上,块内方向键逐字走。从外侧朝块内按方向键不会走进去,而是先把整段文字选中(就是一段普通选区,焦点留在来的这一侧);再按一次方向键跳到另一侧外侧。整段选中时 Shift+方向键按普通选区缩小或扩大。上下键从块外落到块内时同样先选中整段。同一条边上有多块重叠时选范围最大的那块;两块紧挨着时,跳过前一块的同一次按键会选中下一块。不参与嵌套(`parentId` 恒为 `null`),可与其他块任意叠放。光标停在左右边界时都分内外两侧:从块内走到边界或点在底色里是**内侧**,输入算区间内(背景跟着延伸,遇到换行就断);在边界上再朝块外按一次方向键,或点在底色外,是**外侧**(光标画在底色外),输入的文字留在块外、同一行。其他方式落到边界(`setSelection`、撤销等)时,右边界默认内侧、左边界默认外侧。没有 `placeholder` 时,区间内文字删光后块自动移除;有 `placeholder` 时收成零宽,灰字由 SDK 画出来,不进正文,方向键也不把它当成整段选中。样式只需配 `chrome.background`、`chrome.radius`(圆角,默认 3;折行时只有首行的上两角和末行的下两角是圆角,其余角为直角,单行自然四角全圆)、`chrome.paddingX`(水平内边距,不传按 4px,传 `0` 表示不留)、`chrome.hoverBackground`(鼠标悬停时整段含折行各行换成这个底色)和 `chrome.placeholderColor`(灰字颜色,不传是 `#98a2b3`):
78
+ - **`mark`**:纯样式叠层(高亮底色、边框、文字缺省色等)。**交互与普通文本流完全一致**:点击落光标、方向键逐字走、能选中、能编辑;不参与嵌套(`parentId` 恒为 `null`),可与其他块任意叠放。光标停在左右边界时都分内外两侧:从块内走到边界或点在底色里是**内侧**,输入算区间内(背景跟着延伸,遇到换行就断);在边界上再朝块外按一次方向键,或点在底色外,是**外侧**(光标画在底色外),输入的文字留在块外、同一行;朝块内按一次回到内侧。其他方式落到边界(`setSelection`、撤销等)时,右边界默认内侧、左边界默认外侧。没有 `placeholder` 时,区间内文字删光后块自动移除;有 `placeholder` 时收成零宽,灰字由 SDK 画出来,不进正文。样式只需配 `chrome.background`、`chrome.radius`(圆角,默认 3;折行时只有首行的上两角和末行的下两角是圆角,其余角为直角,单行自然四角全圆)、`chrome.paddingX`(水平内边距,不传按 4px,传 `0` 表示不留)、`chrome.hoverBackground`(鼠标悬停时整段含折行各行换成这个底色)和 `chrome.placeholderColor`(灰字颜色,不传是 `#98a2b3`):
79
79
 
80
80
  ```ts
81
81
  editor.insertVirtualBlock({
package/dist/index.js CHANGED
@@ -4657,6 +4657,11 @@ class wa {
4657
4657
  * index 对不上或不再是边界就作废,按 backward 算。
4658
4658
  */
4659
4659
  u(this, "affinity", null);
4660
+ /**
4661
+ * 从外侧移入 mark 时先整段选中。暂时关闭,方向键按字符流进出:
4662
+ * 边界上先换内外侧,再按一次才走进或走出。
4663
+ */
4664
+ u(this, "wholeMarkSelect", !1);
4660
4665
  u(this, "dragScrollTick", () => {
4661
4666
  this.dragScrollRaf = 0;
4662
4667
  const t = this.lastDragEvent;
@@ -5851,7 +5856,7 @@ class wa {
5851
5856
  return t.pos;
5852
5857
  const e = this.sel;
5853
5858
  let n = it(this.layout, e.focus);
5854
- const i = this.wholeSelectedMark();
5859
+ const i = this.wholeMarkSelect ? this.wholeSelectedMark() : null;
5855
5860
  if (i && e.focus === i.end) {
5856
5861
  const o = (r = this.caretStopAt(e.focus)) == null ? void 0 : r.fwdX;
5857
5862
  o != null && (n = { ...n, x: o });
@@ -6138,20 +6143,22 @@ class wa {
6138
6143
  this.sel = d, this.afterCaretMove();
6139
6144
  return;
6140
6145
  }
6141
- const h = this.wholeSelectedMark();
6142
- if (h) {
6143
- this.skipSelectedMark(h, c);
6144
- return;
6145
- }
6146
- const f = this.markEntering(c);
6147
- if (f) {
6148
- this.selectWholeMark(f, c);
6149
- return;
6146
+ if (this.wholeMarkSelect) {
6147
+ const h = this.wholeSelectedMark();
6148
+ if (h) {
6149
+ this.skipSelectedMark(h, c);
6150
+ return;
6151
+ }
6152
+ const f = this.markEntering(c);
6153
+ if (f) {
6154
+ this.selectWholeMark(f, c);
6155
+ return;
6156
+ }
6150
6157
  }
6151
6158
  if (A(this.sel) && this.isMarkBoundary(this.sel.focus)) {
6152
- const p = this.caretAffinity();
6153
- if (t === "ArrowRight" == (p === "backward")) {
6154
- this.affinity = { index: this.sel.focus, dir: p === "backward" ? "forward" : "backward" }, this.verticalGoal = null, this.afterCaretMove();
6159
+ const h = this.caretAffinity();
6160
+ if (t === "ArrowRight" == (h === "backward")) {
6161
+ this.affinity = { index: this.sel.focus, dir: h === "backward" ? "forward" : "backward" }, this.verticalGoal = null, this.afterCaretMove();
6155
6162
  return;
6156
6163
  }
6157
6164
  }
@@ -6164,14 +6171,14 @@ class wa {
6164
6171
  }
6165
6172
  const o = i && ((l = this.verticalGoal) == null ? void 0 : l.focus) === n ? this.verticalGoal.x : this.verticalStartX(n);
6166
6173
  if (!r && t === "ArrowLeft" && (n = this.stepIndex(n, -1)), !r && t === "ArrowRight" && (n = this.stepIndex(n, 1)), t === "ArrowUp" || t === "ArrowDown") {
6167
- const c = t === "ArrowDown" ? 1 : -1, d = e ? null : this.wholeSelectedMark();
6174
+ const c = t === "ArrowDown" ? 1 : -1, d = this.wholeMarkSelect && !e ? this.wholeSelectedMark() : null;
6168
6175
  if (d) {
6169
6176
  const h = c > 0 ? d.end : d.start;
6170
6177
  if (this.affinity = { index: h, dir: c > 0 ? "forward" : "backward" }, n = this.verticalMove(h, c, o), this.wouldBeInsideMark(d, n, o)) {
6171
6178
  this.skipSelectedMark(d, c);
6172
6179
  return;
6173
6180
  }
6174
- } else if (n = this.verticalMove(n, c, o), !e && A(this.sel)) {
6181
+ } else if (n = this.verticalMove(n, c, o), this.wholeMarkSelect && !e && A(this.sel)) {
6175
6182
  const h = this.markLandedInside(n, o);
6176
6183
  if (h) {
6177
6184
  this.selectWholeMark(h, c);