Skip to content

Commit

Permalink
HtmlEditor: change type of "lock" button in image uploader form (#25903)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zedwag authored Oct 27, 2023
1 parent 3bec00b commit 0e74de9
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { extend } from '../../../core/utils/extend';
import { getHeight, getWidth } from '../../../core/utils/size';
import devices from '../../../core/devices';
import { isDefined } from '../../../core/utils/type';
import { isFluent } from '../../themes';
const isMobile = devices.current().deviceType === 'phone';

const DIALOG_IMAGE_CAPTION = 'dxHtmlEditor-dialogImageCaption';
Expand Down Expand Up @@ -318,6 +319,8 @@ class AddUrlStrategy extends BaseStrategy {
}

getItemsConfig() {
const stylingMode = isFluent() ? 'text' : 'outlined';

return [
{ dataField: 'src', colSpan: 11, label: { text: localizationMessage.format(DIALOG_IMAGE_FIELD_URL) },
validationRules: [{ type: 'required' }, { type: 'stringLength', min: 1 }],
Expand All @@ -338,7 +341,7 @@ class AddUrlStrategy extends BaseStrategy {
hint: localizationMessage.format(DIALOG_IMAGE_KEEP_ASPECT_RATIO),
focusStateEnabled: false,
keyExpr: 'value',
stylingMode: 'outlined',
stylingMode,
selectionMode: 'multiple',
selectedItemKeys: ['keepRatio'],
onSelectionChanged: (e) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { Selector } from 'testcafe';
import Form from '../../form/form';
import TextBox from '../../textBox';
import Button from '../../button';

const CLASS = {
buttonGroup: 'dx-buttongroup',
button: 'dx-button',
};

export default class AddImageUrlForm extends Form {
public get url(): TextBox {
Expand All @@ -13,4 +20,8 @@ export default class AddImageUrlForm extends Form {
public get height(): TextBox {
return this.findTextBox('height');
}

public get lockButton(): Button {
return new Button(Selector(this.element.find(`.${CLASS.buttonGroup}`).find(`.${CLASS.button}`)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,31 @@ import { isMaterial, testScreenshot } from '../../../../helpers/themeUtils';
fixture.disablePageReloads`HtmlEditor - add image url`
.page(url(__dirname, '../../../containerQuill.html'));

const ADD_IMAGE_POPUP_CONTENT_SELECTOR = '.dx-htmleditor-add-image-popup .dx-overlay-content';

test('Image uploader from url appearance', async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
const htmlEditor = new HtmlEditor('#container');

await t
.click(htmlEditor.toolbar.getItemByName('image'));

await t
.click(htmlEditor.dialog.addImageUrlForm.lockButton.element);

await t
.click(htmlEditor.dialog.addImageUrlForm.url.element);

await testScreenshot(t, takeScreenshot, 'Image uploader from url appearance.png', { element: ADD_IMAGE_POPUP_CONTENT_SELECTOR });

await t.expect(compareResults.isValid())
.ok(compareResults.errorMessages());
}).before(async () => createWidget('dxHtmlEditor', {
height: 600,
width: 800,
toolbar: { items: ['image'] },
}));

test('Image url should be validate before wil be inserted by add button click', async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
const htmlEditor = new HtmlEditor('#container');
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0e74de9

Please sign in to comment.