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

Cannot set property 'children' of undefined #107

Open
Envov opened this issue Jun 7, 2021 · 4 comments
Open

Cannot set property 'children' of undefined #107

Envov opened this issue Jun 7, 2021 · 4 comments

Comments

@Envov
Copy link

Envov commented Jun 7, 2021

image

@Envov
Copy link
Author

Envov commented Jun 7, 2021

<template>
  <Slate :value="JSON.stringify(value)">
    <Editable :renderLeaf="renderLeaf" :renderElement="renderElement">
    </Editable>
  </Slate>
</template>

<script>
import PageBox from "c/PageBox";

import { Slate, Editable } from "slate-vue";


export default {
  components: { PageBox, Slate, Editable },
  data() {
    return {
      value: [
        {
          type: "h1",
          children: [{ text: "12121" }],
        },
      ],
    };
  },
  created() {
    //  console.log(this.value);
    //    this.$editor.children=this.value
    // console.log(this.$editor);
  },
  methods: {
    renderLeaf({ attributes, children, leaf }) {
      return {
        render() {
          return <span {...{ attrs: attributes }}>{children}</span>;
        },
      };
    },
    renderElement({ attributes, children, element }) {
      console.log({ attributes, children, element });
      return {
        render() {
          return (
            <div {...{ attrs: attributes }} element={element}>
              {children}
            </div>
          );
        },
      };
    },
  },
};
</script>

<style>
</style>

@Envov
Copy link
Author

Envov commented Jun 7, 2021

main.js

import Vue from "vue";
import 'babel-polyfill'
import { SlatePlugin } from 'slate-vue';
import { withHistory } from 'slate-history'
Vue.use(SlatePlugin, {
  editorCreated(editor) {
    withHistory(editor);
  },
});

...

@NeroZonbolt
Copy link

So there was never an answer? Same problem here

@Envov
Copy link
Author

Envov commented May 4, 2023

So there was never an answer? Same problem here

I've switched to tiptap, Everything is nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants