@@ -51,11 +51,27 @@ export class ExperimentsPlugin extends BookReaderPlugin {
5151 localStorageKey : 'BrExperiments' ,
5252
5353 /** The experiments that should be shown in the experiments panel */
54- enabledExperiments : [ 'translate' ] ,
54+ enabledExperiments : [ 'translate' , 'copyLinkToHighlight' ] ,
5555 }
5656
5757 /** @type {ExperimentModel[] } */
5858 allExperiments = [
59+ new class extends ExperimentModel {
60+ name = 'copyLinkToHighlight' ;
61+ title = 'Copy to Selection URL' ;
62+ description = 'Share text selection via URL' ;
63+ learnMore = 'none' ;
64+ icon = null ;
65+ enabled = false ;
66+ async enable ( { manual = false } ) {
67+ this . br . plugins . textSelection . enableSelectionMenu ( ) ;
68+ }
69+ async disable ( ) {
70+ sleep ( 0 ) . then ( ( ) => {
71+ window . location . reload ( ) ;
72+ } ) ;
73+ }
74+ } ( ) ,
5975 new class extends ExperimentModel {
6076 name = 'translate' ;
6177 title = 'Translate Plugin' ;
@@ -123,7 +139,9 @@ export class ExperimentsPlugin extends BookReaderPlugin {
123139 for ( const experiment of this . allExperiments ) {
124140 // TODO: imagesBaseURL should be replaced with assetRoot everywhere
125141 experiment . assetRoot = this . br . options . imagesBaseURL . replace ( / i m a g e s \/ $ / , '' ) ;
126- experiment . icon = experiment . buildAssetPath ( experiment . icon ) ;
142+ if ( experiment . icon ) {
143+ experiment . icon = experiment . buildAssetPath ( experiment . icon ) ;
144+ }
127145 experiment . br = this . br ;
128146 }
129147
@@ -269,7 +287,7 @@ export class BrExperimentToggle extends LitElement {
269287 return html `
270288 <div class= "experiment-card" style = "margin- botto m: 10px;">
271289 <div style= "display: flex; align-items: center; gap: 10px;" >
272- <img src= "${ this . icon } " style = "width: 20px; height: 20px;" alt= "" / >
290+ ${ this . icon ? html ` <img src= "${ this . icon } " style = "width: 20px; height: 20px;" alt= "" / > ` : '' }
273291 <div style= "flex-grow: 1; font-weight: bold;" > ${ this . title } </ div>
274292 </ div>
275293 <p style= "opacity: 0.9" >
0 commit comments