Skip to content

Commit

Permalink
use preview parameter when previewing templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ChlodAlejandro committed Aug 20, 2022
1 parent a5fd408 commit e7d76c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/MwApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class MwApi {
parameters: {
format: 'json',
formatversion: 2,
utf8: 1,
utf8: true,
errorformat: 'html',
errorlang: mw.config.get( 'wgUserLanguage' ),
errorsuselocal: true
Expand Down
7 changes: 3 additions & 4 deletions src/modules/ante/models/AttributionNotice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MediaWikiData, TemplateData, TemplateDataModifier } from './MediaWikiDa
import { AttributionNoticePageLayout } from '../ui/pages/AttributionNoticePageLayout';
import { AttributionNoticePageGenerator } from '../ui/AttributionNoticePageGenerator';
import { CTEParsoidTransclusionTemplateNode } from './CTEParsoidTransclusionTemplateNode';
import MwApi from '../../../MwApi';

/**
* The AttributionNotice abstract class serves as the blueprint for other
Expand Down Expand Up @@ -165,13 +166,11 @@ export default abstract class AttributionNotice
* @return {Promise<string>}
*/
async generatePreview() {
return new mw.Api().post( {
return MwApi.action.post( {
action: 'parse',
format: 'json',
formatversion: '2',
utf8: 1,
title: this.parsoid.getPage(),
text: this.toWikitext(),
preview: true,
disableeditsection: true
} ).then( ( data ) => data.parse.text );
}
Expand Down

0 comments on commit e7d76c0

Please sign in to comment.