Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Editor constructor fails with this.members[i] is undefined when using CodeBlockLowlight since v2.2.3 #5074

Open
1 of 2 tasks
hugorut opened this issue Apr 17, 2024 · 0 comments
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug

Comments

@hugorut
Copy link

hugorut commented Apr 17, 2024

Which packages did you experience the bug in?

extension-code-block-lowlight,core

What Tiptap version are you using?

3.1.0

What’s the bug you are facing?

When using tiptap Editor and CodeBlockLowlight I am unable to render the editor as the innerDeco seems to have two members which are undefined. This causes the DecoraterGroup.locals function to blow up as it calls

let locals = this.members[i].localsInner(node);

where this.members[i] is sometimes undefined.

I have not found why this occurs at the moment, but some replicable code to produce the error is attached below.

Other replies to similar issues mentioned that this might be a prosemiror view version mismatch, but I cannot see this from the various extension package.jsons

What browser are you using?

Firefox

Code example

<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
  <meta charset="UTF-8"/>
  <title>test</title>
  <script type="module">
    import {all, common, createLowlight} from 'https://esm.sh/lowlight@3'
    import { Editor } from 'https://esm.sh/@tiptap/core'
    import StarterKit from 'https://esm.sh/@tiptap/starter-kit'
    import Placeholder from 'https://esm.sh/@tiptap/extension-placeholder'
    import CodeBlockLowlight from 'https://esm.sh/@tiptap/extension-code-block-lowlight'
  
    const lowlight = createLowlight(common)
    window.editor = new Editor({
      element: document.querySelector('.element'),
      extensions: [
        StarterKit.configure({
          codeBlock: false,
        }),
        CodeBlockLowlight.configure({
          lowlight,
        }),
        Placeholder.configure({ placeholder: 'Start writing...' }),
      ],
    })
  </script>
</head>
<body>
      <div class="element"></div>
</body>

whereas if I pin the version to 2.2.3 the example is rendered correctly, e.g:

<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
  <meta charset="UTF-8"/>
  <title>test</title>
  <script type="module">
    import {all, common, createLowlight} from 'https://esm.sh/lowlight@3'
    import { Editor } from 'https://esm.sh/@tiptap/core@2.2.3'
    import StarterKit from 'https://esm.sh/@tiptap/starter-kit@2.2.3'
    import Placeholder from 'https://esm.sh/@tiptap/extension-placeholder@2.2.3'
    import CodeBlockLowlight from 'https://esm.sh/@tiptap/extension-code-block-lowlight@2.2.3'
  
    const lowlight = createLowlight(common)
    window.editor = new Editor({
      element: document.querySelector('.element'),
      extensions: [
        StarterKit.configure({
          codeBlock: false,
        }),
        CodeBlockLowlight.configure({
          lowlight,
        }),
        Placeholder.configure({ placeholder: 'Start writing...' }),
      ],
    })
  </script>
</head>
<body>
      <div class="element"></div>
</body>

What did you expect to happen?

I expected the editor to be rendered.

Anything to add? (optional)

No response

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖
@hugorut hugorut added Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug labels Apr 17, 2024
@hugorut hugorut changed the title [Bug]: this.members[i] is undefined when using CodeBlockLowlight since v2.2.3 [Bug]: Editor constructor fails with this.members[i] is undefined when using CodeBlockLowlight since v2.2.3 Apr 17, 2024
@hugorut hugorut changed the title [Bug]: Editor constructor fails with this.members[i] is undefined when using CodeBlockLowlight since v2.2.3 [Bug]: Editor constructor fails with this.members[i] is undefined when using CodeBlockLowlight since v2.2.3 Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug
Projects
Status: Triage open
Development

No branches or pull requests

1 participant