Skip to content

Commit

Permalink
feat: ✨ apply link
Browse files Browse the repository at this point in the history
  • Loading branch information
Leecason committed Dec 13, 2019
1 parent 6165a58 commit b3d3295
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/MenuBar/CommandButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default {
justify-content: center;
height: 40px;
margin: 2px;
outline: 0;
width: 40px;
&:hover {
Expand Down
20 changes: 20 additions & 0 deletions src/components/MenuBar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
icon="strikethrough"
/>

<command-button
:is-active="editorContext.isActive.link()"
:command="openApplyLinkControl"
tooltip="Apply link"
icon="link"
/>

<command-button
:is-active="editorContext.isActive.code_block()"
:command="editorContext.commands.code_block"
Expand Down Expand Up @@ -164,6 +171,19 @@ export default {
isTextAlignActive (align) {
return isTextAlignActive(this.editor.state, align);
},
openApplyLinkControl () {
this.$prompt('', 'Apply link', {
confirmButtonText: 'Apply',
cancelButtonText: 'Close',
inputPlaceholder: 'Href',
roundButton: true,
}).then(({ value: href }) => {
this.editor.commands.link({ href });
}).catch(() => {
this.editor.focus();
});
},
},
};
</script>
Expand Down
3 changes: 3 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Dropdown,
DropdownMenu,
DropdownItem,
MessageBox,
} from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Expand All @@ -26,6 +27,8 @@ Vue.use(Dropdown);
Vue.use(DropdownMenu);
Vue.use(DropdownItem);

Vue.prototype.$prompt = MessageBox.prompt;

new Vue({
router,
render: h => h(App),
Expand Down
2 changes: 2 additions & 0 deletions src/views/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
Underline,
Italic,
Strike,
Link,
CodeBlock,
Expand Down Expand Up @@ -68,6 +69,7 @@ export default {
new Underline(),
new Italic(),
new Strike(),
new Link(),
new Blockquote(),
new CodeBlock(),
Expand Down

0 comments on commit b3d3295

Please sign in to comment.