Commit graph

144 commits

Author SHA1 Message Date
Philip Molares
c410a58573
Add emoji picker (#329)
* Added emoji-mart as emoji-picker
* Fixed JSON to TypeScript-object parsing
* added fork awesome to emoji-picker
added ForkAwesomeIcons enum, because it's not possible to iterate over a typescript type consisting of strings [1]. This is a bit unfortunate since we now have two lists of all the fork awesome icons, but sadly it can not be done another way.
added fork awesome as a custom category to the emoji picker.

[1]: https://stackoverflow.com/questions/40863488/how-to-iterate-over-a-custom-literal-type-in-typescript
* made picker close, when clicking away
added react-use dependency for useClickAway hook
* Fixed emoji-picker loading images from unpkg instead of using font
* fixed addEmoji function
added tests
* Extract customIcons into useMemo

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
Co-authored-by: Erik Michelson <github@erik.michelson.eu>
Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-08-07 18:54:37 +02:00
Philip Molares
fc2e2bd592
Add codemirror keybindings and addons (#311)
* added codemirror addons
- fullScreen
- autorefresh
added a default:
- extraKeys

Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
Co-authored-by: mrdrogdrog <mr.drogdrog@gmail.com>
Co-authored-by: Erik Michelson <github@erik.michelson.eu>
2020-08-06 13:43:48 +02:00
Erik Michelson
dbce0181a4
Add register via username and refactor email-login to username-login (#313)
* Added config option to enable/disable the email signup

* Added register API call

* Added register button and error handling

* Show register button only if enabled in config

* Renamed login handler, added dir-attribute, removed obsolete css class

* Added separate registration page, changed email-login to internal-login

As an username is sufficient for registration, this commit changes the email-login into an username-based login. This login method is now called "internal" in the code.
This commit also introduces a new registration page instead of using the same form as for login.

* Added information texts below form fields

* Added error differentiation

* Added CHANGELOG entry

* Replace "magic string" with Enum representation

* Removed password-field to DOM rewrite

With the value attribute set, the password would be written to the DOM while typing. That's bad practise as attackers could read that password (e.g. with dirty CSS-hacks).

* Fixed backendConfig to config renaming

* Fixed links on register page being external links

* Refactored error handling to use string-enum that corresponds with i18n keys

* Fix chrome warnings regarding autocomplete and duplicated id

* Refactor login action buttons to use callbacks and handle promises directly

* Remove unnecessary async function

* Added promise chaining
2020-08-04 23:13:12 +02:00
Jakob Klepp
fe2f7403aa
Add plantuml support (#327)
* Add plantuml support
* Enable PlantUML rendering only if plantumlServer config is set
* Show warning box when plantuml is enabled but no server is configured
2020-08-04 11:15:23 +02:00
Erik Michelson
c21503848f
Fix me-API-request to use fetch-config and API-path (#381)
* Move mocked me-API-response into API dir

* Update me-API request to use API path and fetch-config
2020-08-03 23:40:04 +02:00
mrdrogdrog
57baf2fab5
Add key to image replacer (#379)
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-08-03 20:06:57 +02:00
mrdrogdrog
512bca02e7
Improve css in preparation for the sync scroll (#380)
* Improve css in preparation for the sync scroll

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* Remove scroll behaviour

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-08-03 20:06:32 +02:00
Tilman Vatteroth
4356d39ea7 Move editor test content into separate file
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-07-30 22:08:54 +02:00
Philip Molares
d0fc96b929
rework how the frontend is started (#361)
renamed frontend-config to api-url
renamed backend-config to config
removed api call to set frontend-config as the frontend either know where the backend is as it is delivered by it or get's this information via the enviroment variable REACT_APP_BACKEND
always start the client on Port 3001 as the backend will run on 3000 during development. changed the port on multiple occasions to accommodate for this
added package.json script 'start:dev'
changed README to better explain how to run backend and frontend side-by-side
2020-07-29 22:58:01 +02:00
Tilman Vatteroth
287d2e2729 Use twemoji in editor
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-07-29 22:55:13 +02:00
Erik Michelson
9c19bb1d9d
Add support for image-proxies by (optional) piping of image urls through the backend (#315)
* Added config property for image proxies

* Added API call and image url replacing

* Added comment explaining why a local function is needed inside the useEffect

* Added CHANGELOG entry

* Changed wording of the CHANGELOG sentence

* Changed CHANGELOG entry

Co-Authored-By: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* Removed fallback to original src

* Removed unnecessary API call for empty src URLs

* Simplify image url fetching

* Refactored imageframe to avoid rerendering of images

Co-Authored-By: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* Renamed config property to useImageProxy

Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-07-29 22:28:32 +02:00
Tilman Vatteroth
742c6c1efb Add key prop to asciinema
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-07-21 21:16:55 +02:00
Philip Molares
29709d2ba4
Add YAML-metadata for notes and change the document title accordingly (#310)
* Added yaml-frontmatter extracting and error handling
* add tests
* changed document-title, so the editor can change the title to the title of the yaml metadata. closes #303
* extracted first line parsing in a core rule of markdown-it
document title will now be determined like this:
1. yaml metadata title
2. opengraph title
3. first level one heading
4. 'Untitled'
* added documentTitle e2e test

Co-authored-by: Erik Michelson <github@erik.michelson.eu>
Co-authored-by: Philip Molares <philip@mauricedoepke.de>
Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
Co-authored-by: mrdrogdrog <mr.drogdrog@gmail.com>
2020-07-18 22:17:36 +02:00
Erik Michelson
8216958f91
Add Asciinema integration (#326)
* Added Asciinema integration

* Added CHANGELOG entry
2020-07-16 22:14:47 +02:00
Philip Molares
1b52bac838
readd toolbar (#302)
* added all functionality to the toolbar buttons
* added unit tests for the toolbar functions
* added unit tests to CI
* Added translated titles to buttons of toolbar

Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
Co-authored-by: mrdrogdrog <mr.drogdrog@gmail.com>
Co-authored-by: Erik Michelson <github@erik.michelson.eu>
2020-07-16 11:34:56 +02:00
Philip Molares
f0fe7f5ac2
added e2e tests (#298)
- added e2e tests for
  - banner
  - history
  - intro
  - language
  - link
- added e2e workflow
- added cypress badge to README
2020-07-16 11:22:53 +02:00
renovate[bot]
1a5d4f6db8
Update dependency react-bootstrap to v1.2.1 (#320)
* Update dependency react-bootstrap to v1.2.1

* Fixed sort-button event name

With the upgrade to Bootstrap-React 1.2.1 the ButtonProps extend now React.HTMLAttributes which in favor extends the DOMAttributes interface. This interface defines almost every possible attribute for DOM-/HTML-elements.

Our SortButtonProps interface introduced an onChange event handler with a type matching our condition. With the BS-React upgrade the onChange event must not be redefined/overriden with this type and therefore I renamed it.

* updated react-bootstrap to 1.2.2

* fixed wrong prop name in HistoryToolbar

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Erik Michelson <github@erik.michelson.eu>
Co-authored-by: Philip Molares <philip.molares@udo.edu>
2020-07-15 23:34:34 +02:00
Tilman Vatteroth
bee715b8f9 Remove log message and fix null check
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-07-02 23:17:16 +02:00
Erik Michelson
e1e8a76fda
Add note deletion and removal from history modals (#299)
* Fix history element's entry menu deletion button

The note deletion button inside the EntryMenu of a history element has one button to remove the note from the user's history and one to delete the note from the system. Both buttons pointed to the history-removal.

* Added modals for note deletion and note from history removal

* Removed redundant code

* Added CHANGELOG entry

* Added note title in deletion/removal prompts

* Refactored DeleteNoteItem and RemoveNoteEntryItem into one common component

* Refactored DeleteRemoveNoteItem-component and added two composition components

* Redesigned modal dialog to make the note title more clearly readable

* Renamed the generic dropdown-with-deletion-modal-component
2020-07-01 23:28:49 +02:00
Philip Molares
b23a73ac51
added branding option (#301)
added branding option via '@ <logo>' or '@ <name>' after the CodiMD logo and text.

This was a user can personalize their CodiMD instance

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
Co-authored-by: Erik Michelson <github@erik.michelson.eu>
Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-07-01 23:20:00 +02:00
mrdrogdrog
50b04c8403
Add toc sidebar+dropdown (#272)
* Replace markdown-it-table-of-contents with markdown-it-toc-done-right

Co-authored-by: Erik Michelson <github@erik.michelson.eu>
Co-authored-by: Philip Molares <philip.molares@udo.edu>

Extract render window code

Co-authored-by: Erik Michelson <github@erik.michelson.eu>
Co-authored-by: Philip Molares <philip.molares@udo.edu>

add new package

fix stickyness

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

show toc sidebar only if there is enough space

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* add min height class

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* Move markdown toc into own component

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* add sidebar buttons

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* Use other button color

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* Change name of component

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* Fix merge issues and make toc work again

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* pin dependencies

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* remove blank line

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* pin dependency

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* Fix anchors

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* Add use memo

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* Add change log entry for removal of custom slugify
2020-06-29 17:51:40 +02:00
Erik Michelson
8ab7776a82
Replace links to /features with /n/features (#297)
* Replaced links to /features with /n/features

It was discussed and agreed on that all notes should reside under the /n/ namespace in the future. Even if we want to redirect all pre-2.0-notes from the root namespace to the /n/ namespace, it might be better to set the internal links for the features page properly instead on relying on the redirect.

* Improved note placeholder text
2020-06-28 21:25:22 +02:00
Erik Michelson
d13adcc9c3
Refactoring of modals (#294)
* Refactored modals (added CommonModal and DeletionModal besides ErrorModal)

This change allows more code reusage by defining a common modal that has a translated title with an optional icon.

* Replace the eslint-hack with a proper TypeScript conform solution

Instead of asserting non-null and disabling eslint, the 'as ...'-syntax is used to convince the compiler that everything is fine.

* Improved property names and ShowIf-construct

* Fixed missing renamings
2020-06-28 00:00:05 +02:00
Philip Molares
fe55ef7e13 changed comment in markdown-renderer.scss file to explain why the usage of * is necessary
see https://github.com/codimd/react-client/pull/271#pullrequestreview-437942115
2020-06-27 11:23:22 +02:00
Erik Michelson
17cc691403
Fixed bug that two p-tags were encapsulated inside each other (#278)
* Fixed bug that two p-tags were encapsulated inside each other

This bug was introduced because the wider-possible-replacer replaced each element that was subject to be enlarged with a brand new p-surrounding. That surrounding got the key of the old (now inner) element and therefore casts an duplicate key exception.
This fix solves that problem by setting the 'wider-possible' class attribute directly on the selected tag instead of creating a surrounding.

* Removed unnecessary console log

* Optimized attribute assignment to not fail on elements without attribs

* Added comment describing the node.attribs assignment
2020-06-26 00:07:15 +02:00
Philip Molares
937a2e9eb9
View mode wider (#271)
made some components wider in View Mode
These objects include
- `<img>` alone in a paragraph
- `<codimd-youtube>`
- `<codimd-vimeo>`
- `<codimd-pdf>`

This can be toggled via the `wider` prop in `MarkdownRenderer`

Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-25 22:38:10 +02:00
Erik Michelson
0df90c1a2a
Added click-to-load text for pdf embeddings and general option for texts on the embedding preview (#277)
* Added possibility to add a text below the icon on the preview

* Changes naming of i18nKey argument

* Rebase fixes

* Show preview image only if defined
2020-06-25 22:29:09 +02:00
Philip Molares
1db1bcf248
added image-replacer (#273)
added image-replacer

this component replaces all `<img>`'s in the markdown-it output with an ImageFrame component. This enables us to implement image proxies and other per image customization in the future.

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-25 22:25:22 +02:00
mrdrogdrog
0a48fd0aa5
Change pdf embedding size when clicked (#275)
* Add activation callback to one-click-embedding
* use activation callback to change size of pdf

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-25 21:49:15 +02:00
Tilman Vatteroth
66602d98f4 Move fonts into subdirs
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-25 21:16:58 +02:00
Tilman Vatteroth
729144eca3 Add spaces to highlighted code regex
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-25 21:16:36 +02:00
mrdrogdrog
312c86e702
Add "start with line number" and "continue line number" syntax to highlighted code blocks (#267)
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-24 23:53:26 +02:00
mrdrogdrog
cdadc7b41a
Add a wrapper for linkify (#268)
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-24 23:52:45 +02:00
mrdrogdrog
b74bb8e71d
Restructure replacers (#266)
* Restructure replacers

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-23 23:04:51 +02:00
mrdrogdrog
eb56da7871
Restructure highlight code to enable line wrapping (#265)
* Restructure highlight code to enable line wrapping

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-23 22:09:56 +02:00
Erik Michelson
6bf214542e
Added image resizing support via markdown-it-imsize (#262) 2020-06-23 21:44:16 +02:00
Erik Michelson
6a808e76d9
Fixed TOC only showing up to 2 levels instead of 3 (#260) 2020-06-23 21:43:52 +02:00
mrdrogdrog
a03e341f22
Add unique key to highlight codeblock line numbers (#254)
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-23 00:46:22 +02:00
Philip Molares
8133d565cf
added mathjax (#250)
added markdown-it-mathjax

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
Co-authored-by: Philip Molares <philip@mauricedoepke.de>
Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-23 00:38:06 +02:00
Erik Michelson
9e6edb0aeb
Add blockquote extras ([name=...], [time=...], [color=...]) (#249)
* Added regexes to replace name and time extras

* Added [color=#abc] replacements inside of blockquotes

This works with the following "algorithm":
1. Transform any [color=]-Tags with a valid css color into a codimd-quote-options element.
2. While transforming blockquotes, check if one of their paragraphs contains a codimd-quote-options element. If multiple are found, only the first one will be used.
3. Remove the codimd-quote-options element and set the border-left-color of the blockquote appropriately.

* Added correct CSS styling of blockquote extras

* Added tag icon when [color=...] is used outside a blockquote

In version 1.6 of CodiMD the [color=...] tag renders a tag-icon in the specified color when used outside of a blockquote paragraph.

* Added changelog entry

* Flip if-else in quote-options for better readability

* Flip another if-else in quote-options for better readability
2020-06-22 23:37:20 +02:00
mrdrogdrog
e03da3bd76
Feature/highlightjs (#242)
* Add highlighting for code blocks

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-22 22:39:14 +02:00
mrdrogdrog
b3899cd1a5
Extract language codes into object (#246)
* Extract language codes into object
* Restructure language search so it would find more specific language codes first.

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-21 14:09:53 +02:00
Erik Michelson
fd378cf89b
Added TOC and anchors for headings (#243)
* Added TOC support and anchors for headings

* Moved @types/markdown-it-anchor from devDependencies to dependencies

* Add subnode renderer

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* Added node-replacer for toc generation

ul lists may not be nested inside a p element. Therefore replaces this replacer every p that has a div.table-of-contents inside of it with the div directly.

* Add index to replacer function

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* Add TOC to example code

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* Remove unused import

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* Removed unnecessary div wrapper of toc

* Fixed toc-renderer

Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-21 14:04:37 +02:00
Tilman Vatteroth
cb2ea5fa6e Add subnode renderer
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-21 12:04:38 +02:00
mrdrogdrog
7e9a828d44
Refactor video-util.ts and rename markdown-preview (#233)
* Refactor video-util.ts
* Rename markdown-preview to markdown-renderer and refactor some methods

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-20 21:05:24 +02:00
mrdrogdrog
5f4cc63eb4
Deduplicate code (#217)
* Deduplicate code

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-20 20:32:44 +02:00
Philip Molares
ab2a73c6a8 added support for markdown-it-footnote
this makes it possible to use footnotes
2020-06-20 20:26:27 +02:00
mrdrogdrog
2c81b746aa
Add Alerts (#234)
* Add alert banners

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-06-20 20:17:33 +02:00
Philip Molares
4852727f92
added support for markdown-it-abbr (#238)
this makes it possible to use abbreviations like these
```
*[HTML]: Hyper Text Markup Language
*[W3C]:  World Wide Web Consortium
The HTML specification
is maintained by the W3C.
```

Co-authored-by: Philip Molares <philip@mauricedoepke.de>
2020-06-20 19:29:46 +02:00
Philip Molares
09c21e4334
added support for markdown-it-deflist (#240)
this makes it possible to use definition lists like
```
Term 1

:   Definition 1
with lazy continuation.

Term 2 with *inline markup*

:   Definition 2

        { some code, part of Definition 2 }

    Third paragraph of definition 2.

_Compact style:_

Term 1
  ~ Definition 1

Term 2
  ~ Definition 2a
  ~ Definition 2b
```

Co-authored-by: Philip Molares <philip@mauricedoepke.de>
2020-06-20 19:25:31 +02:00