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

Commit 51a8cef

Browse files
feat: use stylo menu for code edit (#1457)
* refactor: move config and constants Signed-off-by: peterpeterparker <[email protected]> * feat: stylo menu to edit code Signed-off-by: peterpeterparker <[email protected]> * feat: menu api update Signed-off-by: peterpeterparker <[email protected]>
1 parent 47914eb commit 51a8cef

File tree

40 files changed

+82
-48
lines changed

40 files changed

+82
-48
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {FunctionalComponent, h} from '@stencil/core';
22

3-
import {EnvironmentDeckDeckGoConfig} from '../../../types/core/environment-config';
3+
import {EnvironmentDeckDeckGoConfig} from '../../../config/environment-config';
44
import {EnvironmentConfigService} from '../../../services/environment/environment-config.service';
55

66
interface AppIconProps {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import errorStore from '../../../stores/error.store';
1010
import {AppIcon} from '../app-icon/app-icon';
1111

1212
import {EnvironmentConfigService} from '../../../services/environment/environment-config.service';
13-
import {EnvironmentCloud, EnvironmentDeckDeckGoConfig} from '../../../types/core/environment-config';
13+
import {EnvironmentCloud, EnvironmentDeckDeckGoConfig} from '../../../config/environment-config';
1414

1515
import {renderI18n} from '../../../utils/core/i18n.utils';
1616
import {firebase, cloud} from '../../../utils/core/environment.utils';

studio/src/app/components/core/storage/app-storage-files/app-storage-files.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {AuthUser, StorageFile, StorageFilesList} from '@deckdeckgo/editor';
55
import store from '../../../../stores/error.store';
66
import i18n from '../../../../stores/i18n.store';
77

8-
import {Constants} from '../../../../types/core/constants';
8+
import {Constants} from '../../../../config/constants';
99

1010
import {getFiles} from '../../../../providers/storage/storage.provider';
1111
import authStore from '../../../../stores/auth.store';

studio/src/app/components/editor/deck/publish/app-publish-edit/app-publish-edit.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import errorStore from '../../../../../stores/error.store';
99
import authStore from '../../../../../stores/auth.store';
1010
import i18n from '../../../../../stores/i18n.store';
1111

12-
import {Constants} from '../../../../../types/core/constants';
12+
import {Constants} from '../../../../../config/constants';
1313

1414
import {publish, publishUrl} from '../../../../../providers/publish/publish.provider';
1515

@@ -18,7 +18,7 @@ import {renderI18n} from '../../../../../utils/core/i18n.utils';
1818
import {AppIcon} from '../../../../core/app-icon/app-icon';
1919
import {firebase} from '../../../../../utils/core/environment.utils';
2020
import {EnvironmentConfigService} from '../../../../../services/environment/environment-config.service';
21-
import {EnvironmentDeckDeckGoConfig} from '../../../../../types/core/environment-config';
21+
import {EnvironmentDeckDeckGoConfig} from '../../../../../config/environment-config';
2222

2323
interface CustomInputEvent extends KeyboardEvent {
2424
data: string | null;

studio/src/app/components/editor/deck/slide/templates/platform/app-templates-default/app-templates-default.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {tenor} from '../../../../../../../utils/core/environment.utils';
1212

1313
import {EnvironmentConfigService} from '../../../../../../../services/environment/environment-config.service';
1414

15-
import {EnvironmentDeckDeckGoConfig} from '../../../../../../../types/core/environment-config';
15+
import {EnvironmentDeckDeckGoConfig} from '../../../../../../../config/environment-config';
1616

1717
import {AppTemplatesFixed} from '../app-templates-fixed/app-templates-fixed';
1818
import {AppIcon} from '../../../../../../core/app-icon/app-icon';
File renamed without changes.

studio/src/app/config/editor.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {h1, h2, h3, StyloConfig, ul} from '@deckdeckgo/stylo';
2+
3+
import i18n from '../stores/i18n.store';
4+
5+
import {imgStorage} from '../plugins/img.storage.plugin';
6+
import {imgUnsplash} from '../plugins/img.unsplash.plugin';
7+
import {imgGif} from '../plugins/img.gif.plugin';
8+
import {code} from '../plugins/code.plugin';
9+
import {hr} from '../plugins/hr.plugin';
10+
11+
export const editorConfig: Partial<StyloConfig> = {
12+
plugins: [h1, h2, h3, ul, imgStorage, imgUnsplash, imgGif, code, hr],
13+
menus: [
14+
{
15+
match: ({paragraph}: {paragraph: HTMLElement}) => paragraph?.nodeName.toLowerCase() === 'deckgo-highlight-code',
16+
actions: [
17+
{
18+
text: i18n.state.editor.edit_code,
19+
icon: `<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 512 512'>
20+
<polygon points='364.13 125.25 87 403 64 448 108.99 425 386.75 147.87 364.13 125.25' style='fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px'/>
21+
<path d='M420.69,68.69,398.07,91.31l22.62,22.63,22.62-22.63a16,16,0,0,0,0-22.62h0A16,16,0,0,0,420.69,68.69Z' style='fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px'/>
22+
</svg>`,
23+
action: async ({paragraph}: {paragraph: HTMLElement}) => {
24+
const editCode: CustomEvent<void> = new CustomEvent<void>('editCode', {
25+
bubbles: true
26+
});
27+
28+
paragraph.dispatchEvent(editCode);
29+
}
30+
}
31+
]
32+
}
33+
]
34+
};

studio/src/app/definitions/i18.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ interface I18nEditor {
401401
transform_slide: string;
402402
add_element: string;
403403
saving: string;
404+
edit_code: string;
404405
}
405406

406407
interface I18nOffline {

studio/src/app/editors/app-deck-editor/app-deck-editor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import {Editor} from '../../types/editor/editor';
3939
import {EnvironmentConfigService} from '../../services/environment/environment-config.service';
4040
import {FontsService} from '../../services/editor/fonts/fonts.service';
4141

42-
import {EnvironmentGoogleConfig} from '../../types/core/environment-config';
42+
import {EnvironmentGoogleConfig} from '../../config/environment-config';
4343
import {cloud} from '../../utils/core/environment.utils';
4444
import {ColorUtils} from '../../utils/editor/color.utils';
4545

@@ -121,7 +121,7 @@ export class AppDeckEditor implements ComponentInterface {
121121

122122
@State()
123123
private editorConfig: Partial<StyloToolbar> = {
124-
actions: {
124+
style: {
125125
list: false,
126126
align: false,
127127
fontSize: false,

0 commit comments

Comments
 (0)