From e413213dbb5440350d93e85d968956c2a5b3ea7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BA=91=E9=A3=9E?= Date: Sat, 27 Nov 2021 12:17:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BC=98=E5=8C=96=E6=9C=80=E5=B0=8F?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6=E9=80=89=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/editor/assets/css/index.css | 2 +- src/editor/core/draw/Draw.ts | 6 +++++- src/editor/index.ts | 1 + src/editor/interface/Editor.ts | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/editor/assets/css/index.css b/src/editor/assets/css/index.css index 194c682..0a20e44 100644 --- a/src/editor/assets/css/index.css +++ b/src/editor/assets/css/index.css @@ -1,5 +1,5 @@ .inputarea { - width: 1px; + width: 0; height: 12px; min-width: 0; min-height: 0; diff --git a/src/editor/core/draw/Draw.ts b/src/editor/core/draw/Draw.ts index b8729c8..7ac4504 100644 --- a/src/editor/core/draw/Draw.ts +++ b/src/editor/core/draw/Draw.ts @@ -375,7 +375,11 @@ export class Draw { // 选区绘制 const { startIndex, endIndex } = this.range.getRange() if (startIndex !== endIndex && startIndex < index && index <= endIndex) { - this.range.render(ctx, x, y, metrics.width, curRow.height) + let width = metrics.width + if (width === 0 && curRow.elementList.length === 1) { + width = this.options.rangeMinWidth + } + this.range.render(ctx, x, y, width, curRow.height) } index++ x += metrics.width diff --git a/src/editor/index.ts b/src/editor/index.ts index 6c52af4..001fd6d 100644 --- a/src/editor/index.ts +++ b/src/editor/index.ts @@ -30,6 +30,7 @@ export default class Editor { strikeoutColor: '#FF0000', rangeAlpha: 0.6, rangeColor: '#AECBFA', + rangeMinWidth: 5, searchMatchAlpha: 0.6, searchMatchColor: '#FFFF00', highlightAlpha: 0.6, diff --git a/src/editor/interface/Editor.ts b/src/editor/interface/Editor.ts index 5ae1474..e02b47c 100644 --- a/src/editor/interface/Editor.ts +++ b/src/editor/interface/Editor.ts @@ -12,6 +12,7 @@ export interface IEditorOption { strikeoutColor?: string; rangeColor?: string; rangeAlpha?: number; + rangeMinWidth?: number; searchMatchColor?: string; searchMatchAlpha?: number; highlightAlpha?: number;