Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix merge conflicts for Markdown Syntax PR from Xavier Leune #3181

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"prettier/prettier": [
"error",
{
"singleQuote": true
"singleQuote": true,
"endOfLine": "auto"
}
],
"react/display-name": "warn",
Expand Down
23 changes: 13 additions & 10 deletions .github/ISSUE_TEMPLATE/---bug-report.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
---
name: "\U0001F41E Bug Report"
about: "Report a bug if something isn't working as expected in the Windows, Linux, or Web Simplenote app."
title: ""
title: ''
labels: bug
assignees: ""
assignees: ''
---

<!-- IMPORTANT NOTE: Do not share any private information here. GitHub issues are public, including any screenshots or files uploaded to this issue. For assistance troubleshooting account-related questions, please contact us at [email protected]. -->

<!-- Please, be as descriptive as possible. Issues lacking detail, or for any other reason than to report a bug, may be closed without action. -->

### Expected

<!-- ***(Required)*** Add a concise description of what you expected. -->

### Observed

<!-- ***(Required)*** Add a concise description of what you observed. -->

### Reproduced

<!--
***(Required)*** If you cannot reproduce this bug consistently, please elaborate. List the steps to reproduce the behavior. For example:
***(Required)*** If you cannot reproduce this bug consistently, please elaborate. List the steps to reproduce the behavior. For example:
1. Go to...
2. Click on...
3. See error...
-->

1.
2.
3.
1. 2. 3.

<!-- ***(Optional)*** If applicable, add screenshots, animations, or videos to help illustrate your problem. -->

### Where did you see the bug

<!-- ***(Required)*** -->

- System Make:
- System Model:
- OS:
- OS version:
- Browser (if applicable):
- Browser version (if applicable):
- Simplenote app version:
- OS version:
- Browser (if applicable):
- Browser version (if applicable):
- Simplenote app version:
9 changes: 6 additions & 3 deletions .github/ISSUE_TEMPLATE/---feature-request.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
name: "\U0001F680 Feature Request"
about: "Suggest a new feature or enhancement to an existing one in the Simplenote Electron app."
title: ""
about: 'Suggest a new feature or enhancement to an existing one in the Simplenote Electron app.'
title: ''
labels: feature request
assignees: ""
assignees: ''
---

<!-- IMPORTANT NOTE: Do not share any private information here. GitHub issues are public, including any screenshots or files uploaded to this issue. For assistance troubleshooting account-related questions, please contact us at [email protected]. -->

<!-- Please, be as descriptive as possible. Issues lacking detail, or for any other reason than to request a feature, may be closed without action. -->

### What

<!-- ***(Required)*** What is the feature you are requesting? Add a concise description of the feature being requested. -->

### Why

<!-- ***(Required)*** Why are you requesting this feature? Add a concise description of the problem this feature solves. -->

### How

<!-- ***(Optional)*** If applicable, add screenshots, animations, or videos to help illustrate how the feature could be done. -->
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ A Simplenote [React](https://reactjs.org/) client packaged in [Electron](https:/
6. For all logging from Electron to be printed to the terminal (e.g. `console.log` statements within `app.js`), you might need to set `env ELECTRON_ENABLE_LOGGING=1`.
7. Sign up for a new account within the app. Use the account for **testing purposes only** as all note data will be periodically cleared out on the server.

_Note: Simplenote API features such as sharing and publishing will not work with development builds. Due to a limitation of `make` installation paths used for build cannot have spaces._
_Note: Simplenote API features such as sharing and publishing will not work with development builds. Due to a limitation of `make` installation paths used for build cannot have spaces. You also need nodejs 12 max to get this app built._

## Building

Expand Down
49 changes: 33 additions & 16 deletions lib/note-content-editor.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable prettier/prettier */
import React, { Component, createRef } from 'react';
import { connect } from 'react-redux';
import Monaco, {
Expand All @@ -12,18 +13,14 @@ import {
Selection,
SelectionDirection,
} from 'monaco-editor';
import * as monacoactions from 'monaco-editor/esm/vs/platform/actions/common/actions';
import { MenuRegistry } from 'monaco-editor/esm/vs/platform/actions/common/actions';

import { searchNotes, tagsFromSearch } from './search';
import actions from './state/actions';
import * as selectors from './state/selectors';
import { getTerms } from './utils/filter-notes';
import { noteTitleAndPreview } from './utils/note-utils';
import {
clearNotePositions,
getNotePosition,
setNotePosition,
} from './utils/note-scroll-position';
import { noteTitleAndPreview, isMarkdown } from './utils/note-utils';
import * as noteScrollPosition from './utils/note-scroll-position';
import { isMac, isSafari } from './utils/platform';
import {
withCheckboxCharacters,
Expand All @@ -32,6 +29,7 @@ import {

import * as S from './state';
import * as T from './types';
import { Note } from './types';

const SPEED_DELAY = 120;

Expand Down Expand Up @@ -179,7 +177,7 @@ class NoteContentEditor extends Component<Props> {
editor: 'full',
content: withCheckboxCharacters(this.props.note.content),
});
const position = getNotePosition(noteId);
const position = noteScrollPosition.getNotePosition(noteId);
if (position) {
this.editor?.setScrollPosition({
scrollTop: position,
Expand All @@ -190,12 +188,12 @@ class NoteContentEditor extends Component<Props> {
this.focusEditor();
this.props.storeFocusEditor(this.focusEditor);
this.props.storeHasFocus(this.hasFocus);
window.addEventListener('resize', clearNotePositions);
window.addEventListener('resize', noteScrollPosition.clearNotePositions);
window.addEventListener('toggleChecklist', this.handleChecklist, true);
this.toggleShortcuts(true);

/* remove unwanted context menu items */
const menus = monacoactions.MenuRegistry._menuItems;
const menus = MenuRegistry._menuItems;
const contextMenuEntry = [...menus].find(
(entry) => entry[0]._debugName === 'EditorContext'
);
Expand All @@ -220,15 +218,22 @@ class NoteContentEditor extends Component<Props> {
}

componentWillUnmount() {
setNotePosition(this.props.noteId, this.editor?.getScrollTop() ?? 0);
noteScrollPosition.setNotePosition(
this.props.noteId,
this.editor?.getScrollTop() ?? 0
);

if (this.bootTimer) {
clearTimeout(this.bootTimer);
}
window.electron?.removeListener('editorCommand');
window.removeEventListener('input', this.handleUndoRedo, true);
window.removeEventListener('toggleChecklist', this.handleChecklist, true);
window.removeEventListener('resize', clearNotePositions, true);
window.removeEventListener(
'resize',
noteScrollPosition.clearNotePositions,
true
);
this.toggleShortcuts(false);
}

Expand Down Expand Up @@ -576,7 +581,19 @@ class NoteContentEditor extends Component<Props> {
Editor.defineTheme('simplenote', {
base: 'vs',
inherit: true,
rules: [{ background: 'FFFFFF', foreground: '#2c3338' }],
rules: [
{ background: 'FFFFFF', foreground: '#2c3338' },
{ token: 'keyword.md', foreground: '#2c3338', fontStyle: 'bold' },
{ token: 'variable.source' },
{ token: 'string.md', background: '#fdf6e3', foreground: '#657b83' },
{ token: 'comment.md', foreground: '#a7aaad' },
{ token: 'keyword.table', foreground: '#a7aaad' },
{
token: 'keyword.table.header',
foreground: '#2c3338',
fontStyle: 'bold',
},
],
colors: {
'editor.foreground': '#2c3338', // $studio-gray-80
'editor.background': '#ffffff',
Expand Down Expand Up @@ -1177,7 +1194,7 @@ class NoteContentEditor extends Component<Props> {
};

render() {
const { lineLength, noteId, searchQuery, theme } = this.props;
const { lineLength, noteId, searchQuery, theme, note } = this.props;
const { content, editor, overTodo } = this.state;
const searchMatches = searchQuery ? this.searchMatches() : [];

Expand Down Expand Up @@ -1206,7 +1223,7 @@ class NoteContentEditor extends Component<Props> {
key={noteId}
editorDidMount={this.editorReady}
editorWillMount={this.editorInit}
language="plaintext"
language={isMarkdown(note) ? 'markdown' : 'plaintext'}
theme={theme === 'dark' ? 'simplenote-dark' : 'simplenote'}
onChange={this.updateNote}
options={{
Expand All @@ -1225,7 +1242,7 @@ class NoteContentEditor extends Component<Props> {
lineHeight: 24,
lineNumbers: 'off',
links: true,
matchBrackets: 'never',
matchBrackets: isMarkdown(note) ? 'always' : 'never',
minimap: { enabled: false },
occurrencesHighlight: false,
overviewRulerBorder: false,
Expand Down
4 changes: 4 additions & 0 deletions lib/utils/note-scroll-position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ const getAllPositions = (): notePositions => {
}
return currentSavedPositions;
};

export function isMarkdown(note: Note) {
throw new Error('Function not implemented.');
}
2 changes: 1 addition & 1 deletion lib/utils/note-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const noteTitleAndPreview = (
return result;
};

function isMarkdown(note: T.Note): boolean {
export function isMarkdown(note: T.Note): boolean {
return note.systemTags.includes('markdown');
}

Expand Down
Loading