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

6.x to main #832

Merged
merged 25 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a94d96e
UHF-9113: Removed external link icon from editor-selectable-icons.
khalima Nov 1, 2023
4fcaacf
UHF-9113: Added support for tables without figure.table wrappers.
khalima Nov 1, 2023
96dbff1
UHF-9113: Added dist and package-lock.json.
khalima Nov 1, 2023
92076fd
UHF-9113: Merge branch '6.x' of https://github.com/City-of-Helsinki/d…
khalima Nov 2, 2023
a66c59b
UHF-9113: Added fixes for the CKEditor anchor links when navigating t…
khalima Nov 2, 2023
6a94ae1
UHF-9113: CKEditor5 creates a <table> markup with <figcaption> after …
khalima Nov 2, 2023
0fb9ec1
UHF-9113: Added user-edited-content class to EU Cookie compliance block.
khalima Nov 2, 2023
3bd032a
UHF-9113: Added dist.
khalima Nov 2, 2023
7882f80
UHF-9113: Merge branch '6.x' of https://github.com/City-of-Helsinki/d…
khalima Nov 2, 2023
8e3a17c
UHF-9113: Fixed table styles in CKE5 after the table refactor.
khalima Nov 2, 2023
3a73d05
UHF-9113: Added dist.
khalima Nov 2, 2023
a06dee0
Merge pull request #819 from City-of-Helsinki/UHF-9113-drupal10-bug-f…
khalima Nov 2, 2023
74a52f6
UHF-9113: Added helper lines to table elements when editing them in C…
khalima Nov 3, 2023
7b9f87a
UHF-9113: Use branch 4.x of platform config in CI.
khalima Nov 6, 2023
c8a366d
UHF-9113: Revert last commit.
khalima Nov 6, 2023
208ce49
Merge pull request #820 from City-of-Helsinki/UHF-9113-drupal10-bug-f…
khalima Nov 6, 2023
05d2280
Merge branch 'main' into 6.x
khalima Nov 13, 2023
25a0df8
Merge branch 'main' of https://github.com/City-of-Helsinki/drupal-hdb…
khalima Nov 16, 2023
990e416
Conflict when platform config 3.* is being installed.
khalima Nov 16, 2023
944b1b3
Merge branch '6.x' of https://github.com/City-of-Helsinki/drupal-hdbt…
khalima Nov 16, 2023
30ca30d
Fixed conflict rule from composer.json.
khalima Nov 16, 2023
14cc5bb
Merge branch 'main' of https://github.com/City-of-Helsinki/drupal-hdb…
khalima Nov 16, 2023
cac6924
Merge branch 'main' of https://github.com/City-of-Helsinki/drupal-hdb…
khalima Nov 16, 2023
5c92f8a
Merge branch 'main' of https://github.com/City-of-Helsinki/drupal-hdb…
khalima Nov 21, 2023
c6e697c
Merge branch 'main' into 6.x
khalima Nov 22, 2023
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"drupal/twig_tweak": "^2.0 || ^3.0"
},
"conflict": {
"drupal/helfi_platform_config": "<3.3.8"
"drupal/helfi_platform_config": "<4.0"
}
}
8 changes: 6 additions & 2 deletions dist/css/ckeditor.min.css

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions dist/css/styles.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/js/handle-figcaption-source-order.min.js

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

2 changes: 1 addition & 1 deletion hdbt.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ libraries-extend:
core/drupal.ajax:
- hdbt/throbber

ckeditor_stylesheets:
ckeditor5-stylesheets:
- dist/css/hdbt-icons.css
- dist/css/ckeditor-icons.css
- dist/css/ckeditor.min.css
8 changes: 8 additions & 0 deletions hdbt.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,11 @@ search-helper:
version: 1.x
js:
dist/js/search-helper.min.js: {}

table-figcaption:
version: 1.0.0
js:
dist/js/handle-figcaption-source-order.min.js: {}
dependencies:
- core/drupal
- core/once
5 changes: 5 additions & 0 deletions hdbt.theme
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ function hdbt_preprocess_page(&$variables): void {

// Set theme path variable.
$variables['theme_path'] = _hdbt_get_theme_path();

// Add the figcaption source order handler JS to current page.
// CKEditor creates a <table> markup with <figcaption> after the <tbody>.
// Fix the source order with JS.
$variables['#attached']['library'][] = 'hdbt/table-figcaption';
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/icons/editor-selectable-icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"instagram",
"key",
"link",
"link-external",
"linkedin",
"locate",
"location",
Expand Down
17 changes: 17 additions & 0 deletions src/js/handle-figcaption-source-order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// CKEditor creates a <table> markup with <figcaption> after the <tbody>.
// Fix the source order with JS.
document.querySelectorAll('.user-edited-content figure').forEach(figure => {
// Adding tabindex="0"
figure.setAttribute('tabindex', '0');

// Finding the figcaption element
const figcaption = figure.querySelector('figcaption');

if (figcaption) {
// Removing figcaption from its current position
figcaption.remove();

// Inserting figcaption as the first child of the figure element
figure.insertBefore(figcaption, figure.firstChild);
}
});
3 changes: 2 additions & 1 deletion src/scss/05_objects/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ p > a.hds-button.hds-button--supplementary:first-child {
// ---------------------------------------------------------------------------------------------------------------------
// Button v2

[data-hds-component='button']:not([class*='hds-button']) {
[data-hds-component='button']:not(a,[class*='hds-button']),
a[href][data-hds-component='button']:not([class*='hds-button']) {
@include font('button');

--border-width: 2px;
Expand Down
192 changes: 186 additions & 6 deletions src/scss/ckeditor.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// stylelint-disable at-rule-empty-line-before
// stylelint-disable no-invalid-position-at-import-rule
// This file includes styling for WYSIWYG editor.

@import 'hds';
Expand All @@ -9,11 +10,169 @@
@import '01_variables/_index';
@import '02_mixins/_index';

// /* Content is created after this point */
@import '03_generic/_index';
@import '04_elements/_index';
@import '05_objects/_index';
@import '06_components/paragraphs/text';
// The hds-button styles depend on hds_base variables.
// TODO: UHF-8794 We should fix the 05_objects/_button to use our own variables and not hds variables (https://helsinkisolutionoffice.atlassian.net/browse/UHF-8794).
@import '03_generic/_hds_base';

.ck-content {
@import '03_generic/_index';

// Text paragraph styles as written in 03_generic/_base.scss and '06_components/paragraphs/text'.
@include font('body');
color: $color-black-90;
font-family: $base-font-family;

// Giving the max-width value here makes sure all the content inside is limited to this max-width.
> * {
max-width: $content-width-max;
}

@import '04_elements/_index';

// Import only the styles that are needed for the ckeditor content creation and not the whole __index.scss
@import '05_objects/_quote';
@import '05_objects/_button';
@include hds-button-colors-on-light-bg;
}

// Additional styling for links.
// The CKEditor link element dom doesn't have all the elements that the rendered version has so we are adding the
// icons here for the links so that the links look similar as in the end result.
.ck-content a {
text-decoration: underline;

// E-mail link styles
&[href^='mailto:']::after {
@include pseudo-icon('mailto', calc(var(--line-height) * 1em), currentColor, inline-block);
overflow: hidden;
}

// Tel link styles. For some reason tel-links have only # in their href on the editor so I added both here in case
// this changes at some point.
&[href^='tel:']::after,
&[href='#']::after {
@include pseudo-icon('tel', calc(var(--line-height) * 1em), currentColor, inline-block);
overflow: hidden;
}

// Button styles rely on data-attributes which are not available in CKE5.
// TODO: UHF-8794 We should fix the 05_objects/_button to drop the support for data-attributes like data-selected-icon (https://helsinkisolutionoffice.atlassian.net/browse/UHF-8794).
&.hds-button:not([data-selected-icon], [data-is-external='true'])::before {
content: none !important;
}

// Switch HDS button label cursor to default to indicate user for an editable element.
&[data-variant] {
cursor: text;
}

// Fix the cursor bug when clicking outside of button link.
&.ck-editor__editable ~ a:not(.ck-editor__editable) {
margin-inline-end: 3px;
margin-inline-start: 3px;
}
}

// CKEditor5 overrides for lists.
.ck-editor .ck-content ul {
list-style-type: disc;

ul {
list-style-type: circle;
}

ul ul {
list-style-type: square;
}
}

.ck-editor .ck-content ol {
list-style-type: decimal;
}

// 04_elements/_table.scss
.ck-editor .ck-content {
@import '04_elements/_table';

// CKEditor and Gin styling overrides. These are quite nasty but so are the styles automatically set by
// the Gin-theme and CKEditor-module.

// CKEditor sets the table to aligned middle, which does not reflect to our theme.
figure.table {
margin: 0;
}

// CKEditor sets a background color and padding for the figcaption and aligns the text to center.
// These lines change the layout similar to what we have on the layout.
figure > figcaption {
@include font('h4');
background-color: transparent;
margin-top: $spacing-triple;
padding: 0;
text-align: left;
}

// CKEditor sets border styles for the tables. Changing that to the design we have.
figure > table {
@include font('body');
background: $color-white;
border: 2px solid $color-black-50;
border-collapse: collapse;
border-spacing: 0;
margin: $spacing 0 0 0;
padding: 0;
width: auto;

// Gin sets this after element for .field-multiple-table thead element but because of the selectors
// inaccuracy it also is visible on the editor. Hiding it with this.
thead::after {
display: none;
}

tr:not(tbody:last-child *:last-child) {
border-bottom: 1px solid $color-black-50;
}

// Gin sets all th-elements to small font size for some reason with very inaccurate selector so we need
// to change the font-size here. Also CKEditor sets background color for the th-element which is not the
// right for our design so changing it here.
th {
background: $color-black-10;
font-size: remify(18px);
font-weight: $font-weight-bold;

strong {
font-weight: $font-weight-bold;
}
}

// CKEditor adds paddings and borders for td- and th-elements so changing them to correct here.
// The padding is set to important because of paragraphs (.paragraphs-tabs-wrapper .field-multiple-table .draggable td)
td,
th {
border: 0;
color: $color-black;
min-width: 0;
padding: $spacing-three-quarters $spacing-and-half !important;
text-align: left;
}

// Add dashed borders to td elements to visualize the table.
// Otherwise it would be hard to understand that the box an editor is dealing with is actually a table.
.ck-editor__editable {
border: 1px dashed #e6e6e6;
}

// Zebra stripes for every other row.
&:has(tr:nth-child(n+5)) tr:nth-child(even) td {
background: $color-black-5;
}
}
}

// hds-button styles for CKEditor. These are copied from the old CKEditor stylesheet so not sure if they are still
// usable/needed when the new version is created.
// TODO: UHF-8489 Check that if these styles are still valid/needed and adjust accordingly.

[data-selected-icon]::before,
[data-is-external]::after,
Expand All @@ -31,6 +190,12 @@
width: $size;
}

// CKEditor5 duplicates current anchor link when navigating with arrow keys.
// This hides those anchor links, as they do not have href attribute set.
a:not([href]) {
display: none;
}

a.hds-button.hds-button--supplementary::before {
order: unset;
}
Expand All @@ -43,7 +208,7 @@ p > a.hds-button.hds-button--supplementary[data-selected-icon]:first-child {
margin-left: 0;
}

a.hds-button.hds-button--supplementary:not([data-selected-icon]):not([data-is-external='true']):before {
a.hds-button.hds-button--supplementary:not([data-selected-icon], [data-is-external='true'])::before {
content: none;
}

Expand Down Expand Up @@ -84,3 +249,18 @@ a.hds-button.hds-button--supplementary:not([data-selected-icon]):not([data-is-ex
[data-is-external].hds-button--secondary .hds-button__label:only-child {
margin-right: 0;
}


// CKEditor5 overrides.
.ck-editor .ck.ck-toolbar.ck-toolbar_grouping>.ck-toolbar__items {
flex-wrap: wrap;
}

.ck-editor .ck.ck-toolbar>.ck-toolbar__items>:not(.ck-toolbar__line-break) {
margin-right: var(--ck-spacing-tiny);
}

// Gin overrides.
.quote::before {
border-radius: 0;
}
3 changes: 1 addition & 2 deletions templates/block/block--eucookiecomplianceblock.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'component--cookie-compliance',
'component--simulated',
],
component_content_class: 'cookie-compliance-block',
component_content_class: 'cookie-compliance-block user-edited-content',
}
%}
{% block component_content %}
Expand All @@ -32,4 +32,3 @@
{% endembed %}
</div>
{% endif %}