@@ -38,6 +38,10 @@ export default Vue.extend({
type: Boolean,
default: true
},
+ draggable: {
+ type: Boolean,
+ default: false
+ },
error: {
required: false,
default: null
@@ -120,6 +124,10 @@ export default Vue.extend({
&:active
color var(--faceTextButtonActive)
+ &.draggable
+ > header
+ cursor move
+
> .warn
color #b19e49
margin 0
diff --git a/src/client/app/common/views/components/page-editor/page-editor.vue b/src/client/app/common/views/components/page-editor/page-editor.vue
index 6d07c5dc6..d70049121 100644
--- a/src/client/app/common/views/components/page-editor/page-editor.vue
+++ b/src/client/app/common/views/components/page-editor/page-editor.vue
@@ -44,9 +44,7 @@
-
- updateItem(v)" @remove="() => remove(child)" :key="child.id" :ai-script="aiScript"/>
-
+
@@ -98,7 +96,7 @@ import { faICursor, faPlus, faMagic, faCog, faCode, faExternalLinkSquareAlt } fr
import { faSave, faStickyNote, faTrashAlt } from '@fortawesome/free-regular-svg-icons';
import i18n from '../../../../i18n';
import XVariable from './page-editor.script-block.vue';
-import XBlock from './page-editor.block.vue';
+import XBlocks from './page-editor.blocks.vue';
import * as uuid from 'uuid';
import { blockDefs } from '../../../../../../misc/aiscript/index';
import { ASTypeChecker } from '../../../../../../misc/aiscript/type-checker';
@@ -109,7 +107,7 @@ export default Vue.extend({
i18n: i18n('pages'),
components: {
- XVariable, XBlock
+ XVariable, XBlocks
},
props: {
@@ -299,25 +297,6 @@ export default Vue.extend({
this.variables.push({ id, name, type: null });
},
- updateItem(v) {
- const i = this.content.findIndex(x => x.id === v.id);
- const newValue = [
- ...this.content.slice(0, i),
- v,
- ...this.content.slice(i + 1)
- ];
- this.content = newValue;
- },
-
- remove(el) {
- const i = this.content.findIndex(x => x.id === el.id);
- const newValue = [
- ...this.content.slice(0, i),
- ...this.content.slice(i + 1)
- ];
- this.content = newValue;
- },
-
removeVariable(v) {
const i = this.variables.findIndex(x => x.name === v.name);
const newValue = [
@@ -343,7 +322,8 @@ export default Vue.extend({
{ value: 'textInput', text: this.$t('blocks.textInput') },
{ value: 'textareaInput', text: this.$t('blocks.textareaInput') },
{ value: 'numberInput', text: this.$t('blocks.numberInput') },
- { value: 'switch', text: this.$t('blocks.switch') }
+ { value: 'switch', text: this.$t('blocks.switch') },
+ { value: 'counter', text: this.$t('blocks.counter') }
]
}, {
label: this.$t('special-blocks'),
diff --git a/src/client/app/common/views/pages/page/page.block.vue b/src/client/app/common/views/pages/page/page.block.vue
index f348107cc..1c421fc2c 100644
--- a/src/client/app/common/views/pages/page/page.block.vue
+++ b/src/client/app/common/views/pages/page/page.block.vue
@@ -15,10 +15,11 @@ import XSwitch from './page.switch.vue';
import XIf from './page.if.vue';
import XTextarea from './page.textarea.vue';
import XPost from './page.post.vue';
+import XCounter from './page.counter.vue';
export default Vue.extend({
components: {
- XText, XSection, XImage, XButton, XNumberInput, XTextInput, XTextareaInput, XTextarea, XPost, XSwitch, XIf
+ XText, XSection, XImage, XButton, XNumberInput, XTextInput, XTextareaInput, XTextarea, XPost, XSwitch, XIf, XCounter
},
props: {
diff --git a/src/client/app/common/views/pages/page/page.counter.vue b/src/client/app/common/views/pages/page/page.counter.vue
new file mode 100644
index 000000000..8d55319fe
--- /dev/null
+++ b/src/client/app/common/views/pages/page/page.counter.vue
@@ -0,0 +1,47 @@
+
+
+ {{ script.interpolate(value.text) }}
+
+
+
+
+
+
diff --git a/src/misc/aiscript/evaluator.ts b/src/misc/aiscript/evaluator.ts
index fef2d4f3a..2bc866dc4 100644
--- a/src/misc/aiscript/evaluator.ts
+++ b/src/misc/aiscript/evaluator.ts
@@ -7,56 +7,6 @@ type Fn = {
exec: (args: Record) => ReturnType;
};
-class AiScriptError extends Error {
- public info?: any;
-
- constructor(message: string, info?: any) {
- super(message);
-
- this.info = info;
-
- // Maintains proper stack trace for where our error was thrown (only available on V8)
- if (Error.captureStackTrace) {
- Error.captureStackTrace(this, AiScriptError);
- }
- }
-}
-
-class Scope {
- private layerdStates: Record[];
- public name: string;
-
- constructor(layerdStates: Scope['layerdStates'], name?: Scope['name']) {
- this.layerdStates = layerdStates;
- this.name = name || 'anonymous';
- }
-
- @autobind
- public createChildScope(states: Record, name?: Scope['name']): Scope {
- const layer = [states, ...this.layerdStates];
- return new Scope(layer, name);
- }
-
- /**
- * 指定した名前の変数の値を取得します
- * @param name 変数名
- */
- @autobind
- public getState(name: string): any {
- for (const later of this.layerdStates) {
- const state = later[name];
- if (state !== undefined) {
- return state;
- }
- }
-
- throw new AiScriptError(
- `No such variable '${name}' in scope '${this.name}'`, {
- scope: this.layerdStates
- });
- }
-}
-
/**
* AiScript evaluator
*/
@@ -238,3 +188,53 @@ export class ASEvaluator {
}
}
}
+
+class AiScriptError extends Error {
+ public info?: any;
+
+ constructor(message: string, info?: any) {
+ super(message);
+
+ this.info = info;
+
+ // Maintains proper stack trace for where our error was thrown (only available on V8)
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, AiScriptError);
+ }
+ }
+}
+
+class Scope {
+ private layerdStates: Record[];
+ public name: string;
+
+ constructor(layerdStates: Scope['layerdStates'], name?: Scope['name']) {
+ this.layerdStates = layerdStates;
+ this.name = name || 'anonymous';
+ }
+
+ @autobind
+ public createChildScope(states: Record, name?: Scope['name']): Scope {
+ const layer = [states, ...this.layerdStates];
+ return new Scope(layer, name);
+ }
+
+ /**
+ * 指定した名前の変数の値を取得します
+ * @param name 変数名
+ */
+ @autobind
+ public getState(name: string): any {
+ for (const later of this.layerdStates) {
+ const state = later[name];
+ if (state !== undefined) {
+ return state;
+ }
+ }
+
+ throw new AiScriptError(
+ `No such variable '${name}' in scope '${this.name}'`, {
+ scope: this.layerdStates
+ });
+ }
+}