feat: use stylekit fonts for the editor

This commit is contained in:
Baptiste Grob
2021-02-10 10:42:45 +01:00
parent 841077ce21
commit 5cb3bbf435
4 changed files with 14 additions and 19 deletions

View File

@@ -209,7 +209,7 @@
on-load='self.onEditorLoad', on-load='self.onEditorLoad',
application='self.application' application='self.application'
) )
textarea#note-text-editor.editable( textarea#note-text-editor.editable.font-editor(
dir='auto', dir='auto',
ng-attr-spellcheck='{{self.state.spellcheck}}', ng-attr-spellcheck='{{self.state.spellcheck}}',
ng-change='self.contentChanged()', ng-change='self.contentChanged()',

View File

@@ -47,11 +47,6 @@ const ElementIds = {
EditorContent: 'editor-content', EditorContent: 'editor-content',
NoteTagsComponentContainer: 'note-tags-component-container' NoteTagsComponentContainer: 'note-tags-component-container'
}; };
const Fonts = {
DesktopMonospaceFamily: `Menlo,Consolas,'DejaVu Sans Mono',monospace`,
WebMonospaceFamily: `monospace`,
SansSerifFamily: `inherit`
};
type NoteStatus = { type NoteStatus = {
message?: string message?: string
@@ -945,20 +940,18 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
} }
reloadFont() { reloadFont() {
const editor = document.getElementById( const root = document.querySelector(':root') as HTMLElement;
ElementIds.NoteTextEditor const propertyName = '--sn-stylekit-editor-font-family';
);
if (!editor) {
return;
}
if (this.state.monospaceFont) { if (this.state.monospaceFont) {
if (this.state.isDesktop) { root.style.setProperty(
editor.style.fontFamily = Fonts.DesktopMonospaceFamily; propertyName,
} else { 'var(--sn-stylekit-monospace-font)'
editor.style.fontFamily = Fonts.WebMonospaceFamily; );
}
} else { } else {
editor.style.fontFamily = Fonts.SansSerifFamily; root.style.setProperty(
propertyName,
'var(--sn-stylekit-sans-serif-font)'
);
} }
} }

View File

@@ -144,7 +144,6 @@ $heading-height: 75px;
} }
.editable { .editable {
font-family: monospace;
overflow-y: scroll; overflow-y: scroll;
width: 100%; width: 100%;
background-color: var(--sn-stylekit-editor-background-color); background-color: var(--sn-stylekit-editor-background-color);

View File

@@ -172,6 +172,9 @@ $screen-md-max: ($screen-lg-min - 1) !default;
fill: currentColor; fill: currentColor;
} }
.font-editor {
font-family: var(--sn-stylekit-editor-font-family);
}
.font-semibold { .font-semibold {
font-weight: 600 !important; font-weight: 600 !important;
} }