Skip to content

Commit 494fc22

Browse files
committed
fix(wiki): added wiki to ssr
1 parent 43ffb69 commit 494fc22

5 files changed

Lines changed: 13 additions & 8 deletions

File tree

src/@types/ace-builds.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module 'ace-builds/src-noconflict/ext-language_tools';

src/app/app.routes.server.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ export const serverRoutes: ServerRoute[] = [
141141
path: ':id/metadata/:recordId',
142142
renderMode: RenderMode.Server,
143143
},
144+
{
145+
path: ':id/wiki',
146+
renderMode: RenderMode.Server,
147+
},
144148
{
145149
path: ':id/files/**',
146150
renderMode: RenderMode.Server,

src/app/shared/components/wiki/edit-section/edit-section.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ describe('EditSectionComponent', () => {
186186
});
187187
});
188188

189-
it('should configure editor when onEditorLoaded is called', () => {
190-
component.onEditorLoaded(mockEditorInstance);
189+
it('should configure editor when onEditorLoaded is called', async () => {
190+
await component.onEditorLoaded(mockEditorInstance);
191191

192192
expect((component as any).editorInstance).toBe(mockEditorInstance);
193193
expect(mockEditorInstance.setShowPrintMargin).toHaveBeenCalledWith(false);

src/app/shared/components/wiki/edit-section/edit-section.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import { FormsModule } from '@angular/forms';
1010

1111
import { CustomDialogService } from '@osf/shared/services/custom-dialog.service';
1212

13-
import 'ace-builds/src-noconflict/ext-language_tools';
14-
1513
import { WikiSyntaxHelpDialogComponent } from '../wiki-syntax-help-dialog/wiki-syntax-help-dialog.component';
1614

1715
@Component({
@@ -63,14 +61,16 @@ export class EditSectionComponent {
6361
}
6462

6563
// eslint-disable-next-line @typescript-eslint/no-explicit-any
66-
onEditorLoaded(editor: any) {
64+
async onEditorLoaded(editor: any) {
6765
this.editorInstance = editor;
6866
editor.setShowPrintMargin(false);
69-
const langTools = ace.require('ace/ext/language_tools');
67+
await import('ace-builds/src-noconflict/ext-language_tools');
68+
const aceGlobal = (globalThis as { ace?: { require?: (path: string) => { snippetCompleter?: unknown } } }).ace;
69+
const langTools = aceGlobal?.require?.('ace/ext/language_tools');
7070
editor.setOptions({
7171
enableBasicAutocompletion: this.autoCompleteEnabled,
7272
enableLiveAutocompletion: this.autoCompleteEnabled,
73-
enableSnippets: [langTools.snippetCompleter],
73+
enableSnippets: langTools?.snippetCompleter ? [langTools.snippetCompleter] : [],
7474
});
7575
}
7676

src/app/shared/components/wiki/wiki-list/wiki-list.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<p-skeleton width="100%" height="1.5rem" class="mb-2 flex" />
1111
} @else {
1212
@if (expanded()) {
13-
<p-panel showHeader="false">
13+
<p-panel ngSkipHydration [showHeader]="false">
1414
<div
1515
class="flex align-items-center mt-3 mb-2"
1616
[class]="canEdit() ? 'justify-content-between' : 'justify-content-end'"

0 commit comments

Comments
 (0)