Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import HtmlEditor from '@ts/ui/html_editor/html_editor';

const CLASSES = {
content: 'dx-htmleditor-content',
toolbarWrapper: 'dx-htmleditor-toolbar-wrapper',
Expand All @@ -10,6 +12,15 @@ export class HtmlEditorModel {
return this.root.querySelector(`.${CLASSES.content}`) as HTMLElement;
}

public getInstance(): HtmlEditor {
return HtmlEditor.getInstance(this.root);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
public getQuillInstance(): any {
return this.getInstance().getQuillInstance();
}

public getToolbarWrapper(): HTMLElement {
return this.root.querySelector(`.${CLASSES.toolbarWrapper}`) as HTMLElement;
}
Expand All @@ -32,4 +43,11 @@ export class HtmlEditorModel {

return event;
}

// Since Jest doesn't have native events, Quill can't process
// click on itself to focus and do all its internal work.
// So we need to set selection manually to simulate focus.
public setQuillFocus(): void {
this.getQuillInstance().setSelection(0, 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,40 @@ describe('HtmlEditor focus escape (Ctrl+Shift+Up/Down)', () => {
expect(event.defaultPrevented).toBe(false);
});
});

describe('HtmlEditor Tab key handling (inlineTabInsertion)', () => {
afterEach(() => {
editors.forEach((instance) => instance.dispose());
editors.length = 0;
document.body.innerHTML = '';
});

it('should not paste the /t symbol in editor on Tab keypress by default', () => {
const model = createEditor();
const quill = model.getQuillInstance();
model.setQuillFocus();

expect(quill.getText()).not.toContain('\t');

const event = model.pressKeyInContent('Tab');

expect(event.defaultPrevented).toBe(false);
Comment thread
pharret31 marked this conversation as resolved.
expect(quill.getText()).not.toContain('\t');
});

it('should insert a tab character on Tab keypress when inlineTabInsertion is enabled', () => {
const model = createEditor({
customizeModules: (modules) => {
modules.keyboard.inlineTabInsertion = true;
},
});
const quill = model.getQuillInstance();
model.setQuillFocus();

expect(quill.getText()).not.toContain('\t');
const event = model.pressKeyInContent('Tab');

expect(event.defaultPrevented).toBe(true);
expect(quill.getText()).toContain('\t');
Comment thread
Raushen marked this conversation as resolved.
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,10 @@ class HtmlEditor extends Editor<Properties> {
};
}

_getKeyboardModuleConfig(): { onKeydown: (e: DxEvent) => void } {
_getKeyboardModuleConfig(): { onKeydown: (e: DxEvent) => void, inlineTabInsertion: boolean } {
return {
onKeydown: (e) => this._saveValueChangeEvent(dxEvent(e)),
inlineTabInsertion: false,
};
}

Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

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

23 changes: 2 additions & 21 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ preferWorkspacePackages: true
saveWorkspaceProtocol: false
packageManagerStrict: false
engineStrict: true
minimumReleaseAge: 0

overrides:
"basic-ftp@<5.3.1": ">=5.3.1"
Expand Down Expand Up @@ -60,7 +61,7 @@ catalog:
devexpress-diagram: 2.2.29
devexpress-gantt: 4.1.69
devextreme-exceljs-fork: 4.4.11
devextreme-quill: 1.7.10
devextreme-quill: 1.8.0
"@eslint/js": 9.39.4
eslint: 9.39.4
eslint-config-airbnb-typescript: 18.0.0
Expand Down Expand Up @@ -132,23 +133,3 @@ patchedDependencies:
testcafe-hammerhead@31.7.8: patches/testcafe-hammerhead@31.7.8.patch
systemjs-builder@0.16.15: patches/systemjs-builder@0.16.15.patch
babel-core@6.26.3: patches/babel-core@6.26.3.patch

minimumReleaseAgeExclude:
- "eslint-config-devextreme"
- devextreme-quill@1.7.10
- '@nx/devkit@23.0.1'
- '@nx/jest@23.0.1'
- '@nx/js@23.0.1'
- '@nx/nx-darwin-arm64@23.0.1'
- '@nx/nx-darwin-x64@23.0.1'
- '@nx/nx-freebsd-x64@23.0.1'
- '@nx/nx-linux-arm-gnueabihf@23.0.1'
- '@nx/nx-linux-arm64-gnu@23.0.1'
- '@nx/nx-linux-arm64-musl@23.0.1'
- '@nx/nx-linux-x64-gnu@23.0.1'
- '@nx/nx-linux-x64-musl@23.0.1'
- '@nx/nx-win32-arm64-msvc@23.0.1'
- '@nx/nx-win32-x64-msvc@23.0.1'
- '@nx/workspace@23.0.1'
- nx@23.0.1
- devextreme-internal-tools@22.0.0
Loading