ueberdosis / tiptap

The headless rich text editor framework for web artisans.
https://tiptap.dev
MIT License
26.54k stars 2.23k forks source link

[Bug]: RangeError: Schema is missing its top node type ('doc') #4043

Closed BobidaHombre closed 1 year ago

BobidaHombre commented 1 year ago

Which packages did you experience the bug in?

@tiptap/vue-2

What Tiptap version are you using?

2.0.3

What’s the bug you are facing?

I am trying to create text editor with tip tap, but I am encountering error:

RangeError: Schema is missing its top node type ('doc')

Code I am using in my component (Nuxt 2):

export default {
  props: {
    value: {
      type: String,
      default: '',
    },
  },
  data: () => ({
    editor: null,
  }),
  async mounted() {
    await this.$nextTick();
    this.mountEditor();
  },
  methods: {
    mountEditor() {
      this.editor = new Editor({
        content: this.value,
      });
    },
  },
};

This is very simple code, so I have no clue why it's not working.

Using Node v16.16.0 and npm 8.11.0

What browser are you using?

Chrome

Code example

No response

What did you expect to happen?

I expect editor to work.

Anything to add? (optional)

No response

Did you update your dependencies?

Are you sponsoring us?

viell-dev commented 1 year ago

Same in vue3, error thrown from prosemirror-model/dist/index.js

Uncaught (in promise) RangeError: Schema is missing its top node type ('doc')
    at NodeType.compile (index.js:2246:19)
    at new Schema (index.js:2372:35)
    at getSchemaByResolvedExtensions (getSchemaByResolvedExtensions.ts:190:10)
    at new ExtensionManager (ExtensionManager.ts:34:19)
    at Editor2.createExtensionManager (Editor.ts:240:29)
    at new Editor (Editor.ts:79:10)
    at new Editor2 (Editor.ts:50:5)
    at useEditor.ts:10:20
    at runtime-core.esm-bundler.js:2675:88
    at callWithErrorHandling (runtime-core.esm-bundler.js:158:18)
svenadlung commented 1 year ago
{
  type: String,
  default: '',
},

Doesn't seem to be valid content. What about just passing an empty string instead?

props: {
  value: '',
},

Could you please provide a CodeSandbox if the issue still persists?

bdbch commented 1 year ago

You don't have any extensions in your editor which leads to the Editor complaining about the missing doc nodeType. Install the starter kit and add extensions: [StarterKit] to your editor setup.

vazsonyidl commented 1 month ago

Hello.

I receive the same error even though providing Heading as an extension. Is it mandatory to provide the StarterKit to get rid off this error?

nperez0111 commented 1 month ago

You need the StarterKit extension or if you want to install each extension individually, the document extension. To get a barebones editor refer to this example: https://tiptap.dev/docs/examples/basics/minimal-setup