Skip to content

Commit 02d754f

Browse files
authored
Merge pull request #8 from steelydylan/hotfix/0.3.1
chore: vup to 1.3.1
2 parents 5a824b4 + 2253d2a commit 02d754f

File tree

8 files changed

+27
-10
lines changed

8 files changed

+27
-10
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ jobs:
2424
- name: install
2525
run: yarn --frozen-lockfile
2626
# まだtagがないバージョンなら、Git Tagをpushする
27+
- name: package-version
28+
run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV
2729
- name: package-version-to-git-tag
2830
uses: pkgdeps/action-package-version-to-git-tag@v1
2931
with:
3032
github_token: ${{ secrets.GITHUB_TOKEN }}
3133
github_repo: ${{ github.repository }}
3234
git_commit_sha: ${{ github.sha }}
3335
git_tag_prefix: ""
36+
version: ${{ env.PACKAGE_VERSION }}
3437
- name: get-npm-version
3538
id: package-version
3639
uses: martinbeentjes/npm-get-version-action@master

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ Not Yet
2424

2525
## Install
2626

27+
You should also import zenn-markdown-html as peer dependencies
28+
2729
```sh
28-
$ npm install react-split-mde --save
30+
$ npm install react-split-mde zenn-markdown-html --save
2931
```
3032

3133
## Usage
@@ -34,6 +36,7 @@ $ npm install react-split-mde --save
3436
import React, { useCallback, useState } from 'react';
3537
import { render } from 'react-dom';
3638
import { Editor, useProvider } from 'react-split-mde';
39+
import { parser } from 'react-split-mde/lib/parser';
3740
import 'react-split-mde/css/index.css';
3841

3942
const MDE = () => {
@@ -44,6 +47,7 @@ const MDE = () => {
4447

4548
return (
4649
<Editor
50+
parser={parser}
4751
value={markdown}
4852
onChange={handleValueChange}
4953
/>

demo/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from "react";
22
import { render } from "react-dom";
33
import { useProvider } from "../src/hooks";
44
import "../css/index.css";
5+
import { parser } from "../src/parser";
56
import { Editor, defaultCommands, EnterKey } from "../src";
67
import markdown from "./markdown.txt";
78

@@ -66,6 +67,7 @@ const Main = () => {
6667
</div>
6768
<div className="demo">
6869
<Editor
70+
parser={parser}
6971
value={value}
7072
onChange={handleValueChange}
7173
commands={{

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-split-mde",
3-
"version": "0.1.3",
3+
"version": "0.3.1",
44
"description": "",
55
"main": "./lib/index.js",
66
"types": "./lib/index.d.ts",
@@ -25,7 +25,9 @@
2525
"morphdom": "^2.6.1",
2626
"react-textarea-autosize": "^8.3.0",
2727
"use-eventmit": "^1.0.3",
28-
"xss": "^1.0.8",
28+
"xss": "^1.0.8"
29+
},
30+
"peerDependencies": {
2931
"zenn-markdown-html": "^0.1.70"
3032
},
3133
"devDependencies": {
@@ -54,6 +56,7 @@
5456
"webpack": "^4.43.0",
5557
"webpack-cli": "^3.3.11",
5658
"webpack-dev-server": "^3.11.0",
57-
"worker-loader": "^3.0.3"
59+
"worker-loader": "^3.0.3",
60+
"zenn-markdown-html": "^0.1.70"
5861
}
5962
}

src/commands/bulletList.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const generateSpace = (count: number) => {
1616
};
1717

1818
export const bulletList: Command = (target, option) => {
19-
const { lineAll } = option;
19+
const { lineAll, line } = option;
2020
const lineWithoutSpace = lineAll.replace(/^(\s*)/g, "");
2121
const spaces = lineAll.match(/^(\s*)/);
2222
let spaceLength = 0;
@@ -38,6 +38,9 @@ export const bulletList: Command = (target, option) => {
3838
if (option.metaKey || option.ctrlKey) {
3939
return { stop: true, change: false };
4040
}
41+
if (line.length === 0) {
42+
return { stop: false, change: true };
43+
}
4144
if (lineWithoutSpace.length > 2) {
4245
const text = startWithHyphen
4346
? `\n${generateSpace(spaceLength)}- `

src/commands/orderedList.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const generateSpace = (count: number) => {
1616
};
1717

1818
export const orderedList: Command = (target, option) => {
19-
const { lineAll } = option;
19+
const { lineAll, line } = option;
2020
const lineWithoutSpace = lineAll.replace(/^(\s*)/g, "");
2121
const spaces = lineAll.match(/^(\s*)/);
2222
let spaceLength = 0;
@@ -36,6 +36,9 @@ export const orderedList: Command = (target, option) => {
3636
if (option.ctrlKey || option.metaKey) {
3737
return { stop: true, change: false };
3838
}
39+
if (line.length === 0) {
40+
return { stop: false, change: true };
41+
}
3942
const [_, number] = lineWithoutSpace.match(/^(\d+)/);
4043
if (lineWithoutSpace.length - number.length <= 2) {
4144
removeTextAtFirstLine(target, lineAll.length);

src/components/Editor.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ import { Textarea } from "./Textarea";
44
import * as defaultCommands from "../commands";
55
import { Command } from "../types";
66
import { useDebounce } from "../hooks/debounce";
7-
import { parser as defaultParser } from "../parser";
87

98
type Props = {
109
commands?: Record<string, Command>;
1110
previewClassName?: string;
1211
textareaClassName?: string;
1312
previewCallback?: Record<string, (node: any) => any>;
14-
parser?: (text: string) => Promise<string>;
13+
parser: (text: string) => Promise<string>;
1514
value: string;
1615
onChange?: (value: string) => void;
1716
psudoMode?: boolean;
@@ -61,7 +60,7 @@ export const Editor: React.FC<Props> = ({
6160
value={debouncedValue}
6261
className={previewClassName}
6362
callback={previewCallback}
64-
parser={parser ?? defaultParser}
63+
parser={parser}
6564
/>
6665
</div>
6766
</div>

src/components/Textarea.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const Textarea = React.forwardRef(
7777
ref
7878
) => {
7979
const [lineHeightMap, setLineHeightMap] = useState<number[]>([]);
80-
const composing = useRef(false)
80+
const composing = useRef(false);
8181
const htmlRef = useRef<HTMLTextAreaElement>();
8282
const oldScrollRef = useRef<number>(0);
8383
const historyManager = useRef(

0 commit comments

Comments
 (0)