-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
293 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.my-editor, | ||
.prism-editor-wrapper { | ||
color: #ccc; | ||
font-family: JetBrains Mono, Fira code, Fira Mono, Consolas, Menlo, Courier, | ||
monospace; | ||
font-size: 14px; | ||
line-height: 1.5; | ||
padding: 5px; | ||
@apply bg-gray-900 rounded-lg; | ||
} | ||
.prism-editor__textarea:focus { | ||
outline: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
src/components/newtab/workflow/edit/EditJavascriptCode.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<template> | ||
<div class="mb-2 mt-4"> | ||
<ui-textarea | ||
:model-value="data.description" | ||
autoresize | ||
placeholder="Description" | ||
class="w-full mb-2" | ||
@change="updateData({ description: $event })" | ||
/> | ||
<ui-input | ||
type="number" | ||
:model-value="data.timeout" | ||
class="mb-2 w-full" | ||
placeholder="Timeout" | ||
title="Javascript code execution timeout" | ||
@change="updateData({ timeout: +$event })" | ||
/> | ||
<prism-editor | ||
v-if="!showCodeModal" | ||
:model-value="data.code" | ||
:highlight="highlighter('javascript')" | ||
readonly | ||
class="p-4 max-h-80" | ||
@click="showCodeModal = true" | ||
/> | ||
<ui-modal | ||
v-model="showCodeModal" | ||
title="Javascript code" | ||
content-class="max-w-3xl" | ||
> | ||
<prism-editor | ||
v-model="code" | ||
class="py-4" | ||
:highlight="highlighter('javascript')" | ||
line-numbers | ||
style="height: calc(100vh - 18rem)" | ||
/> | ||
<div> | ||
Note: | ||
<ol class="list-decimal pl-5"> | ||
<li> | ||
To execute the next block, you can call the | ||
<code>automaNextBlock</code> function. This function accepts one | ||
parameter, which you can use to save data to the workflow. Data | ||
format: | ||
<ul class="list-disc space-y-2 mt-2 text-sm pl-5"> | ||
<li><code>{ key: value }</code></li> | ||
<li> | ||
<code>[{ key: value }, { key: value }]</code> | ||
</li> | ||
</ul> | ||
You must use the column that you added as a key. | ||
</li> | ||
<li> | ||
To reset the execution timeout of the code, you can call the | ||
<code>automaResetTimeout</code> function. | ||
</li> | ||
</ol> | ||
</div> | ||
</ui-modal> | ||
</div> | ||
</template> | ||
<script setup> | ||
import { ref, watch } from 'vue'; | ||
import { PrismEditor } from 'vue-prism-editor'; | ||
import { highlighter } from '@/lib/prism'; | ||
const props = defineProps({ | ||
data: { | ||
type: Object, | ||
default: () => ({}), | ||
}, | ||
}); | ||
const emit = defineEmits(['update:data']); | ||
const code = ref(props.data.code); | ||
const showCodeModal = ref(false); | ||
function updateData(value) { | ||
emit('update:data', { ...props.data, ...value }); | ||
} | ||
watch(code, (value) => { | ||
updateData({ code: value }); | ||
}); | ||
</script> | ||
<style scoped> | ||
code { | ||
@apply bg-gray-900 text-sm text-white p-1 rounded-md; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.