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

Do not prevent shift tab #2907

Merged
merged 2 commits into from
Dec 11, 2024
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
Expand Up @@ -207,30 +207,33 @@ export class AutoFormatPlugin implements EditorPlugin {
}
break;
case 'Tab':
formatTextSegmentBeforeSelectionMarker(
editor,
(model, _previousSegment, paragraph, _markerFormat, context) => {
const { autoBullet, autoNumbering } = this.options;
let shouldList = false;
if (autoBullet || autoNumbering) {
shouldList = keyboardListTrigger(
model,
paragraph,
context,
autoBullet,
autoNumbering
);
context.canUndoByBackspace = shouldList;
event.rawEvent.preventDefault();
if (!rawEvent.shiftKey) {
formatTextSegmentBeforeSelectionMarker(
editor,
(model, _previousSegment, paragraph, _markerFormat, context) => {
const { autoBullet, autoNumbering } = this.options;
let shouldList = false;
if (autoBullet || autoNumbering) {
shouldList = keyboardListTrigger(
model,
paragraph,
context,
autoBullet,
autoNumbering
);
context.canUndoByBackspace = shouldList;
}
if (shouldList) {
event.rawEvent.preventDefault();
}
return shouldList;
},
{
changeSource: ChangeSource.AutoFormat,
apiName: 'autoToggleList',
}

return shouldList;
},
{
changeSource: ChangeSource.AutoFormat,
apiName: 'autoToggleList',
}
);
);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,6 @@ describe('Content Model Auto Format Plugin Test', () => {
format: {},
};

event.rawEvent.preventDefault = jasmine.createSpy('preventDefault');

formatTextSegmentBeforeSelectionMarkerSpy.and.callFake((editor, callback, options) => {
callback(
inputModel,
Expand Down Expand Up @@ -445,6 +443,7 @@ describe('Content Model Auto Format Plugin Test', () => {
key: 'Tab',
defaultPrevented: false,
handledByEditFeature: false,
preventDefault: jasmine.createSpy('preventDefault'),
} as any,
};
runTest(
Expand Down Expand Up @@ -506,6 +505,7 @@ describe('Content Model Auto Format Plugin Test', () => {
key: 'Tab',
defaultPrevented: false,
handledByEditFeature: false,
preventDefault: jasmine.createSpy('preventDefault'),
} as any,
};
runTest(
Expand Down Expand Up @@ -567,6 +567,7 @@ describe('Content Model Auto Format Plugin Test', () => {
key: 'Tab',
defaultPrevented: false,
handledByEditFeature: false,
preventDefault: jasmine.createSpy('preventDefault'),
} as any,
};
runTest(
Expand All @@ -592,7 +593,7 @@ describe('Content Model Auto Format Plugin Test', () => {
},
{ autoBullet: true, autoNumbering: false },
true,
true
false
);
});

Expand All @@ -603,6 +604,7 @@ describe('Content Model Auto Format Plugin Test', () => {
key: 'Tab',
defaultPrevented: false,
handledByEditFeature: false,
preventDefault: jasmine.createSpy('preventDefault'),
} as any,
};
runTest(
Expand Down Expand Up @@ -639,6 +641,7 @@ describe('Content Model Auto Format Plugin Test', () => {
key: 'Ctrl',
defaultPrevented: false,
handledByEditFeature: false,
preventDefault: jasmine.createSpy('preventDefault'),
} as any,
};
runTest(
Expand Down Expand Up @@ -675,6 +678,7 @@ describe('Content Model Auto Format Plugin Test', () => {
key: 'Tab',
defaultPrevented: true,
handledByEditFeature: false,
preventDefault: jasmine.createSpy('preventDefault'),
} as any,
};
runTest(
Expand Down Expand Up @@ -710,6 +714,45 @@ describe('Content Model Auto Format Plugin Test', () => {
rawEvent: {
key: 'Tab',
defaultPrevented: false,
preventDefault: jasmine.createSpy('preventDefault'),
} as any,
handledByEditFeature: true,
};
runTest(
event,
true,
{
blockGroupType: 'Document',
format: {},
blocks: [
{
blockType: 'Paragraph',
format: {},
segments: [
{
segmentType: 'Text',
text: '*',
format: {},
},
marker,
],
},
],
},
{ autoBullet: true, autoNumbering: true },
false,
false
);
});

it('[TAB] should not trigger keyboardListTrigger - shift key', () => {
const event: KeyDownEvent = {
eventType: 'keyDown',
rawEvent: {
key: 'Tab',
defaultPrevented: false,
shiftKey: true,
preventDefault: jasmine.createSpy('preventDefault'),
} as any,
handledByEditFeature: true,
};
Expand Down
Loading