Skip to content

Block alignment [Feature] #10

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

Closed
eagleusa opened this issue May 20, 2023 · 1 comment · May be fixed by #26
Closed

Block alignment [Feature] #10

eagleusa opened this issue May 20, 2023 · 1 comment · May be fixed by #26

Comments

@eagleusa
Copy link

Would it be possible to add a feature of alignment of blocks such as

<p align="center">

or similar for other blocks and alignment? (Left, Right, Top, Middle, etc.) / (h1, h2, etc.)?

Also font attributes such as color, size, etc. ?

Thank you for all your work.

@eagleusa
Copy link
Author

I was able to achieve this by modifying the ParagraphComponent within the Components folder. The modification was a quick and dirty one which will probably be refactored and cleaned up some later. However wanted to provide it here just in case anyone else is looking for this type of solution. In this component, the following code was added.

        else if (listItemNode.IsBlockNode())
          {
              var attributes = listItemNode.GetAttributes();
              foreach (var attribute in attributes)
              {
                  if (attribute.Name == "align")
                  {
                      if(attribute.Value.ToLower() == "left")
                      {
                          container = container.AlignLeft();
                      }
                      if (attribute.Value.ToLower() == "center")
                      {
                          container = container.AlignCenter();
                      }
                      if (attribute.Value.ToLower() == "right")
                      {
                          container = container.AlignRight();
                      }
                  }
              }

This is after the if statement checking whether it is a numbered list within the Compose method. Around line 45.

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

Successfully merging a pull request may close this issue.

1 participant