-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need a way to resize height (and width?) of editor on the fly #160
Comments
When I added the So, this should be easy, but I couldn't figure it out last time. I do it on the initial load with I've added it to the 0.1.2 release and see if I can get it in. |
Sweet, thanks man! In the mean time, I've got a working solution. Incase anyone else wants to do something similar, what I did is this: Markup <div id="epiceditor_wrap">
<div id="epiceditor_box"> ... EpicEditors Container... </div>
<div id="epiceditor_resizable"></div>
<div id="epiceditor_resizable_mask"></div>
</div> JavaScript $('#epiceditor_resizable').resizable({
alsoResize : '#epiceditor_wrap, #epiceditor_box',
handles : 's'
})
// If we have a previously saved height
if ( '' != ee_height ) {
ee_box.height( ee_height + 'px' );
ee_wrap.height( ee_height + 'px' );
}
ee_resize.bind( "resizestart", function(event, ui) {
ee_box.css({ 'opacity' : '0.5' });
ee_resize_mask.show().height( ee_box.height() );
});
ee_resize.bind( "resizestop", function(event, ui) {
// Reload EE so it fits it's container again
eEditor.load();
ee_box.css({ 'opacity' : '1' });
ee_resize_mask.hide().height( '100%' );
// Save editors height
setUserSetting('ee_height', ee_wrap.height() );
}); CSS #epiceditor_wrap {
position: relative;
height: 380px;
}
#epiceditor_box {
position: relative;
z-index: 2;
height: 380px;
}
#epiceditor_resizable {
position: absolute;
z-index: 1;
top: 0;
left: 0;
width: 100%;
height: 100%;
padding-bottom: 20px;
}
#epiceditor_resizable_mask {
position: absolute;
z-index: 3;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: none;
} The reason I have that resize mask div is to cover up EpicEditor while the height is being adjusted. The problem was that if I moused over it while resizing, it would lose focus on the handle. Video demo: http://cl.ly/IEJZ |
That actually looks pretty decent! Thanks for posting that. I'll try to look into making some kind of API call tho too. |
P.S. I added color syntaxing to your comment. Reading all that without it was hard ;) If you didn't know you could just do |
Oh awesome, I didn't know about that! Thanks :D |
@OscarGodson Does this work in EE too? |
@techwraith which thing? |
@OscarGodson The ```js thing :) |
@techwraith Yes/no. It does output the correct HTML: <pre><code class="lang-javascript">alert('test')</code></pre> but we just haven't added the syntax coloring stuff yet. It wouldn't be hard on the developer end tho. Just inject a script tag to the previewer. We want to add this soon tho. |
…iner without having to reload the entire editor
@sebnitu I'm almost done with this ticket finally (funny how newborns slow down pet project progress :P), so if you get a chance, could you try it out? I added a // You're only changing the width and you only want to resize the width of the editor
$('#epiceditor').css({ width: '100px' });
editor.reflow('width');
// You're only changing the height of the editor
$('#epiceditor').css({ height: '100px' });
editor.reflow('height');
// Or, you're changing both
$('#epiceditor').css({ width: '100px', height: '100px' });
editor.reflow(); To test try out the Only things left that I know of are:
|
Oh, and @sebnitu here's a demo: http://jsbin.com/efabek/2/ |
So, it looks like I've hit a crossroads. This If i remove the lines where I reset the width and height on exiting fullscreen than the editor can't automatically be fluid width because when you exit fullscreen the editor needs to know what size to be again. I can manually set it to the width it was before entering fullscreen (a px value) or let it resize itself (the Furthermore, there's no way for me to tell the actual, original value of the editor wrapper was: http://stackoverflow.com/questions/12880615/how-to-tell-if-an-element-has-a-fluid-width#12880776 Now, here's the choices:
var editor = new EpicEditor({ container: 'editor-wrapper' }).load();
$(window).on('resize', function () {
$('#editor-wrapper').css({ width: $(window).width() + 'px' });
editor.reflow();
}); @sebnitu What are you thoughts? Or, do you have any better solutions or tricks or, better yet, magic? 🎱 |
Looks like it's possible to get the original CSS value... however... it's extremely unperformant: var stylesheets = document.styleSheets
, rules;
for (var s=0; stylesheets.length; s++) {
rules = stylesheets[s].rules || stylesheets[s].cssRules;
for (var i=0; rules.length; i++) {
var rule = rules[i];
if (rule.selectorText.toLowerCase() == '.foo') {
alert(rule.style.getPropertyValue("width"));
}
}
} Yes... we're literally parsing ALL CSS rules for ALL stylesheets...Also, this isn't 100% accurate depending on how you've nested your |
I'm going to go ahead and write tests for this and put it into develop since it's been about a month. It's not as bad as I initially thought because unless you need to use |
fluid width containers will no longer be fluid after using reflow() or reflow('width') because on reflow we change the style="width" so the width becomes hardcoded.
OK @sebnitu this is in develop. Whenever you get time test it out! Tests pass in latest Chrome, Firefox, IE9 and 10. |
Here's how I'm currently doing this:
editor_markdown
is the editors container.I have to call jQuery UI's resizable method on the wrapper after it's been loaded or else it will override the HTML it puts in it with the iframe. I then have to bind the resize trigger so I can load EpicEditor again so it resizes itself to fit in the newly resized container. But after that it overrides the resizable HTML elements so I can't resize it further.
It would be nice if I had a
eEditor.resetHeight()
to use, then I could just use it as a callback on resizable resize event.The only other workaround I can think of is injecting a second element along side the editors container and layer them with equal heights. Then I can use
alsoResize
them together so when I resize the second element, the editors container also adjusts and then I'd reload the editor like I do above.Thoughts? Am I coming at this the wrong way?
The text was updated successfully, but these errors were encountered: