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

Add basic Microsoft Narrator tables PoC #17083

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 17 additions & 3 deletions packages/ckeditor5-table/src/converters/downcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,23 @@ export function downcastCell( options: { asWidget?: boolean } = {} ): ElementCre
const isHeading = tableSlot.row < headingRows || tableSlot.column < headingColumns;
const cellElementName = isHeading ? 'th' : 'td';

result = options.asWidget ?
toWidgetEditable( writer.createEditableElement( cellElementName ), writer ) :
writer.createContainerElement( cellElementName );
const cellElement = writer.createContainerElement( cellElementName );

if ( options.asWidget ) {
const divElement = toWidgetEditable(
writer.createEditableElement( 'div', { class: 'ck-table-cell-content' } ),
writer
);

writer.insert(
writer.createPositionAt( divElement, 0 ),
writer.createSlot()
);

writer.insert( writer.createPositionAt( cellElement, 0 ), divElement );
}

result = cellElement;
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ export default class TableColumnResizeEditing extends Plugin {
const viewWriter = conversionApi.writer;

viewWriter.insert(
viewWriter.createPositionAt( viewElement!, 'end' ),
viewWriter.createPositionAt( viewElement!.getChild( 0 )!, 'end' ),
viewWriter.createUIElement( 'div', { class: 'ck-table-column-resizer' } )
);
}, { priority: 'lowest' } );
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-table/src/tableediting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default class TableEditing extends Plugin {
conversion.for( 'upcast' ).add( ensureParagraphInTableCell( 'td' ) );
conversion.for( 'upcast' ).add( ensureParagraphInTableCell( 'th' ) );

conversion.for( 'editingDowncast' ).elementToElement( {
conversion.for( 'editingDowncast' ).elementToStructure( {
model: 'tableCell',
view: downcastCell( { asWidget: true } )
} );
Expand Down
8 changes: 7 additions & 1 deletion packages/ckeditor5-table/theme/table.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
& td,
& th {
min-width: 2em;
padding: .4em;

/* The border is inherited from .ck-editor__nested-editable styles, so theoretically it's not necessary here.
However, the border is a content style, so it should use .ck-content (so it works outside the editor).
Expand Down Expand Up @@ -82,3 +81,10 @@ when content is available outside the editor. See https://github.com/ckeditor/ck
*/
width: 100%;
}

.ck-editor__editable .ck-table-cell-content {
box-sizing: border-box;
min-height: 100%;
padding: .4em;
margin: -1px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@
* So do not use `@mixin ck-focus-ring;` here, or any other border styles.
* See more: https://github.com/ckeditor/ckeditor5/issues/16979
*/
&.ck-editor__nested-editable.ck-editor__nested-editable_focused,
&.ck-editor__nested-editable:focus {
/* A very slight background to highlight the focused cell */
&:has(.ck-editor__nested-editable.ck-editor__nested-editable_focused),
&:has(.ck-editor__nested-editable:focus) {
background: var(--ck-color-selector-focused-cell-background);
outline: 1px solid var(--ck-color-focus-border);
outline-offset: -1px; /* progressive enhancement - no IE support */
box-shadow: none;

& .ck-editor__nested-editable.ck-editor__nested-editable_focused,
& .ck-editor__nested-editable:focus {
/* A very slight background to highlight the focused cell */
background: none;
border: 0;
box-shadow: none;
}

}
}
}