|
|
@@ -5,6 +5,8 @@
|
|
|
<setting-text name="editor" ref="editor" :json="true" />
|
|
|
<button v-text="i18n('buttonSave')" @click="onSave"></button>
|
|
|
<button v-text="i18n('buttonReset')" @click="onReset"></button>
|
|
|
+ <button v-text="i18n('buttonShowEditorState')" @click="toggleStateHint" />
|
|
|
+ <pre v-text="hint" class="monospace-font dim-hint" />
|
|
|
</section>
|
|
|
</template>
|
|
|
|
|
|
@@ -16,6 +18,9 @@ import SettingText from '#/common/ui/setting-text';
|
|
|
import defaults from '#/common/options-defaults';
|
|
|
|
|
|
export default {
|
|
|
+ data() {
|
|
|
+ return { hint: null };
|
|
|
+ },
|
|
|
components: {
|
|
|
SettingText,
|
|
|
},
|
|
|
@@ -37,6 +42,45 @@ export default {
|
|
|
const toggled = selection === 'false' && 'true' || selection === 'true' && 'false';
|
|
|
if (toggled) document.execCommand('insertText', false, toggled);
|
|
|
},
|
|
|
+ async toggleStateHint() {
|
|
|
+ if (this.hint) {
|
|
|
+ this.hint = null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const HIDE_OPTS = [
|
|
|
+ // we activate only one mode: js
|
|
|
+ 'mode',
|
|
|
+ // duh
|
|
|
+ 'value',
|
|
|
+ // these accept only a function
|
|
|
+ 'configureMouse',
|
|
|
+ 'lineNumberFormatter',
|
|
|
+ 'specialCharPlaceholder',
|
|
|
+ ];
|
|
|
+ const opts = {};
|
|
|
+ Object.entries({
|
|
|
+ ...(await import('codemirror')).defaults,
|
|
|
+ ...(await import('#/common/ui/code')).cmOptions,
|
|
|
+ ...options.get('editor'),
|
|
|
+ })
|
|
|
+ // sort by keys alphabetically to make it more readable
|
|
|
+ .sort(([a], [b]) => (a < b ? -1 : a > b))
|
|
|
+ .filter(([key, val]) => !HIDE_OPTS.includes(key) && typeof val !== 'function')
|
|
|
+ .forEach(([key, val]) => { opts[key] = val; });
|
|
|
+ this.hint = JSON.stringify(opts, null, ' ');
|
|
|
+ setTimeout(() => {
|
|
|
+ if (this.$el.getBoundingClientRect().bottom > window.innerHeight) {
|
|
|
+ this.$el.scrollIntoView({ behavior: 'smooth' });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
+
|
|
|
+<style>
|
|
|
+ .dim-hint {
|
|
|
+ font-size: .85rem;
|
|
|
+ color: gray;
|
|
|
+ }
|
|
|
+</style>
|