سؤال

I am adding a text editor to a web app. I want the user to be able to create the text as they want: bold, underlined, colored, etc. If I store this in a JSON will it maintain the format or will it just be plain text when I retrieve it once again?

I researched online and didn't come across anything that could help answer my question.

I am using NicEdit on my website

هل كانت مفيدة؟

المحلول

Your question is too vague. What editor program are you using? As an example: if you use tinymce, you can retrieve and store the formatting by calling:

tinyMCE.get( theTextAreaInput.id ).getContent();

This will return a string similar to:

<p><b>This is bolded,</b> but this is not</p> 

EDIT: nicEdit works exactly the same way:

[nicInstance].getContent()

http://wiki.nicedit.com/w/page/521/Javascript%20API

And FYI: nicEdit recommends you switch to tinyMCE.

Nicedit is no longer under active development, you might want to try CKEditor or TinyMCE instead.

نصائح أخرى

It all depends on how your editor stores the data behind the scenes. If you're storing some sort of markup (or markdown as the case may be in recent editors), then you should be ok. Otherwise, it's going to be stored as plaintext.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top