Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

T/56: Block content in table cells. #97

Merged
merged 48 commits into from
Sep 6, 2018
Merged

T/56: Block content in table cells. #97

merged 48 commits into from
Sep 6, 2018

Conversation

jodator
Copy link
Contributor

@jodator jodator commented Aug 1, 2018

Suggested merge commit message (convention)

Feature: Support block content inside table. Closes ckeditor/ckeditor5#3199.

BREAKING CHANGE: Removed table/commands/utils~getParentTable() method. Use table/commands/utils~findAncestor() instead.


Additional information

# Conflicts:
#	tests/converters/downcast.js
# Conflicts:
#	src/tableediting.js
writer.insertElement( 'tableCell', Position.createAt( table.getChild( rowIndex ), 'end' ) );
const tableCell = writer.createElement( 'tableCell' );
writer.insert( tableCell, Position.createAt( table.getChild( rowIndex ), 'end' ) );
writer.insertElement( 'paragraph', tableCell );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Check all nodes inside table cell on insert/remove operations (also other blocks).
const tableCell = entry.position && entry.position.parent;

if ( tableCell && tableCell.is( 'tableCell' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tableCell.is( 'tableCell' ) 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could name it possibleTableCell ;P

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or parent. But tableCell is fine too.


const tableCell = conversionApi.writer.createElement( 'tableCell' );
conversionApi.writer.insert( tableCell, ModelPosition.createAt( row, 'end' ) );
conversionApi.writer.insertElement( 'paragraph', ModelPosition.createAt( tableCell, 'end' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// Continue after inserted element.
data.modelCursor = data.modelRange.end;
}, { priority: 'normal' } );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normal is a default value, so I would not define it. It's a detail but it's a few bytes of code more.

@oskarwrobel
Copy link
Contributor

The code looks good to me. I found a few places where you can reduce the number of created operations (it should matter for insertRow and insertColumn commands where many operations are created at once).

@jodator
Copy link
Contributor Author

jodator commented Aug 3, 2018

Align Left does not work in the table cell. Align feature assumes that default alignment is left and but for table call is center.

Yeah - I've already pinged oleq about this.

@Mgsy
Copy link
Member

Mgsy commented Aug 6, 2018

Steps to reproduce

  1. Go to the table block content sample.
  2. Put the caret in the last cell of the first column.
  3. Press Tab to select the image.
  4. Press Delete.

Current result

The editor crashes.

Notes

The editor crashes after deleting every type of a block element. It won't crash if you'll use cut instead of delete.

Error

domconverter.js:280 Uncaught TypeError: Cannot read property 'parent' of null
    at DomConverter.viewRangeToDom (domconverter.js:280)
    at View.scrollToTheSelection (view.js:269)
    at Document.listenTo (delete.js:42)
    at Document.fire (emittermixin.js:196)
    at Document.DeleteObserver.document.on (deleteobserver.js:54)
    at Document.fire (emittermixin.js:196)
    at KeyObserver.fire (domeventobserver.js:96)
    at KeyObserver.onDomEvent (keyobserver.js:28)
    at ProxyEmitter.listenTo (domeventobserver.js:79)
    at ProxyEmitter.fire (emittermixin.js:196)

Browser: All browsers

@Mgsy
Copy link
Member

Mgsy commented Aug 6, 2018

Steps to reproduce

  1. Go to the table block content sample.
  2. Select whole block element in some cell.
  3. Press Ctrl + X.

Current result

The table toolbar has disappeared.

Browser: Edge, Chrome, Safari

In Firefox, the toolbar disappears for a second and shows up again.

@Mgsy
Copy link
Member

Mgsy commented Aug 6, 2018

Steps to reproduce

  1. Go to the table block content sample.
  2. Put the caret in the last cell of the first column.
  3. Press Tab to select the image.
  4. Copy it.
  5. Paste it to same cell with a content.
  6. Put the selection outside of this cell.
  7. Navigate to this cell with Tab.

Current result

Whole table's content is selected.

Browser: All browsers

@Mgsy
Copy link
Member

Mgsy commented Aug 6, 2018

Steps to reproduce

  1. Go to the table block content sample.
  2. Put the caret in the last cell of the first column.
  3. Press Tab to select the image.
  4. Repeat the previous step.

Current result

The selection moves to the beginning of the editor.


(edit) Reported here: https://github.com/ckeditor/ckeditor5-widget/issues/50)

@jodator
Copy link
Contributor Author

jodator commented Aug 7, 2018

After some testing and talks - I'd remove Image support in tables for this MVP as widget-ception causes some problems. Added a follow-up: #99.

@jodator
Copy link
Contributor Author

jodator commented Aug 8, 2018

Fixed:

The editor crashes after deleting every type of a block element. It won't crash if you'll use cut instead of delete.

In Firefox, the toolbar disappears for a second and shows up again.

@jodator
Copy link
Contributor Author

jodator commented Aug 8, 2018

@oskarwrobel & @Mgsy I've updated the PR with your comments i mind :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support block content inside tables
4 participants