mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui: add fill to pretest button (#1109)
This commit is contained in:
1 parent
0f75f7ce36
commit
c1327a55a2
3 files changed
+33
No files matched your search
@@ -57,6 +57,12 @@ code
|
||||
border-radius: 0px !important
|
||||
background: none !important
|
||||
|
||||
.scratchpad-fill-button
|
||||
display: none
|
||||
|
||||
.mode--scratchpad .scratchpad-fill-button
|
||||
display: inline-block
|
||||
|
||||
.token.tab:not(:empty),
|
||||
.token.cr,
|
||||
.token.lf,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import $ from 'jquery';
|
||||
import Notification from 'vj/components/notification';
|
||||
import { AutoloadPage } from 'vj/misc/Page';
|
||||
import { i18n, tpl } from 'vj/utils';
|
||||
|
||||
@@ -33,6 +34,31 @@ const highlighterPage = new AutoloadPage('highlighterPage', () => {
|
||||
$output.parent().prepend($(tpl`<h2>${i18n('Sample Output')} ${id}</h2>`))
|
||||
.addClass('medium-6 columns sample').appendTo($c);
|
||||
}
|
||||
if ($root.find('.scratchpad-fill-button').length) return;
|
||||
const $toolbar = $root.find('.toolbar');
|
||||
const $button = $(tpl`
|
||||
<div class="toolbar-item scratchpad-fill-button">
|
||||
<a href="javascript:;">${i18n('Fill to Pretest')}</a>
|
||||
</div>
|
||||
`);
|
||||
$button.on('click', (e) => {
|
||||
const store = (window as any).store;
|
||||
if (!store) return;
|
||||
e.preventDefault();
|
||||
try {
|
||||
store.dispatch({
|
||||
type: 'SCRATCHPAD_PRETEST_DATA_CHANGE',
|
||||
payload: {
|
||||
type: 'input',
|
||||
value: $code.text(),
|
||||
},
|
||||
});
|
||||
Notification.success(i18n('Input filled to pretest!'), 2000);
|
||||
} catch (err) {
|
||||
Notification.error(i18n('Failed to fill input'));
|
||||
}
|
||||
});
|
||||
$toolbar.append($button);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user