mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-22 12:49:55 +09:00
Add 'textarea' editor skin for simple replacement
This commit is contained in:
parent
e91c2114ab
commit
9f652e422f
4 changed files with 76 additions and 0 deletions
35
modules/editor/skins/textarea/editor.html
Normal file
35
modules/editor/skins/textarea/editor.html
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<load target="css/textarea.css" />
|
||||
|
||||
<div id="textarea_wrapper_{$editor_sequence}" class="rx_editor_wrapper">
|
||||
<textarea id="textarea_instance_{$editor_sequence}" class="rx_editor_textarea {$colorset}" data-editor-sequence="{$editor_sequence}" data-editor-primary-key-name="{$editor_primary_key_name}" data-editor-content-key-name="{$editor_content_key_name}"></textarea>
|
||||
<script>
|
||||
$(function(){
|
||||
"use strict";
|
||||
|
||||
// Set editor styles
|
||||
var textarea = $("#textarea_instance_{$editor_sequence}");
|
||||
textarea.css("font-family", {json_encode($content_font ?: null)});
|
||||
textarea.css("font-size", {json_encode($content_font_size)});
|
||||
textarea.css("line-height", {json_encode($content_line_height)});
|
||||
if ({json_encode($content_word_break)} === 'none') {
|
||||
textarea.css("white-space", "nowrap");
|
||||
} else {
|
||||
textarea.css("word-break", {json_encode($content_word_break ?: 'normal')});
|
||||
textarea.css("word-wrap", "break-word");
|
||||
}
|
||||
|
||||
// Load existing content
|
||||
var content_key = textarea.data("editor-content-key-name");
|
||||
var content_input = textarea.parents("form").find("input[name='" + content_key + "']");
|
||||
if (content_input.size()) {
|
||||
textarea.val(String(content_input.val()).stripTags().unescape());
|
||||
}
|
||||
|
||||
// Save edited content
|
||||
textarea.on("change", function() {
|
||||
content_input.val("<p>" + String($(this).val()).escape().replace(/\r?\n/, "</p>\n<p>") + "</p>");
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue