Closed (fixed)
Project:
HAX
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
18 Apr 2018 at 12:14 UTC
Updated:
21 Jun 2018 at 20:59 UTC
Jump to comment: Most recent, Most recent file
First of all I am very happy to submit the first issue on this project. :-)
I have seen the DrupalCon Nashville 2018 Presentation "Webcomponents, Polymer and HAX: decoupling authoring for Drupal and beyond" and for me it seems that HAX is the ultimate tool to move forward with Drupal as a Backend.
Is there any plan to port it on 8.x.
Thanks.
There's a functional HAX for Drupal 8 at https://github.com/mlsamuelson/hax. We're currently looking for testers to provide feedback and review.
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | bower.json_.zip | 1.13 KB | btopro |
| #24 | hax-screenshot-app-error.png | 78.48 KB | mlsamuelson |
Comments
Comment #2
btopro commentedHa, nice!
There is a port currently in the works and much discussion on twitter currently about it and we're very interested in getting help towards the goal of having this in D8 (hell I'll port it to D5 if I could stand it up anywhere just to showcase the concept).
We are very interested in having this happen but I learn through reverse engineering so it's hard for me to pick up D8 without someone doing a bunch of initial work on it to have me then figure out the guts of the structure and improve upon it.
Comment #3
btopro commentedthere is a boilerplate start to a port here -- https://github.com/onelittlebecca/drupal_hax8
Comment #4
mlsamuelson commentedI've spun off an upgrade effort using drupalmoduleupdater to get started. After conversing with @onelittlebecca I did it as a separate repo: https://github.com/mlsamuelson/hax
Currently, the admin settings UI works.
It's in a bit of a state while I sort out the best method/location for attaching header links in D8, and comment out the parts from the .module file that have moved to the DefaultController.php. I'm likely to commit a HaxModeController.php before long, to handle the HAX mode handling on nodes.
Collaborative effort would be welcomed, for anyone else interested in collaboration, etc.
Comment #5
gloriaswebtech commentedHey @mlsamuelson, I am very interested in helping further this project. I have cloned a copy of your repo but am unsure of how I should go about contributing to it. I assume a merge request or fork but would like your input. I am new to contributing but know the basics of git/github and d8 theming + module development.
Comment #6
btopro commentedLet's use https://github.com/mlsamuelson/hax to base PRs off of just so we have a known location to be doing this from. I like PR workflow way more then direct d.o. contribution. Once we get things cleaned up and working off of that repo then we can commit it here. I don't have any experience w/ D8 modules but as project maintainer on HAX / the D7 work I'm always available to answer questions relative to where this should go / how it should operate.
Phase 1 is just make it do what the D7 module does. Phase 2 once we get there will be more of a wholistic "ok, what should the HAX module support" permissions, capabilities, etc and where it should go from there. Some of that back and forth may involve the hax-body series of tags being tweaked to support some CMS specific customizations (for example I could see a need to prevent tags on a per field level where as hax-body currently manages this sanitization internally relative to what tags it registered during boot + html primatives)
Comment #7
mlsamuelson commented@btopro Sounds like a plan.
@Gtucker6 Pull requests work great. I'm happy to have the help!
My current challenge is determining the correct/best means of getting the
markup from
_hax_node_form()in D7, around the body field.So far I've found a number of ways to *not* do it. ;) Including the commented out \Drupal\hax\Controller\DefaultController::_hax_node_form() method. That route failed to return a Response object, so only the field and markup around it returned, with the rest of the page left out. I read somewhere that's by design.
Next I set up the \Drupal\hax\Controller\HaxModeController::hax_node_form() method, tied to the hax.node_form route. And I'm still exploring this option.
As well as the implementation of hook_ENTITY_TYPE_view(), hax_node_view() in the hax.module file, towards the same end. That function has the markup apply to the $build data structure cleanly, but I am yet to see it actually show up in the UI, apart from my dpm()s. Obviously I'm missing something.
Comment #8
mlsamuelson commentedHelpful resources for D8 Entity CRUD, and the render pipeline that have proven helpful, so far:
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...
https://www.drupal.org/docs/8/api/render-api/the-drupal-8-render-pipeline
@btopro, My current goal is just work out how to get HAX rendered in the UI, then, I'll want to pick your brain to make sure we maintain feature parity. Having minimal experience with HAX in D7, I'm definitely coming at this from the point of view of a reverse-engineer. :)
Comment #9
btopro commentedhttps://www.computerminds.co.uk/articles/rendering-drupal-8-fields-right...
Comment #10
mlsamuelson commented@btopro Thanks. That helped, as did https://www.drupal.org/forum/support/module-development-and-code-questio...
See my latest commit:
https://github.com/mlsamuelson/hax/commit/ace5074a433f2df36fabe5c4852c1b...
As in the comments there, need to figure out why this is only working with the code block acting on the $entity object and the other acting on the $build variable. Comment out one or the other, and it doesn't update the field.
Also, the cms-hax markup is being escaped...
Comment #11
mlsamuelson commentedSo that's not working on an input format with Full HTML, but if I switch the input format on the edit page for the node to "Basic HTML" and I add
<cms-hax open-default end-point body-offset-left app-store-connection>to the Basic HTML format's allowed tags, it's working.Full HTML doesn't allow you to edit the tags unless you have checked "Limit allowed HTML tags and correct faulty HTML" - the ramifications of which, using with Full HTML format I haven't explored yet.
Possibly helpful: https://www.drupal.org/node/1829860
And https://medium.com/@djphenaproxima/how-to-bend-drupal-8-plugins-to-your-...
Comment #12
mlsamuelson commentedI should note that one of our the code blocks that adds the tag is now superflous and needs to be pulled out.
Comment #13
btopro commentedI believe correct faulty needs to be off. You'll have to have faith that HAX will ensure it's a legit tag (which it should). Security wise though Limit allowed HTML tags should work though we might want to make our own input filter that dynamically adds only known webcomponent tags / HAX provided autoloaded tags.
Comment #14
mlsamuelson commentedSo, with what’s in the repo right now, that’ll deploys the HAX editor… but for both the hax mode tab AND the node view tab due to the use of the hook_ENTITY_TYPE_view()… and I could call to get the path or route so we only show on the HAX mode page… But there's caching with that hook and I'm hesitant to break the cache in this context.
I also tried again via the controller class HaxModeController, but I’ve not yet identified how to add the cms-hax tag to the body so it’ll render. Current work for that is not in the repo, and I suspect I'm going about it wrong with trying to use that.
Time has caught me for today. But it’s looking like maybe a Drupal 8 field formatter plugin is what's called for to get the component attachments and the cms-hax tag deployed in a targeted way:
https://drupal.stackexchange.com/questions/183393/which-is-the-preferred...
Comment #15
mlsamuelson commentedThe kickback on a custom field formatter for HAX is going to be that it requires configuration in the UI, or if we attempt to deploy it programmatically, I could see us hitting the same dead ends we've already experienced... unless hook_entity_view_alter() could be used.
Really hoping to keep this zero config.
But maybe we could still do that with some programmatic combination of a HAX field formatter, HAX view mode. Directions to explore.
Comment #16
btopro commentedwhy does one need a hax field formatter again? Are you thinking of having any field able to be "haxed" in the context of a normal drupal form which has other settings applied to it? Also not sure why a HAX view mode would be needed if the element definitions are on the page; would possibly need a hax input filter to ensure that the tags coming across are valid as defined by the W3C spec and not Drupal directly (which might throw out thing-stuff tags for example but this is a guess)
Comment #17
mlsamuelson commented@btopro Yeah, I'm looking askance at the field formatter option, too, but the top response on https://drupal.stackexchange.com/questions/183393/which-is-the-preferred... led me to it.
Essentially, the issue is, it's not real clear what the best way to alter a field before it renders from a module is in D8 in our situation. I have a feeling if I'd started from scratch, rather than trying to "make it work" with the DrupalModuleUpdater code, it would be clearer.
Another option could be to do it from a theme template for the field. Something like - https://drupal.stackexchange.com/questions/170032/overriding-field-html-...
@btopro Philosophically - targeting just the body field is the preference? Correct?
Comment #18
mlsamuelson commentedProgress:
HAX mode tab now functional, and caching is correctly applying, based on the route "hax.node_form" due to specifying the "route.name" #cache context and doing the work in hax_preprocess_field(). hax_page_attachments() to add the supporting links to the html_head.
Of note is that the XSS::filterAdmin() function prevents us from adding the wrapper to the body field via #prefix and #suffix, and I've not identified any means to alter the allowed tags in that class. See Xss.php in core/lib/Drupal/Component/Utility (namespace \Drupal\Component\Utility\Xss).
The fallback I have in place is to directly apply the tag to #text. The drawback there is it'll require the user to configure the text format to allow the cms-hax tag and its attributes, like so:
<cms-hax open-default end-point body-offset-left app-store-connection>Editing on the content with HAX now works. Doing a save results in a 405 "method not allowed." And I haven't looked into any of the code related to that yet. So that's the next task on my list.
Comment #19
mlsamuelson commentedReading up on https://www.drupal.org/docs/8/core/modules/rest/javascript-and-drupal-8-... and https://www.drupal.org/docs/8/core/modules/rest/1-getting-started-rest-c... to determine if that's the way to go forward from here since the submission is coming from the front end - possibly using the built in node resource.
Comment #20
mlsamuelson commentedSo, HAX saves node bodies now. :)
See commit: https://github.com/mlsamuelson/hax/commit/815e67698f3e3d2322f384ac1eb910...
The commit message:
I feel like we're over the hump now.
Up next
Comment #21
btopro commentedThis is excellent news! As for the PUT we can variableize the method if it would help. Nice thing about these components is they are really easy to extend as needed. Could you post a screen shot / paste of the JS error in question?
Comment #22
btopro commentedhttps://github.com/LRNWebComponents/cms-hax/blob/master/cms-hax.html#L47
Now if you pass a method="POST" you could do POST for example while the default is still PUT if undefined.
Comment #23
mlsamuelson commented@btopro Cool deal! If we decide to fully integrate with the D8 REST system vs using a Controller endpoint, we'll probably need that. What we're doing now is more in line with the D7 functionality, so I'm going to stick with it for now, unless we hit any walls.
Another task for the TODO list:
- Ensuring we're leveraging proper security practices. Check into https://www.drupal.org/docs/8/api/text-editor-api/overview
On the JS error with the app store... I'm pretty sure that's due to upgrades needed to the code in that call. Will give that a look, and if it's still there after upgrading the code, will share the error.
Comment #24
mlsamuelson commentedAlright. I've sorted out the app store code updates, and have the path
hax-app-store/{token}handling token validation and the response object correctly, as well as the hooks and alters.The error is still popping up in the console. See screenshot.
Looks to be that hax-store.html is not hitting the endpoint successfully. I haven't tracked the issue back to its source yet.
Comment #25
mlsamuelson commentedDiscovered the json_encode() around the app-store-connection wasn't the issue, after comparing with the D7 version's markup. There's more filtering in D8 getting in the way here.
Comment #26
mlsamuelson commentedAlright, whatever quirk of caching caused me to think we needed to enable "Limit Allowed Tags" to get Hax to work, is no longer a thing. I've updated the README.md to remove those steps, and the hax.routing.yml to remove dependencies it turns out we don't need, given the resolution on the PUT (which we can support via the Symfony routing backend). Much cleaner install, on par with the D7 version.
Comment #27
mlsamuelson commentedAw, and having the "Limit allowed tags" unchecked on the text format resolves the issue with the App Store link, which I was seeing in the console (as per the screenshot shared earlier).
Comment #28
btopro commentedthis makes me wonder just how aggressively applied those things are if they are impacting the tag being applied to the page itself. We'll probably want to make some kind of limit allowed tags variation that automatically adds any tag defined on the backend.
Sounds like your making great strides though :) Pull the latest 0.13.0 release of hax-body and update hax-body-behaviors. It has lots of enhancements to keyboard operations, selection of things in things and performance enhancements
Comment #29
mlsamuelson commentedI've done a lot of cleanup (https://github.com/mlsamuelson/hax/commit/23942f1840836862dd7494fe2da00e...), now that things have stabilized. The file save handling hasn't had any attention or testing, really, and I wanted to catch up with you, @btopro, to help me understand when that comes into play, and the philosophy for file handling in HAX.
At this point, short of the files bit, I think we could use some testers - install and try it out. @TheodorosPloumis and @Gtucker6 ? ;)
Clone from master: https://github.com/mlsamuelson/hax
Comment #30
mlsamuelson commentedIn Core, for file create access checks \Drupal\file\FileAccessControlHandler :
So, in light of that, since we only have the one route, and it already has _hax_file_access(), I've added the "Upload files via HAX editor" permission, and we check it there and again in _hax_file_save().
Comment #31
btopro commentednice, thanks for detailing why that would be the case too.
We'll want to do a full on HAX permissions audit after it hits feature parity and people are noticing they want / need the ability to set what people have access to on the back end (which will have implications for the parts of the UI to show to different groups but that's fine).
Comment #32
mlsamuelson commentedWith the commit https://github.com/mlsamuelson/hax/commit/8beb64689ef6b774df7cc59ebe1991..., we're now ready for some testing.
Issues to note:
1. HAX toolbar opens automatically on HAX Mode tab. Issue to be addressed in HAX itself?
2. Clicking "Cancel" button on HAX toolbar results in save occurring. Another one to be addressed in HAX itself?
Comment #33
mlsamuelson commentedUpdating status.
Comment #34
btopro commented1. That's due to a flag in the 2. https://github.com/LRNWebComponents/hax-body/issues/111 in place for the cancel issue, need to tweak hax a bit to support this and then clean it up in the integration tags of cms-hax app-editor-hax and wysiwyg-hax tags but totally doable.
Comment #35
mlsamuelson commentedAlready had some community feedback in the GitHub repo. Have resolved an issue with the README.md having an unnecessary reference to restui, and have merged a code formatting fix that includes renaming the controller and many of its methods away from the D7 names for them, putting them on par with D8 standards for such things.
Comment #36
mmenavas commentedI was able to install HAX in a D8 site (standard installation profile and Bartik theme). Below are the issues I encountered:
Thanks for porting this module to D8! I'm excited to see everything this module can do once it's finalized.
Comment #37
btopro commented@mmenavas thanks for the feedback; dependency tree w/ builds is def annoying and confusing right now. I'm attaching an updated bower.json that will automatically resolve these issues. As we get out of active development and into implementation phase we can generate a static single asset (for the majority of it) which then people could point to and it would be a single download instead of mass dependency tree.
Perhaps the build clean up will resolve the other things you mention but we'll see
Comment #38
mlsamuelson commentedI've committed the updated bower.json: https://github.com/mlsamuelson/hax/commit/8873c0a4e2d11d2d6d4e6b96545e6e... from #37.
Comment #39
mlsamuelson commentedFrom @mmenavas in #36:
This is by design, mimics D7 version, and is touched on in the README.md: "NOTE on Text Formats: HAX is designed to work with nodes with bodies in the default Full HTML format where "Limit allowed HTML tags and correct faulty HTML" is unchecked, or with formats with similarly permissive settings."
Perhaps the workflow, expectations or "signage" could be improved. A candidate for a follow up ticket, I'm thinking.
I experienced the same thing. Same with the PDF viewer. I was thinking it must be something with filtering, but the markup was there. Turns out it was the hax_is_current_route_supported() call in hax_page_attachments(). I've commented that out and slated it for removal. Looks like that was a bit of code that came over with a copy/paste from hax_preprocess_field() and one that wasn't needed in this instance, as we don't want to constrain the web component imports on the view tab - we need it in order to display the web components.
FIXED and committed: https://github.com/mlsamuelson/hax/commit/6dc57144ac9946060ee857f1088a5a...
I'm seeing those too - errors related to JS files in core/assets/vendor/ckeditor. Haven't investigated the cause yet.
Thanks, for the great test findings @mmenavas !
Comment #40
mlsamuelson commented@btopro, thanks for https://github.com/LRNWebComponents/hax-body/issues/111. Re-upping through bower install, the Cancel button no longer triggers a save. But the Save button continues to save. So that's fixed.
Still seeing the HAX toolbar auto-open on the Hax Mode tab, but perhaps that's by design - and now that Cancel doesn't trigger a save, it's not really an issue.
NOTE (maybe something to spin off into a separate issue):
Allowed tags filtering on the frontend:
https://github.com/LRNWebComponents/hax-body/issues/70#issuecomment-3914...
@btopro, Any thoughts on next steps? More testers, any fixes, then a release?
Comment #41
btopro commentedauto opening is by design and is also a boolean value that can be changed (could wire it to a Drupal setting if you wanted to I guess). You can see what triggers that here -- https://github.com/mlsamuelson/hax/blob/master/hax.module#L58-L61
"open-default"
On the tag filtering on the front end, you could make an array of tags that Drupal will allow, serialize it and then in the same code block as above inject something like
... allowed-tags="' . json_encode(array('p', 'div', 'li', 'ul')) . '" ...where that array of values would be driven (somehow) based on a Drupal input filter.Is the D8 version saving to the backend? If it is saving and recalling the app store spec to allow for "finding" assets and generally working I'd say that this sounds like it's worth both publishing to d.o. as well as cutting like a 1.0.0-alpha1 release. Thoughts?
Comment #42
mlsamuelson commentedYeah, we should be fully functional. I'd be happy to see this get an alpha release. Let me know what I can do to help make that happen. :)
Comment #43
btopro commentedthere is now a branch established for 8.x-2.x. Please commit your code to this branch so we an keep all 3 versions on their respective 2.x branch. I've also made you a maintainer on d.o. so you'll now be able to checkout and push to d.o.
Comment #45
mlsamuelson commentedAlright. I've cut a 8.x-2.0-alpha1 release, and it's downloadable from the project page.
Are we good to close this ticket?
Comment #46
btopro commentedmoving to 8.x and closing this. All new issues with the actual release now that we have one should take place via d.o. still but be in new issues that are opened related to the 8.x-2.x branch. Incredible work mlsamuelson!