Skip to content

Text frames/absolute elements #47

@Alexnortung

Description

@Alexnortung

I would like to be able to convert absolute elements. docx have support for text frames which can be used for this issue. However I am not sure how we can implement it properly in this library.

Considerations

  • Anchor positioning - if there are no relative elements, it should just be at the start of the document. If there is a relative element as a parent, the anchor should be placed there.
  • Some styles cannot be cascaded (e.g. position, left, top), but in the current implementation, I think that all styles are cascaded to its children.

Example HTML

Consider the following HTML

<div style="position: relative">
<p style="position: absolute; left: 10px; top: 10px;">
Floating text
</p>
</div>

If we convert it to DocumentElements we actually lose information about the div and that it was actually providing a context for the paragraph.

[
  {
    "type": "paragraph",
    "text": "Floating text",
    "styles": {
      "position": "absolute",
      "left": "10px",
      "top": "10px"
    },
    "attributes": {},
    "metadata": {
      "tagName": "p"
    }
  }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions