Resolve #5755
This commit is contained in:
parent
36b9a0d42f
commit
11cc9cbc7c
28 changed files with 195 additions and 63 deletions
|
@ -46,7 +46,7 @@
|
|||
</div>
|
||||
</template>
|
||||
|
||||
<x-blocks class="content" v-model="content" :ai-script="aiScript"/>
|
||||
<x-blocks class="content" v-model="content" :aoi-script="aoiScript"/>
|
||||
|
||||
<mk-button @click="add()" v-if="!readonly"><fa :icon="faPlus"/></mk-button>
|
||||
</section>
|
||||
|
@ -62,7 +62,7 @@
|
|||
@input="v => updateVariable(v)"
|
||||
@remove="() => removeVariable(variable)"
|
||||
:key="variable.name"
|
||||
:ai-script="aiScript"
|
||||
:aoi-script="aoiScript"
|
||||
:name="variable.name"
|
||||
:title="variable.name"
|
||||
:draggable="true"
|
||||
|
@ -73,11 +73,10 @@
|
|||
</div>
|
||||
</mk-container>
|
||||
|
||||
<mk-container :body-togglable="true" :expanded="false">
|
||||
<template #header><fa :icon="faCode"/> {{ $t('_pages.inspector') }}</template>
|
||||
<div style="padding:0 32px 32px 32px;">
|
||||
<mk-textarea :value="JSON.stringify(content, null, 2)" readonly tall>{{ $t('_pages.content') }}</mk-textarea>
|
||||
<mk-textarea :value="JSON.stringify(variables, null, 2)" readonly tall>{{ $t('_pages.variables') }}</mk-textarea>
|
||||
<mk-container :body-togglable="true" :expanded="true">
|
||||
<template #header><fa :icon="faCode"/> {{ $t('script') }}</template>
|
||||
<div>
|
||||
<prism-editor v-model="script" :line-numbers="false" language="js"/>
|
||||
</div>
|
||||
</mk-container>
|
||||
</div>
|
||||
|
@ -86,6 +85,9 @@
|
|||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import * as XDraggable from 'vuedraggable';
|
||||
import "prismjs";
|
||||
import "prismjs/themes/prism.css";
|
||||
import PrismEditor from 'vue-prism-editor';
|
||||
import { faICursor, faPlus, faMagic, faCog, faCode, faExternalLinkSquareAlt } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faSave, faStickyNote, faTrashAlt } from '@fortawesome/free-regular-svg-icons';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
@ -108,7 +110,7 @@ export default Vue.extend({
|
|||
i18n,
|
||||
|
||||
components: {
|
||||
XDraggable, XVariable, XBlocks, MkTextarea, MkContainer, MkButton, MkSelect, MkSwitch, MkInput
|
||||
XDraggable, XVariable, XBlocks, MkTextarea, MkContainer, MkButton, MkSelect, MkSwitch, MkInput, PrismEditor
|
||||
},
|
||||
|
||||
props: {
|
||||
|
@ -143,7 +145,8 @@ export default Vue.extend({
|
|||
alignCenter: false,
|
||||
hideTitleWhenPinned: false,
|
||||
variables: [],
|
||||
aiScript: null,
|
||||
aoiScript: null,
|
||||
script: '',
|
||||
showOptions: false,
|
||||
url,
|
||||
faPlus, faICursor, faSave, faStickyNote, faMagic, faCog, faTrashAlt, faExternalLinkSquareAlt, faCode
|
||||
|
@ -163,14 +166,14 @@ export default Vue.extend({
|
|||
},
|
||||
|
||||
async created() {
|
||||
this.aiScript = new ASTypeChecker();
|
||||
this.aoiScript = new ASTypeChecker();
|
||||
|
||||
this.$watch('variables', () => {
|
||||
this.aiScript.variables = this.variables;
|
||||
this.aoiScript.variables = this.variables;
|
||||
}, { deep: true });
|
||||
|
||||
this.$watch('content', () => {
|
||||
this.aiScript.pageVars = collectPageVars(this.content);
|
||||
this.aoiScript.pageVars = collectPageVars(this.content);
|
||||
}, { deep: true });
|
||||
|
||||
if (this.initPageId) {
|
||||
|
@ -193,6 +196,7 @@ export default Vue.extend({
|
|||
this.currentName = this.page.name;
|
||||
this.summary = this.page.summary;
|
||||
this.font = this.page.font;
|
||||
this.script = this.page.script;
|
||||
this.hideTitleWhenPinned = this.page.hideTitleWhenPinned;
|
||||
this.alignCenter = this.page.alignCenter;
|
||||
this.content = this.page.content;
|
||||
|
@ -223,6 +227,7 @@ export default Vue.extend({
|
|||
name: this.name.trim(),
|
||||
summary: this.summary,
|
||||
font: this.font,
|
||||
script: this.script,
|
||||
hideTitleWhenPinned: this.hideTitleWhenPinned,
|
||||
alignCenter: this.alignCenter,
|
||||
content: this.content,
|
||||
|
@ -317,7 +322,7 @@ export default Vue.extend({
|
|||
|
||||
name = name.trim();
|
||||
|
||||
if (this.aiScript.isUsedName(name)) {
|
||||
if (this.aoiScript.isUsedName(name)) {
|
||||
this.$root.dialog({
|
||||
type: 'error',
|
||||
text: this.$t('_pages.variableNameIsAlreadyUsed')
|
||||
|
@ -382,7 +387,7 @@ export default Vue.extend({
|
|||
} else {
|
||||
list.push({
|
||||
category: block.category,
|
||||
label: this.$t(`script.categories.${block.category}`),
|
||||
label: this.$t(`_pages.script.categories.${block.category}`),
|
||||
items: [{
|
||||
value: block.type,
|
||||
text: this.$t(`_pages.script.blocks.${block.type}`)
|
||||
|
@ -394,7 +399,7 @@ export default Vue.extend({
|
|||
const userFns = this.variables.filter(x => x.type === 'fn');
|
||||
if (userFns.length > 0) {
|
||||
list.unshift({
|
||||
label: this.$t(`script.categories.fn`),
|
||||
label: this.$t(`_pages.script.categories.fn`),
|
||||
items: userFns.map(v => ({
|
||||
value: 'fn:' + v.name,
|
||||
text: v.name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue