Skip to content

Commit

Permalink
feat: use stylekit fonts for the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
arielsvg committed Feb 10, 2021
1 parent 841077c commit 5cb3bbf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/views/editor/editor-view.pug
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
on-load='self.onEditorLoad',
application='self.application'
)
textarea#note-text-editor.editable(
textarea#note-text-editor.editable.font-editor(
dir='auto',
ng-attr-spellcheck='{{self.state.spellcheck}}',
ng-change='self.contentChanged()',
Expand Down
27 changes: 10 additions & 17 deletions app/assets/javascripts/views/editor/editor_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ const ElementIds = {
EditorContent: 'editor-content',
NoteTagsComponentContainer: 'note-tags-component-container'
};
const Fonts = {
DesktopMonospaceFamily: `Menlo,Consolas,'DejaVu Sans Mono',monospace`,
WebMonospaceFamily: `monospace`,
SansSerifFamily: `inherit`
};

type NoteStatus = {
message?: string
Expand Down Expand Up @@ -945,20 +940,18 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
}

reloadFont() {
const editor = document.getElementById(
ElementIds.NoteTextEditor
);
if (!editor) {
return;
}
const root = document.querySelector(':root') as HTMLElement;
const propertyName = '--sn-stylekit-editor-font-family';
if (this.state.monospaceFont) {
if (this.state.isDesktop) {
editor.style.fontFamily = Fonts.DesktopMonospaceFamily;
} else {
editor.style.fontFamily = Fonts.WebMonospaceFamily;
}
root.style.setProperty(
propertyName,
'var(--sn-stylekit-monospace-font)'
);
} else {
editor.style.fontFamily = Fonts.SansSerifFamily;
root.style.setProperty(
propertyName,
'var(--sn-stylekit-sans-serif-font)'
);
}
}

Expand Down
1 change: 0 additions & 1 deletion app/assets/stylesheets/_editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ $heading-height: 75px;
}

.editable {
font-family: monospace;
overflow-y: scroll;
width: 100%;
background-color: var(--sn-stylekit-editor-background-color);
Expand Down
3 changes: 3 additions & 0 deletions app/assets/stylesheets/_ui.scss
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ $screen-md-max: ($screen-lg-min - 1) !default;
fill: currentColor;
}

.font-editor {
font-family: var(--sn-stylekit-editor-font-family);
}
.font-semibold {
font-weight: 600 !important;
}
Expand Down

0 comments on commit 5cb3bbf

Please sign in to comment.