-
-
Save pingzh/c6a054b08455f22ac68f to your computer and use it in GitHub Desktop.
Fill container TinyMCE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html,body { | |
height: 100%; | |
background: blue; | |
} | |
.fill-div { | |
height: 100%; | |
width: 100% | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="TinyMCE addapts to container" /> | |
<script src="http://code.jquery.com/jquery.min.js"></script> | |
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" /> | |
<script src="http://getbootstrap.com/dist/js/bootstrap.js"></script> | |
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script> | |
</head> | |
<body> | |
<div class="fill-div"> | |
</div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The magic config - http://www.tinymce.com/wiki.php/Configuration | |
var config = {}; | |
config = $.extend(config, { | |
statusbar: false, | |
resize: false, | |
width: "100%", | |
height: '100%', | |
autoresize: true | |
}); | |
function resize() { | |
setTimeout(function () { | |
// Main container | |
var max = $('.mce-tinymce') | |
.css('border', 'none') | |
.parent().outerHeight(); | |
// Menubar | |
max += -$('.mce-menubar.mce-toolbar').outerHeight(); | |
// Toolbar | |
max -= $('.mce-toolbar-grp').outerHeight(); | |
// Random fix lawl - why 1px? no one knows | |
max -= 1; | |
// Set the new height | |
$('.mce-edit-area').height(max); | |
}, 200); | |
} | |
$(window).on('resize', function () { | |
resize(); | |
}); | |
// Setup plugins | |
config.toolbar = ["undo redo | styleselect | bold italic | alignleft aligncenter alignright | bullist numlist outdent indent "]; | |
// Choose selector | |
config.selector = ".fill-div"; | |
// Set content once initialized | |
config.init_instance_callback = function (editor) { | |
resize(); | |
}; | |
tinyMCE.init(config); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment