From 68ea1819793f03ed9927fcdd27aa9a311e556471 Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Fri, 5 Feb 2021 12:12:16 +0100 Subject: [PATCH] refactoring --- packages/extension-focus/src/focus.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/extension-focus/src/focus.ts b/packages/extension-focus/src/focus.ts index 665792f6..e24c26f2 100644 --- a/packages/extension-focus/src/focus.ts +++ b/packages/extension-focus/src/focus.ts @@ -62,16 +62,13 @@ export const FocusClasses = Extension.create({ currentLevel += 1 - const isOutOfScope = typeof this.options.levels === 'number' + const outOfScope = typeof this.options.levels === 'number' && ( - this.options.start === 'shallow' - ? currentLevel > this.options.levels - : maxLevels - currentLevel > this.options.levels + (this.options.start === 'deep' && maxLevels - currentLevel > this.options.levels) + || (this.options.start === 'shallow' && currentLevel > this.options.levels) ) - console.log(node.type.name, currentLevel, maxLevels, this.options.levels) - - if (isOutOfScope) { + if (outOfScope) { return this.options.start === 'deep' }