Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ui/analyse/css/study/_modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,9 @@
@extend %break-word-hard, %ellipsis;
max-width: 100%;
}
.preview-in-editor {
float: right;
margin-top: 0.2em;
}
}
}
24 changes: 19 additions & 5 deletions ui/analyse/src/study/chapterNewForm.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { parseFen } from 'chessops/fen';
import { defined, prop, Prop, toggle } from 'common';
import * as licon from 'common/licon';
import { bind, bindSubmit, onInsert, looseH as h } from 'common/snabbdom';
import { bind, bindSubmit, onInsert, looseH as h, dataIcon } from 'common/snabbdom';
import { storedProp } from 'common/storage';
import * as xhr from 'common/xhr';
import { VNode } from 'snabbdom';
Expand Down Expand Up @@ -237,14 +237,28 @@ export function view(ctrl: StudyChapterNewForm): VNode {
activeTab === 'fen' &&
h('div.form-group', [
h('input#chapter-fen.form-control', {
attrs: { value: ctrl.root.node.fen, placeholder: noarg('loadAPositionFromFen') },
attrs: {
value: ctrl.root.node.fen,
placeholder: noarg('loadAPositionFromFen'),
spellcheck: 'false',
},
hook: onInsert((el: HTMLInputElement) => {
el.addEventListener('change', () => el.reportValidity());
el.addEventListener('input', _ =>
el.setCustomValidity(parseFen(el.value.trim()).isOk ? '' : 'Invalid FEN'),
);
el.addEventListener('input', _ => {
if (parseFen(el.value.trim()).isOk) {
el.setCustomValidity('');
ctrl.root.node.fen = el.value;
} else el.setCustomValidity('Invalid FEN');
});
}),
}),
h(
'a.preview-in-editor',
{
hook: bind('click', () => ctrl.tab('edit'), ctrl.root.redraw),
},
[h('i.text', { attrs: dataIcon(licon.Eye) }), noarg('editor')],
),
]),
activeTab === 'pgn' &&
h('div.form-group', [
Expand Down