From eabcecb550e90b37be7dbb697b0f58ea4604cf91 Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Fri, 2 Oct 2020 15:45:45 +0200 Subject: [PATCH 1/3] add comment about broken autoFocus option --- docs/src/demos/Examples/Focus/index.spec.js | 2 -- docs/src/demos/Examples/Focus/index.vue | 2 +- docs/src/links.yaml | 4 ++-- packages/core/src/Editor.ts | 7 +++++++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/src/demos/Examples/Focus/index.spec.js b/docs/src/demos/Examples/Focus/index.spec.js index f36629de..1c7271a6 100644 --- a/docs/src/demos/Examples/Focus/index.spec.js +++ b/docs/src/demos/Examples/Focus/index.spec.js @@ -5,8 +5,6 @@ context('/examples/focus', () => { it('should have class', () => { cy.get('.ProseMirror').then(([{ editor }]) => { - editor.focus('start') - cy.get('.ProseMirror p:first').should('have.class', 'has-focus') }) }) diff --git a/docs/src/demos/Examples/Focus/index.vue b/docs/src/demos/Examples/Focus/index.vue index 063f9212..033c14da 100644 --- a/docs/src/demos/Examples/Focus/index.vue +++ b/docs/src/demos/Examples/Focus/index.vue @@ -1,5 +1,5 @@ diff --git a/docs/src/links.yaml b/docs/src/links.yaml index 94e80146..fb415661 100644 --- a/docs/src/links.yaml +++ b/docs/src/links.yaml @@ -56,8 +56,8 @@ # - title: Placeholder # link: /examples/placeholder # draft: true - # - title: Focus - # link: /examples/focus + - title: Focus + link: /examples/focus # - title: Title # link: /examples/title # draft: true diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index 2be9f517..87e50e39 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -122,7 +122,14 @@ export class Editor extends EventEmitter { this.registerCommands(coreCommands) this.injectCSS() + // TODO: The autoFocus option has no impact + // Doesn’t work this.proxy.focus(this.options.autoFocus) + // Does work + // window.setTimeout(() => { + // console.log(this.options.autoFocus) + // this.proxy.focus(this.options.autoFocus) + // }, 100) } /** From 6baa758ec321098d42b3bda7dffa766458f127a0 Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Fri, 2 Oct 2020 15:49:58 +0200 Subject: [PATCH 2/3] clean up the test --- docs/src/demos/Examples/Focus/index.spec.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/src/demos/Examples/Focus/index.spec.js b/docs/src/demos/Examples/Focus/index.spec.js index 1c7271a6..029eb69e 100644 --- a/docs/src/demos/Examples/Focus/index.spec.js +++ b/docs/src/demos/Examples/Focus/index.spec.js @@ -4,8 +4,6 @@ context('/examples/focus', () => { }) it('should have class', () => { - cy.get('.ProseMirror').then(([{ editor }]) => { - cy.get('.ProseMirror p:first').should('have.class', 'has-focus') - }) + cy.get('.ProseMirror p:first').should('have.class', 'has-focus') }) }) From b6a06c071fb2057c9767f25574961501c56b0673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 2 Oct 2020 21:57:46 +0200 Subject: [PATCH 3/3] refactoring --- packages/core/src/Editor.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index 87e50e39..f935946e 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -122,14 +122,7 @@ export class Editor extends EventEmitter { this.registerCommands(coreCommands) this.injectCSS() - // TODO: The autoFocus option has no impact - // Doesn’t work - this.proxy.focus(this.options.autoFocus) - // Does work - // window.setTimeout(() => { - // console.log(this.options.autoFocus) - // this.proxy.focus(this.options.autoFocus) - // }, 100) + window.setTimeout(() => this.proxy.focus(this.options.autoFocus), 0) } /**