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

TypeError: Cannot read property 'addExtensions' of undefined #1580

Closed
devgeni opened this issue Jul 12, 2021 · 5 comments
Closed

TypeError: Cannot read property 'addExtensions' of undefined #1580

devgeni opened this issue Jul 12, 2021 · 5 comments
Labels
Type: Bug The issue or pullrequest is related to a bug

Comments

@devgeni
Copy link

devgeni commented Jul 12, 2021

Description
Error while trying to convert html string to json object with node using tiptap/html

Steps to reproduce the bug
Steps to reproduce the behavior:

  1. npm install @tiptap/extension-document @tiptap/extension-paragraph @tiptap/extension-text @tiptap/html
  2. Create file test.js and put the code below inside it:
const Document = require("@tiptap/extension-document");
const Paragraph = require("@tiptap/extension-paragraph");
const Text = require("@tiptap/extension-text");

const generateJSON = require("@tiptap/html").generateJSON;

const html = "<p>Hello World</p>";
const json = generateJSON(html, [Document, Paragraph, Text]);

console.log(json);
  1. node index.js
  2. See error message in the console

Expected behavior
It should output { type: 'doc', content: [ { type: 'paragraph', content: [Array] } ] } in the console.

Additional context
Here is how the error looks llike:

if (extension.config[field] === undefined && extension.parent) {
                        ^

TypeError: Cannot read property 'addExtensions' of undefined
    at getExtensionField (../node_modules/@tiptap/core/dist/tiptap-core.cjs.js:427:25)
    at ../node_modules/@tiptap/core/dist/tiptap-core.cjs.js:816:35
    at Array.map (<anonymous>)
    at Function.flatten (../node_modules/@tiptap/core/dist/tiptap-core.cjs.js:811:14)
    at Function.resolve (../node_modules/@tiptap/core/dist/tiptap-core.cjs.js:807:55)
    at Object.getSchema (../node_modules/@tiptap/core/dist/tiptap-core.cjs.js:3273:49)
    at generateJSON (../node_modules/@tiptap/html/dist/tiptap-html.cjs.js:26:25)
    at ../test.js:8:14

Here is the link to the source where it happens:
https://github.com/ueberdosis/tiptap/blob/main/packages/core/src/ExtensionManager.ts#L143

@devgeni devgeni added Type: Bug The issue or pullrequest is related to a bug v2 labels Jul 12, 2021
@devgeni devgeni closed this as completed Jul 16, 2021
@marco-scoppetta-qatalog

Hey @devgeni - what was the solution which made it work for you?

@hanspagel
Copy link
Contributor

Update your dependencies ✌️

@marco-scoppetta-qatalog

We have the latest version of TipTap core and all the extensions - but still stuck on this issue. Anything else we could check?

@philippkuehn
Copy link
Contributor

default export in node doesn’t work. you have to do:

const { Document } = require("@tiptap/extension-document")

instead of

const Document = require("@tiptap/extension-document")

@tomi-bigpi
Copy link
Contributor

FYI for anyone running across this: I ran into this because I was still using StarterKit which uses the default imports. I switched to custom extension setup with the correct imports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests

5 participants