Answer the question
In order to leave comments, you need to log in
How to make WysiHat use the element it's initialized with for editing?
Have a nice day.
I'm trying to implement the WysiHat editor into the project github.com/swilliams/jq-wysihat
When you pass an element to it for initialization, it simply hides it and creates the editor in an empty div.
If I want to edit h1 with all its styles and content, then I don't want to end up with an empty div at all.
Is it possible to somehow slip the necessary element with content to the editor?
JS:
function onDOMReady(){
var editableElements = $('.editable'),
index = editableElements.length;
while(index--){
var element = editableElements[index];
var editor = WysiHat.Editor.attach($(element));
}
}
$(document).ready(onDOMReady);
<article>
<h1 class="editable">Some title</h1>
<div class="editable">
<p>Some content</p>
</div>
</article>
<script src="http://yandex.st/jquery/1.7.2/jquery.min.js"></script>
<script src="wysihat.js"></script>
<script src="wysihat/dom/ierange.js"></script>
<script src="wysihat/dom/range.js"></script>
<script src="wysihat/dom/selection.js"></script>
<script src="wysihat/dom/bookmark.js"></script>
<script src="wysihat/element/sanitize_contents.js"></script>
<script src="wysihat/events/field_change.js"></script>
<script src="wysihat/events/frame_loaded.js"></script>
<script src="wysihat/events/selection_change.js"></script>
<script src="wysihat/toolbar.js"></script>
<script src="wysihat/features.js"></script>
<script src="wysihat/editor.js"></script>
<script src="wysihat/commands.js"></script>
<script src="wysihat/formatting.js"></script>
<script src="editor.js"></script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question