Coder Social home page Coder Social logo

evitanrelta / markgh Goto Github PK

View Code? Open in Web Editor NEW
12.0 1.0 3.0 19.3 MB

Online WYSIWYG GFM editor. Same look as Github's markdown. Supports HTML-in-Markdown feat. (eg. center-align/superscript/underline)

Home Page: https://evitanrelta.github.io/markgh

HTML 3.88% TypeScript 94.46% JavaScript 1.39% CSS 0.27%
editor gfm html-to-markdown markdown wysiwyg wysiwyg-editor

markgh's Introduction

MarkGH

Online markdown editor for 

  • Avoid writing raw markdown
  • Edit it like a Word document

Hide this HTML-Markdown mess:

<h1 align="center">
  MarkGH <img src="./assets/github_logo.png" height="30" />
</h1>

Online markdown editor for&nbsp; <img src="./assets/github_logo.png" height="25" />

*   Avoid writing **_raw markdown_**
*   Edit it like a **_Word document_**

markgh's People

Contributors

evitanrelta avatar swxk19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

markgh's Issues

Unable to set `whiteSpace` style on `NodeViewContent`

NodeViewContent and NodeViewWrapper overrides the whiteSpace style, as shown:

return value of NodeViewContent:
image

Which prevents us from changing the whiteSpace styling:

image

Rendered HTML:
image

Which forces our text in codeblocks to wrap instead of having a horizontal overflow scrollbar:

image

Expected:
image

I've already submitted an issue (ueberdosis/tiptap#2883) on the TipTap repo, and a pull request (ueberdosis/tiptap#2884) to fix it.
But for now, we'll likely have to temporarily patch it on our side.

Importing `customCss` after `githubMarkdownCss` files & and removing `!important`

VSCode has updated their Typescript version, which added the feature to prevent organizing specific imports (like CSS overwriting files that needs to be imported last).

Quote from the Typescript PR:

when organizing imports in each block of newline-contiguous
import c from "C";

import d from "D";
import a from "A";
import b from "B";

turns into

import c from "C";

import a from "A";
import b from "B";
import d from "D";

Thus, we can now properly import the customCss files after the githubMarkdownCss files, and remove unnecessary !important CSS property that was previously needed.

Incorrect syntax-highlight coloring

Left: Expected coloring
Right: What's rendered

image

Its's caused by hljs adding both hljs-tag and hljs-attr to the same element, which causes them to override each other's CSS
image

image

Setup Github Actions to publish via "gh-pages"

We should create a published branch that when receiving a new push, will automatically build & publish it via gh-pages using Github Actions workflow.

Since, currently, the site is published (via gh-pages) from any branch/commits (basically whenever we feel like it), without any documentation on which commit the published site is using, having a dedicated published branch will also document which commits are included in the published Github Page.

Add support for tables

  • Add TipTap extensions for tables
  • Allow attributes (eg. align, width, height) on table elements
  • Basic conversion to markdown
  • Pretty formatting of markdown tables, by aligning the columns:
    | Left Header | Right Header |
    | ----------- | ------------ |
    | left | a |
    | asd | aaaaaa |
  • Convert to HTML-syntax when table elements has unsupported attributes
  • Convert to HTML-syntax when table has unsupported elements (eg. codeblocks)
  • Properly convert cell contents (currently gets contents via cell.innerText which doesn't have any formatting)
  • If entire column has same align, use GFM table align syntax:
    | Left-aligned | Center-aligned | Right-aligned |
    | :--- | :---: | ---: |
    | git status | git status | git status |
    | git diff | git diff | git diff |
  • Add buttons for adding/formatting tables
  • Allow setting alignment of entire column in TipTap

Replace TipTap's TextAlign's inline style with "align" attribute

Currently, TipTap's TextAlign extension sets alignment using inline styles, as shown:


But since Github's markdown uses the align attribute (eg. <h1 align="center">) instead, perhaps extending the TextAlign extension to use align attribute too would be easier on the HTML-to-Markdown converter.

Temporary fix for #8

For now, #8 can be fixed by applying the below CSS to every BulletList / OrderedList TipTap node.

.markdown-body ol.no-list-item-spacing > li > p,
.markdown-body ul.no-list-item-spacing > li > p {
    margin: 0 !important;
}

I've yet to figured out how to create an TipTap extension for the ol / ul element. I've only managed to add the classname to the li element in the fix-008-list-item-spacing branch.

Cannot type in codeblock

When creating a new codeblock, user is unable to type anything inside it, as shown:
cannot type codeblock

User needs to press Enter before being able to type. However, this problem seems to go away when disabling Github's markdown's CSS:
disable github css

A similar reported problem (ueberdosis/tiptap#728) also suggests that it's due to CSS.

Unable to type before codeblock

You cannot type outside and before a codeblock.
Meaning that if a codeblock is the first thing in the editor, and you want to type something before it, you'll need un-codeblock, type something before it, then codeblock the section agn.

cannot input before codeblock

Implement React-Redux

States such as the current markdown text, and the import-into-editor function is used in many components. Thus it'd be useful to abstract them out to a global store using Redux.

States to track using redux:

  • Editor object
  • Converted markdown text
  • Current color theme (eg. light mode, dark mode)
  • Github user details / authentication data

Redesign TipTap's buttons

Currently, the formatting buttons of TipTap are bareboned, as shown:
image


They need to be redesigned to icon-buttons, similar to Google Docs:
image


Or like QuillJS:
image

Reloading clears language input of 1st codeblock

Reloading the webpage clears the syntax-language input box.
Only happens to the first codeblock, as its likely due to React reusing the codeblock element, and not unmounting-remounting the element.
reloading clears language input

Allow elements in Tiptap's code blocks

Elements (like images) aren't allowed in Tiptip editor's codeblocks, but can be added to Github's markdown using HTML syntax

Like this:


Thus, it should be allowed in the editor.

Switching editor lib as QuillJS is dead

QuillJS hasn't had any release since 2019. A few of their recent pull-request have been approved (indicating some activity), but there's currently 1.1k open issues (indicating the repo isn't well-maintained) and there's no release date for the next version (v2.0.0). There's also many Issues on their Github asking if QuillJS is dead (eg. 1, 2, 3, 4)

The documentation for customisation is also IMO lacking.

There's also features that we need (eg. image resizing, insert image via URL, nested codeblocks/quotes, set language for syntax highlighting etc.) that QuillJS doesn't support; and many 3rd-party QuillJS modules that implements those feats. (eg. quill-image-resize-module) are outdated and don't work anymore.

Thus, we should switch our rich-text editor library. Some libraries were suggested on a QuillJS's issue, including:

Misleading Github language-type

Currently, according to Github, the majority of the code is CSS. Which might be a bit misleading since this is suppose to be a JS/Typescript/React project.

Perhaps, we could move the Github CSS files (the biggest CSS files) to another repo, so that this repo will be labeled as a Typescript project?

Or somehow ignore them in Github's language statistics?

image

Replace anonymous `default` export with named exported

Typescript keeps warning about anonymous default exports.
image

Anonymous default exports also has problems with being unable to declare the export type (microsoft/TypeScript#13626).

And Typescript might not be able to infer the export type too:
image


Thus, we should replace them with named export. From this:

import Code from '@tiptap/extension-code'

export default Code.extend({ excludes: '' })

To this:

import Code from '@tiptap/extension-code'

export const CodeNoExcludes = Code.extend({ excludes: '' })

No selection-highlight on Tiptap images

Attempting to drag-highlight images on TipTap editor doesn't highlight the image (but highlights the surrounding text).
Though, if you try copy-pasting it, it will copy the image.

Mentioned on this TipTap Github Issue


no selection-highlight on images

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.