Skip to content

Commit

Permalink
fix editor in new page context
Browse files Browse the repository at this point in the history
  • Loading branch information
tiger committed Apr 23, 2024
1 parent e243733 commit dc8a7d5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
{% set codemirrorOptions = {'spellcheck': 'true', 'mode': 'gfm', 'ignore': ['code', 'preview']}|merge(field.codemirror|default({})) %}
{% endif %}

{% set value = (value is null ? field.default : value) %}
{% set value = (value is null ? (field.default is null ? "" : field.default) : value) %}

{% block label %}
{% if field.label %}
{% set hint = field.help ? 'data-hint="' ~ field.help|tu|raw ~ '"': '' %}
Expand All @@ -12,8 +13,8 @@

{% block field %}
{% if field.name == 'content' %}

<div class="form-data grav-editor studio-markdown-editor">
<div class="form-data grav-editor studio-markdown-editor">
<div id="editorContainer" class="form-field {{ field.classes|default('') }}">
<div id="wmd-panel" class="wmd-panel grav-editor-content is-active">
<div class="layout-wrapper-l1">
Expand Down Expand Up @@ -85,7 +86,7 @@
name="{{ (scope ~ field.name)|fieldName }}"
id="wmd-input-store"
{% if field.classes is defined %}class="{{ field.classes }} hide" {% endif %}
{% if not field.classes is defined %}class="{{ field.classes }} hide" {% endif %}
{% if not field.classes is defined %}class="hide" {% endif %}
{% if field.style is defined %}style="{{ field.style|e }}" {% endif %}
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
{% if field.placeholder %}placeholder="{{ field.placeholder|tu }}"{% endif %}
Expand Down
3 changes: 2 additions & 1 deletion assets/res/eventMgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ define([
eventListenerListMap[eventName] = getExtensionListenerList(eventName);
return function() {
logger.log(eventName, arguments);

var eventArguments = arguments;
_.each(eventListenerListMap[eventName], function(listener) {
// Use try/catch in case userCustom listener contains error
try {
listener.apply(null, eventArguments);
}
catch(e) {
console.error(_.isObject(e) ? e.stack : e);
console.error(_.isObject(e) ? e.stack : e);
}
});
};
Expand Down
3 changes: 1 addition & 2 deletions assets/res/extensions/findReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ define([
show();
e.preventDefault();
});
};

};
return findReplace;
});
11 changes: 2 additions & 9 deletions assets/res/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,11 @@ define([
}

function resizeAll() {
/*
windowSize = {
width: window.innerWidth,
height: window.innerHeight
};
*/
var wmdPanelWidth = $('#wmd-panel').innerWidth();
var editorHeight = window.innerHeight - $('.studio-media-field').innerHeight() - 60;
var editorHeight = window.innerHeight - ($('.studio-media-field').length ? $('.studio-media-field').innerHeight() : 0) - 60;

if (!$('.studio-markdown-editor').hasClass('studio-editor-fullscreen')) {
editorHeight = ($('.content-wrapper').innerHeight() / 2) - $('.studio-media-field').innerHeight() - 60;
editorHeight = ($('.content-wrapper').innerHeight() / 2) - ($('.studio-media-field').length ? $('.studio-media-field').innerHeight() : 0) - 60;
if (editorHeight < 480) {
editorHeight = 480;
}
Expand All @@ -290,7 +284,6 @@ define([
width: wmdPanelWidth,
height: editorHeight
};

while (true) {
// Layout wrapper level 1
wrapperL1.y = navbar.isOpen ? 0 : -navbarHeight;
Expand Down

0 comments on commit dc8a7d5

Please sign in to comment.