Markdown editor with live formatting - javascript

I want to create an online markdown editor that has limited wysiwyg formatting. If you're familiar with iA Writer, I'm trying to create an editor similar to their desktop version. For the most part it's just a simple text editor, but it does a few snazzy things that I'm trying to duplicate.
Automatically underline/bolds thing in *italics*, **bold**, ***bold italics***
Indents ">" blockquotes
Outdents "#" headers and "-" lists so that the text is left aligned, much like on the old three hole punched line paper you could align the text to the red line and put list numbers to the left of it.
I have a few thoughts about how to go about implementing this but I've run into some concerns with each of them.
Editable iFrame
How do I outdent text or apply a css class to it
The formatting happens automatically, so how would I change the selection of the text, reformat it and then go back to the original selection location
I hear that you can load another page into your editable iFrame to do more advanced features, but I'm not too familiar with that - any good resources?
Pure javavascript
How do I create a blinking cursor in an area because I don't think I'll be able to do this in a input or textarea...
Possibly make every line a div that converts into an input box when I click on it (similar to how the tags box works on the tags box when you ask a question (though doesn't work for inline formatting)
Any suggestions to how I might go about doing something like this?

A good start would be to look at Code Mirror (http://codemirror.net/) whom already provides Markdown Editor and a Strong API.
You should be able to add features and live rendering on top of it.

Related

OnSelectionChanged Need More Of An OnStyleChange - JavaScript

I am building a simple WYSIWYG editor, many out there are way to complex to integrate, or does not give the user good feedback.
I can do what I want with the OnSelectionChanged event, but that seems to be too wide of a net, the event fires more often than I want/need. What I would like is an event that fires if say the font changed, or bold changed at the current cursor location.
for example, if I have a line of text "this has a BOLD in the lin^e" and the cursor is at the '^', then click or move the cursor towards the word Bold, I do not need the event to fire until it hits the word that is bolded, or other change (text color, size, style...).
Currently, in the event code, it calls the queryCommandState, and looks to see what parts of the toolbar buttons become highlighted, in this example the "B" gets highlighted, when it hits Bold, just like a normal text editor, like Word.
My concern with the round trip time, looking for a couple of things is not bad, but when I look at all the formatting, (bold, underline, size, color, style...) it starts to add up. I thought about putting an escape hatch in, but it still needs to go through and look at what is the current values and then compare it to the last state, so I do not gain anything.
Is there a better event option than the one i am using, such as some kind of stylechanged event, or an event that fire when it sees a tag change.
Thanks,
Dave
I think that you should revisit your premise that integrating a wysiwyg editor is way too complex and that building one is a reasonable alternative.
I've included one js file from a cdn and added this single line of javascript to transform a textarea into a rich text editor, with nice visual feedback regarding formatting options.
CKEDITOR.replace('editor1');
https://codepen.io/anon/pen/GyWGvY

Combining text and an image into one "entity"

I need some assistance while working with a rich text editor (specifically the Dojo Editor dijit), but this question should apply to all RTE's.
I am seeking a way (via HTML/JS/etc, whatever works in a text editor..) to combine some text and an image, in such a way that they can be manipulated as 1 entity. So I should be able to, for instance, select the entity as a whole, and cut/paste it elsewhere in the textbox, or delete it with a single key press, etc.
I am not sure what features text editors do and don't support, but is there a feature that is equivalent to a container/wrapper/textbox, which combines the text and image into 1 single entity?
Thanks
First save image, and then add text on the image using photo editing software or word art or microsoft powerpoint. (You can try whatever.) Then save the image again with the text. Then you can use the image and text whole as a single entity. But the issue is you can't change the text dynamically on your webpage. It will become static.

wysiwyg html editor build in html/javascript for position absolute elements

I'm currently on the stage of research for my new project. I'm looking for a wysiwyg html editor that builds the html elements with position absolute. The reason why I want this is because I want to give users more freedom when they design their pages. Something similar with designing a html page in photoshop.
I'm not looking for anything fancy. The users can only add rectangles(width, height, x,y , color) , text, image and probably some form elements(textarea, button, combo-box etc.)
So.. is there anything already done, that I could use , or I need to build it myself which could take some time and is not a priority for my project.
I know that are a lot of wysiwyg html editors but I couldn't find one that suits my needs: freedom in design.
I believe Most of the editors have this option to switch from static to absolute positioning.
There should be property to set for this purpose.

JS text editor control with flexible dynamic visual styling capabilities

I'm looking for a JS text editor control for any sane framework, that would allow me to color and otherwise style text in run-time as user types it in a custom markdownesque format.
Note that the actual format is quite different from Markdown, so I can't simply reuse some existing Markdown editor. Also, the purpose of this stuff is to help user with semi-structured data input, not fancy text formatting by itself.
In addition to styling text, I would like to be able to dynamically insert UI elements (say, buttons) in the text, again, depending on what user typed in.
I must also be able to send changes to the server-side in background, in some more-or-less effective way. I think that I would need to write some custom callbacks there anyway, but it would be cool if a control would provide a comfortable framework for that (or at least if it would not stand in my way).
Support for the usual features like undo/redo and copy/paste is, of course, a must.
A silly synthetic example to clarify what rules I want to be able to code:
The text:
-- Foo
Bar {green}
*Baz*
-- Alpha {red}
Styles:
From line with Foo to line before Alpha: background color is green.
Line with Alpha: red background
Word *Baz* (along with asterisks) is in bold.
Next to words Foo and Alpha: buttons with a trash can image, if pressed delete whole section of text from current -- to the next one.
When user presses Return on line with --, cursor position on the next line is auto-indented.
If user types -- at the beginning of (indented) line, new section is started and line is unindented. (Actual indentation characters /spaces/ must appear in the text.)
Note that I want these visual styles to be applied in the editor as user types. If, in the example, user changes {green} to {blue}, background color should be changed accordingly.
Check out the Yahoo Rich Text Editor. It's open source.

Javascript/jQuery legend widget

Is there a JS/jQuery widget that would allow me to display a simple legend that contains for example a small colored rectanlge and a text label next to it?
In this specific case the legend would show meanings behind different color codes in an inline jQuery UI datepicker widget, which would be customized to enable multiple selections by a user and showing different colors for specific days.
In fact, the thing that I need would look exactly like the list of SO sites at the footer of this page (but ideally listed vertically next to the picker). So if there is no ready-made solution I guess I'll try and look at this page source.
You have to hand it to the StackOverflow crew. Their method for creating the legends is pretty clever. Basically, they use the character ■ (ASCII 254) in place of any image or div. They insert it in a span, which is styled with a font size and color property. Next to it is a styled anchor tag. Rinse and repeat.
What is particularly clever about it is that it all fits inline in a div and lines up on the baseline! Let me say that again: it lines up on the baseline! So there is no disparity in image offsets, etc. A tip of the hat to the UI engineer who made it that simple. Thanks for calling my attention to that, or I probably never would have looked and learned.
EDIT: ASCII 254 is incorrect. The actual value yielded by "■".charCodeAt(0) is 9632 and is probably some flavor of Unicode. Same look and shape, but different value.

Categories