Skip links with iframes

This commit is contained in:
yflory 2025-03-12 12:40:32 +01:00
parent b735d8ffab
commit 3494516b6c
5 changed files with 24 additions and 8 deletions

View File

@ -610,6 +610,7 @@ define([
Framework.create({
toolbarContainer: '#cme_toolbox',
contentContainer: '#cp-app-code-editor',
skipLink: '.CodeMirror',
thumbnail: {
getContainer: getThumbnailContainer,
filter: function (el, before) {

View File

@ -2666,7 +2666,8 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
},
sfCommon: common,
$container: $bar,
$contentContainer: $('#cp-app-oo-container')
$contentContainer: $('#cp-app-oo-container'),
skipLink: 'iframe[name="frameEditor"]|#editor_sdk'
};
toolbar = APP.toolbar = Toolbar.create(configTb);
toolbar.showColors();

View File

@ -865,22 +865,35 @@ MessengerUI, Messages, Pages, PadTypes) {
Bar.createSkipLink = function (toolbar, config) {
const targetId = config.skipLink || '#cp-skip-link';
const $targetElement = $(targetId);
const $skipLink = $('<a>', {
'class': 'cp-toolbar-skip-link',
'href': targetId,
'tabindex': 0,
'text': 'Skip to Main Content'
'text': 'Skip to Main Content' // XXX
});
toolbar.$top.append($skipLink);
$skipLink.on('click', function (event) {
event.preventDefault();
const $firstFocusable = $targetElement.find('a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])').first();
if ($firstFocusable.length) {
$firstFocusable.trigger('focus');
}
let split = targetId.split('|'); // split for iframes
let $container = $('body');
split.some(selector => {
let $targetElement = $container.find(selector);
if ($targetElement.is('iframe')) {
$container = $targetElement.contents();
return;
}
const $firstFocusable = $targetElement.find('a, button, input, select, textarea, [tabindex]:not([tabindex="-1"]), [contenteditable="true"]').first();
if ($firstFocusable.length) {
$firstFocusable.trigger('focus');
}
return true;
});
/*
*/
});
return $skipLink;
};

View File

@ -250,6 +250,7 @@ define([
Framework.create({
toolbarContainer: '#cme_toolbox',
contentContainer: '#cp-app-diagram-editor',
skipLink: '#cp-app-diagram-content|body .geSearchSidebar',
// validateContent: validateXml,
}, function (framework) {
onFrameworkReady(framework);

View File

@ -1335,7 +1335,7 @@ define([
Framework.create({
toolbarContainer: '#cp-app-pad-toolbar',
contentContainer: '#cp-app-pad-editor',
skipLink: '#cke_1_contents',
skipLink: '#cke_1_contents .cke_wysiwyg_frame|html',
patchTransformer: ChainPad.NaiveJSONTransformer,
/*thumbnail: {
getContainer: function () { return $('iframe').contents().find('html')[0]; },