add load sample button

This commit is contained in:
Reorx 2023-02-05 16:19:21 +08:00
parent af4c6a6348
commit d0ecf537d9
3 changed files with 10 additions and 0 deletions

View File

@ -23,6 +23,7 @@
<button id="fn-new-data">New Data</button> <button id="fn-new-data">New Data</button>
<button id="fn-upload-data">Upload Data</button> <button id="fn-upload-data">Upload Data</button>
<input type="file" name="upload-data" style="display: none;"> <input type="file" name="upload-data" style="display: none;">
<button id="fn-load-sample">Load Sample</button>
</div> </div>
</div> </div>
<div class="middle column editor-container"></div> <div class="middle column editor-container"></div>

View File

@ -6,6 +6,7 @@ import objectPath from 'object-path';
import { JSONEditor } from '@json-editor/json-editor/dist/jsoneditor'; import { JSONEditor } from '@json-editor/json-editor/dist/jsoneditor';
import * as sampleModule from '../../sample.resume.json';
import { saveCVJSON } from '../lib/store'; import { saveCVJSON } from '../lib/store';
import { import {
createElement, createElement,
@ -150,6 +151,7 @@ const $btnUploadData = $('#fn-upload-data')
const $inputUploadData = $('input[name=upload-data]') const $inputUploadData = $('input[name=upload-data]')
const $btnDownloadJSON = $('#fn-download-json') const $btnDownloadJSON = $('#fn-download-json')
const $btnDownloadHTML = $('#fn-download-html') const $btnDownloadHTML = $('#fn-download-html')
const $btnLoadSample = $('#fn-load-sample')
$btnShowPreview.on('click', () => { $btnShowPreview.on('click', () => {
$outputJSON.hide() $outputJSON.hide()
@ -227,3 +229,9 @@ $btnDownloadJSON.on('click', () => {
$btnDownloadHTML.on('click', () => { $btnDownloadHTML.on('click', () => {
downloadCV('html') downloadCV('html')
}) })
$btnLoadSample.on('click', () => {
if (!confirm('Are you sure to load sample data? Your current data will be covered.')) return
editor.setValue(sampleModule.default)
})

View File

@ -63,6 +63,7 @@ body {
margin-bottom: var(--gap2); margin-bottom: var(--gap2);
border-bottom: 1px solid var(--grey-2); border-bottom: 1px solid var(--grey-2);
font-weight: 700; font-weight: 700;
user-select: none;
} }
.editor-toc { .editor-toc {