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

Extra attributes in formats #94

Open
mdathersajjad opened this issue Nov 24, 2020 · 0 comments
Open

Extra attributes in formats #94

mdathersajjad opened this issue Nov 24, 2020 · 0 comments

Comments

@mdathersajjad
Copy link

Thanks for this library, @nozer . I am trying to implement blockquote in two ways, one with background and other without background for that i added a separate block quote like this

import { Quill } from "react-quill";

let Block = Quill.import('blots/block');

class Blockquote extends Block {
  static create(value) {
    console.log(value);
    let node = super.create();

    if(typeof value !== "object"){
      return node;
    }

    if(!value.quote){
      return node;
    }

    node.setAttribute("class", "ql-customquote")
    return node;
  }

  static formats(node) {
    return {
      quote: node.getAttribute("class") === "ql-customquote"
    }
  }
}

Blockquote.blotName = 'blockquote';
Blockquote.tagName = 'blockquote';

export default Blockquote;

While adding the format i am sending quote: true or false. The delta ops looks like this.

{"ops":[{"insert":"Test"},{"attributes":{"blockquote":{"quote":true}},"insert":"\\n"},{"insert":"Test"},{"attributes":{"blockquote":{"quote":true}},"insert":"\\n"},{"insert":"TEst"},{"attributes":{"blockquote":{"quote":true}},"insert":"\\n"},{"insert":"\\n"}]}

In before render i am not able to get the attribute value as {blockquote: { quote: true/false}} instead i am getting { blockquote: true}. i want to style the content based on the quote flag. In editor it works fine. I tried custom tag and custom tag attributes.Any suggestions on how to achieve with this library

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

1 participant