mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-17 18:29:55 +09:00
36 lines
1.5 KiB
HTML
36 lines
1.5 KiB
HTML
<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)});
|
|
textarea.height({intval($editor_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>
|