react-headless-mde 0.0.8 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js ADDED
@@ -0,0 +1,24 @@
1
+ module.exports = {
2
+ parser: '@typescript-eslint/parser',
3
+ parserOptions: {
4
+ ecmaVersion: 'latest',
5
+ sourceType: 'module',
6
+ project: ['./tsconfig.json'], // Specify it only for TypeScript files
7
+ },
8
+ settings: {
9
+ react: {
10
+ version: 'detect',
11
+ },
12
+ },
13
+ env: {
14
+ browser: true,
15
+ es2021: true,
16
+ },
17
+ extends: ['plugin:react/recommended', 'standard-with-typescript', 'plugin:prettier/recommended'],
18
+ overrides: [],
19
+ plugins: ['react', 'import', 'simple-import-sort'],
20
+ rules: {
21
+ '@typescript-eslint/strict-boolean-expressions': 0,
22
+ '@typescript-eslint/explicit-function-return-type': 0,
23
+ },
24
+ };
@@ -0,0 +1,23 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/ru/actions/quickstart
3
+
4
+ name: Publish with @next
5
+
6
+ on:
7
+ release:
8
+ types: [created]
9
+
10
+ jobs:
11
+ build-and-publish:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - uses: actions/setup-node@v3
16
+ with:
17
+ node-version: 18
18
+ registry-url: 'https://registry.npmjs.org'
19
+ - run: npm install
20
+ - run: npm run build
21
+ - run: npm publish --tag next
22
+ env:
23
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -1,11 +1,14 @@
1
1
  # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
2
+ # For more information see: https://docs.github.com/ru/actions/quickstart
3
3
 
4
- name: Publish to NPM
4
+ name: Publish
5
5
 
6
6
  on:
7
- release:
8
- types: [created]
7
+ push:
8
+ branches:
9
+ - 'main'
10
+ # release:
11
+ # types: [created]
9
12
 
10
13
  jobs:
11
14
  build-and-publish:
@@ -14,11 +17,10 @@ jobs:
14
17
  - uses: actions/checkout@v3
15
18
  - uses: actions/setup-node@v3
16
19
  with:
17
- node-version: 16
20
+ node-version: 18
18
21
  registry-url: 'https://registry.npmjs.org'
19
- - run: yarn install
20
- - run: yarn build
22
+ - run: npm install
23
+ - run: npm run build
21
24
  - run: npm publish
22
- # - run: npm publish --tag next
23
25
  env:
24
26
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ node_modules/.bin/lint-staged
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npm run check-types
package/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # Introduction
2
+
3
+ A simple yet powerful and extensible **React Markdown Editor** that aims to have feature parity with the Github Markdown editor.
4
+ React-mde-headless has no 3rd party dependencies.
5
+
6
+ ## [Demo](https://codesandbox.io/s/competent-jepsen-qyz51q?file=/src/index.tsx)
7
+
8
+ ## Installing
9
+
10
+ npm i react-headless-mde
11
+
12
+ ## Using
13
+
14
+ ```jsx
15
+ import { bold, italic, link, useTextAreaMarkdownEditor } from 'react-mde-headless';
16
+
17
+ export const MarkdownEditor = () => {
18
+ const { ref } = useTextAreaMarkdownEditor();
19
+
20
+ return (
21
+ <div className={'mb-4'}>
22
+ <div className={'mb-3 gap-1 flex flex-wrap'}>
23
+ <button onClick={bold}>B</button>
24
+ </div>
25
+
26
+ <textarea ref={ref} />
27
+ </div>
28
+ );
29
+ };
30
+ ```
31
+
32
+ ## Supported commands
33
+
34
+ - bold
35
+ - italic
36
+ - strikethrough
37
+ - headingLevel1
38
+ - headingLevel2
39
+ - headingLevel3
40
+ - headingLevel4
41
+ - headingLevel5
42
+ - headingLevel6
43
+ - link
44
+ - quote
45
+ - code
46
+ - codeBlock
47
+ - checkedList
48
+ - orderedList
49
+ - unorderedList
50
+ - image
51
+ - attachment
52
+
53
+ ## Todo
54
+
55
+ - Check execution on SSR (For example, Next.js) and, if necessary, regenerate eslint config, taking into account execution on node.js
56
+ - Add to awesome-react-headless-components on stable version https://github.com/jxom/awesome-react-headless-components
57
+ - peerDependencies React?
58
+ - heading undo
59
+
60
+ ### Third party
61
+
62
+ - https://github.com/grassator/insert-text-at-cursor by https://twitter.com/d_kubyshkin
63
+
64
+ ### XSS concerns
65
+
66
+ React-mde-headless does not automatically sanitize the HTML preview. If your using Showdown,
67
+ this has been taken from [their documentation](<https://github.com/showdownjs/showdown/wiki/Markdown's-XSS-Vulnerability-(and-how-to-mitigate-it)>):
68
+
69
+ > Cross-side scripting is a well known technique to gain access to private information of the users
70
+ > of a website. The attacker injects spurious HTML content (a script) on the web page which will read
71
+ > the user’s cookies and do something bad with it (like steal credentials). As a countermeasure,
72
+ > you should filter any suspicious content coming from user input. Showdown doesn’t include an
73
+ > XSS filter, so you must provide your own. But be careful in how you do it…
74
+
75
+ You might want to take a look at [showdown-xss-filter](https://github.com/VisionistInc/showdown-xss-filter).
76
+
77
+ ## Licence
78
+
79
+ React-mde-headless is [MIT licensed](https://github.com/andrerpena/react-mde/blob/master/LICENSE).
80
+
81
+ ## About the authors
82
+
83
+ Created by [André Pena](https://github.com/andrerpena). Maintained and developed by https://github.com/webbrother.