Skip to content

Commit

Permalink
After CR
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasOsti committed Nov 2, 2023
1 parent 8581f21 commit 102de3f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/bundle/Resources/public/js/scripts/admin.focus.mode.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
(function (global, doc) {
let activeFieldEdit = null;
const ENABLE_FOCUS_MODE_EVENT_NAME = 'ibexa-focus-mode:on';
const DISABLE_FOCUS_MODE_EVENT_NAME = 'ibexa-focus-mode:off';
const FOCUS_MODE_ENABLE_EVENT_NAME = 'ibexa-focus-mode:enable';
const FOCUS_MODE_DISABLE_EVENT_NAME = 'ibexa-focus-mode:disable';
const focusModeEnableBtns = doc.querySelectorAll('.ibexa-field-edit__focus-mode-control-btn--enable');
const focusModeDisbaleBtns = doc.querySelectorAll('.ibexa-field-edit__focus-mode-control-btn--disable');
const changeFocusModeState = (active) => {
if (!activeFieldEdit) {
return;
}

const dispatchEventName = active ? ENABLE_FOCUS_MODE_EVENT_NAME : DISABLE_FOCUS_MODE_EVENT_NAME;
const dispatchEventName = active ? FOCUS_MODE_ENABLE_EVENT_NAME : FOCUS_MODE_DISABLE_EVENT_NAME;
const editorSourceElement = activeFieldEdit.querySelector('.ibexa-data-source__richtext');
const editorInstance = editorSourceElement.ckeditorInstance;

Expand All @@ -28,8 +28,8 @@
activeFieldEdit = null;
}
};
const watchDisableFocusModeByKeyboard = (event) => {
if (event.key === 'Escape' || event.keyCode === 27) {
const handleKeyPress = (event) => {
if (event.key === 'Escape') {
changeFocusModeState(false);
}
};
Expand All @@ -49,13 +49,13 @@
});

doc.body.addEventListener(
ENABLE_FOCUS_MODE_EVENT_NAME,
() => doc.body.addEventListener('keydown', watchDisableFocusModeByKeyboard),
FOCUS_MODE_ENABLE_EVENT_NAME,
() => doc.body.addEventListener('keydown', handleKeyPress),
false,
);
doc.body.addEventListener(
DISABLE_FOCUS_MODE_EVENT_NAME,
() => doc.body.removeEventListener('keydown', watchDisableFocusModeByKeyboard),
FOCUS_MODE_DISABLE_EVENT_NAME,
() => doc.body.removeEventListener('keydown', handleKeyPress),
false,
);
})(window, window.document);
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@

.ibexa-field-edit {
&__focus-mode {
margin: auto 0 0 0;
margin: auto 0 0;
align-self: baseline;
}

Expand Down Expand Up @@ -161,7 +161,7 @@
overflow-y: auto;
align-self: stretch;
flex-grow: 1;
padding: calculateRem(8px) calculateRem(32px) calculateRem(32px) calculateRem(32px);
padding: calculateRem(8px) calculateRem(32px) calculateRem(32px);
background: $ibexa-color-white;
border-radius: 0 0 $ibexa-border-radius $ibexa-border-radius;

Expand Down
2 changes: 1 addition & 1 deletion src/bundle/Resources/translations/messages.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@
<target state="new">Exit focus mode.</target>
<note>key: focus_mode.disable.tooltip</note>
</trans-unit>
<trans-unit id="9ccf325057537b909b7b1a20ca8d17faa434124d" resname="focus_mode.disbale_hint">
<trans-unit id="9ccf325057537b909b7b1a20ca8d17faa434124d" resname="focus_mode.disbale_hint__">
<source>To exit focus mode, click the %icon% or press Esc</source>
<target state="new">To exit focus mode, click the %icon% or press Esc</target>
<note>key: focus_mode.disbale_hint</note>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@

{%- block richtext_widget -%}
{% set attr = attr|merge({ 'hidden': true }) %}

<div class="ibexa-data-source ibexa-data-source--richtext">
<textarea {{ block('widget_attributes') }}>{{ value }}</textarea>
<div class="hidden" data-udw-config-name="richtext_embed" data-udw-config="{{ ibexa_udw_config('richtext_embed', udw_context) }}"></div>
Expand Down Expand Up @@ -507,7 +508,7 @@
</svg>
{%- endset -%}
{%- set title -%}
{{ 'focus_mode.disbale_hint'|trans({ '%icon%': title_icon|raw })|desc('To exit focus mode, click the %icon% or press Esc')|raw }}
{{ 'focus_mode.disable_hint'|trans({ '%icon%': title_icon|raw })|desc('To exit focus mode, click the %icon% or press Esc')|raw }}
{%- endset -%}

<div class="ibexa-field-edit__focus-mode">
Expand Down

0 comments on commit 102de3f

Please sign in to comment.