Skip to content

Commit 66e049a

Browse files
committed
Firefox doesn't support pasting
1 parent 8f82c2d commit 66e049a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/components/VisualEditor.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<p>You can start building your model by dragging collections, processes etc. from the left area and dropping them here.</p>
3333
<p>Alternatively, you can also import existing processes into the model builder:</p>
3434
<ul>
35-
<li>Paste the JSON from your clipboard by clicking <button type="button" @click="paste" title="Paste from clipboard"><i class="fas fa-paste"></i></button> or use <kbd>CTRL</kbd> + <kbd>V</kbd> (Windows, Linux) or <kbd>⌘</kbd> + <kbd>V</kbd> (MacOS) when the model builder is in focus.</li>
35+
<li v-if="canPaste">Paste the JSON from your clipboard by clicking <button type="button" @click="paste" title="Paste from clipboard"><i class="fas fa-paste"></i></button> or use <kbd>CTRL</kbd> + <kbd>V</kbd> (Windows, Linux) or <kbd>⌘</kbd> + <kbd>V</kbd> (MacOS) when the model builder is in focus.</li>
3636
<li>Drag and drop a JSON file from your computer</li>
3737
<li>Import a JSON file from your computer or another source such as the internet by clicking <button type="button" @click="importProcess" title="Import process from external source"><i class="fas fa-cloud-download-alt"></i></button></li>
3838
</ul>
@@ -134,6 +134,7 @@ export default {
134134
showHelpOverlay: this.showIntro,
135135
canUndo: false,
136136
canRedo: false,
137+
canPaste: false,
137138
compactMode: false,
138139
hasSelection: false,
139140
formula: null,
@@ -163,6 +164,9 @@ export default {
163164
}
164165
}
165166
},
167+
mounted() {
168+
this.canPaste = navigator && navigator.clipboard && typeof navigator.clipboard.readText === 'function';
169+
},
166170
methods: {
167171
...Utils.mapMutations('editor', ['setInitialNode']),
168172
commit(value) {
@@ -173,6 +177,9 @@ export default {
173177
this.$emit('input', value);
174178
},
175179
async paste() {
180+
if (!this.canPaste) {
181+
Utils.error(this, 'error', 'Pasting is not supported by your browser.');
182+
}
176183
try {
177184
const text = await navigator.clipboard.readText();
178185
let process = JSON.parse(text);

0 commit comments

Comments
 (0)