258258 </a >
259259 </li >
260260 <li v-if =" loggedIn && postData.data.thread.locked" >
261- <a href =" " @click.prevent =" copyQuote(post)" data-balloon =" Quote" >
261+ <a href =" " @click.prevent =" copyQuote({ id: post.id, body: post.body, body_html: post.body_html, created_at: post.created_at, thread_slug: threadSlug, user: { username: post.user.username }} )" data-balloon =" Quote" >
262262 <svg xmlns =" http://www.w3.org/2000/svg" viewBox =" 0 0 48 48" >
263263 <title ></title >
264264 <path
@@ -422,6 +422,7 @@ import PollViewer from '@/components/polls/PollViewer.vue'
422422import PollCreator from ' @/components/polls/PollCreator.vue'
423423import RankDisplay from ' @/components/users/RankDisplay.vue'
424424import humanDate from ' @/composables/filters/humanDate'
425+ import decode from ' @/composables/filters/decode'
425426import dayjs from ' dayjs'
426427import { userRoleHighlight } from ' @/composables/utils/userUtils'
427428import truncate from ' @/composables/filters/truncate'
@@ -867,11 +868,17 @@ export default {
867868 postsApi .unlock (post .id ).then (() => post .locked = false )
868869 }
869870 const loadEditor = (post ) => {
871+ v .showEditor = false
872+ v .editPost = null
873+ v .quote = null
870874 v .editPost = post
875+ if (post? .id ) $router .push ({ path: $route .path , query: $route .query , hash: ` #${ post .id } ` })
871876 v .showEditor = true
872877 }
873- const addQuote = (post ) => {
878+ const addQuote = post => {
879+ v .showEditor = false
874880 v .quote = null
881+ v .editPost = null
875882 let quote = ' [quote author=' + post .user .username
876883 if (post .thread_slug ) {
877884 quote += ' link='
@@ -880,13 +887,42 @@ export default {
880887 quote += ' date=' + new Date (post .created_at ).getTime () + ' ]'
881888 quote += post .body || post .body_html
882889 quote += ' [/quote]'
883- console .log (quote)
884890 v .quote = post
885891 v .quote .body = quote
892+ $router .push ({ path: $route .path , query: $route .query , hash: ` #${ post .id } ` })
886893 delete v .quote .id
887894 v .showEditor = true
888895 }
889- const copyQuote = (post ) => console .log (post, ' copyQuote' )
896+ const copyQuote = post => {
897+ let quote = ' [quote author=' + post .user .username
898+ if (post .thread_slug ) {
899+ quote += ' link='
900+ quote += ' /threads/' + post .thread_slug + ' /posts?page=' + v .postData .data .page + ' #' + post .id
901+ }
902+ quote += ' date=' + new Date (post .created_at ).getTime () + ' ]'
903+ quote += post .body || post .body_html
904+ quote += ' [/quote]'
905+ $router .push ({ path: $route .path , query: $route .query , hash: ` #${ post .id } ` })
906+ let copyText = decode (quote)
907+
908+ // create temp element
909+ let copyElement = document .createElement (' span' )
910+ copyElement .appendChild (document .createTextNode (copyText))
911+ copyElement .id = ' tempCopyToClipboard'
912+ document .body .append (copyElement)
913+
914+ // select the text
915+ let range = document .createRange ()
916+ range .selectNode (copyElement)
917+ window .getSelection ().removeAllRanges ()
918+ window .getSelection ().addRange (range)
919+
920+ // copy & cleanup
921+ document .execCommand (' copy' )
922+ window .getSelection ().removeAllRanges ()
923+ copyElement .remove ()
924+ $alertStore .success (' Quote successfully copied to clipboard' )
925+ }
890926 const showUserControls = () => (v .loggedIn && (! v .postData .data .thread .watched || canCreatePoll ()))
891927 const highlightPost = () => {
892928 if ($route .hash ) {
0 commit comments