Skip to content
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

CKEditor: Fix for tables and default styles #2815

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 80 additions & 1 deletion ui/src/helpers/form-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@ const formHelpers = function() {
$container.css('transform-origin', '0 0');
$container.css('word-wrap', 'inherit');
$container.css('line-height', 'normal');
$container.css('padding', '0');
$container
.css('outline-width', (CKEDITOR_OVERLAY_WIDTH / scale));

Expand All @@ -751,7 +752,9 @@ const formHelpers = function() {
scale: scale,
});

$container.find('p').css('margin', '0 0 16px');
$container.find('p')
.css('margin', '0 0 16px')
.css('margin-top', 0);
$container.show();
} else {
$('#cke_' + field + ' iframe').contents().find('head').append(
Expand Down Expand Up @@ -1123,6 +1126,82 @@ const formHelpers = function() {
$sourceElement = $sourceElement.siblings('textarea');
}

// Add CKEditor default CSS to the content to match the editor
// Convert into temporary DOM element
const $tempObj = $('<div>' + data + '</div>');

// Inject necessary CSS
const setCSSDefaultRules = function(els, rules) {
$(els).each(function(_idx, el) {
const $el = $(el);

for (const rule in rules) {
if (Object.hasOwn(rules, rule)) {
const value = rules[rule];
const oldStyle = $el.attr('style');

$el.attr('style', `${rule}: ${value}; ${oldStyle}`);
}
}
});
};

// Tables
$tempObj.find('.table').each((_idx, table) => {
const $table = $(table);

setCSSDefaultRules(
$table,
{
margin: '0.9em auto',
display: 'table',
},
);

setCSSDefaultRules(
$table.find('.ck-table-resized'),
{
'table-layout': 'fixed',
},
);

setCSSDefaultRules(
$table.find('table'),
{
overflow: 'hidden',
'border-collapse': 'collapse',
'border-spacing': '0',
width: '100%',
height: '100%',
border: '1px double hsl(0, 0%, 70%)',
},
);

setCSSDefaultRules(
$table.find('td, th'),
{
'text-align': 'left',
'overflow-wrap': 'break-word',
position: 'relative',
'min-width': '2em',
padding: '.4em',
border: '1px solid hsl(0, 0%, 75%)',
},
);

setCSSDefaultRules(
$table.find('th'),
{
'font-weight': 'bold',
'background-color': 'hsla(0, 0%, 0%, 5%)',
},
);
});

// Save object back to data string
// and inhect necessary CSS
data = $tempObj.html();

$sourceElement.val(data);

// If we're not saving, trigger change for saving
Expand Down
2 changes: 1 addition & 1 deletion ui/src/style/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
z-index: calc($properties-panel-rich-text-container-z-index + 1) !important;
}

.ck-editor-body-detached .ck-body-wrapper .ck-balloon-panel.ck-toolbar-container {
.ck-editor-body-detached .ck-body-wrapper .ck-balloon-panel.ck-toolbar-container.ck-balloon-panel_toolbar_east {
right: 150px !important;
left: auto !important;
top: 66px ! important;
Expand Down
4 changes: 4 additions & 0 deletions ui/src/vendor/ckeditor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Changelog
=========

All changes in the package are documented in https://github.com/ckeditor/ckeditor5/blob/master/CHANGELOG.md.
4 changes: 4 additions & 0 deletions ui/src/vendor/ckeditor/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Contributing
========================================

See the [official contributors' guide to CKEditor&nbsp;5](https://ckeditor.com/docs/ckeditor5/latest/framework/contributing/contributing.html) to learn more.
4 changes: 2 additions & 2 deletions ui/src/vendor/ckeditor/build/ckeditor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/ckeditor.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/af.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/ar.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/ast.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/az.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/bg.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/bn.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/bs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/ca.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/cs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/da.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/de-ch.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/de.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/el.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/en-au.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/en-gb.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/eo.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/es-co.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/es.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/et.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/eu.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/fa.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/fi.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/fr.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/gl.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/gu.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/he.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/hi.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/hr.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/hu.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/hy.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/id.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/it.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/ja.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/jv.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/vendor/ckeditor/build/translations/kk.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading