Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 187edb0

Browse files
fix: apply style if all list is selected
1 parent 917e24f commit 187edb0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

webcomponents/inline-editor/src/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
<body style="overflow: hidden">
1212
<p contenteditable>Bet on the Web</p>
1313

14+
<ul contenteditable="true">
15+
<li>lksandsk</li>
16+
<li>sadflkmdsklm</li>
17+
</ul>
18+
1419
<h2 contenteditable>Environment variables with StencilJS</h2>
1520

1621
<div>
@@ -34,7 +39,7 @@ <h3 contenteditable>Credits</h3>
3439

3540
<p contenteditable><img style="width: 100px" src="https://deckdeckgo.com/assets/favicon/android-chrome-512x512.png" /></p>
3641

37-
<deckgo-inline-editor sticky-mobile="true" containers="h1,h2,h3,h4,h5,h6,p" img-editable="true" custom-actions="my-inline-action">
42+
<deckgo-inline-editor sticky-mobile="true" containers="h1,h2,h3,h4,h5,h6,p,ol,ul" img-editable="true" custom-actions="my-inline-action">
3843
<span style="color: red" slot="my-inline-action">My</span>
3944
</deckgo-inline-editor>
4045

webcomponents/inline-editor/src/utils/execcommand-style.utils.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ async function updateSelection(container: HTMLElement, action: ExecCommandStyle,
3232
async function replaceSelection(container: HTMLElement, action: ExecCommandStyle, selection: Selection, containers: string) {
3333
const range: Range = selection.getRangeAt(0);
3434

35+
// User selected a all list?
36+
if (range.commonAncestorContainer && ['ol', 'ul', 'dl'].some((listType) => listType === range.commonAncestorContainer.nodeName.toLowerCase())) {
37+
await updateSelection(range.commonAncestorContainer as HTMLElement, action, containers);
38+
return;
39+
}
40+
3541
const fragment: DocumentFragment = range.extractContents();
3642

3743
const span: HTMLSpanElement = await createSpan(container, action, containers);

0 commit comments

Comments
 (0)