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

Rich text support #11

Merged
merged 28 commits into from
Nov 4, 2017
Merged

Rich text support #11

merged 28 commits into from
Nov 4, 2017

Conversation

rwb27
Copy link
Contributor

@rwb27 rwb27 commented Nov 3, 2017

This branch uses my DOMParser in the browser, and extends the rendering to allow rich text (including hyperlinks) in the various long text fields. This fixes #5 and #6 as well as making it easy to embed into a GitHub microsite or preview a file you're working on without the need to recompile an HTML page (one of the things I wanted to do the most).

It includes everything I did in #7.

Richard Bowman and others added 28 commits July 4, 2017 14:10
It would be nice not to have the intermediate JSON representation.
Unfortunately the object returned by xml2js isn't drop-in compatible
with that returned by the JSON parser.
Question: should node_modules be in the repo, or should we gitignore it??
I got it to work as far as rendering bricks and parts go.  However, if I try to render the steps, it all goes wrong, and I can't debug the React errors...
It now loads from XML correctly, and can display my file.  Next step: adding my improvements to the rendering!
I'd disabled files and components on assembly steps - now fixed.
tried to install a markdown renderer (but it doesn't work from typescript :( )
I tried using an XML tag with a src attribute to load an XML file from disk - but it doesn't seem to work :(

I've moved my docubricks to the project/ directory, and gitignored it for cleanliness...
to save duplicating my (large!) docubricks project, I've gitignored it here...
It was assumed that all the images, etc. were defined relative to "./project/" or "./project/name/".  I have added a property base_url to the docubricks project class, which allows this to be specified (the default is still "./project/" but I've lost the automatic /name/).
I realised a4eb05e introduces a potential flaw - you could potentially override any page using this viewer code just by specifying docubricks_xml_url in the query string.  Now, it only follows that URL if you set the contents of the "docubricks_xml_url" div to a particular value.
I've switched over to DOMParser, but everything's broken...
The browser provides a (native, hopefully fast and bug-free!) parser and manipulation tools for XML DOMs.  I've used these instead of an external library, as I hope it will give better XML manipulation tools.
turns out getElementsByTagName didn't do what I thought (it's recursive rather than just returning immediate children).
unsuccessfully tried using an iframe and using a file input control to load the XML file locally - neither worked (yet).
Steo descriptions can now use safe HTML tags.  "Safe" HTML is defined in the function domNodeChildrenToReactElements
Attributes are now passed correctly to HTML elements in descriptions.  This means hyperlinks work!!
The BOM now contains hyperlinks to the individual parts.  Also tweaked the debug printing code for the BOM to make recursion clearer.
<ul> tags were previously modified to remove their bullets globally.  Now that they are allowed in the descriptions of steps, I've modified the CSS to disable them only in the sidebar (as they look ugly in the navigation list).
CSS now forces page breaks before bricks - convenient for PDFs.  Also, I've added <code> and <pre> to the list of allowed tags.
@mahogny mahogny merged commit c8158d3 into DocuBricks:master Nov 4, 2017
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 this pull request may close these issues.

Some elements are not using their classes
2 participants