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

Missing text align justify and list checkbox #3

Open
100tomtomas100 opened this issue Apr 24, 2024 · 3 comments
Open

Missing text align justify and list checkbox #3

100tomtomas100 opened this issue Apr 24, 2024 · 3 comments

Comments

@100tomtomas100
Copy link

Thank you for this package!

I want to align-text-justify and it is not set by default. As well i can not only change funtionality for just justify, i need to do styling for all other align possibilities.

paragraph: (props) => {
            //@ts-ignore
            if (props.format === "justify") {
              return (
                <p className={styles.paragraphJustify}>{props.children}</p>
              );
            } 
          }

If paragraph is not align-text-justify it returns empty and nothing is rendered. If i want to make other options work i have to style it one by one even though the other options are already styled by default.

I have similar issue with lists and checkbox

list: (props) => {
           //@ts-ignore
           if (props.listType === "check") {     
               return (
                 <CheckBox >{props.children}</CheckBox>
               );
             }
           } else if (props.listType === "bullet") {
             return <ul>{props.children}</ul>;
           } else if (props.listType === "number") {
             return <ol>{props.children}</ol>;
           }
         },

My question is if i can add text-align-justify without the need to style other options (as they are already styled by default) as well as add checkbox without the need to do styling for ol and ul?

Thank you !

@schaschjan
Copy link
Contributor

schaschjan commented Apr 25, 2024

Hey @100tomtomas100, if you want to change styles only for lists of the type check, then you could try this:

import { defaultElementRenderers } from "@atelier-disko/payload-lexical-react-renderer";
...
list: (element) => {
    if (props.listType === "check") {
        return (
            <CheckBox>{props.children} < /CheckBox>
        );
    }

    return defaultElementRenderers.list(element)
}

@schaschjan
Copy link
Contributor

@100tomtomas100 i just published version 1.0.4 including the missing type options. Thanks for the report!

@100tomtomas100
Copy link
Author

Thank you! It works perfectly

I have another request with the check lists
At the moment I have to check if the box is checked before sending it to the component of checkBox

list: (props) => {         
            if (props.listType === "check") {
              //workaround to mark checkbox checked
              if (checkedBoxes) {
                const isChecked = checkedBoxes[0];
                checkedBoxes.shift();

                return (
                  <CheckBox checked={isChecked}>{props.children}</CheckBox>
                );
              }
            }
            return defaultElementRenderers.list(props);
            }

I feel it is unecessary dificult and it does not work on livePreview.
Would it be possible to add checked or not to the props which we are sending to the custom component.
It is possible to see if its checked before PayloadLexicalReactRenderer but inside it is not visible anymore. I basicaly maped through all the nodes and checked which are checked boxes and which are not and then send one by one to the checkbox component.

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