Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add plus button behavior #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
32 changes: 25 additions & 7 deletions src/AlisEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:editor="editor"
v-if="insertButton.isVisibleInsertButton"
:style="{
left: `${insertButton.posX}px`,
left: `calc(50% - 400px)`,
top: `${insertButton.posY}px`
}"
@upload="handleUpload"
Expand Down Expand Up @@ -55,7 +55,7 @@ export default Vue.extend({
data() {
return {
insertButton: {
isVisibleInsertButton: true,
isVisibleInsertButton: false,
posX: 0,
posY: 0,
target: null
Expand All @@ -71,9 +71,26 @@ export default Vue.extend({
links: null
};
},
mounted: function() {
mounted() {
// プラスボタンの挙動制御
document.addEventListener('selectionchange', event => {
const selection = window.getSelection()
const target = selection.anchorNode
if (target === null) {
this.insertButton.isVisibleInsertButton = false
return
}
if (target.textContent === "") {
const rect = target.getBoundingClientRect()
this.insertButton.posY = rect.top - 12 + window.pageYOffset
this.insertButton.isVisibleInsertButton = true
} else {
this.insertButton.isVisibleInsertButton = false
}
})
// バルーンエディタ
BalloonEditor
.create( document.querySelector( '#editor' ), {
.create( document.querySelector('#editor'), {
plugins: [
EssentialsPlugin,
BoldPlugin,
Expand Down Expand Up @@ -133,12 +150,11 @@ export default Vue.extend({
);
}
const screenName = urlArr[1];
console.log(screenName);
return (
'<div style="position: relative; padding-bottom: 180px;">' +
'<div>' +
`<iframe src="http://localhost:3000/media_embed/twitter_profile/${screenName}" +
frameborder="0" allow="autoplay; encrypted-media" allowfullscreen +
style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;">` +
style="width: 100%; height: 160px; left: 0;">` +
'</iframe>' +
'</div>'
);
Expand Down Expand Up @@ -332,6 +348,8 @@ a {
letter-spacing: 0.7px;
line-height: 1.5;
margin-bottom: 8px;
overflow: hidden;
height: 3.6em;
}

.site {
Expand Down