-
Notifications
You must be signed in to change notification settings - Fork 3
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
IDEA: allow editing the placeholder in-place (like GCP docs) #6
Comments
Hi, thanks for the suggestion. I like the idea, since it is far more intuitive than the (sometimes pretty large) tables that are currently used to set placeholders. I think it should be possible to implement, since the dynamic (default) placeholders already are replaced with a bit of HTML. Adding a onclick event to that, that would turn it into a textbox should thus be possible. Live-updating is also supported (without reloading the page), if only dynamic placeholders are in use. I will see if I find some time this weekend to try to implement it (or at least a prototype to see if it would work as expected). |
@six-two in a separate but related idea, it would be great to have the input boxes scale to the width of the current text (which will be critical for the in-place editing). I messed around with it today and it's actually kind of painful to dynamically scale the width of |
Neat, I never knew you could make I hacked together a small prototype using the |
@six-two also, while I have you here, I see that you are often working on the actual string version of the rendered pages (when looking for the input tags to mutate with default values). Rather than trying to build your own XML parser, it's actually possible to hook into the Python For example, I made this hook/plugin which finds |
Thanks for the tip! That might also be useful some of my other extensions (like mkdocs-badges) where I remember implementing some custom markdown parsing to see whether I am in a table or code listing |
The only thing to remember, is that when you use a markdown extension, it will only affect the actual content from But at least for the placeholder plug-in I think that's fine, because I don't know why you would want placeholders outside of the main content. |
Three more ideas:
|
Regarding the three ideas:
|
@thesuperzapper I have implemented the UI features (tooltip, special styling, etc) and support for dropdown/checkbox placeholders. Is there anything (except a revert button) missing related to the inline placeholder editors or are there any obvious bugs? The only thing I noticed is tooltips not being shown on my smartphone, but that is more of a general issue with touch devices not having mouse pointers. The latest version is deployed at https://dev.mkdocs-placeholder-plugin.six-two.dev/demo and pushed to the main branch. If there is nothing broken/missing, I would like to release v0.4.2 with this new feature in a couple days. |
@six-two A few things:
|
@thesuperzapper Thanks for the feedback. Regarding the points you raised:
I do not see this behavior with Firefox on Linux on my test site. To help me reproduce and fix it: What browser/OS and URL did you encounter this on? Can you maybe send a screencapture?
Implemented: for now it is a pink square with the width of the letter
Good point, I will think about it. Although I would probably implement it as a opt-out by default (by mapping
I tried to implement it with an inline dropdown that shown up when the user hovers or clicks on the placeholder, but that was both very buggy. For example when selecting a value in the One of the advantages I see with inline editors is that we do not need to rely on placeholder tables anymore. While they work OK on small to medium sized pages, they become way to big on very large pages, where it is a real pain having to scroll to them, find the correct placeholder and scroll down to your place again. Thus I would like to have all placeholders support inline editors. And if a site owner really dislikes the behavior, they could selectively disable the inline editors for these placeholders ( |
This week I made some changes to the code:
@thesuperzapper Do you see any more glitches, bugs or problems with the code in the current state? Do you have details for reproducing the "the input boxes in the table now glitchy resize (get smaller) when you first edit them" bug? |
@six-two I can't seem to reproduce the glitchy size error, so it might have been fixed with your other updates. Based on your demo my main comments are now about styling: High Priority
Medium Priority
|
Hi, it ha been a while, but I had a lot of private stuff to do. In response to the issues you raised:
|
I noticed that |
@six-two it's looking really great, it will be a seriously cool addition to the world of MKDocs! I have a few more notes (assuming this demo is the latest version):
|
The beauty with inline edit is; there's no need for an automatic input table anymore. You can design your own input table or "overview" of all the values in markdown any way any style you like. |
@thesuperzapper Nice, sooks like we are mostly past the functional bugs. Thanks for your testing. Yes, the site you reference is built with Vercel every time I push a commit, so it should reflect the latest changes. Regarding the new issues:
|
@six-two ok, its looks much better now, but there are a few new bugs:
|
|
Update for 1: I tried to fix it properly (by adding a span around the text the user edits), but it broke too many things. Instead I added a function after every input event, that ensures that the icon is still there and that there is no text behind it. It should prevent the issue you described. I also just checked on my phone and it also highlights/selects the icon too, but my "fix" seems to work there too. Can you confirm that it is fixed? |
@six-two for context, my primary browser is Brave (which is chromium). Regarding your fix for 1, it seems to have a strange effect on Safari, which is that hitting backspace on an empty input field scrolls the page back to the top. Separately, double clicking on the content of an open editor (trying to select the full text) actually selects the entire page text (but this is less serious). Are you sure you can't arrange the spans differently so the content-editable only affects the part before the icon? Currently you have: <span contenteditable="plaintext-only">
text for this input
<span>
<svg></svg>
</span>
</span> Can't you do something like: <div> // with `display: inline-flex` or `display: inline-block`
<span contenteditable="plaintext-only">
text for this input
<span>
<svg></svg>
</span>
</div> |
This is purely a "looks" comment, which may be further down the line for you while trying to fix functionality... I've started using this in an experimental site (smallish doc/project-suggestion collection project... so it's perfect for driving an initial template generation). I'm actually slightly in favour of a de-cluttering option which would only render the edit-ability in either a specifically marked block, or by default on the first templated element. Possibly even not rendering any special color on the other parts of the document... not quite sure. But regardless, the way you can already now design your very own "input table" makes things work well. And the version I was testing now, where the pen icon hides worked very fine. Ideally the text doesn't change color but instead there's a slight background shade difference.. tough to do reliably perhaps. Either way. Love it so far! I was leaning towards something as simple or subtle as this in the flowing text at least: cursor: text;
/* color: var(--inline-editor-color); */
/* border-color: var(--inline-editor-color); */
/* font-style: italic; */
outline: none;
word-wrap: break-word;
background-color: #e6f7ff; I also tried to default to a black with alpha |
@frimik Thanks for your comment. I believe I already tried to do the highlighting via background color, but it had some disadvantages (like bad contrast, etc). It also has to work with light and dark themes, so that makes it even harder. Personally I think the current look is fine as a default, but of course you are always free to customise the styling. Maybe I could add an official theming support in the future (and include multiple themes that the user can choose without having to manually write/include CSS), but that is a topic for another issue.
Personally I would not include it into the plugin because:
|
@thesuperzapper Yeah, Safari has weird behaviours. It selects the whole page when you select the SVG. I already fixed a bug where it highlighted the entire page when clicking a placeholder, by only selecting the text node, not the SVG when you start editing it. I tried to change the layout of inline-editors to the following, before coming up with the work-arounds: <span class="placeholder-value-editable">
<span class="text-editor" contenteditable="true">text for this input</span>
<span class="inline-editor-icon-span">
<svg>...</svg>
</span>
</span> The issue is, that all my code (like value validator, event handlers, etc) expects to just read/set the value of the first text node. Changing it to use the PS: |
Ah, the @frimik @thesuperzapper What are your thoughts on that? The latest deployment (https://dev.mkdocs-placeholder-plugin.six-two.dev/demo/) has the icon hidden when editing a placeholder, if you want to try it out. If it is OK from a UX perspective, it should work around most of the bugs that were recently brought up. |
@six-two the problem with hiding the icon is that it causes the page content to jump around because the content changes width. We should try and keep the edit mode the same width as the non-edit mode. Also, regarding the complexity of Every keypress then updates the corresponding |
Everyone has their style..
I think having that option to highlight in orange is a great compromise, if it's a toggle that's even better. Mainly: No icon, but as long as I can actually control the style myself anything goes and I understand your focus on a default that works for all audiences, especially considering high contrast needs. Hope that makes sense? |
@thesuperzapper It only makes the content jump around when showing the icon by default or if you hover over the text before. If you use the simple style (icons on hover only) and tab into the editor, it should not change. With the simple style on touch devices (phone/tablet) it might even provide a better experience if I fix the flickering in and out of the icon. And personally I would ship the simple style as the default. @frimik I will try to add a third style that has no highlighting or icon and only does minimal changes like the cursor. That should make custom styles easier, since you no longer have to unset all the values I set. Then it should only be a couple lines of CSS to have things like a different background or an outline. |
@thesuperzapper I changed the behavior to minimize resizing. If you are using the @frimik There is now a |
@six-two on your demo the icon now jumps upwards when you open the editor (which it didn't do a few times ago). Also, a few commits ago there was no size change (when opening the edit box), but now I think the padding on the icon is causing it to change. Also, if you plan to give an option which disables the edit icon (when the input is open), please make sure it's an option. I also think that keeping the icon visible should be the defualt. |
@thesuperzapper The size should now stay the same when editing. There is still a small inconsistency with the icon jumping up and down a few pixels. But I think it is good enough to release, given that that is the non-default style.
The Personally I hope that after the 0.5.0 release someone with some UI/UX experience writes some nicer styles for placeholders. Then we could bundle them with future versions of the plugin. The current styles with the border have some disadvantages like the border changing the width of an element, when it is focused. Honestly, the whole styling code could use a rewrite in the future. It would be much nicer, if it was modularized into small CSS files that individual themes can pick and choose from, rather than having one huge string in some python file. But that is a TODO for future me and not relevant for this release. Are there any functional bugs or major UI glitches, or can I prepare the code for release? |
@six-two where can I look at a demo of the other styles? Also, a few commits ago it did not change width or move the icon at all, what changed? |
@thesuperzapper What changed is that I use inline SVGs instead of the :after pseudo-element, since it has some issues and is really hard to debug. Switching between the SVG (normal/hover) and :after (editing) causes leads to some slightly different styling. :after is used when editing, since it works around the ton of functional issues you found with the SVG implementation. To change the style in the demo, click the gear icon in the placeholder table and switch the dropdown from |
Works great. Although I of course use the |
Thank you both for your feedback and your time! Version 0.5.0 is now live. If there are any more noteworthy issues with this feature, please open a new issue (this one forces me to scroll too much 😉). |
The Google Cloud docs have an interesting placeholder implementation.
Users can click on the placeholder instances to turn them into the corresponding input box, so they can be updated in-place.
EXAMPLE PAGE: https://cloud.google.com/kubernetes-engine/docs/how-to/api-server-authentication#applications_in_other_environments
Step 1 - Default
Step 2 - Click to edit
Step 3 - Changes are reflected across page
They also have real-time mutation, but that is not necessary.
The text was updated successfully, but these errors were encountered: