Skip to content

Commit

Permalink
add button for unfurling links
Browse files Browse the repository at this point in the history
  • Loading branch information
fr0tt committed Feb 27, 2022
1 parent cf8daa8 commit bc90db8
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 39 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "App for bookmarks and notes.",
"keywords": ["laravel", "lumen", "bookmark", "notes"],
"license": "MIT",
"version": "2.1.5",
"version": "2.1.6",
"type": "project",
"require": {
"php": "^7.2.5",
Expand Down
38 changes: 38 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"dependencies": {
"@tiptap/core": "^2.0.0-beta.159",
"@tiptap/extension-link": "^2.0.0-beta.36",
"@tiptap/extension-placeholder": "^2.0.0-beta.26",
"@tiptap/extension-typography": "^2.0.0-beta.13",
"@tiptap/extension-underline": "^2.0.0-beta.16",
Expand Down
2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/service-worker.js

Large diffs are not rendered by default.

15 changes: 6 additions & 9 deletions resources/js/UnfurlingLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ export default Node.create({

addCommands() {
return {
setUnfurlingLink: options => ({ tr, dispatch }) => {
const { selection } = tr
const node = this.type.create(options)

if (dispatch) {
tr.replaceRangeWith(selection.from, selection.to, node)
}

return true
setUnfurlingLink: options => ({ commands, editor }) => {
commands.deleteSelection()
return commands.insertContent({
type: this.name,
attrs: { href: editor.state.selection.$to.nodeBefore.text },
})
},
}
},
Expand Down
43 changes: 23 additions & 20 deletions resources/js/components/EditorMenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,72 +26,75 @@
</transition>
</button>

<!--
really neccessary ?
<button class="menubar-button" :class="{ 'is-active': editor.isActive('paragraph') }"
@click="editor.chain().focus().setParagraph().run()">
<svg-vue class="editor-icon" icon="zondicons/text-decoration"/>
</button>
-->

<i class="delimiter"></i>

<button class="menubar-button" :class="{ 'is-active': editor.isActive('bold') }"
@click="editor.chain().focus().toggleBold().run()">
@click="editor.chain().focus().toggleBold().run()" title="Bold">
<svg-vue class="editor-icon" icon="material/format_bold"/>
</button>

<button class="menubar-button" :class="{ 'is-active': editor.isActive('italic') }"
@click="editor.chain().focus().toggleItalic().run()">
@click="editor.chain().focus().toggleItalic().run()" title="Italic">
<svg-vue class="editor-icon" icon="material/format_italic"/>
</button>

<button
class="menubar-button" :class="{ 'is-active': editor.isActive('underline') }"
@click="editor.chain().focus().toggleUnderline().run()">
@click="editor.chain().focus().toggleUnderline().run()" title="Underline">
<svg-vue class="editor-icon" icon="material/format_underlined"/>
</button>

<i class="delimiter"></i>

<button class="menubar-button" :class="{ 'is-active': editor.isActive('bulletList') }"
@click="editor.chain().focus().toggleBulletList().run()" >
@click="editor.chain().focus().toggleBulletList().run()" title="Bullet List">
<svg-vue class="editor-icon" icon="material/list_bulleted"/>
</button>

<button class="menubar-button" :class="{ 'is-active': editor.isActive('orderedList') }"
@click="editor.chain().focus().toggleOrderedList().run()">
@click="editor.chain().focus().toggleOrderedList().run()" title="Ordered List">
<svg-vue class="editor-icon" icon="material/list_numbered"/>
</button>

<i class="delimiter"></i>

<button class="menubar-button" :class="{ 'is-active': editor.isActive('blockquote') }"
@click="editor.chain().focus().toggleBlockquote().run()">
@click="editor.chain().focus().toggleBlockquote().run()" title="Blockquote">
<svg-vue class="editor-icon" icon="material/format_quote"/>
</button>

<button class="menubar-button" :class="{ 'is-active': editor.isActive('codeBlock') }"
@click="editor.chain().focus().toggleCodeBlock().run()">
@click="editor.chain().focus().toggleCodeBlock().run()" title="Code Block">
<svg-vue class="editor-icon" icon="material/code"/>
</button>

<button class="menubar-button" @click="editor.chain().focus().setHorizontalRule().run()">

<button class="menubar-button" @click="editor.chain().focus().setHorizontalRule().run()"
title="Horizontal Rule">
<svg-vue class="editor-icon" icon="material/horizontal_rule"/>
</button>

<i class="delimiter"></i>

<button class="menubar-button" @click="editor.chain().focus().undo().run()">
<button class="menubar-button" @click="editor.chain().focus().setUnfurlingLink().run()"
title="Unfurling Link">
<svg-vue class="editor-icon" icon="material/art_track"/>
</button>

<i class="delimiter"></i>

<button class="menubar-button" @click="editor.chain().focus().undo().run()"
title="Undo">
<svg-vue class="editor-icon" icon="material/undo"/>
</button>

<button class="menubar-button" @click="editor.chain().focus().redo().run()">
<button class="menubar-button" @click="editor.chain().focus().redo().run()"
title="Redo">
<svg-vue class="editor-icon" icon="material/redo"/>
</button>

</div>
</template>

<script>
export default {
props: ['editor'],
Expand Down
11 changes: 7 additions & 4 deletions resources/js/components/UnfurlingLink.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<NodeViewWrapper class="unfurling-link max-w-md block whitespace-normal" >
<NodeViewWrapper class="unfurling-link max-w-md block whitespace-normal">
<a class="shadow-md flex my-1"
target="_blank" rel="noopener noreferrer nofollow"
:href="node.attrs.href"
Expand Down Expand Up @@ -41,7 +41,7 @@ export default {
},
created () {
if (this.node.attrs['data-title'] === null ||
if (this.node.attrs['data-title'] === null ||
this.node.attrs['data-title'] === '') {
axios.get('/api/meta', {
params: {
Expand All @@ -59,17 +59,20 @@ export default {
}).catch(error => {
console.log(error)
})
} else {
const domain = new URL(this.node.attrs.href).origin.replace(/https?:\/\//, '')
this.image = `https://external-content.duckduckgo.com/ip3/${domain}.ico`
}
}
}
</script>
<style>
.has-focus {
box-shadow: 0 1px 3px 0 rgb(255 119 0 / 42%), 0 1px 2px 0 rgb(255 119 0 / 38%);
}
.unfurling-link a {
@apply no-underline;
}
</style>
3 changes: 0 additions & 3 deletions resources/js/components/pages/Collection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ export default {
condition: this.isRealCollection
}
])
},
currentCollection: function (newValue, oldValue) {
this.$store.commit('appbar/setTitle', newValue.name, { root: true })
}
},
computed: {
Expand Down
1 change: 1 addition & 0 deletions resources/svg/material/art_track.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bc90db8

Please sign in to comment.