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

Commit 2b6de51

Browse files
merge: studio support for ordered and unordered lists
2 parents 970faca + 552d724 commit 2b6de51

File tree

31 files changed

+411
-132
lines changed

31 files changed

+411
-132
lines changed

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

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ The "WYSIWYG inline editor" component is an extra component which will be use in
1717
## Showcase
1818

1919
<div>
20-
<h1 style={{color: '#3880ff'}} contenteditable>DeckDeckGo (editable title)</h1>
20+
<h1 style={{color: '#3880ff'}} contenteditable slot="title">DeckDeckGo (editable title)</h1>
2121

22-
<h2 style={{color: '#3880ff'}} contenteditable>The Progressive Web App alternative for simple presentations 🚀 (editable subtitle)</h2>
22+
<h2 style={{color: '#3880ff'}} contenteditable slot="title">The Progressive Web App alternative for simple presentations 🚀 (editable subtitle)</h2>
2323

24-
<p style={{color: '#3880ff'}} contenteditable>Edit anywhere, display everywhere (editable paragraph)</p>
24+
<p style={{color: '#3880ff'}} contenteditable slot="content">Edit anywhere, display everywhere (editable paragraph)</p>
2525
</div>
2626

2727
<deckgo-inline-editor sticky-desktop="true" sticky-mobile="true"></deckgo-inline-editor>
@@ -65,6 +65,7 @@ The `<deckgo-inline-editor/>` expose the following properties:
6565
| `stickyDesktop` | `sticky-desktop` | Use a sticky footer toolbar on desktop | `boolean` | `false` |
6666
| `stickyMobile` | `sticky-mobile` | Use a sticky footer toolbar on mobile. Note: except iOS, feel free to send a PR if you know how to handle this with the software keyboard | `boolean` | `false` |
6767
| `attachTo` | `attach-to` | Could be use to attach the inline editor event listeners (mousedown, touchstart and keydown) to a specific element instead of the document | `HTMLElement` | |
68+
| `containerAttribute` | `container-attribute` | The container where the inline editor should be use need to be identified with an attribute in order to allow the component to detect some information like the current style or color | `string` | `slot` |
6869

6970
### Styling
7071

@@ -87,7 +88,8 @@ The `<deckgo-inline-editor/>` could be styled using the following CSS4 variables
8788
| --deckgo-inline-editor-button-color-active | black | The color of the buttons when active |
8889
| --deckgo-inline-editor-button-color-disabled | #f4f5f8 | The color of the buttons when disabled |
8990
| --deckgo-inline-editor-link-color | #3880ff | The color of the input field for the url |
90-
| --deckgo-inline-editor-link-placeholder-color | #3880ff | Ther color of the placeholder of the input field for the url |
91+
| --deckgo-inline-editor-link-placeholder-color | #3880ff | The color of the placeholder of the input field for the url |
92+
| --deckgo-inline-editor-width | 300px | The width of the toolbar |
9193

9294
Furthermore, the following variables are also available but only have an effects on mobile devices:
9395

@@ -106,22 +108,12 @@ Furthermore, the following variables are also available but only have an effects
106108

107109
** like above but for mobile
108110

109-
### Slot
110-
111-
The icon for the link action should be provided using a dedicated slot name `link`
112-
113-
```
114-
<deckgo-inline-editor>
115-
<span slot="link">L</span>
116-
</deckgo-inline-editor>
117-
```
118-
119111
### Examples
120112

121113
```
122-
<p contenteditable>This text will be editable</p>
114+
<p contenteditable slot="content">This text will be editable</p>
123115
124-
<h1 contenteditable>This title too</h1>
116+
<h1 contenteditable slot="title">This title too</h1>
125117
126118
<deckgo-inline-editor></deckgo-inline-editor>
127119
```

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ export class AppComponentsInlineEditor {
4848
</ul>
4949
<h2 id="app-components-inline-editor-showcase">Showcase</h2>
5050
<div>
51-
<h1 style={{color: '#3880ff'}} contenteditable>DeckDeckGo (editable title)</h1>
51+
<h1 style={{color: '#3880ff'}} contenteditable slot="title">DeckDeckGo (editable title)</h1>
5252

53-
<h2 style={{color: '#3880ff'}} contenteditable>The Progressive Web App alternative for simple presentations 🚀 (editable subtitle)</h2>
53+
<h2 style={{color: '#3880ff'}} contenteditable slot="title">The Progressive Web App alternative for simple presentations 🚀 (editable subtitle)</h2>
5454

55-
<p style={{color: '#3880ff'}} contenteditable>Edit anywhere, display everywhere (editable paragraph)</p>
55+
<p style={{color: '#3880ff'}} contenteditable slot="content">Edit anywhere, display everywhere (editable paragraph)</p>
5656
</div>
5757

5858
<p><deckgo-inline-editor sticky-desktop="true" sticky-mobile="true"></deckgo-inline-editor></p>
@@ -111,6 +111,13 @@ export class AppComponentsInlineEditor {
111111
<td><code>HTMLElement</code></td>
112112
<td></td>
113113
</tr>
114+
<tr>
115+
<td><code>containerAttribute</code></td>
116+
<td><code>container-attribute</code></td>
117+
<td>The container where the inline editor should be use need to be identified with an attribute in order to allow the component to detect some information like the current style or color</td>
118+
<td><code>string</code></td>
119+
<td><code>slot</code></td>
120+
</tr>
114121
</tbody></table>
115122
<h3 id="app-components-inline-editor-styling">Styling</h3>
116123
<p>The <code>&lt;deckgo-inline-editor/&gt;</code> could be styled using the following CSS4 variables which would only applies on the type <code>&lt;svg/&gt;</code>:</p>
@@ -200,7 +207,12 @@ export class AppComponentsInlineEditor {
200207
<tr>
201208
<td>--deckgo-inline-editor-link-placeholder-color</td>
202209
<td>#3880ff</td>
203-
<td>Ther color of the placeholder of the input field for the url</td>
210+
<td>The color of the placeholder of the input field for the url</td>
211+
</tr>
212+
<tr>
213+
<td>--deckgo-inline-editor-width</td>
214+
<td>300px</td>
215+
<td>The width of the toolbar</td>
204216
</tr>
205217
</tbody></table>
206218
<p>Furthermore, the following variables are also available but only have an effects on mobile devices:</p>
@@ -264,13 +276,9 @@ export class AppComponentsInlineEditor {
264276
</tr>
265277
</tbody></table>
266278
<p>** like above but for mobile</p>
267-
<h3 id="app-components-inline-editor-slot">Slot</h3>
268-
<p>The icon for the link action should be provided using a dedicated slot name <code>link</code></p>
269-
<deckgo-highlight-code language="javascript">
270-
<code slot="code">&lt;deckgo-inline-editor&gt;{'\n'} &lt;span slot=&quot;link&quot;&gt;L&lt;&#47;span&gt;{'\n'}&lt;&#47;deckgo-inline-editor&gt;</code>
271-
</deckgo-highlight-code><h3 id="app-components-inline-editor-examples">Examples</h3>
279+
<h3 id="app-components-inline-editor-examples">Examples</h3>
272280
<deckgo-highlight-code language="javascript">
273-
<code slot="code">&lt;p contenteditable&gt;This text will be editable&lt;&#47;p&gt;{'\n'}{'\n'}&lt;h1 contenteditable&gt;This title too&lt;&#47;h1&gt;{'\n'}{'\n'}&lt;deckgo-inline-editor&gt;&lt;&#47;deckgo-inline-editor&gt;</code>
281+
<code slot="code">&lt;p contenteditable slot=&quot;content&quot;&gt;This text will be editable&lt;&#47;p&gt;{'\n'}{'\n'}&lt;h1 contenteditable slot=&quot;title&quot;&gt;This title too&lt;&#47;h1&gt;{'\n'}{'\n'}&lt;deckgo-inline-editor&gt;&lt;&#47;deckgo-inline-editor&gt;</code>
274282
</deckgo-highlight-code></main>
275283

276284
<app-footer></app-footer>

studio/src/app/components/core/app-footer/app-footer.scss

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ app-footer {
1515
}
1616
}
1717

18-
19-
2018
ion-split-pane {
2119

2220
&:not(.split-pane-visible) {
@@ -33,3 +31,20 @@ ion-split-pane {
3331
}
3432
}
3533
}
34+
35+
@media (prefers-color-scheme: dark) {
36+
ion-split-pane {
37+
app-footer {
38+
div {
39+
ion-anchor {
40+
color: white;
41+
42+
&:hover, &.active {
43+
color: var(--ion-color-secondary);
44+
border-bottom-color: var(--ion-color-secondary);
45+
}
46+
}
47+
}
48+
}
49+
}
50+
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
div {
22
color: transparent;
33

4-
vertical-align: var(--deckgo-logo-vertical-align);
54
margin-right: var(--deckgo-logo-margin-end);
65

7-
background-color: transparent;
8-
background-image: var(--deckgo-logo-url, url('/assets/img/deckdeckgo-logo-round.svg'));
9-
background-repeat: no-repeat;
10-
11-
width: var(--deckgo-logo-size, 2rem);
12-
height: var(--deckgo-logo-size, 2rem);
13-
146
border-radius: 50%;
157
border: 1px solid white;
168

17-
display: inline-block;
9+
display: flex;
10+
justify-content: center;
11+
align-items: center;
12+
13+
background: var(--ion-color-primary);
14+
15+
ion-icon {
16+
font-size: var(--deckgo-logo-size, 2rem);
17+
}
1818
}

studio/src/app/components/core/app-logo/app-logo.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {Component} from '@stencil/core';
88
export class AppLogo {
99

1010
render() {
11-
return <div></div>;
11+
return <div>
12+
<ion-icon src="/assets/img/deckdeckgo-logo-round.svg"></ion-icon>
13+
</div>;
1214
}
1315
}

studio/src/app/components/core/app-navigation/app-navigation.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,13 @@ app-navigation {
2525
}
2626

2727
}
28+
29+
@media (prefers-color-scheme: dark) {
30+
app-navigation {
31+
ion-anchor {
32+
&:hover, &:active {
33+
border-bottom: 1px solid transparent;
34+
}
35+
}
36+
}
37+
}

studio/src/app/components/editor/app-editor-toolbar/app-editor-toolbar.tsx

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ export class AppEditorToolbar {
162162
this.selectedElement.classList.add('deckgo-untouched');
163163
}
164164

165+
this.selectedElement.removeEventListener('paste', this.cleanOnPaste, true);
166+
165167
await this.hideToolbar();
166168
}
167169

@@ -196,6 +198,76 @@ export class AppEditorToolbar {
196198
return element && element.nodeName && (element.nodeName.toLowerCase().indexOf('deckgo-deck') > -1 || element.nodeName.toLowerCase().indexOf('deckgo-slide') > -1)
197199
}
198200

201+
private cleanOnPaste = async ($event) => {
202+
return new Promise<void>(async (resolve) => {
203+
if (!$event || !document) {
204+
resolve();
205+
return;
206+
}
207+
208+
const parseText: string = $event.clipboardData.getData('text/plain');
209+
210+
if (!parseText || parseText.length <= 0) {
211+
resolve();
212+
return;
213+
}
214+
215+
// In the future, Safari isn't yet ready / without preventDefault
216+
// // @ts-ignore
217+
// navigator.permissions.query({name: 'clipboard-write'}).then(async result => {
218+
// if (result.state === 'granted' || result.state === 'prompt') {
219+
// // @ts-ignore
220+
// await navigator.clipboard.writeText(parseText);
221+
// }
222+
// });
223+
224+
$event.preventDefault();
225+
226+
const parseTexts: string[] = parseText.replace(/(?:\r\n|\r|\n)/g, '<br/>').split('<br/>');
227+
228+
if (!parseTexts || parseTexts.length <= 0) {
229+
resolve();
230+
return;
231+
}
232+
233+
const selected: Selection = await this.getSelection();
234+
if (selected && selected.rangeCount) {
235+
const range = selected.getRangeAt(0);
236+
range.deleteContents();
237+
238+
parseTexts.forEach((text: string, index: number) => {
239+
const newTextNode: Text = document.createTextNode(text);
240+
range.insertNode(newTextNode);
241+
242+
if (index < parseTexts.length - 1) {
243+
const br: HTMLBRElement = document.createElement('br');
244+
range.insertNode(br);
245+
}
246+
});
247+
248+
selected.empty();
249+
}
250+
251+
resolve();
252+
});
253+
};
254+
255+
private getSelection(): Promise<Selection> {
256+
return new Promise<Selection>((resolve) => {
257+
let selectedSelection: Selection = null;
258+
259+
if (window && window.getSelection) {
260+
selectedSelection = window.getSelection();
261+
} else if (document && document.getSelection) {
262+
selectedSelection = document.getSelection();
263+
} else if (document && (document as any).selection) {
264+
selectedSelection = (document as any).selection.createRange().text;
265+
}
266+
267+
resolve(selectedSelection);
268+
});
269+
}
270+
199271
private displayToolbar(element: HTMLElement): Promise<void> {
200272
return new Promise<void>(async (resolve) => {
201273
if (!element) {
@@ -497,13 +569,17 @@ export class AppEditorToolbar {
497569
this.selectedElement = element;
498570
this.deckOrSlide = this.isElementSlideOrDeck(element);
499571

572+
if (element) {
573+
element.addEventListener('paste', this.cleanOnPaste, false);
574+
}
575+
500576
resolve();
501577
});
502578
}
503579

504580
private async openForDeckOrSlide($event: UIEvent, myFunction: Function) {
505581
if (!this.deckOrSlide) {
506-
myFunction();
582+
await myFunction();
507583
return;
508584
}
509585

@@ -516,7 +592,7 @@ export class AppEditorToolbar {
516592
popover.onDidDismiss().then(async (detail: OverlayEventDetail) => {
517593
if (detail.data) {
518594
this.applyToAllDeck = detail.data.deck;
519-
myFunction();
595+
await myFunction();
520596
}
521597
});
522598

studio/src/app/components/feed/app-popular/app-popular.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@ app-popular {
33
--background: white;
44
}
55
}
6+
7+
@media (prefers-color-scheme: dark) {
8+
app-popular {
9+
h1 {
10+
color: black;
11+
}
12+
}
13+
}

studio/src/app/components/feed/app-popular/app-popular.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export class AppPopular {
1818

1919
<p padding-top>What does that mean 🤔?</p>
2020

21-
<p padding-top>It means that every presentations you write, present and publish with DeckDeckGo are themselves also <strong>apps</strong> for desktop and mobile 🤪</p>
21+
<p padding-top>It means that every presentations you write and publish with DeckDeckGo are also <strong>apps</strong> for desktop and mobile 🤪</p>
2222

23-
<p padding-top>DeckDeckGo aims to be an online community for sharing presentations, slides and talks about your interests and ideas too.</p>
23+
<p padding-top>Furthermore, DeckDeckGo aims to be an online community for sharing presentations, slides and talks about your interests and ideas too.</p>
2424

2525
<p padding-top><strong>Edit anywhere, display everywhere</strong></p>
2626
</ion-card-content>

studio/src/app/helpers/editor/editor.helper.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@ export class EditorHelper {
155155

156156
this.deck = await this.deckService.put(this.deck);
157157
} else {
158+
// TODO: Deck name to be solve with the UX
158159
this.deck = {
159-
deck_slides: [slide.slide_id]
160+
deck_slides: [slide.slide_id],
161+
deck_name: 'Presentation A'
160162
};
161163

162164
this.deck = await this.deckService.post(this.deck);

0 commit comments

Comments
 (0)