Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Typescript Conversion #29

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Typescript Conversion #29

wants to merge 17 commits into from

Conversation

TheodoreChu
Copy link
Contributor

@TheodoreChu TheodoreChu commented Jun 12, 2020

Changes:

  • Update dependencies
  • Add watch and server commands
  • Convert .js to .tsx
  • Create tsconfig.json
  • Update webpack.config.js
  • Remove Component Manager, use EditorKit
  • Remove synchronized scrolling feature since it inhibits scrolling on split screen. Addresses Scrolling is choppy/stutters on iOS #18
  • Add spellcheck=true for Enable Spellcheck in Desktop App #19 and Spellcheck? #10
  • Update styling for tables Fixes Table background color #21
  • Update styling for pre and code
  • Slightly increase font size to 16px to improve accessibility
  • Fix line-height in textarea to match rendered text (1.5em). Addresses line-height issue #3
  • Update HTML metadata and code to HTML5 standards (checked with validator)
  • Convert var's to let and const
  • Convert functions to arrow functions
  • Remove usage of this for document.getElementById
  • Introduce semantic tags -- Convert <div> buttons to <buttons>
  • Introduced code splitting: React and React-dom are loaded separately, improving performance
  • Update README.md
  • Add keyMap for keyboard shortcuts
  • Refactored modes into enum types
  • Refactored custom preview updater to use editorKit
  • Add Prettier
  • Update Favicon

@TheodoreChu TheodoreChu requested a review from moughxyz June 12, 2020 07:47
app/components/Home.tsx Outdated Show resolved Hide resolved
app/components/Home.tsx Outdated Show resolved Hide resolved
app/components/Home.tsx Outdated Show resolved Hide resolved
app/components/Home.tsx Outdated Show resolved Hide resolved
app/components/Home.tsx Outdated Show resolved Hide resolved
app/components/Home.tsx Outdated Show resolved Hide resolved
app/components/Home.tsx Outdated Show resolved Hide resolved
app/components/Home.tsx Outdated Show resolved Hide resolved
app/components/Home.tsx Outdated Show resolved Hide resolved
app/index.html Outdated Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
@TheodoreChu TheodoreChu requested a review from moughxyz June 12, 2020 21:44
app/components/Home.tsx Outdated Show resolved Hide resolved
app/components/Home.tsx Outdated Show resolved Hide resolved
@moughxyz
Copy link
Member

It doesn't look like we're handling preview generation (related to EditorKit, not markdown editor):
https://github.com/standardnotes/editor-kit/blob/master/src/lib/EditorKitInternal.js#L212

https://github.com/sn-extensions/markdown-basic/blob/master/app/components/Home.js#L163

Previews related to what is shown in the two lines under the note title in the list of notes. Here we want to escape markdown syntax. This is why we render the content even if they are just in edit mode.

For example, if the user types "# hello" in the first line of the note, the preview in the list of notes in the SN interface should just say "hello".

preview.textContent || preview.innerText
);
return {
html: `<div>${previewText}</div>`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be returning either html or plain, but not both. Some editors use HTML, like the Task Editor, to generate rich previews, but this editor doesn't.

Copy link
Contributor Author

@TheodoreChu TheodoreChu Jul 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok. Why doesn't this editor use HTML? Why can't we return both html and plain? I referenced the Token Vault editor to write this code, which uses both html and plain: https://github.com/sn-extensions/token-vault/blob/master/app/components/Home.js#L57

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, you're right, it's possible to use both. This is because on web we support rich previews, but on mobile we need only plain reviews. But for Markdown documents, if you use # Hello in the first line, we don't want a huge header in your note preview. So that's why we want plain only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the huge header in the note preview is an issue here because we are only taking the textContent or innerText of the Preview HTML, so we're escaping all the HTML tags. See this reference: https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_node_textcontent_innerhtml_innertext

app/components/Home.tsx Outdated Show resolved Hide resolved
app/components/Home.tsx Outdated Show resolved Hide resolved
app/components/Home.tsx Outdated Show resolved Hide resolved
app/components/Home.tsx Outdated Show resolved Hide resolved
app/components/Home.tsx Outdated Show resolved Hide resolved
app/components/Home.tsx Outdated Show resolved Hide resolved
app/components/Home.tsx Outdated Show resolved Hide resolved
EditorContainer = 'editor-container',
Header = 'header',
Preview = 'preview',
SimpleMarkdown = 'simple-markdown',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is poorly named (probably pre-existing). We should take this chance to rename this to something that better describes what exactly this element is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you want to rename them? We'll probably need to change them in the CSS as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly is the element? If it's a container, it should be called that. If it's the root, it should be called that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly do you want renamed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change simple-markdown to root or preview to preview-container, but I think editor-container and header are pretty clear

app/stylesheets/main.scss Outdated Show resolved Hide resolved
app/stylesheets/main.scss Outdated Show resolved Hide resolved
app/stylesheets/main.scss Outdated Show resolved Hide resolved
app/stylesheets/main.scss Outdated Show resolved Hide resolved
webpack.config.js Outdated Show resolved Hide resolved
webpack.config.js Outdated Show resolved Hide resolved
tsconfig.json Outdated Show resolved Hide resolved
@TheodoreChu
Copy link
Contributor Author

When the PR is ready, feel free to delete Home.js

Wait what? You should delete this file as part of your PR if that's what constitutes a wholly complete code refactor.

I thought you might have wanted to do the honors of deleting Home.js. I deleted it: 3c26a08

@TheodoreChu TheodoreChu requested a review from moughxyz July 2, 2020 22:06
Copy link
Member

@moughxyz moughxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline comments.

@TheodoreChu TheodoreChu requested a review from moughxyz July 3, 2020 17:46
@moughxyz moughxyz requested a review from ningsongshen July 10, 2020 15:07
@moughxyz
Copy link
Member

@ningsongshen can you review this PR and test locally in SN env? Especially see if previews are being generated correctly (as in the 2-line preview that appears in SN under the note's title)

@ningsongshen
Copy link
Contributor

So I've just tested it (will look at the PR code a bit later), here are my comments:

  • I can only see one line of preview, whether it is on web or desktop or Windows or Linux
  • If there is nothing in the editor, the preview has null in it.
  • Links, headings, lists, tables, formatting, images, blockquotes, html, work fine (no formatting stuff in preview, as expected)

@moughxyz
Copy link
Member

I can only see one line of preview, whether it is on web or desktop or Windows or Linux

I think that's expected.

If there is nothing in the editor, the preview has null in it.

@TheodoreChu

@ningsongshen
Copy link
Contributor

ningsongshen commented Jul 14, 2020

EDIT: nevermind it is an error on my end. Note to self: use http not https

This didn't happen when I last tested it but now I can't seem to import the extension 😢

image

Copy link
Contributor

@ningsongshen ningsongshen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm no TS expert 😞 but things look okay and the editor is working 👍 for me.

new ExtractTextPlugin({ filename: './dist.css', disable: false, allChunks: true}),
new MiniCssExtractPlugin({
filename: 'dist.css',
}),
new webpack.DefinePlugin({
Copy link
Contributor

@ningsongshen ningsongshen Jul 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was updating the Bold Editor webpack config, I think that this is not needed in the later versions. (L47/64)

@ningsongshen
Copy link
Contributor

ningsongshen commented Aug 11, 2020

So Theodore requested some assistance finish up this PR but it's pretty big so I wanted to split it up into smaller parts that I can test and try it out to understand the changes (and for whoever is coming to work on this after me!)

  • update dependencies (including webpack)
  • docs, npm commands, readme, favicons
  • beautify/prettier code, es6, semantic tags, and html5
  • remove unnecessary/not great features
  • add requested and needed features
  • typescript conversion

@johnny243 johnny243 changed the base branch from master to main February 22, 2021 01:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table background color
3 participants