Skip to content

Block alignment [Feature] #10

Closed

Description

@eagleusa

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.

Activity

  1. eagleusa commented on May 22, 2023

    @eagleusa
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions