mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-06 02:17:49 +08:00
upgraded to tippy.js v6
This commit is contained in:
parent
d4d070ae7a
commit
cf5dc9685b
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Fuse from 'fuse.js'
|
import Fuse from 'fuse.js'
|
||||||
import tippy from 'tippy.js'
|
import tippy, { roundArrow } from 'tippy.js'
|
||||||
import Icon from 'Components/Icon'
|
import Icon from 'Components/Icon'
|
||||||
import { Editor, EditorContent, EditorMenuBar } from 'tiptap'
|
import { Editor, EditorContent, EditorMenuBar } from 'tiptap'
|
||||||
import {
|
import {
|
||||||
@ -46,6 +46,7 @@ import {
|
|||||||
Bold,
|
Bold,
|
||||||
Italic,
|
Italic,
|
||||||
} from 'tiptap-extensions'
|
} from 'tiptap-extensions'
|
||||||
|
import 'tippy.js/dist/svg-arrow.css'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
@ -159,7 +160,6 @@ export default {
|
|||||||
filteredUsers: [],
|
filteredUsers: [],
|
||||||
navigatedUserIndex: 0,
|
navigatedUserIndex: 0,
|
||||||
insertMention: () => {},
|
insertMention: () => {},
|
||||||
observer: null,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -217,41 +217,28 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.popup = tippy(node, {
|
// ref: https://atomiks.github.io/tippyjs/v6/all-props/
|
||||||
content: this.$refs.suggestions,
|
this.popup = tippy('.page', {
|
||||||
trigger: 'mouseenter',
|
// function that returns a ClientRect object
|
||||||
|
getReferenceClientRect: node.getBoundingClientRect,
|
||||||
|
appendTo: () => document.body,
|
||||||
interactive: true,
|
interactive: true,
|
||||||
|
arrow: roundArrow,
|
||||||
|
content: this.$refs.suggestions,
|
||||||
|
trigger: 'mouseenter', // manual
|
||||||
|
showOnCreate: true,
|
||||||
theme: 'dark',
|
theme: 'dark',
|
||||||
placement: 'top-start',
|
placement: 'top-start',
|
||||||
inertia: true,
|
inertia: true,
|
||||||
duration: [400, 200],
|
duration: [400, 200],
|
||||||
showOnInit: true,
|
|
||||||
arrow: true,
|
|
||||||
arrowType: 'round',
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// we have to update tippy whenever the DOM is updated
|
|
||||||
if (MutationObserver) {
|
|
||||||
this.observer = new MutationObserver(() => {
|
|
||||||
this.popup.popperInstance.scheduleUpdate()
|
|
||||||
})
|
|
||||||
this.observer.observe(this.$refs.suggestions, {
|
|
||||||
childList: true,
|
|
||||||
subtree: true,
|
|
||||||
characterData: true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
destroyPopup() {
|
destroyPopup() {
|
||||||
if (this.popup) {
|
if (this.popup) {
|
||||||
this.popup.destroy()
|
this.popup[0].destroy()
|
||||||
this.popup = null
|
this.popup = null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.observer) {
|
|
||||||
this.observer.disconnect()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -306,7 +293,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tippy-tooltip.dark-theme {
|
.tippy-box[data-theme~=dark] {
|
||||||
background-color: $color-black;
|
background-color: $color-black;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
@ -314,28 +301,28 @@ export default {
|
|||||||
color: $color-white;
|
color: $color-white;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
|
||||||
.tippy-backdrop {
|
&[data-placement^=top]>.tippy-arrow:before {
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tippy-roundarrow {
|
|
||||||
fill: $color-black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tippy-popper[x-placement^=top] & .tippy-arrow {
|
|
||||||
border-top-color: $color-black;
|
border-top-color: $color-black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tippy-popper[x-placement^=bottom] & .tippy-arrow {
|
&[data-placement^=bottom]>.tippy-arrow:before {
|
||||||
border-bottom-color: $color-black;
|
border-bottom-color: $color-black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tippy-popper[x-placement^=left] & .tippy-arrow {
|
&[data-placement^=left]>.tippy-arrow:before {
|
||||||
border-left-color: $color-black;
|
border-left-color: $color-black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tippy-popper[x-placement^=right] & .tippy-arrow {
|
&[data-placement^=right]>.tippy-arrow:before {
|
||||||
border-right-color: $color-black;
|
border-right-color: $color-black;
|
||||||
|
}
|
||||||
|
|
||||||
|
&>.tippy-backdrop {
|
||||||
|
background-color: $color-black;
|
||||||
|
}
|
||||||
|
|
||||||
|
&>.tippy-svg-arrow {
|
||||||
|
fill: $color-black;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
"sass-loader": "^8.0.0",
|
"sass-loader": "^8.0.0",
|
||||||
"style-loader": "^1.0.1",
|
"style-loader": "^1.0.1",
|
||||||
"terser": "^4.4.2",
|
"terser": "^4.4.2",
|
||||||
"tippy.js": "^4.3.5",
|
"tippy.js": "^6.1.0",
|
||||||
"vue": "^2.6.10",
|
"vue": "^2.6.10",
|
||||||
"vue-loader": "^15.7.2",
|
"vue-loader": "^15.7.2",
|
||||||
"vue-router": "^3.1.3",
|
"vue-router": "^3.1.3",
|
||||||
|
20
yarn.lock
20
yarn.lock
@ -1665,6 +1665,11 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@types/node" ">= 8"
|
"@types/node" ">= 8"
|
||||||
|
|
||||||
|
"@popperjs/core@^2.1.1":
|
||||||
|
version "2.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.1.1.tgz#12c572ab88ef7345b43f21883fca26631c223085"
|
||||||
|
integrity sha512-sLqWxCzC5/QHLhziXSCAksBxHfOnQlhPRVgPK0egEw+ktWvG75T2k+aYWVjVh9+WKeT3tlG3ZNbZQvZLmfuOIw==
|
||||||
|
|
||||||
"@sindresorhus/is@^0.7.0":
|
"@sindresorhus/is@^0.7.0":
|
||||||
version "0.7.0"
|
version "0.7.0"
|
||||||
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd"
|
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd"
|
||||||
@ -9467,11 +9472,6 @@ pngquant-bin@^5.0.0:
|
|||||||
execa "^0.10.0"
|
execa "^0.10.0"
|
||||||
logalot "^2.0.0"
|
logalot "^2.0.0"
|
||||||
|
|
||||||
popper.js@^1.14.7:
|
|
||||||
version "1.16.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.0.tgz#2e1816bcbbaa518ea6c2e15a466f4cb9c6e2fbb3"
|
|
||||||
integrity sha512-+G+EkOPoE5S/zChTpmBSSDYmhXJ5PsW8eMhH8cP/CQHMFPBG/kC9Y5IIw6qNYgdJ+/COf0ddY2li28iHaZRSjw==
|
|
||||||
|
|
||||||
portfinder@^1.0.20:
|
portfinder@^1.0.20:
|
||||||
version "1.0.25"
|
version "1.0.25"
|
||||||
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.25.tgz#254fd337ffba869f4b9d37edc298059cb4d35eca"
|
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.25.tgz#254fd337ffba869f4b9d37edc298059cb4d35eca"
|
||||||
@ -12182,12 +12182,12 @@ timsort@^0.3.0:
|
|||||||
resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4"
|
resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4"
|
||||||
integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=
|
integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=
|
||||||
|
|
||||||
tippy.js@^4.3.5:
|
tippy.js@^6.1.0:
|
||||||
version "4.3.5"
|
version "6.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/tippy.js/-/tippy.js-4.3.5.tgz#882bff8d92f09bb0546d2826d5668c0560006f54"
|
resolved "https://registry.yarnpkg.com/tippy.js/-/tippy.js-6.1.0.tgz#9c58b94f92f3044d5e861b9d83da3c2a6d3d4323"
|
||||||
integrity sha512-NDq3efte8nGK6BOJ1dDN1/WelAwfmh3UtIYXXck6+SxLzbIQNZE/cmRSnwScZ/FyiKdIcvFHvYUgqmoGx8CcyA==
|
integrity sha512-cRFydlVZlvo4soQSUfVNbH2K77zDUhDAzaAjxseyn81gGIa+j72y98yDL2yB0n8gas/E+Zlr1iOyR5ckslUFqA==
|
||||||
dependencies:
|
dependencies:
|
||||||
popper.js "^1.14.7"
|
"@popperjs/core" "^2.1.1"
|
||||||
|
|
||||||
tmp@^0.0.33:
|
tmp@^0.0.33:
|
||||||
version "0.0.33"
|
version "0.0.33"
|
||||||
|
Loading…
Reference in New Issue
Block a user