Content deleted Content added
actually load preview from api parse |
es6-polyfills removed |
||
(9 intermediate revisions by the same user not shown) | |||
Line 15:
EFFPRH.init = function () {
mw.loader.using(
[ 'vue', '
EFFPRH.run
);
Line 53:
border: 1px solid black;
margin: 10px 0 10px 0;
}▼
}
/* Override normal rules for indenting lists */
.
margin-left: 0px;
}
/* Separate the dropdown and input */
.
margin-bottom: 10px;
}
/* Reduce vertical space in the dropdown options */
.
line-height: 1em;
}▼
}
/* Center form elements and labels */
.script-EFFPRH-handler td {
vertical-align: middle;
▲ }
/* Don't use the grey background in the preview */
.script-EFFPRH-preview {
background-color: white;
}
`);
Line 124 ⟶ 119:
// Handler options, see {{EFFP}}
EFFPRH.responseOptions = [
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{ value: 'pin', label: 'Pin' },
{ value: 'moot', label: 'Moot (filter working properly)' },
{ value: 'mootefm', label: 'Moot (may need a change to filter)' }
];
Line 150 ⟶ 148:
// We shouldn't use the mw.loader access directly, but I'm not
// pasing around the `require` function everywhere
const
// Extra component to render wikitext preview
const previewRenderer = EFFPRH.getPreviewComponent();
const handlerApp = {
components: {
CdxSelect: cdx.CdxSelect,
CdxTextInput: cdx.CdxTextInput,
CdxToggleButton: cdx.CdxToggleButton,
previewRenderer: previewRenderer
},
Line 200 ⟶ 198:
},
methods: {
onCommentChange: function ( newComment ) {▼
},▼
},▼
reloadPage: function () {
// Needs to be a function instead of using href so that we
Line 246 ⟶ 238:
<tr>
<td><span>Action:</span></td>
<td><
</tr>
<tr>
<td><span>Comment:</span></td>
<td><
</tr>
</tbody></table>
Line 259 ⟶ 251:
<li v-show="editError">Uh-oh, something went wrong. Please check the console for details.</li>
</ul>
<
<
<
<!-- v-if so that we don't call the api to parse and render a preview when its not needed, do not render with no response template chosen -->
<preview-renderer v-if="showPreview && canSubmit" :wikitext="responseWikiText"></preview-renderer>
Line 284 ⟶ 276:
};
},
// Separate from the watcher so that can be called on mounted too
wikitext: function ( newValue ) {▼
loadPreview: function ( wikitextToPreview ) {
// Reset when the wikitext to preview changes▼
this.previewHtml = '';▼
this.haveHtml = false;▼
new mw.Api().get( {
action: 'parse',
formatversion: 2,
title: mw.config.get( 'wgPageName' ),
text:
prop: 'text|wikitext',
pst: true,
Line 313 ⟶ 303:
);
}
▲ },
watch: {
▲ // Reset when the wikitext to preview changes
▲ this.previewHtml = '';
▲ this.haveHtml = false;
this.loadPreview( newValue );
// Preview starting wikitext
this.loadPreview( this.wikitext );
},
template: `
<div class="script-EFFPRH-preview">
<hr>
<div v-if="haveHtml" v-html="previewHtml"></div>
<div v-else>Loading preview of {{ wikitext }}</div>
|