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

I/8798 disable commands embed html #8899

Merged
merged 9 commits into from
Jan 26, 2021
Merged

Conversation

magda-chrzescian
Copy link
Contributor

@magda-chrzescian magda-chrzescian commented Jan 25, 2021

Suggested merge commit message (convention)

Fix (table): The insertTable command should be disabled if any object is selected. Closes #8798.

Fix (media-embed): The insertMediaEmbed command should be disabled if any non-media object is selected. See #8798.

Other (widget): The checkSelectionOnObject function should be exported by the @ckeditor/ckeditor5-widget/src/utils package. See #8798.

Tests (html-embed): The manual test should show the insert table and insert media buttons and describe their correct state. See #8798.

Copy link
Member

@oleq oleq left a comment

Choose a reason for hiding this comment

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

LGTM!

One small note, make sure you use Markdown in Suggested merge commit message. This saves time when merging the pull request  :) 

You should also write it keeping in mind that some of those entries (fix, other, feature) will land in the main CHANGELONG.md file. So the main fix in this PR (in table?) should have (closes #N) and others (see #N) to let people reading the changelog know where they came from.

@@ -304,6 +304,19 @@ export function findOptimalInsertionPosition( selection, model ) {
return selection.focus;
}

/**
* Checks if the selection is on object.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Checks if the selection is on object.
* Checks if the selection is on an object.


expect( isSelectionOnObject ).to.be.true;
} );
} );
Copy link
Member

Choose a reason for hiding this comment

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

I think we're missing two cases here

  • <paragraph>fo[o</paragraph><image></image><paragraph>ba]r</paragraph>
  • <image>[foo]</image> (this will require allowing $text in image)

// @returns {Boolean}
function isMediaSelected( selection ) {
const element = selection.getSelectedElement();
return element && element.name === 'media' || false;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return element && element.name === 'media' || false;
return !!element && element.name === 'media';

is more natural and does not raise confusion regarding the order of operators.

export function checkSelectionOnObject( selection, schema ) {
const selectedElement = selection.getSelectedElement();

return selectedElement && schema.isObject( selectedElement ) || false;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return selectedElement && schema.isObject( selectedElement ) || false;
return !!selectedElement && schema.isObject( selectedElement );

is simpler and does not make you think about the order of operators.

@pomek
Copy link
Member

pomek commented Jan 26, 2021

What about the horizontal line and page break features? They are also marked as an object in the schema and rendered as a widget in the editing data.

@oleq
Copy link
Member

oleq commented Jan 26, 2021

They're fine :)

@oleq oleq merged commit 4289176 into master Jan 26, 2021
@oleq oleq deleted the i/8798-disable-commands-embed-html branch January 26, 2021 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some toolbar items are active when editing html embed
3 participants