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

Commit d4995b1

Browse files
feat: trigger an event linkCreated when a link is, well, created by the inline editor
1 parent 7705333 commit d4995b1

File tree

6 files changed

+18
-0
lines changed

6 files changed

+18
-0
lines changed

docs/docs/components/app-components-inline-editor/app-components-inline-editor.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ The event `input` will be automatically triggered when the content will be modif
127127
| Event | Description | Type |
128128
| -------------- | ----------- | -------------------------- |
129129
| `imgDidChange` | Triggered when an image is manipulated. Note: the event won't provide directly the image but rather its container element. | `CustomEvent<HTMLElement>` |
130+
| `linkCreated` | Triggered when a link is created by the user using this component |
130131
| `stickyToolbarActivated` | Triggered when the sticky toolbar would be activated or not. Useful for example if you want to catch the event to hide things in your footer, as the sticky toolbar is display above it. | `CustomEvent<boolean>` |
131132

132133
### Methods

docs/src/app/pages/docs/components/app-components-inline-editor/app-components-inline-editor.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@ export class AppComponentsInlineEditor {
337337
<td><code>CustomEvent&lt;HTMLElement&gt;</code></td>
338338
</tr>
339339
<tr>
340+
<td><code>linkCreated</code></td>
341+
<td>Triggered when a link is created by the user using this component</td>
342+
<td></td>
343+
</tr>
344+
<tr>
340345
<td><code>stickyToolbarActivated</code></td>
341346
<td>Triggered when the sticky toolbar would be activated or not. Useful for example if you want to catch the event to hide things in your footer, as the sticky toolbar is display above it.</td>
342347
<td><code>CustomEvent&lt;boolean&gt;</code></td>

studio/src/app/handlers/editor/events/deck/deck-events.handler.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export class DeckEventsHandler {
6161
this.el.addEventListener('slideDelete', this.onSlideDelete, false);
6262
this.el.addEventListener('codeDidChange', this.onCustomEventChange, false);
6363
this.el.addEventListener('imgDidChange', this.onCustomEventChange, false);
64+
this.el.addEventListener('linkCreated', this.onCustomEventChange, false);
6465

6566
this.updateSlideSubscription = this.updateSlideSubject.pipe(debounceTime(500)).subscribe(async (element: HTMLElement) => {
6667
await this.updateSlide(element);
@@ -83,6 +84,7 @@ export class DeckEventsHandler {
8384
this.el.removeEventListener('slideDelete', this.onSlideDelete, true);
8485
this.el.removeEventListener('codeDidChange', this.onCustomEventChange, true);
8586
this.el.removeEventListener('imgDidChange', this.onCustomEventChange, true);
87+
this.el.removeEventListener('linkCreated', this.onCustomEventChange, true);
8688

8789
if (this.updateSlideSubscription) {
8890
this.updateSlideSubscription.unsubscribe();

webcomponents/inline-editor/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<a name="1.0.0-alpha.13"></a>
2+
# 1.0.0-alpha.13 (Not released yet)
3+
4+
* trigger an event `linkCreated` when a link is created
5+
16
<a name="1.0.0-alpha.12"></a>
27
# 1.0.0-alpha.12 (2019-08-06)
38

webcomponents/inline-editor/src/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ declare namespace LocalJSX {
4646
'imgPropertyWidth'?: string;
4747
'mobile'?: boolean;
4848
'onImgDidChange'?: (event: CustomEvent<HTMLElement>) => void;
49+
'onLinkCreated'?: (event: CustomEvent<HTMLElement>) => void;
4950
'onStickyToolbarActivated'?: (event: CustomEvent<boolean>) => void;
5051
'stickyDesktop'?: boolean;
5152
'stickyMobile'?: boolean;

webcomponents/inline-editor/src/components/inline-editor/deckdeckgo-inline-editor.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ export class DeckdeckgoInlineEditor {
102102

103103
@Event() private imgDidChange: EventEmitter<HTMLElement>;
104104

105+
@Event() private linkCreated: EventEmitter<HTMLElement>;
106+
105107
@Prop()
106108
imgAnchor: string = 'img';
107109

@@ -806,6 +808,8 @@ export class DeckdeckgoInlineEditor {
806808
target.parentElement.replaceChild(a, target);
807809
}
808810

811+
this.linkCreated.emit(container as HTMLElement);
812+
809813
this.toolbarActions = ToolbarActions.SELECTION;
810814

811815
resolve();

0 commit comments

Comments
 (0)