Medium.com WYSIWYG editor clone. Uses contenteditable API to implement a rich text solution.
const removeFormat = {
name: 'removeFormat',
aria: 'remove formatting',
action: 'removeFormat',
contentDefault: '<b>X</b>',
contentFA: '<i class="fa fa-eraser"></i>',
handleClick: function (event) {
event.preventDefault();
event.stopPropagation();
// Undo default
this.execAction('removeFormat');
// Undo selection for all custom extension
const extensions = this.base.extensions;
const extensionsCustomOnly = this.base.options.extensions;
for (const key in extensions) {
const extension = extensions[key];
if (typeof extension.setInactive !== 'function') {
continue;
}
if (typeof extension.classApplier !== 'object') {
continue;
}
extension.classApplier.undoToSelection();
extension.setInactive();
this.base.checkSelection();
console.log(`undo ${extension.name}`);
}
}
};
@sloan-dog @j0k3r @nmielnik FWIW: in the https://github.com/linkeddata/dokieli project, we use medium-editor.. but considering to switch to something else because of lack of dev activity in ME. Don't take this as criticism :) I decided to use ME awhile back because it hit the right boxes for dokieli's needs - also ME dev was quite active at the time. There are however some important issues IMHO - don't we all? - that makes it hard to work with or extend ME. From dokieli's POV, we just want to reuse an existing library as much as possible.. and the core of it need to be quite stable. We're not in the "business" of developing our own editor so counting on what the smart/hardworking folks are doing out there. I still think ME is great but it may be aging.. so if it gets picked up again, that'd be great. I don't know if there are fundamental shortcomings of the ME architecture that would make it more reasonable for a rewrite or whatever - this is something you folks know better. FYI recent discussion re the switch starts here: https://gitter.im/linkeddata/dokieli?at=5cb0caffbd70a40d5f3bd5ef . Note:
We need to factor in: regular WYSIWYG-like editing [..], collaborative-editing, versioning-friendly?, extensible for different forms of annotations (like RDFa embedding, Web Annotation..), active dev community
Hey, I'm trying to get Medium to work with a runat="server"
div.
<div class="editable" id="myDiv" runat="server">Information</div>
Then my back end.
var html = myDiv.InnerHtml
yet html
always results in an empty string. If I remove the editable
class html
returns Information as expected. Does anyone have experience with getting the innerhtml from a medium editor?
Solved
Seems like using a textarea instead of a div works.
<textarea class="editable" id="myTextArea" runat="server">Information</div>
It seems Medium creates a div and hides the textarea and auto updates the hidden textarea when the text within the div is changed.
Then the contents can be grabbed in the backend like myTextArea.Value