Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ toolbar: {
h3: true,
h4: true,
img: true,
youtube: true,
link: true,
code: true,
preview: true,
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ toolbar: {
h4: true, // h4
img: true, // 图片
link: true, // 链接
youtube: true, // 添加Youtube链接
code: true, // 代码块
preview: true, // 预览
expand: true, // 全屏
Expand Down
8 changes: 4 additions & 4 deletions dist/index.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface IToolbar {
h3?: boolean
h4?: boolean
img?: boolean
youtube?: boolean
link?: boolean
code?: boolean
preview?: boolean
Expand All @@ -23,6 +24,7 @@ export interface IWords {
undo?: string
redo?: string
img?: string
youtube?: string
link?: string
code?: string
save?: string
Expand All @@ -33,6 +35,7 @@ export interface IWords {
fullscreenOff?: string
addImgLink?: string
addImg?: string
addYoutubeLink?: string
}
interface IP {
value?: string
Expand Down
5 changes: 5 additions & 0 deletions src/components/toolbar_left.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ class Toolbars extends React.Component<IP, IS> {
<i className="foricon for-link" />
</li>
)}
{toolbar.youtube && (
<li onClick={() => this.onClick('youtube')} title={words.youtube}>
{words.addYoutubeLink}
</li>
)}
{toolbar.code && (
<li onClick={() => this.onClick('code')} title={words.code}>
<i className="foricon for-code" />
Expand Down
8 changes: 8 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface IToolbar {
h3?: boolean
h4?: boolean
img?: boolean
youtube?: boolean
link?: boolean
code?: boolean
preview?: boolean
Expand All @@ -35,6 +36,7 @@ export interface IWords {
undo?: string
redo?: string
img?: string
youtube?: string
link?: string
code?: string
save?: string
Expand All @@ -45,6 +47,7 @@ export interface IWords {
fullscreenOff?: string
addImgLink?: string
addImg?: string
addYoutubeLink?: string
}

interface ILeft {
Expand Down Expand Up @@ -240,6 +243,11 @@ class MdEditor extends React.Component<IP, IS> {
subfix: ')',
str: 'url'
},
youtube: {
prefix: '[![alt](http://img.youtube.com/vi/YOUTUBE_VIDEO_ID/0.jpg)](',
subfix: ' "title")',
str: 'http://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID'
},
code: {
prefix: '```',
subfix: '\n\n```',
Expand Down
1 change: 1 addition & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const CONFIG: ICONFIG = {
h3: true,
h4: true,
img: true,
youtube: true,
link: true,
code: true,
preview: true,
Expand Down
4 changes: 3 additions & 1 deletion src/lib/lang/en/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"h3": "Header 3",
"h4": "Header 4",
"img": "Image Link",
"youtube": "Youtube Link",
"link": "Link",
"code": "Code",
"save": "Save",
Expand All @@ -16,5 +17,6 @@
"fullscreenOn": "FullScreen ON",
"fullscreenOff": "FullScreen OFF",
"addImgLink": "Add Image Link",
"addImg": "Upload Image"
"addImg": "Upload Image",
"addYoutubeLink": "Add Youtube Link"
}
4 changes: 3 additions & 1 deletion src/lib/lang/zh-CN/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"h3": "三级标题",
"h4": "四级标题",
"img": "添加图片链接",
"youtube": "添加Youtube链接",
"link": "链接",
"code": "代码块",
"save": "保存",
Expand All @@ -16,5 +17,6 @@
"fullscreenOn": "全屏编辑",
"fullscreenOff": "退出全屏",
"addImgLink": "添加图片链接",
"addImg": "上传图片"
"addImg": "上传图片",
"addYoutubeLink": "添加Youtube链接"
}