2019-04-29 09:11:57 +09:00
|
|
|
<template>
|
|
|
|
<div>
|
2020-01-30 04:37:25 +09:00
|
|
|
<div class="gwbmwxkm _panel">
|
2019-04-29 09:11:57 +09:00
|
|
|
<header>
|
2020-03-22 10:51:40 +09:00
|
|
|
<div class="title"><fa :icon="faStickyNote"/> {{ readonly ? $t('_pages.readPage') : pageId ? $t('_pages.editPage') : $t('_pages.newPage') }}</div>
|
2019-04-29 09:11:57 +09:00
|
|
|
<div class="buttons">
|
2020-01-30 04:37:25 +09:00
|
|
|
<button class="_button" @click="del()" v-if="!readonly"><fa :icon="faTrashAlt"/></button>
|
|
|
|
<button class="_button" @click="() => showOptions = !showOptions"><fa :icon="faCog"/></button>
|
|
|
|
<button class="_button" @click="save()" v-if="!readonly"><fa :icon="faSave"/></button>
|
2019-04-29 09:11:57 +09:00
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<section>
|
2020-03-22 10:51:40 +09:00
|
|
|
<router-link class="view" v-if="pageId" :to="`/@${ author.username }/pages/${ currentName }`"><fa :icon="faExternalLinkSquareAlt"/> {{ $t('_pages.viewPage') }}</router-link>
|
2019-04-29 14:46:35 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
<mk-input v-model="title">
|
2020-03-22 10:51:40 +09:00
|
|
|
<span>{{ $t('_pages.title') }}</span>
|
2020-01-30 04:37:25 +09:00
|
|
|
</mk-input>
|
2019-04-29 09:11:57 +09:00
|
|
|
|
|
|
|
<template v-if="showOptions">
|
2020-01-30 04:37:25 +09:00
|
|
|
<mk-input v-model="summary">
|
2020-03-22 10:51:40 +09:00
|
|
|
<span>{{ $t('_pages.summary') }}</span>
|
2020-01-30 04:37:25 +09:00
|
|
|
</mk-input>
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
<mk-input v-model="name">
|
2019-04-30 06:40:02 +09:00
|
|
|
<template #prefix>{{ url }}/@{{ author.username }}/pages/</template>
|
2020-03-22 10:51:40 +09:00
|
|
|
<span>{{ $t('_pages.url') }}</span>
|
2020-01-30 04:37:25 +09:00
|
|
|
</mk-input>
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-03-22 10:51:40 +09:00
|
|
|
<mk-switch v-model="alignCenter">{{ $t('_pages.alignCenter') }}</mk-switch>
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
<mk-select v-model="font">
|
2020-03-22 10:51:40 +09:00
|
|
|
<template #label>{{ $t('_pages.font') }}</template>
|
|
|
|
<option value="serif">{{ $t('_pages.fontSerif') }}</option>
|
|
|
|
<option value="sans-serif">{{ $t('_pages.fontSansSerif') }}</option>
|
2020-01-30 04:37:25 +09:00
|
|
|
</mk-select>
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-03-22 10:51:40 +09:00
|
|
|
<mk-switch v-model="hideTitleWhenPinned">{{ $t('_pages.hideTitleWhenPinned') }}</mk-switch>
|
2019-07-07 06:56:13 +09:00
|
|
|
|
2019-04-29 09:11:57 +09:00
|
|
|
<div class="eyeCatch">
|
2020-03-22 10:51:40 +09:00
|
|
|
<mk-button v-if="eyeCatchingImageId == null && !readonly" @click="setEyeCatchingImage()"><fa :icon="faPlus"/> {{ $t('_pages.eyeCatchingImageSet') }}</mk-button>
|
2019-04-29 09:11:57 +09:00
|
|
|
<div v-else-if="eyeCatchingImage">
|
|
|
|
<img :src="eyeCatchingImage.url" :alt="eyeCatchingImage.name"/>
|
2020-03-22 10:51:40 +09:00
|
|
|
<mk-button @click="removeEyeCatchingImage()" v-if="!readonly"><fa :icon="faTrashAlt"/> {{ $t('_pages.eyeCatchingImageRemove') }}</mk-button>
|
2019-04-29 09:11:57 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2019-05-02 17:55:59 +09:00
|
|
|
<x-blocks class="content" v-model="content" :ai-script="aiScript"/>
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
<mk-button @click="add()" v-if="!readonly"><fa :icon="faPlus"/></mk-button>
|
2019-04-29 09:11:57 +09:00
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
<mk-container :body-togglable="true">
|
2020-03-22 10:51:40 +09:00
|
|
|
<template #header><fa :icon="faMagic"/> {{ $t('_pages.variables') }}</template>
|
2019-04-29 09:11:57 +09:00
|
|
|
<div class="qmuvgica">
|
2019-05-10 16:04:32 +09:00
|
|
|
<x-draggable tag="div" class="variables" v-show="variables.length > 0" :list="variables" handle=".drag-handle" :group="{ name: 'variables' }" animation="150" swap-threshold="0.5">
|
|
|
|
<x-variable v-for="variable in variables"
|
|
|
|
:value="variable"
|
|
|
|
:removable="true"
|
|
|
|
@input="v => updateVariable(v)"
|
|
|
|
@remove="() => removeVariable(variable)"
|
|
|
|
:key="variable.name"
|
|
|
|
:ai-script="aiScript"
|
|
|
|
:name="variable.name"
|
|
|
|
:title="variable.name"
|
|
|
|
:draggable="true"
|
|
|
|
/>
|
|
|
|
</x-draggable>
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
<mk-button @click="addVariable()" class="add" v-if="!readonly"><fa :icon="faPlus"/></mk-button>
|
2019-04-29 09:11:57 +09:00
|
|
|
</div>
|
2020-01-30 04:37:25 +09:00
|
|
|
</mk-container>
|
2019-05-01 20:48:56 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
<mk-container :body-togglable="true" :expanded="false">
|
2020-03-22 10:51:40 +09:00
|
|
|
<template #header><fa :icon="faCode"/> {{ $t('_pages.inspector') }}</template>
|
2019-05-01 20:48:56 +09:00
|
|
|
<div style="padding:0 32px 32px 32px;">
|
2020-03-22 10:51:40 +09:00
|
|
|
<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>
|
2019-05-01 20:48:56 +09:00
|
|
|
</div>
|
2020-01-30 04:37:25 +09:00
|
|
|
</mk-container>
|
2019-04-29 09:11:57 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2019-05-10 16:04:32 +09:00
|
|
|
import * as XDraggable from 'vuedraggable';
|
2019-05-01 20:48:56 +09:00
|
|
|
import { faICursor, faPlus, faMagic, faCog, faCode, faExternalLinkSquareAlt } from '@fortawesome/free-solid-svg-icons';
|
2019-04-29 09:11:57 +09:00
|
|
|
import { faSave, faStickyNote, faTrashAlt } from '@fortawesome/free-regular-svg-icons';
|
2020-01-30 04:37:25 +09:00
|
|
|
import { v4 as uuid } from 'uuid';
|
|
|
|
import i18n from '../../i18n';
|
2019-04-29 09:11:57 +09:00
|
|
|
import XVariable from './page-editor.script-block.vue';
|
2019-05-02 17:55:59 +09:00
|
|
|
import XBlocks from './page-editor.blocks.vue';
|
2020-01-30 04:37:25 +09:00
|
|
|
import MkTextarea from '../../components/ui/textarea.vue';
|
|
|
|
import MkContainer from '../../components/ui/container.vue';
|
|
|
|
import MkButton from '../../components/ui/button.vue';
|
|
|
|
import MkSelect from '../../components/ui/select.vue';
|
|
|
|
import MkSwitch from '../../components/ui/switch.vue';
|
|
|
|
import MkInput from '../../components/ui/input.vue';
|
2020-04-12 19:38:19 +09:00
|
|
|
import { blockDefs } from '../../scripts/aoiscript/index';
|
|
|
|
import { ASTypeChecker } from '../../scripts/aoiscript/type-checker';
|
2020-01-30 04:37:25 +09:00
|
|
|
import { url } from '../../config';
|
|
|
|
import { collectPageVars } from '../../scripts/collect-page-vars';
|
2020-04-05 17:55:51 +09:00
|
|
|
import { selectDriveFile } from '../../scripts/select-drive-file';
|
2019-04-29 09:11:57 +09:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2020-01-30 04:37:25 +09:00
|
|
|
i18n,
|
2019-04-29 09:11:57 +09:00
|
|
|
|
|
|
|
components: {
|
2020-01-30 04:37:25 +09:00
|
|
|
XDraggable, XVariable, XBlocks, MkTextarea, MkContainer, MkButton, MkSelect, MkSwitch, MkInput
|
2019-04-29 09:11:57 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
2019-05-24 19:19:43 +09:00
|
|
|
initPageId: {
|
|
|
|
type: String,
|
2019-04-29 09:11:57 +09:00
|
|
|
required: false
|
2019-04-30 06:40:02 +09:00
|
|
|
},
|
2019-05-24 19:19:43 +09:00
|
|
|
initPageName: {
|
|
|
|
type: String,
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
initUser: {
|
|
|
|
type: String,
|
|
|
|
required: false
|
2019-04-30 06:40:02 +09:00
|
|
|
},
|
2019-04-29 09:11:57 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2019-04-30 06:40:02 +09:00
|
|
|
author: this.$store.state.i,
|
2019-05-24 19:19:43 +09:00
|
|
|
readonly: false,
|
|
|
|
page: null,
|
2019-04-29 09:11:57 +09:00
|
|
|
pageId: null,
|
2019-04-29 14:46:35 +09:00
|
|
|
currentName: null,
|
2019-04-29 09:11:57 +09:00
|
|
|
title: '',
|
|
|
|
summary: null,
|
|
|
|
name: Date.now().toString(),
|
|
|
|
eyeCatchingImage: null,
|
|
|
|
eyeCatchingImageId: null,
|
|
|
|
font: 'sans-serif',
|
|
|
|
content: [],
|
|
|
|
alignCenter: false,
|
2019-07-07 06:56:13 +09:00
|
|
|
hideTitleWhenPinned: false,
|
2019-04-29 09:11:57 +09:00
|
|
|
variables: [],
|
|
|
|
aiScript: null,
|
|
|
|
showOptions: false,
|
|
|
|
url,
|
2019-05-01 20:48:56 +09:00
|
|
|
faPlus, faICursor, faSave, faStickyNote, faMagic, faCog, faTrashAlt, faExternalLinkSquareAlt, faCode
|
2019-04-29 09:11:57 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
async eyeCatchingImageId() {
|
|
|
|
if (this.eyeCatchingImageId == null) {
|
|
|
|
this.eyeCatchingImage = null;
|
|
|
|
} else {
|
|
|
|
this.eyeCatchingImage = await this.$root.api('drive/files/show', {
|
|
|
|
fileId: this.eyeCatchingImageId,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2019-05-24 19:19:43 +09:00
|
|
|
async created() {
|
2019-05-01 18:33:11 +09:00
|
|
|
this.aiScript = new ASTypeChecker();
|
2019-04-29 09:11:57 +09:00
|
|
|
|
|
|
|
this.$watch('variables', () => {
|
2019-05-01 18:33:11 +09:00
|
|
|
this.aiScript.variables = this.variables;
|
2019-04-29 09:11:57 +09:00
|
|
|
}, { deep: true });
|
|
|
|
|
|
|
|
this.$watch('content', () => {
|
2019-05-01 18:33:11 +09:00
|
|
|
this.aiScript.pageVars = collectPageVars(this.content);
|
2019-04-29 09:11:57 +09:00
|
|
|
}, { deep: true });
|
|
|
|
|
2019-05-24 19:19:43 +09:00
|
|
|
if (this.initPageId) {
|
|
|
|
this.page = await this.$root.api('pages/show', {
|
|
|
|
pageId: this.initPageId,
|
|
|
|
});
|
|
|
|
} else if (this.initPageName && this.initUser) {
|
|
|
|
this.page = await this.$root.api('pages/show', {
|
|
|
|
name: this.initPageName,
|
|
|
|
username: this.initUser,
|
|
|
|
});
|
|
|
|
this.readonly = true;
|
|
|
|
}
|
|
|
|
|
2019-04-29 09:11:57 +09:00
|
|
|
if (this.page) {
|
2019-05-01 20:48:56 +09:00
|
|
|
this.author = this.page.user;
|
|
|
|
this.pageId = this.page.id;
|
|
|
|
this.title = this.page.title;
|
|
|
|
this.name = this.page.name;
|
|
|
|
this.currentName = this.page.name;
|
|
|
|
this.summary = this.page.summary;
|
|
|
|
this.font = this.page.font;
|
2019-07-07 06:56:13 +09:00
|
|
|
this.hideTitleWhenPinned = this.page.hideTitleWhenPinned;
|
2019-05-01 20:48:56 +09:00
|
|
|
this.alignCenter = this.page.alignCenter;
|
|
|
|
this.content = this.page.content;
|
|
|
|
this.variables = this.page.variables;
|
|
|
|
this.eyeCatchingImageId = this.page.eyeCatchingImageId;
|
2019-04-29 09:11:57 +09:00
|
|
|
} else {
|
2019-08-18 12:42:58 +09:00
|
|
|
const id = uuid();
|
2019-04-29 09:11:57 +09:00
|
|
|
this.content = [{
|
|
|
|
id,
|
|
|
|
type: 'text',
|
|
|
|
text: 'Hello World!'
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
provide() {
|
|
|
|
return {
|
2019-04-30 06:40:02 +09:00
|
|
|
readonly: this.readonly,
|
|
|
|
getScriptBlockList: this.getScriptBlockList,
|
|
|
|
getPageBlockList: this.getPageBlockList
|
2019-04-29 09:11:57 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
save() {
|
2019-08-28 08:00:05 +09:00
|
|
|
const options = {
|
|
|
|
title: this.title.trim(),
|
|
|
|
name: this.name.trim(),
|
|
|
|
summary: this.summary,
|
|
|
|
font: this.font,
|
|
|
|
hideTitleWhenPinned: this.hideTitleWhenPinned,
|
|
|
|
alignCenter: this.alignCenter,
|
|
|
|
content: this.content,
|
|
|
|
variables: this.variables,
|
|
|
|
eyeCatchingImageId: this.eyeCatchingImageId,
|
|
|
|
};
|
|
|
|
|
2019-09-02 06:21:43 +09:00
|
|
|
const onError = err => {
|
2019-09-02 06:02:35 +09:00
|
|
|
if (err.id == '3d81ceae-475f-4600-b2a8-2bc116157532') {
|
2019-09-02 06:04:12 +09:00
|
|
|
if (err.info.param == 'name') {
|
2019-09-02 06:02:35 +09:00
|
|
|
this.$root.dialog({
|
|
|
|
type: 'error',
|
2020-03-22 10:51:40 +09:00
|
|
|
title: this.$t('_pages.invalidNameTitle'),
|
|
|
|
text: this.$t('_pages.invalidNameText')
|
2019-09-02 06:02:35 +09:00
|
|
|
});
|
|
|
|
}
|
2019-09-02 06:04:12 +09:00
|
|
|
} else if (err.code == 'NAME_ALREADY_EXISTS') {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'error',
|
2020-03-22 10:51:40 +09:00
|
|
|
text: this.$t('_pages.nameAlreadyExists')
|
2019-09-02 06:04:12 +09:00
|
|
|
});
|
|
|
|
}
|
2019-09-02 06:21:43 +09:00
|
|
|
};
|
2019-09-02 06:02:35 +09:00
|
|
|
|
2019-04-29 09:11:57 +09:00
|
|
|
if (this.pageId) {
|
2019-08-28 08:00:05 +09:00
|
|
|
options.pageId = this.pageId;
|
|
|
|
this.$root.api('pages/update', options)
|
|
|
|
.then(page => {
|
2019-04-29 14:46:35 +09:00
|
|
|
this.currentName = this.name.trim();
|
2019-04-29 09:11:57 +09:00
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
2020-03-22 10:51:40 +09:00
|
|
|
text: this.$t('_pages.updated')
|
2019-04-29 09:11:57 +09:00
|
|
|
});
|
2019-09-02 06:04:12 +09:00
|
|
|
}).catch(onError);
|
2019-04-29 09:11:57 +09:00
|
|
|
} else {
|
2019-08-28 08:00:05 +09:00
|
|
|
this.$root.api('pages/create', options)
|
|
|
|
.then(page => {
|
2019-04-29 09:11:57 +09:00
|
|
|
this.pageId = page.id;
|
2019-04-29 14:46:35 +09:00
|
|
|
this.currentName = this.name.trim();
|
2019-04-29 09:11:57 +09:00
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
2020-03-22 10:51:40 +09:00
|
|
|
text: this.$t('_pages.created')
|
2019-04-29 09:11:57 +09:00
|
|
|
});
|
2020-01-30 04:37:25 +09:00
|
|
|
this.$router.push(`/my/pages/edit/${this.pageId}`);
|
2019-09-02 06:04:12 +09:00
|
|
|
}).catch(onError);
|
2019-04-29 09:11:57 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
del() {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'warning',
|
2020-03-22 10:51:40 +09:00
|
|
|
text: this.$t('removeAreYouSure', { x: this.title.trim() }),
|
2019-04-29 09:11:57 +09:00
|
|
|
showCancelButton: true
|
|
|
|
}).then(({ canceled }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
this.$root.api('pages/delete', {
|
|
|
|
pageId: this.pageId,
|
|
|
|
}).then(() => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
2020-03-22 10:51:40 +09:00
|
|
|
text: this.$t('_pages.deleted')
|
2019-04-29 09:11:57 +09:00
|
|
|
});
|
2020-01-30 04:37:25 +09:00
|
|
|
this.$router.push(`/my/pages`);
|
2019-04-29 09:11:57 +09:00
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
async add() {
|
|
|
|
const { canceled, result: type } = await this.$root.dialog({
|
|
|
|
type: null,
|
2020-03-22 10:51:40 +09:00
|
|
|
title: this.$t('_pages.chooseBlock'),
|
2019-04-29 09:11:57 +09:00
|
|
|
select: {
|
2019-04-30 12:15:41 +09:00
|
|
|
groupedItems: this.getPageBlockList()
|
2019-04-29 09:11:57 +09:00
|
|
|
},
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2019-08-18 12:42:58 +09:00
|
|
|
const id = uuid();
|
2019-04-29 09:11:57 +09:00
|
|
|
this.content.push({ id, type });
|
|
|
|
},
|
|
|
|
|
|
|
|
async addVariable() {
|
|
|
|
let { canceled, result: name } = await this.$root.dialog({
|
2020-03-22 10:51:40 +09:00
|
|
|
title: this.$t('_pages.enterVariableName'),
|
2019-04-29 09:11:57 +09:00
|
|
|
input: {
|
|
|
|
type: 'text',
|
|
|
|
},
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
name = name.trim();
|
|
|
|
|
|
|
|
if (this.aiScript.isUsedName(name)) {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'error',
|
2020-03-22 10:51:40 +09:00
|
|
|
text: this.$t('_pages.variableNameIsAlreadyUsed')
|
2019-04-29 09:11:57 +09:00
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-18 12:42:58 +09:00
|
|
|
const id = uuid();
|
2019-04-29 09:11:57 +09:00
|
|
|
this.variables.push({ id, name, type: null });
|
|
|
|
},
|
|
|
|
|
|
|
|
removeVariable(v) {
|
|
|
|
const i = this.variables.findIndex(x => x.name === v.name);
|
|
|
|
const newValue = [
|
|
|
|
...this.variables.slice(0, i),
|
|
|
|
...this.variables.slice(i + 1)
|
|
|
|
];
|
|
|
|
this.variables = newValue;
|
|
|
|
},
|
|
|
|
|
2019-04-30 06:40:02 +09:00
|
|
|
getPageBlockList() {
|
|
|
|
return [{
|
2020-03-22 10:51:40 +09:00
|
|
|
label: this.$t('_pages.contentBlocks'),
|
2019-04-30 12:15:41 +09:00
|
|
|
items: [
|
2020-01-30 04:37:25 +09:00
|
|
|
{ value: 'section', text: this.$t('_pages.blocks.section') },
|
|
|
|
{ value: 'text', text: this.$t('_pages.blocks.text') },
|
|
|
|
{ value: 'image', text: this.$t('_pages.blocks.image') },
|
|
|
|
{ value: 'textarea', text: this.$t('_pages.blocks.textarea') },
|
2019-04-30 12:15:41 +09:00
|
|
|
]
|
2019-04-30 06:40:02 +09:00
|
|
|
}, {
|
2020-03-22 10:51:40 +09:00
|
|
|
label: this.$t('_pages.inputBlocks'),
|
2019-04-30 12:15:41 +09:00
|
|
|
items: [
|
2020-01-30 04:37:25 +09:00
|
|
|
{ value: 'button', text: this.$t('_pages.blocks.button') },
|
|
|
|
{ value: 'radioButton', text: this.$t('_pages.blocks.radioButton') },
|
|
|
|
{ value: 'textInput', text: this.$t('_pages.blocks.textInput') },
|
|
|
|
{ value: 'textareaInput', text: this.$t('_pages.blocks.textareaInput') },
|
|
|
|
{ value: 'numberInput', text: this.$t('_pages.blocks.numberInput') },
|
|
|
|
{ value: 'switch', text: this.$t('_pages.blocks.switch') },
|
|
|
|
{ value: 'counter', text: this.$t('_pages.blocks.counter') }
|
2019-04-30 12:15:41 +09:00
|
|
|
]
|
2019-04-30 06:40:02 +09:00
|
|
|
}, {
|
2020-03-22 10:51:40 +09:00
|
|
|
label: this.$t('_pages.specialBlocks'),
|
2019-04-30 12:15:41 +09:00
|
|
|
items: [
|
2020-01-30 04:37:25 +09:00
|
|
|
{ value: 'if', text: this.$t('_pages.blocks.if') },
|
|
|
|
{ value: 'post', text: this.$t('_pages.blocks.post') }
|
2019-04-30 12:15:41 +09:00
|
|
|
]
|
2019-04-30 06:40:02 +09:00
|
|
|
}];
|
|
|
|
},
|
|
|
|
|
2019-04-29 09:11:57 +09:00
|
|
|
getScriptBlockList(type: string = null) {
|
|
|
|
const list = [];
|
|
|
|
|
2019-05-05 15:17:29 +09:00
|
|
|
const blocks = blockDefs.filter(block => type === null || block.out === null || block.out === type || typeof block.out === 'number');
|
2019-04-29 09:11:57 +09:00
|
|
|
|
|
|
|
for (const block of blocks) {
|
|
|
|
const category = list.find(x => x.category === block.category);
|
|
|
|
if (category) {
|
|
|
|
category.items.push({
|
|
|
|
value: block.type,
|
2020-01-30 04:37:25 +09:00
|
|
|
text: this.$t(`_pages.script.blocks.${block.type}`)
|
2019-04-29 09:11:57 +09:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
list.push({
|
|
|
|
category: block.category,
|
|
|
|
label: this.$t(`script.categories.${block.category}`),
|
|
|
|
items: [{
|
|
|
|
value: block.type,
|
2020-01-30 04:37:25 +09:00
|
|
|
text: this.$t(`_pages.script.blocks.${block.type}`)
|
2019-04-29 09:11:57 +09:00
|
|
|
}]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const userFns = this.variables.filter(x => x.type === 'fn');
|
|
|
|
if (userFns.length > 0) {
|
|
|
|
list.unshift({
|
|
|
|
label: this.$t(`script.categories.fn`),
|
|
|
|
items: userFns.map(v => ({
|
|
|
|
value: 'fn:' + v.name,
|
|
|
|
text: v.name
|
|
|
|
}))
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
},
|
|
|
|
|
|
|
|
setEyeCatchingImage() {
|
2020-04-05 17:55:51 +09:00
|
|
|
selectDriveFile(this.$root, false).then(file => {
|
2019-04-29 09:11:57 +09:00
|
|
|
this.eyeCatchingImageId = file.id;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
removeEyeCatchingImage() {
|
|
|
|
this.eyeCatchingImageId = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.gwbmwxkm {
|
|
|
|
margin-bottom: var(--margin);
|
|
|
|
|
|
|
|
> header {
|
|
|
|
background: var(--faceHeader);
|
|
|
|
|
|
|
|
> .title {
|
|
|
|
z-index: 1;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0 16px;
|
|
|
|
line-height: 42px;
|
|
|
|
font-size: 0.9em;
|
|
|
|
font-weight: bold;
|
|
|
|
color: var(--faceHeaderText);
|
|
|
|
box-shadow: 0 var(--lineWidth) rgba(#000, 0.07);
|
|
|
|
|
|
|
|
> [data-icon] {
|
|
|
|
margin-right: 6px;
|
|
|
|
}
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
&:empty {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
> .buttons {
|
|
|
|
position: absolute;
|
|
|
|
z-index: 2;
|
|
|
|
top: 0;
|
|
|
|
right: 0;
|
|
|
|
|
|
|
|
> button {
|
|
|
|
padding: 0;
|
|
|
|
width: 42px;
|
|
|
|
font-size: 0.9em;
|
|
|
|
line-height: 42px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
> section {
|
|
|
|
padding: 0 32px 32px 32px;
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
@media (max-width: 500px) {
|
|
|
|
padding: 0 16px 16px 16px;
|
|
|
|
}
|
2019-04-29 14:46:35 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
> .view {
|
|
|
|
display: inline-block;
|
|
|
|
margin: 16px 0 0 0;
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
> .content {
|
|
|
|
margin-bottom: 16px;
|
|
|
|
}
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
> .eyeCatch {
|
|
|
|
margin-bottom: 16px;
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
> div {
|
|
|
|
> img {
|
|
|
|
max-width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
.qmuvgica {
|
|
|
|
padding: 32px;
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
@media (max-width: 500px) {
|
|
|
|
padding: 16px;
|
|
|
|
}
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
> .variables {
|
|
|
|
margin-bottom: 16px;
|
|
|
|
}
|
2019-04-29 09:11:57 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
> .add {
|
|
|
|
margin-bottom: 16px;
|
|
|
|
}
|
|
|
|
}
|
2019-04-29 09:11:57 +09:00
|
|
|
</style>
|