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

How to get pure HTML? #523

Closed
PaulMaly opened this issue Nov 28, 2016 · 13 comments
Closed

How to get pure HTML? #523

PaulMaly opened this issue Nov 28, 2016 · 13 comments

Comments

@PaulMaly
Copy link

Hello guys! How can I get pure HTML after editing? Thanks!

@SgtOddball
Copy link
Contributor

SgtOddball commented Nov 28, 2016

By writing your backend to output the blocks as pure HTML - This isn't here to render, build or otherwise output your HTML for you, it's just here to offer a nice way to abstract away the process of creating the content in the first place then letting your sever side code handle the blocks in an appropriate manner (I've plumed this into bootstrap others into angularjs - the choice is yours to make and YMMV)

@PaulMaly PaulMaly reopened this Nov 28, 2016
@raffij
Copy link
Contributor

raffij commented Nov 29, 2016

@PaulMaly as @SgtOddball says. What programming language are you using to output the data?

@ilyatulvio
Copy link
Contributor

ilyatulvio commented Nov 29, 2016

As an example, here is a list of backend implementations for Sir Trevor: https://github.com/madebymany/sir-trevor-js#implementations

While most of these are concerned with integrating with a CMS (i.e. rendering the editor and handling the saving of data), the Sir Trevor Rails gem handles rendering the structured data into HTML.

We've recently also worked on rendering Sir Trevor data in React Native. I'm hoping we can release this somehow in the future.

@PaulMaly
Copy link
Author

Thanks guys for your answers! Really sad that Sir Trevor can't handle this regular feature. Actually, I don't even know any other WYSIWYG editor which doesn't allow you to get HTML source code, created via it. But if it's design intent - no problem, I can handle it by myself. Thanks!

@SgtOddball
Copy link
Contributor

Sir Trevor isn't a WYSIWYG editor - it's a content editor (common misconception). So it doesn't fit everybody's needs but for modern responsive or multi device websites should you really be trusting your users with doing the layout themselves? Thats the point of Sir trev

@ilyatulvio
Copy link
Contributor

Well, the main reason for this is that most WYSIWYG editors are HTML editors. And we don't want to be storing HTML blobs — the whole point of a block editor is to produce structured data so you can make reasoned choices about it when rendering it, for example turning it into HTML.

@PaulMaly
Copy link
Author

@SgtOddball I edit something and I see what I'm editing instantly in place. For me it's calling WYSIWYG editor. In this case Sir Trevor can be mapped to this term as well. If what you write and you see at the same time doesn't correspond, then what differs from at once to write using syntax for a structured data? You can just write JSON manually, because you don't even know "what you get".

@ilyaporopudas yes, I understand this point and this part is cool, really. But you already have HTML output than you're editing. So, why an editor can't output it as optional feature? Which reason to send it to the server to get HTML which I already see and use? I'm talking not about storing (JSON is good), but about representation in place.

@SgtOddball
Copy link
Contributor

Using that logic then, notepad is a WYSIWYG editor... which it most emphatically isn't. As for just writing structured data - the end user doesn't want to do that and that what this is for. It's an abstraction to turn blobs of content (referred to as Blocks in Sir Trevor) into a structure of your choosing with out having the limitations of the WYSIWYG editor imposed on you. As for the HTML being used - it's all inline elements wrapped in a block element - even then thats not fixed and can be coded to behave differently.

It also means that in a year or two or ten that the data can still be read and outputted to a new site if the design totally changes (which usually ruins a WYSIWYG layout or seriously hampers such progressive moves).

@PaulMaly
Copy link
Author

@SgtOddball Using that logic, Sir Trevor is "What You See Is Not What You Get" editor, right? )))))

As for just writing structured data - the end user doesn't want to do that and that what this is for.

Agree, but I believe that user want to write something and instantly see final output. So, WYSIWYG editors is the way for this.

It's an abstraction to turn blobs of content (referred to as Blocks in Sir Trevor) into a structure of your choosing with out having the limitations of the WYSIWYG editor imposed on you.

No doubt, that it's a great feature that I can get structured JSON data to store it on my server, but I don't understand why in this case I can't get HTML output "what i see"?

It also means that in a year or two or ten that the data can still be read and outputted to a new site if the design totally changes (which usually ruins a WYSIWYG layout or seriously hampers such progressive moves).

First of all, WYSIWYG is a principle. So if something doesn't work well, it's just a bad implementation of this principle. Sir Trevor already doesn't have many problems of the others WYSIWYG editors, but
imposes new restrictions and it's sad. (((

@SgtOddball
Copy link
Contributor

Now that you've established that Sir Trev doesn't work as WYSIWYG editor, please tell me where it ever claimed to be one?

@raffij
Copy link
Contributor

raffij commented Nov 29, 2016

@PaulMaly Sir Trevor doesn't and never will include html output of the internal representation of the data.

What I suggest is you take the output of the editor and render html without your own javascript functions. If you want to provide a repo and make this reusable to others I will happily add it to the docs somewhere such as https://github.com/madebymany/sir-trevor-js#implementations

@raffij raffij closed this as completed Nov 29, 2016
@PaulMaly
Copy link
Author

PaulMaly commented Dec 2, 2016

Then how to reset JSON data into SirTrevor instance? I need to edit already stored content, so I've JSON like {data: [...]}, how to init SirTrevor instance with this data?

@raffij
Copy link
Contributor

raffij commented Dec 2, 2016

Sir Trevor is currently linked to a form and textarea element so the way to deal with this for now is: #393 (comment)

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

No branches or pull requests

4 participants