Skip to content

Commit

Permalink
2.4.14
Browse files Browse the repository at this point in the history
  • Loading branch information
hinesboy committed Dec 20, 2017
1 parent cb44a6b commit 990a81e
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 35 deletions.
6 changes: 6 additions & 0 deletions LOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# 更新日志
- **2.4.14** 细节性调整(17.12.20)
- 在mavon最外层添加样式`text-align: left`,防止受到外部样式影响
- 单双栏切换逻辑调整,单双栏切换更加合理
- 去除自动切换单双栏逻辑(在 `width < 768px`变单栏)
- 添加链接、图片链接弹出页面优化,支持TAB键、回车键操作
- 上传图片限制文件格式为`gif,jpeg,jpg,png,svg`
- **2.4.13** 修复bug[#79](https://github.com/hinesboy/mavonEditor/issues/79), 修改`markdown-it`实例获取方式,引入插件`markdown-it-highlightjs-external`(17.12.12 [CHENXCHEN](https://github.com/CHENXCHEN))
- **2.4.11** 修复bug[#147](https://github.com/hinesboy/mavonEditor/issues/147)(17.12.7 [CHENXCHEN](https://github.com/CHENXCHEN))
- **2.4.10** 添加图片名正则过滤(17.12.6)
Expand Down
3 changes: 1 addition & 2 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ exports default {
### Note

- **Default size: min-height: 300px , ming-width: 300px , Can be covered**
- **Default size: min-height: 300px , min-width: 300px , Can be covered**
- **z-index: 1500**
- **If screen resolution less than 768px ,replace【single column | double column】 edit mode to 【edit | preview】 edit mode**
- **Just for show html of md: toolbarsFlag: false , subfield: false, default_open: "preview"**
## API

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ exports default {
###

- **默认大小样式为 min-height: 300px , ming-width: 300px 可自行覆盖**
- **默认大小样式为 min-height: 300px , min-width: 300px 可自行覆盖**
- **基础z-index: 1500**
- **屏幕分辨率低于768px ,自动取消【单栏 | 双栏】编辑模式 ,更改为【编辑 | 预览】切换 )**
- **仅用作展示可以设置props: toolbarsFlag: false , subfield: false, default_open: "preview"**

## API 文档
Expand Down
2 changes: 1 addition & 1 deletion dist/mavon-editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mavon-editor",
"version": "2.4.13",
"version": "2.4.14",
"description": "Vue markdown editor",
"main": "dist/mavon-editor.js",
"scripts": {
Expand Down
13 changes: 8 additions & 5 deletions src/components/s-md-toolbar-left.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<div class="op-image popup-dropdown" v-show="s_img_dropdown_open">
<div class="dropdown-item" @click.stop="$toggle_imgLinkAdd('imagelink')" title="ctrl+alt+l"><span>{{d_words.tl_image}}</span></div>
<div class="dropdown-item" style="overflow: hidden">
<input type="file" @change="$imgAdd($event)" :key="img_file[0][0]"/>{{d_words.tl_upload}}
<input type="file" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" @change="$imgAdd($event)" :key="img_file[0][0]"/>{{d_words.tl_upload}}
</div>

<div class="dropdown-item dropdown-images" v-if="index > 0" v-for="(item, index) in img_file" @click.stop="$imgFileListClick(index)">
Expand Down Expand Up @@ -99,7 +99,7 @@
aria-hidden="true"></i>
<h3 class="title">{{d_words.tl_popup_link_title}}</h3>
<div class="link-text input-wrapper">
<input type="text" v-model="link_text" :placeholder="d_words.tl_popup_link_text">
<input ref="linkTextInput" type="text" v-model="link_text" :placeholder="d_words.tl_popup_link_text">
</div>
<div class="link-addr input-wrapper">
<input type="text" v-model="link_addr" :placeholder="d_words.tl_popup_link_addr">
Expand Down Expand Up @@ -137,8 +137,8 @@
s_img_link_open: false,
trigger: null,
num: 0,
link_text: null,
link_addr: null,
link_text: '',
link_addr: '',
link_type: 'link'
}
},
Expand All @@ -149,8 +149,11 @@
},
$toggle_imgLinkAdd(type) {
this.link_type = type;
this.link_text = this.link_addr = null;
this.link_text = this.link_addr = '';
this.s_img_link_open = true;
this.$nextTick(() => {
this.$refs.linkTextInput.focus()
})
this.s_img_dropdown_open = false;
},
$imgFileListClick(pos) {
Expand Down
6 changes: 0 additions & 6 deletions src/components/s-md-toolbar-right.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
<button type="button" v-if="toolbars.navigation" @click="$clicks('navigation')" v-show="s_navigation"
class="op-icon fa fa-mavon-bars selected"
aria-hidden="true" :title="`${d_words.tl_navigation_off} (F8)`"></button>
<!-- <button type="button" @click="$clicks('phone')" v-show="s_screen_phone && s_screen_phone_toggle"
class="op-icon fa fa-mavon-eye"
aria-hidden="true" :title="`${d_words.tl_preview} (F9)`"></button>
<button type="button" @click="$clicks('phone')" v-show="s_screen_phone && !s_screen_phone_toggle"
class="op-icon fa fa-mavon-eye-slash selected"
aria-hidden="true" :title="`${d_words.tl_edit} (F9)`"></button>-->
<button type="button" v-if="toolbars.preview" @click="$clicks('preview')" v-show="s_preview_switch"
class="op-icon fa fa-mavon-eye-slash selected"
aria-hidden="true" :title="`${d_words.tl_edit} (F9)`"></button>
Expand Down
30 changes: 27 additions & 3 deletions src/dev/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</h2>
<button @click="uploadimg">upload</button>
<button @click="imgreplace">imgreplace</button>
<mavon-editor ref=md :subfield="subfield" :toolbarsFlag="toolbarsFlag" :editable="editable" :code_style="code_style"
<mavon-editor ref=md :subfield="subfield" :toolbarsFlag="toolbarsFlag" :editable="editable"
:language="d_language" @change="change" @save="saveone" :ishljs="true" class="item-editor" v-model="help1"
:external_link="external_link"
@imgAdd="$imgAdd" @imgDel="$imgDel" @subfieldtoggle="$subfieldtoggle" @previewtoggle="$previewtoggle"></mavon-editor>
Expand Down Expand Up @@ -73,9 +73,8 @@
},
subfield: true,
editable: true,
toolbarsFlag: true,
toolbarsFlag: true,
img_file: {},
code_style: 'solarized-dark',
external_link: {
markdown_css: function() {
return '/markdown/github-markdown.min.css';
Expand All @@ -95,6 +94,31 @@
katex_js: function() {
return '/katex/katex.min.js';
}
},
toolbar_settings: {
undo: true, // 上一步
redo: true, // 下一步
bold: true, // 粗体
italic: true, // 斜体
header: true, // 标题
underline: true, // 下划线
strikethrough: true, // 中划线
quote: true, // 引用
ol: true, // 有序列表
ul: true, // 无序列表
link: true, // 链接
code: true, // code
readmodel: true, // 沉浸式阅读
htmlcode: true, // 展示html源码
/* 2.1.8 */
alignleft: true, // 左对齐
aligncenter: true, // 居中
alignright: true, // 右对齐
/* 2.2.1 */
subfield: true, // 单双栏模式
preview: true, // 预览
/* 1.4.2 */
navigation: true, // 导航目录
}
}
},
Expand Down
18 changes: 15 additions & 3 deletions src/lib/core/keydown-listen.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const KEY_CODE = {
C: 76,
T: 84,
DELETE: 8,
TAB: 9
TAB: 9,
ENTER: 13
};
export const keydownListen = ($vm) => {
$vm.$el.addEventListener('keydown', function (e) {
Expand Down Expand Up @@ -83,10 +84,21 @@ export const keydownListen = ($vm) => {
}
case KEY_CODE.TAB: {
// TAB
e.preventDefault()
$vm.insertTab();
if (!$vm.$refs.toolbar_left.s_img_link_open) {
e.preventDefault()
$vm.insertTab();
}
break;
}
case KEY_CODE.ENTER: {
// enter
console.log('enter')
if ($vm.$refs.toolbar_left.s_img_link_open) {
e.preventDefault()
$vm.$refs.toolbar_left.$imgLinkAdd();
}
break;
}
}
} else if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey) {
// ctrl +
Expand Down
1 change: 1 addition & 0 deletions src/lib/css/mavon-editor.styl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
transition all 0.3s linear 0s
background #fff
z-index 1500
text-align left
&.fullscreen
position fixed
left 0
Expand Down
10 changes: 4 additions & 6 deletions src/lib/toolbar_right_click.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ function $toolbar_right_fullscreen_click($vm) {
}
function $toolbar_right_subfield_click ($vm) {
$vm.s_subfield = !$vm.s_subfield
if ($vm.s_subfield) {
$vm.s_preview_switch = true;
// $vm.$refs.vNoteDivEdit.innerHTML = $vm.s_markdown.render($vm.d_value)
if ($vm.previewtoggle) {
$vm.previewtoggle($vm.s_preview_switch, $vm.d_value)
}
$vm.s_preview_switch = $vm.s_subfield;
// $vm.$refs.vNoteDivEdit.innerHTML = $vm.s_markdown.render($vm.d_value)
if ($vm.previewtoggle) {
$vm.previewtoggle($vm.s_preview_switch, $vm.d_value)
}
// $vm.$refs.vNoteDivEdit.innerHTML = $vm.s_markdown.render($vm.d_value)
if ($vm.subfieldtoggle) {
Expand Down
12 changes: 6 additions & 6 deletions src/mavon-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
import hljsLangs from './lib/core/hljs/lang.hljs.js'
import {
fullscreenchange,
windowResize,
/* windowResize, */
scrollLink,
insertTextAtCaret,
getNavigation,
Expand Down Expand Up @@ -184,8 +184,8 @@
d_render: '',// props 文本内容render
s_preview_switch: (() => {
let default_open_ = this.default_open;
if (this.subfield && !default_open_) {
default_open_ = 'preview';
if (!default_open_) {
default_open_ = this.subfield ? 'preview' : 'edit';
}
return default_open_ === 'preview' ? true : false;
})(), // props true 展示编辑 false展示预览
Expand Down Expand Up @@ -254,7 +254,7 @@
$vm.$drag(e);
})
// 浏览器siz大小
windowResize(this);
/* windowResize(this); */
keydownListen(this);
// fullscreen事件
fullscreenchange(this);
Expand Down Expand Up @@ -584,8 +584,8 @@
},
default_open: function (val) {
let default_open_ = val;
if (this.subfield && !default_open_) {
default_open_ = 'preview';
if ( !default_open_) {
default_open_ = this.subfield?'preview':'edit';
}
return this.s_preview_switch = default_open_ === 'preview' ? true : false;
},
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3323,6 +3323,10 @@ markdown-it-for-inline@~0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/markdown-it-for-inline/-/markdown-it-for-inline-0.1.1.tgz#435f2316f5b5e68e1450cfa2242f2b8d59adc75f"

markdown-it-highlightjs-external@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/markdown-it-highlightjs-external/-/markdown-it-highlightjs-external-1.0.1.tgz#8595fd4b0207ec429c93341f996637fa31da2d53"

markdown-it-images-preview@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/markdown-it-images-preview/-/markdown-it-images-preview-1.0.1.tgz#17d6eb8491cccd2343d4e4419a1abe9ca43c0bbb"
Expand Down

0 comments on commit 990a81e

Please sign in to comment.