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

Moving fieldset in Bard deletes text #1714

Closed
vladdu opened this Issue Jan 13, 2018 · 10 comments

Comments

Projects
None yet
3 participants
@vladdu

vladdu commented Jan 13, 2018

Steps to reproduce

  1. Create a page with a bard field with a fieldset containing text and image (just like the one used in the docs).
  2. Edit the page with one of each, add some values to the fields.
  3. In the text field, mark everything as bold, then make a part in the middle as normal text again
  4. Move the image by dragging it over the text: first, the text filed is split where the normal text is, so you can drop the image in the middle; but when doing it, the normal text is deleted. In the yaml, it is replaced with  

I don't have a strong opinion on if the text should be possible to split like that (I tend to think 'no'), but its contents should definitely not be deleted.

If I make the text field a H2 and then back to a regular text, then the problem disappears because the content is now wrapped in <p></p>. So I suppose the issue is in the bard editor, if the text is not inside a html tag, the DOM gets messed up.

I suppose the content of the text should get wrapped in a paragraph from the start, if it is a top-level text fieldset?

Server Details

Operating System: Ubuntu 17.10
Web Server: Apache 2.4
PHP Version: 7
Statamic Version: 2.8
Updated from an older Statamic or fresh install: updated

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Jan 15, 2018

Can you record a video of this?

@vladdu

This comment has been minimized.

vladdu commented Jan 15, 2018

https://www.youtube.com/watch?v=9xEw_GlQm_A

A related issue I noticed: If one presses </>, the saved value of the text is wrapped in <p> and the <b> tags have even style="font-name: whatever", although the latter I can't reproduce.

@vladdu

This comment has been minimized.

vladdu commented Jan 15, 2018

Could it be that I initialized the values by hand, and the top-level text did not have a <p> around it? I see that when clicking in the Bard filed to create new paragraphs, the values are wrapped from the beginning.

Is the <p> wrapper required, or is it an artifact?

@vladdu

This comment has been minimized.

vladdu commented Jan 15, 2018

I see now that the docs say that the text fields are saved as HTML, so I guess my above comment is correct. So I guess that when the CP form is initialized, it should check if there are p tags around the text and add them.

In a related vein, would it be possible to save the text as Markdown, with an option?

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Jan 15, 2018

What was the original HTML?

You can already save as markdown by adding markdown: true

@vladdu

This comment has been minimized.

vladdu commented Jan 15, 2018

Originally there was no HTML, just a text string.

Sorry, I expressed myself wrong: I meant, use markdown and keep the toolbar and rendered formatting. So a save_as_markdown option for the regular mode. The full markdown mode allows for more advanced formatting that would be difficult to do inline.

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Jan 15, 2018

I mean add markdown: true to the Bard config.

story:
  type: bard
  markdown: true
  sets: ...
@vladdu

This comment has been minimized.

vladdu commented Jan 15, 2018

Yes, I did that and the text paragraphs became pure text. The toolbar disappears as the docs say and the markdown is shown raw, not rendered. Which is kind of the purpose of Bard. On the other hand, the markdown option is experimental.

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Jan 15, 2018

We decided that if you're choosing Markdown, you're choosing it for the writing experience. You aren't gaining much by just saving markdown. It's experimental until we can bring back a toolbar and maybe a couple of other things.

@vladdu

This comment has been minimized.

vladdu commented Jan 15, 2018

Ok, fair enough. But if the initial value of a paragraph is not wrapped in p tags, it should be done automatically, then the original issue gets irrelevant, as the text will never be naked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment