提交 bb7b9798 编写于 作者: 璃白.'s avatar 璃白. 🌻

feat:@用户匹配大小写

上级 8c56ab19
{ {
"name": "markdown-editor", "name": "markdown-editor",
"description": " A open source markdown editor of csdn codechina team contributed", "description": " A open source markdown editor of csdn codechina team contributed",
"version": "0.6.3", "version": "0.7.2",
"publisher": "guoweijia", "publisher": "guoweijia",
"scripts": { "scripts": {
"start": "webpack serve --mode=development", "start": "webpack serve --mode=development",
......
...@@ -406,7 +406,6 @@ export default { ...@@ -406,7 +406,6 @@ export default {
} }
}); });
}).then(res => { }).then(res => {
console.log("返回的列表", res);
res.forEach(item => { res.forEach(item => {
item.csdn = true; item.csdn = true;
const linkEl = vDom.querySelector("#" + item.id); const linkEl = vDom.querySelector("#" + item.id);
......
...@@ -77,7 +77,8 @@ export function initStyle({ ...@@ -77,7 +77,8 @@ export function initStyle({
codeBgColor, codeBgColor,
codeTheme, codeTheme,
helpdocColor, helpdocColor,
itemActiveBgColor itemActiveBgColor,
linkCardBgColor
}) { }) {
// 夜晚模式 // 夜晚模式
if (dark) { if (dark) {
...@@ -91,6 +92,13 @@ export function initStyle({ ...@@ -91,6 +92,13 @@ export function initStyle({
contentBgColor = "#222226"; contentBgColor = "#222226";
helpdocColor = "#CCCCD8"; helpdocColor = "#CCCCD8";
itemActiveBgColor = "#777888"; itemActiveBgColor = "#777888";
linkCardBgColor = "#222226";
}
if (linkCardBgColor) {
document.documentElement.style.setProperty(
"--md-editor-link-card-bg-color",
linkCardBgColor
);
} }
if (frameBgColor) { if (frameBgColor) {
document.documentElement.style.setProperty( document.documentElement.style.setProperty(
...@@ -193,9 +201,7 @@ export function checkBoswer() { ...@@ -193,9 +201,7 @@ export function checkBoswer() {
} }
export function isAndroid() { export function isAndroid() {
const agent = navigator.userAgent.match( const agent = navigator.userAgent.match(/(Android)/i);
/(Android)/i
);
return agent !== null; return agent !== null;
} }
// 去除头部空格行 // 去除头部空格行
...@@ -374,11 +380,15 @@ export function getLinkTitle(linkEl) { ...@@ -374,11 +380,15 @@ export function getLinkTitle(linkEl) {
export function renderLinkCard(title, item) { export function renderLinkCard(title, item) {
return ` return `
<span class="md_link_title">${title || item.title || ""}</span> <span class="md_link_title">${title || item.title || ""}</span>
${item.desc ? `<span class="md_link_desc">${item.desc}</span>` : ""} ${
item.description
? `<span class="md_link_desc">${item.description}</span>`
: ""
}
<span class="md_flex_card"> <span class="md_flex_card">
${ ${
item.img item.icon
? `<img class="md_link_img" src="${item.img}" />` ? `<img class="md_link_img" src="${item.icon}" />`
: "<span class='md_link_img icon iconfont icon-lianjie'></span>" : "<span class='md_link_img icon iconfont icon-lianjie'></span>"
} }
<span class="flex-1"> <span class="flex-1">
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
box-sizing: border-box; box-sizing: border-box;
border-radius: 4px; border-radius: 4px;
border: 1px solid var(--md-editor-border-color); border: 1px solid var(--md-editor-border-color);
background: #f5f7fa; background: var(--md-editor-link-card-bg-color);
transition: border 0.3s; transition: border 0.3s;
margin: 4px 0; margin: 4px 0;
max-width: 640px; max-width: 640px;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
--md-editor-item-active-bg-color: #f5f7fa; --md-editor-item-active-bg-color: #f5f7fa;
--md-editor-helpdoc-color: #666666; --md-editor-helpdoc-color: #666666;
--md-editor-code-bg-color: #f3f4f5; --md-editor-code-bg-color: #f3f4f5;
--md-editor-link-card-bg-color: #f5f7fa;
--md-editor-fullScrren-zIndex: 2000; --md-editor-fullScrren-zIndex: 2000;
--md-editor-disabled-opacity: 0.5; --md-editor-disabled-opacity: 0.5;
} }
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
</div> </div>
</template> </template>
<script> <script>
import { throttle as throttleFn } from "@/assets/js/utils";
export default { export default {
props: { props: {
position: { position: {
...@@ -49,8 +48,6 @@ export default { ...@@ -49,8 +48,6 @@ export default {
computed: { computed: {
list() { list() {
const list = this.userList; const list = this.userList;
console.log("list", list);
if (!list.length) return []; if (!list.length) return [];
return list.map((item, index) => { return list.map((item, index) => {
if (index === 0) { if (index === 0) {
...@@ -60,9 +57,6 @@ export default { ...@@ -60,9 +57,6 @@ export default {
} }
return item; return item;
}); });
},
throttle() {
return throttleFn();
} }
}, },
watch: { watch: {
...@@ -77,16 +71,17 @@ export default { ...@@ -77,16 +71,17 @@ export default {
data() { data() {
return { return {
left: 0, left: 0,
top: 0 top: 0,
selectDisable: false
}; };
}, },
methods: { methods: {
selectUser(user) { selectUser(user) {
console.log(this.throttle); if (this.selectDisable) return;
this.selectDisable = true;
this.throttle(() => {
console.log(111);
this.$emit("selectUser", user); this.$emit("selectUser", user);
setTimeout(() => {
this.selectDisable = false;
}, 1000); }, 1000);
}, },
isActive(index) { isActive(index) {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
@keydown.stop.50="handleCallUser" @keydown.stop.50="handleCallUser"
@keydown.stop.229="handleCallUser" @keydown.stop.229="handleCallUser"
@focus="setFocus(true)" @focus="setFocus(true)"
@blur="setFocus(false)" @blur="blur"
@paste="pasteFile" @paste="pasteFile"
@keydown.stop.up="changeActiveUserIndex($event, 'up')" @keydown.stop.up="changeActiveUserIndex($event, 'up')"
@keydown.stop.down="changeActiveUserIndex($event, 'down')" @keydown.stop.down="changeActiveUserIndex($event, 'down')"
...@@ -297,6 +297,10 @@ export default { ...@@ -297,6 +297,10 @@ export default {
this.$emit("update:textLength", this.textContent.length); this.$emit("update:textLength", this.textContent.length);
this.emitText(); this.emitText();
}, },
blur() {
this.renderUserTags()
this.setFocus(false);
},
createHideEl(type) { createHideEl(type) {
const textEl = document.getElementById(this.id); const textEl = document.getElementById(this.id);
if (!textEl) return; if (!textEl) return;
......
...@@ -5,8 +5,9 @@ export default { ...@@ -5,8 +5,9 @@ export default {
allUserList: [] allUserList: []
}; };
}, },
mounted() { methods: {
setTimeout(() => { renderUserTags() {
if (this.showSelectUser) return;
const text = this.text; const text = this.text;
if (/(\@\S+\s{0,1})/g.test(text)) { if (/(\@\S+\s{0,1})/g.test(text)) {
this.$emit("queryUserList", ""); this.$emit("queryUserList", "");
...@@ -18,9 +19,7 @@ export default { ...@@ -18,9 +19,7 @@ export default {
}); });
}); });
} }
}, 0);
}, },
methods: {
handleSelectUser(user) { handleSelectUser(user) {
const originalText = this.textContent; const originalText = this.textContent;
const queryInfo = this.queryInfo; const queryInfo = this.queryInfo;
......
...@@ -204,7 +204,7 @@ export default { ...@@ -204,7 +204,7 @@ export default {
icon: "lianjie", icon: "lianjie",
tip: "添加链接", tip: "添加链接",
doc: "[标题](链接)", doc: "[标题](链接)",
startStr: "[链接标题](", startStr: "[](",
endStr: ")" endStr: ")"
}, },
{ {
......
...@@ -178,7 +178,7 @@ function initMdEditor(obj) { ...@@ -178,7 +178,7 @@ function initMdEditor(obj) {
if (!keyWord) return callback(list); if (!keyWord) return callback(list);
callback( callback(
list.filter(item => { list.filter(item => {
return item.nickname.includes(keyWord); return item.nickname.toLowerCase().includes(keyWord.toLowerCase());
}) })
); );
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册