diff --git a/package.json b/package.json index 99ebc76..f6ae84f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@electron-forge/maker-squirrel": "6.0.0-beta.63", "@electron-forge/maker-zip": "6.0.0-beta.63", "@electron-forge/publisher-github": "6.0.0-beta.63", - "electron": "17.1.x", + "electron": "18.0.x", "shx": "^0.3.2" } } diff --git a/src/webview/highlight.js b/src/webview/highlight.js index 8e37867..de738b1 100644 --- a/src/webview/highlight.js +++ b/src/webview/highlight.js @@ -1 +1 @@ -function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c ".concat(h?"\uD83D\uDDE8":"\uD83D\uDCAC"," ");var j=i.document.querySelector("textarea");j.value=f,j.setSelectionRange(0,j.value.length),j.addEventListener("blur",d),j.addEventListener("keydown",a=>{switch(a.code){case"Enter":a.metaKey||a.ctrlKey?a.target.value+="\n":!a.shiftKey&&d(a);break;case"Escape":j.value=f,d(a);}}),i.addEventListener("blur",d)}class RdTooltip{constructor(a,b){var{onColorClick:c,onNoteClick:d,onRemoveClick:e}=b;_defineProperty(this,"_parent",null),_defineProperty(this,"_menu",null),_defineProperty(this,"_listeners",{}),_defineProperty(this,"_hidden",!0),_defineProperty(this,"_colors",["yellow","blue","green","red"]),_defineProperty(this,"_classMenu","rdhm"),_defineProperty(this,"_classButtonColor","rdhbh"),_defineProperty(this,"_classButtonNote","rdhbn"),_defineProperty(this,"_classButtonRemove","rdhbr"),_defineProperty(this,"_idCss","rdhss"),_defineProperty(this,"_attrColor","data-rdhsc"),this._parent=a,this._listeners={onColorClick:c,onNoteClick:d,onRemoveClick:e},this._initStyles(),this._initMenu(),this.show=this.show.bind(this),this.hide=this.hide.bind(this),this._windowMouseDown=this._windowMouseDown.bind(this),this._windowResize=this._windowResize.bind(this),this._parent._window.removeEventListener("mousedown",this._windowMouseDown),this._parent._window.addEventListener("mousedown",this._windowMouseDown),this._parent._window.removeEventListener("resize",this._windowResize),this._parent._window.addEventListener("resize",this._windowResize)}show(a,b){var c=2=this._parent._window.innerWidth&&(f=this._parent._window.innerWidth-110),this._parent._window.scrollY>g&&(g=this._parent._window.scrollY),this._menu.setAttribute("style","left: ".concat(f,"px !important; top: ").concat(g,"px !important;")),this._menu.querySelectorAll("[".concat(this._attrColor,"]")).forEach(a=>a.removeAttribute("data-active")),c){var j=this._menu.querySelector("[".concat(this._attrColor,"=\"").concat(c.trim(),"\"]"));j&&j.setAttribute("data-active","true")}var h=this._menu.querySelector(".".concat(this._classButtonNote));d?h.setAttribute("data-badge","1"):h.removeAttribute("data-badge");var i=this._menu.querySelector(".".concat(this._classButtonRemove));i.setAttribute("hidden",e?"false":"true"),this._menu.removeAttribute("hidden"),this._hidden=!1}hide(){this._menu&&(this._hidden=!0,this._menu.setAttribute("hidden","true"))}_windowMouseDown(a){this._hidden||a.target==this._menu||this._menu.contains(a.target)||this.hide()}_windowResize(){this._hidden||this.hide()}_colorClick(a){a.preventDefault();"function"!=typeof this._listeners.onColorClick||this._listeners.onColorClick(a.currentTarget.getAttribute(this._attrColor)||"")}_noteClick(a){a.preventDefault();"function"!=typeof this._listeners.onNoteClick||this._listeners.onNoteClick(a.screenX-14,a.screenY-14)}_removeClick(a){a.preventDefault();"function"!=typeof this._listeners.onRemoveClick||this._listeners.onRemoveClick()}_initMenu(){this._menu||(this._menu=this._parent._document.createElement("menu"),this._menu.className=this._classMenu,this._menu.setAttribute("hidden","true"),this._menu.innerHTML="
  • ".concat(this._colors.map(a=>" ")).join(""),"
  • "),this._parent._container.appendChild(this._menu),this._menu.querySelectorAll(".".concat(this._classButtonColor)).forEach(a=>{this._colorClick=this._colorClick.bind(this),a.removeEventListener("click",this._colorClick),a.addEventListener("click",this._colorClick)}),this._menu.querySelectorAll(".".concat(this._classButtonNote)).forEach(a=>{this._noteClick=this._noteClick.bind(this),a.removeEventListener("click",this._noteClick),a.addEventListener("click",this._noteClick)}),this._menu.querySelectorAll(".".concat(this._classButtonRemove)).forEach(a=>{this._removeClick=this._removeClick.bind(this),a.removeEventListener("click",this._removeClick),a.addEventListener("click",this._removeClick)}))}_initStyles(){if(!this._parent._container.querySelector("#".concat(this._idCss))){var a=this._parent._document.createElement("style");a.id=this._idCss,a.innerHTML=" .".concat(this._classMenu," { position: absolute !important; display: flex !important; z-index: 99999999 !important; background-color: transparent !important; margin: 4px !important; width: auto !important; height: auto !important; left: 0 !important; top: 0 !important; box-shadow: none !important; animation: none !important; transition: opacity .15s ease-in-out !important; will-change: opacity; border: 0 !important; padding: 0 !important; backdrop-filter: blur(20px) !important; -webkit-backdrop-filter: blur(20px) !important; } .").concat(this._classMenu,", .").concat(this._classMenu," *, .").concat(this._classMenu,":after { border-radius: 5px !important; } .").concat(this._classMenu,":after { content: '' !important; position: absolute !important; left: 0 !important; top: 0 !important; right: 0 !important; bottom: 0 !important; z-index: -1 !important; background-color: Menu !important; box-shadow: 0 0 0 0.5px GrayText, 0 5px 30px rgb(0 0 0 / 30%) !important; } @supports (backdrop-filter: blur(20px)) { .").concat(this._classMenu,":after { opacity: .6 !important; } } @supports (-webkit-backdrop-filter: blur(20px)) { .").concat(this._classMenu,":after { opacity: .6 !important; background-color: Window !important; } } .").concat(this._classMenu,", .").concat(this._classMenu," * { box-sizing: border-box !important; user-select: none !important; -webkit-user-select: none !important; } .").concat(this._classMenu,"[hidden='true'] { pointer-events: none !important; opacity: 0 !important; } /* Dropdown */ .").concat(this._classMenu," > li { display: flex !important; flex-direction: column !important; flex-wrap: wrap; !important; max-height: 32px !important; transition: max-height .15s ease-in !important; transition-delay: .1s !important; will-change: max-height; overflow: hidden !important; } .").concat(this._classMenu," > li:hover { max-height: ").concat(32*this._colors.length,"px !important; } /* Buttons */ .").concat(this._classMenu," button { cursor: pointer !important; color: WindowText !important; width: 32px !important; height: 32px !important; appearance: none !important; background: transparent !important; border: 0 !important; box-shadow: none !important; margin: 0 !important; padding: 0 !important; display: flex !important; align-items: center !important; justify-content: center !important; transition: background .1s linear, color .1s linear !important; will-change: background, color; filter: none !important; position: relative !important; } .").concat(this._classMenu," button:hover { background: rgba(100,100,100,.3) !important; } .").concat(this._classMenu," button:active { filter: brightness(50%) !important; } .").concat(this._classMenu," button[hidden='true'] { display: none !important; } .").concat(this._classMenu," button[data-badge]:before { content: attr(data-badge) !important; width: 16px !important; height: 16px !important; border-radius: 14px !important; display: flex !important; align-items: center !important; justify-content: center !important; background: red !important; color: white !important; position: absolute !important; top: -3px !important; right: -3px !important; font-size: 11px !important; line-height: 11px !important; font-weight: 600 !important; box-shadow: inset 0 0 0 .5px rgba(255,255,255,.2), 0 0 0 0.5px rgba(0,0,0,.2), 0 3px 15px rgba(0,0,0,.2) !important; } .").concat(this._classMenu," button[data-active='true'] { order: -1 !important; } .").concat(this._classMenu," * { fill: currentColor !important; } /* Color */ .").concat(this._classMenu," button[").concat(this._attrColor,"]:before { content: '' !important; display: block !important; width: 18px !important; height: 18px !important; border-radius: 18px !important; box-shadow: inset 0 0 0 0.5px rgba(0,0,0,.4) !important; background-image: linear-gradient(to bottom, rgba(255,255,255,.5) 0, rgba(255,255,255,.4) 100%) !important; } ").concat(this._colors.map(a=>" .".concat(this._classMenu," button[").concat(this._attrColor,"=").concat(a,"]:before { background-color: ").concat(a," !important; } ")).join("")," "),this._parent._container.appendChild(a)}}}class RdSelection{constructor(a){_defineProperty(this,"_parent",null),_defineProperty(this,"_tooltip",null),this._parent=a,this._tooltip=new RdTooltip(a,{onColorClick:a=>this._parent.addSelection({color:a}),onNoteClick:(a,b)=>this._parent.noteSelection(a,b)}),this.render=this.render.bind(this),this._onSelectionChange=this._onSelectionChange.bind(this),this._parent._document.removeEventListener("selectionchange",this._onSelectionChange),this._parent._document.addEventListener("selectionchange",this._onSelectionChange),this._parent._window.removeEventListener("focus",this.render),this._parent._window.addEventListener("focus",this.render),this._parent._window.removeEventListener("blur",this.render),this._parent._window.addEventListener("blur",this.render),this._onSelectionChange()}have(){var a=this._parent._window.getSelection();return a&&0{}),_defineProperty(this,"onRemove",()=>{}),_defineProperty(this,"onAdd",()=>{}),this._container=a,this._document=this._container.ownerDocument,this._window=this._document.defaultView,this._markClick=this._markClick.bind(this),this._markColorClick=this._markColorClick.bind(this),this._markNoteClick=this._markNoteClick.bind(this),this._markRemoveClick=this._markRemoveClick.bind(this),this._navClick=this._navClick.bind(this),this._selection=new RdSelection(this),this._tooltip=new RdTooltip(this,{onColorClick:this._markColorClick,onNoteClick:this._markNoteClick,onRemoveClick:this._markRemoveClick})}apply(){var a=0a.outerHTML=a.innerText),this._container.querySelectorAll(".".concat(this._classNav)).forEach(a=>a.remove())}scrollToId(a){if(a){var b=this._container.querySelector("mark[".concat(this._attrId,"=\"").concat(a+"","\"]"));b&&b.scrollIntoView({behavior:"smooth",block:"center"})}}addSelection(){var a=0{a.trim()&&this.addSelection({note:a})}):alert("Notes/annotations only available in Pro plan")}copySelection(){this._document.execCommand("copy")}mark(a,b){var{_id:c,color:d,note:e}=b;a.forEach((b,f)=>{var g=this._document.createElement("mark");if(g.setAttribute(this._attrId,c),d&&"yellow"!=d&&g.setAttribute("style","".concat(this._cssColorVar,": ").concat(d)),e&&g.setAttribute("title",e),g.addEventListener("click",this._markClick),g.addEventListener("contextmenu",this._markClick),b.surroundContents(g),f==a.length-1&&e&&g.insertAdjacentHTML("beforeend"," ")),this.nav&&0==f){var h=this._document.createElement("a");h.className=this._classNav,h.setAttribute(this._attrId,c);var i=b.getBoundingClientRect();h.setAttribute("style"," ".concat(d&&"yellow"!=d?"".concat(this._cssColorVar,": ").concat(d,";"):""," top: ").concat(100/this._document.documentElement.scrollHeight*(this._window.scrollY+i.top-10),"%; ").trim()),h.addEventListener("click",this._navClick),this._container.appendChild(h)}b.detach()})}_markClick(a){if("A"!=a.currentTarget.parentElement.tagName){a.preventDefault(),a.stopPropagation();var b=a.currentTarget,c=b.getAttribute(this._attrId),d=(getComputedStyle(b).getPropertyValue(this._cssColorVar)||"").trim(),e=b.hasAttribute("title");this._activeMarkId=c,this._tooltip.show(a.pageX,a.pageY,d,e,!0)}}_markColorClick(a){this._activeMarkId&&(this.onUpdate({_id:this._activeMarkId,color:a}),this._tooltip.hide())}_markNoteClick(a,b){if(this._activeMarkId){var c=this._container.querySelector("[".concat(this._attrId,"=\"").concat(this._activeMarkId,"\"]")),d=c.getAttribute("title")||"";RdPrompt(a,b,"Note...",d,a=>{d!=a&&this.onUpdate({_id:this._activeMarkId,note:a})}),this._tooltip.hide()}}_markRemoveClick(){if(this._activeMarkId){var a=this._container.querySelector("[".concat(this._attrId,"=\"").concat(this._activeMarkId,"\"]")),b=!a.hasAttribute("title")||confirm("Remove highlight?");b&&(this.onRemove({_id:this._activeMarkId}),this._tooltip.hide())}}_navClick(a){a.preventDefault(),a.stopPropagation();var b=a.currentTarget,c=b.getAttribute(this._attrId);this.scrollToId(c)}_initStyles(){if(!this._container.querySelector("#".concat(this._idCss))){var a=this._document.createElement("style");a.id=this._idCss,a.innerHTML=" mark[".concat(this._attrId,"], .").concat(this._classNav,":before { background: var(").concat(this._cssColorVar,", #ffee00) !important; user-select: none !important; -webkit-user-select: none !important; } mark[").concat(this._attrId,"] { background-image: linear-gradient(to bottom, rgba(255,255,255,.7) 0, rgba(255,255,255,.7) 100%) !important; color: black !important; -webkit-text-fill-color: black !important; cursor: pointer !important; } .").concat(this._classNoteIcon," { display: inline !important; margin: 0 !important; padding: 0 !important; border: 0 !important; color: inherit !important; opacity: 0.5 !important; fill: currentColor !important; background: transparent !important; border-radius: 0 !important; margin-left: 0.3em !important; margin-right: 0.3em !important; width: 0.85em !important; height: 0.85em !important; } .").concat(this._classNav," { position: fixed !important; right: 0px !important; padding: 10px !important; padding-right: 6px !important; cursor: pointer !important; } .").concat(this._classNav,":before { content: '' !important; display: block !important; width: 10px !important; height: 10px !important; border-radius: 10px !important; box-shadow: 0 0 0 0.5px ButtonShadow, 0 5px 30px rgb(0 0 0 / 30%) !important; background-image: linear-gradient(to bottom, rgba(255,255,255,.2) 0, rgba(255,255,255,.2) 100%) !important; } .").concat(this._classNav,":hover:before { background-image: linear-gradient(to bottom, rgba(255,255,255,.5) 0, rgba(255,255,255,.5) 100%) !important; } .").concat(this._classNav,":active { filter: brightness(50%) !important; } "),this._container.appendChild(a)}}_getRanges(a,b){var d=b.replace(/\s+/g,""),e="",f=[],g=function(){for(var i in h.textContent){var c=h.textContent[i];"string"==typeof c&&c.trim()&&(f[e.length]=[h,parseInt(i)],e+=c)}var a=e.indexOf(d);if(-1==a)return"continue";var b=f.slice(a,a+d.length),g=new Map;return b.forEach((a,c)=>{var d=g.get(a[0])||[-1,-1];-1==d[0]&&(d[0]=a[1]),c==b.length-1?d[1]=a[1]+1:-1==d[1]&&(d[1]=a[0].textContent.length),g.set(a[0],d)}),{v:Array.from(g).map(a=>{var b=new Range;return b.setStart(a[0],a[1][0]),b.setEnd(a[0],a[1][1]),b})}};for(var h of a){var i=g();if("continue"!==i&&"object"==typeof i)return i.v}return[]}_getTextNodes(a){if(a&&a.childNodes){var b=[];for(var c of a.childNodes)switch(c.nodeType){case 1:c.offsetParent&&!c.hasAttribute(this._attrId)&&b.push(...this._getTextNodes(c));break;case 3:b.push(c);}return b}}}var rdh,rdhEmbed={enabled:!1,wait:[],send:()=>{},receive:()=>{}};if("object"==typeof chrome&&chrome.runtime&&chrome.runtime.onMessage||"object"==typeof browser&&browser.runtime&&browser.runtime.onMessage){var{runtime}="object"==typeof browser?browser:chrome;rdhEmbed.enabled=!0,rdhEmbed.send=(a,b)=>runtime.sendMessage(null,{type:a,payload:b});var onMessage=(a,b)=>{var{type:c,payload:d}=a;b.id!=runtime.id||"string"!=typeof c||"undefined"!=typeof d&&"object"!=typeof d||rdhEmbed.receive(c,d)};runtime.onMessage.removeListener(onMessage),runtime.onMessage.addListener(onMessage)}else if("function"==typeof require){rdhEmbed.enabled=!0;var{ipcRenderer}=require("electron");rdhEmbed.send=(a,b)=>ipcRenderer.sendToHost("RDH",{type:a,payload:b});var _onMessage=(a,b)=>rdhEmbed.receive(b.type,b.payload);ipcRenderer.removeListener("RDH",_onMessage),ipcRenderer.on("RDH",_onMessage)}else if(window.self!==window.top){rdhEmbed.enabled=!0,rdhEmbed.send=(a,b)=>window.parent.postMessage({type:a,payload:b},"*");var _onMessage2=a=>{var{data:b,source:c}=a;c!==window.parent||"object"!=typeof b||"string"!=typeof b.type||"undefined"!=typeof b.payload&&"object"!=typeof b.payload||rdhEmbed.receive(b.type,b.payload)};window.removeEventListener("message",_onMessage2),window.addEventListener("message",_onMessage2)}if(rdhEmbed.enabled){function a(){if(window.removeEventListener("load",a),rdh=new RdHighlight(document.body),rdh.onUpdate=a=>rdhEmbed.send("RDH_UPDATE",a),rdh.onRemove=a=>rdhEmbed.send("RDH_REMOVE",a),rdh.onAdd=a=>rdhEmbed.send("RDH_ADD",a),rdhEmbed.wait.length){for(var{type:b,payload:c}of rdhEmbed.wait)rdhEmbed.receive(b,c);rdhEmbed.enabled=[]}rdhEmbed.send("RDH_READY",{url:location.href})}rdhEmbed.receive=(a,b)=>rdh?void("RDH_APPLY"===a?rdh.apply(b):"RDH_CONFIG"===a?("boolean"==typeof b.enabled&&(rdh.enabled=b.enabled),"boolean"==typeof b.pro&&(rdh.pro=b.pro),"boolean"==typeof b.nav&&(rdh.nav=b.nav)):"RDH_SCROLL"===a?rdh.scrollToId(b._id):"RDH_ADD_SELECTION"===a?rdh.addSelection(b):"RDH_NOTE_SELECTION"===a?rdh.noteSelection():void 0):void rdhEmbed.wait.push({type:a,payload:b}),"complete"==document.readyState?a():(window.removeEventListener("load",a),window.addEventListener("load",a))} +function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c ".concat(h?"\uD83D\uDDE8":"\uD83D\uDCAC"," ");var j=i.document.querySelector("textarea");j.value=f,j.setSelectionRange(0,j.value.length),j.addEventListener("keydown",a=>{switch(a.code){case"Enter":a.metaKey||a.ctrlKey?a.target.value+="\n":!a.shiftKey&&d(a);break;case"Escape":j.value=f,d(a);}}),setTimeout(()=>{j.addEventListener("blur",d),i.document.activeElement!=j&&d()},100)}class RdTooltip{constructor(a,b){var{onColorClick:c,onNoteClick:d,onRemoveClick:e}=b;_defineProperty(this,"_parent",null),_defineProperty(this,"_menu",null),_defineProperty(this,"_listeners",{}),_defineProperty(this,"_hidden",!0),_defineProperty(this,"_colors",["yellow","blue","green","red"]),_defineProperty(this,"_classMenu","rdhm"),_defineProperty(this,"_classButtonColor","rdhbh"),_defineProperty(this,"_classButtonNote","rdhbn"),_defineProperty(this,"_classButtonRemove","rdhbr"),_defineProperty(this,"_idCss","rdhss"),_defineProperty(this,"_attrColor","data-rdhsc"),this._parent=a,this._listeners={onColorClick:c,onNoteClick:d,onRemoveClick:e},this._initStyles(),this._initMenu(),this.show=this.show.bind(this),this.hide=this.hide.bind(this),this._windowMouseDown=this._windowMouseDown.bind(this),this._windowResize=this._windowResize.bind(this),this._parent._isMobile?(this._parent._document.removeEventListener("touchstart",this._windowMouseDown),this._parent._document.addEventListener("touchstart",this._windowMouseDown),this._parent._document.removeEventListener("touchend",this._windowMouseUp),this._parent._document.addEventListener("touchend",this._windowMouseUp)):(this._parent._window.removeEventListener("mousedown",this._windowMouseDown),this._parent._window.addEventListener("mousedown",this._windowMouseDown)),this._parent._window.removeEventListener("resize",this._windowResize),this._parent._window.addEventListener("resize",this._windowResize)}show(a,b){var c=2i&&(f=i);var j=this._parent._window.scrollY+10,k=j+this._parent._window.innerHeight-this._menu.offsetHeight-10;if(gk&&(g=k),this._menu.setAttribute("style","left: ".concat(f,"px !important; top: ").concat(g,"px !important;")),this._menu.querySelectorAll("[".concat(this._attrColor,"]")).forEach(a=>a.removeAttribute("data-active")),c){var n=this._menu.querySelector("[".concat(this._attrColor,"=\"").concat(c.trim(),"\"]"));n&&n.setAttribute("data-active","true")}var l=this._menu.querySelector(".".concat(this._classButtonNote));d?l.setAttribute("data-badge","1"):l.removeAttribute("data-badge");var m=this._menu.querySelector(".".concat(this._classButtonRemove));m.setAttribute("hidden",e?"false":"true"),this._menu.removeAttribute("hidden"),this._hidden=!1}hide(){this._menu&&(this._hidden=!0,this._menu.setAttribute("hidden","true"))}_windowMouseDown(a){this._hidden||a.target==this._menu||this._menu.contains(a.target)||this.hide()}_windowResize(){this._hidden||this.hide()}_colorClick(a){a.preventDefault();"function"!=typeof this._listeners.onColorClick||this._listeners.onColorClick(a.currentTarget.getAttribute(this._attrColor)||"")}_noteClick(a){a.preventDefault();"function"!=typeof this._listeners.onNoteClick||this._listeners.onNoteClick(a.screenX-14,a.screenY-14)}_removeClick(a){a.preventDefault();"function"!=typeof this._listeners.onRemoveClick||this._listeners.onRemoveClick()}_initMenu(){this._menu||(this._menu=this._parent._document.createElement("menu"),this._menu.className=this._classMenu,this._menu.setAttribute("hidden","true"),this._menu.innerHTML="
  • ".concat(this._colors.map(a=>" ")).join(""),"
  • "),this._parent._container.appendChild(this._menu),this._menu.querySelectorAll(".".concat(this._classButtonColor)).forEach(a=>{this._colorClick=this._colorClick.bind(this),a.removeEventListener(this._parent._isMobile?"touchend":"click",this._colorClick),a.addEventListener(this._parent._isMobile?"touchend":"click",this._colorClick)}),this._menu.querySelectorAll(".".concat(this._classButtonNote)).forEach(a=>{this._noteClick=this._noteClick.bind(this),a.removeEventListener(this._parent._isMobile?"touchend":"click",this._noteClick),a.addEventListener(this._parent._isMobile?"touchend":"click",this._noteClick)}),this._menu.querySelectorAll(".".concat(this._classButtonRemove)).forEach(a=>{this._removeClick=this._removeClick.bind(this),a.removeEventListener(this._parent._isMobile?"touchend":"click",this._removeClick),a.addEventListener(this._parent._isMobile?"touchend":"click",this._removeClick)}))}_initStyles(){if(!this._parent._container.querySelector("#".concat(this._idCss))){var a=this._parent._document.createElement("style");a.id=this._idCss,a.innerHTML=" :root { --r-menu-bg: Canvas; --r-menu-color: FieldText; --r-menu-active: GrayText; --r-menu-item-width: 34px; --r-menu-item-height: 32px; --r-menu-border-radius: 8px; } @supports (background-color: -apple-system-control-background) { :root { --r-menu-bg: -apple-system-control-background; } } /* mobile */ @media (pointer: coarse) { /* android */ @supports not (-webkit-backdrop-filter: blur(0)) { :root { --r-menu-item-width: 44px; --r-menu-item-height: 48px; --r-menu-border-radius: 24px; } /* android preferes system theme */ @media (prefers-color-scheme: dark) { :root { --r-menu-bg: #282828; --r-menu-color: white; --r-menu-active: rgba(255,255,255,.2); } } @media (prefers-color-scheme: light) { :root { --r-menu-bg: white; --r-menu-color: black; --r-menu-active: rgba(0,0,0,.2); } } } /* ios */ @supports (-webkit-backdrop-filter: blur(0)) { :root { /* ios safari always black */ --r-menu-bg: black; --r-menu-color: white; --r-menu-active: rgba(255,255,255,.3); --r-menu-item-width: 48px; --r-menu-item-height: 38px; --r-menu-border-radius: 8px; } } } .".concat(this._classMenu," { position: absolute !important; display: flex !important; z-index: 99999999 !important; background-color: var(--r-menu-bg) !important; background-image: linear-gradient(to bottom, rgba(255,255,255,.1) 0, rgba(255,255,255,.1) 100%) !important; box-shadow: 0 0 0 .5px rgba(0,0,0,.15), 0 .5px 0 rgba(0,0,0,.1), 0 6px 12px rgba(0,0,0,.1), 0 10px 20px rgba(0,0,0,.05) !important; margin: 4px !important; width: auto !important; height: auto !important; left: 0 !important; top: 0 !important; animation: none !important; transition: opacity .15s ease-in-out !important; will-change: opacity; border: 0 !important; padding: 0 !important; border-radius: var(--r-menu-border-radius) !important; overflow: hidden !important; } .").concat(this._classMenu,", .").concat(this._classMenu," * { margin: 0 !important; } .").concat(this._classMenu,", .").concat(this._classMenu," * { box-sizing: border-box !important; user-select: none !important; -webkit-user-select: none !important; } .").concat(this._classMenu,"[hidden='true'] { pointer-events: none !important; opacity: 0 !important; } /* Dropdown */ .").concat(this._classMenu," > li { display: flex !important; flex-direction: row !important; flex-wrap: wrap !important; } /* Dropdown grow down on desktop on hover */ @media (pointer: fine) { .").concat(this._classMenu," > li { display: grid !important; max-height: var(--r-menu-item-height) !important; transition: max-height .2s ease-in-out !important; transition-delay: .25s !important; will-change: max-height; overflow: hidden !important; } .").concat(this._classMenu," > li:hover { transition-delay: .15s !important; max-height: ").concat(32*this._colors.length,"px !important; } } /* Buttons */ .").concat(this._classMenu," button { -webkit-tap-highlight-color: transparent !important; flex-shrink: 0 !important; cursor: default !important; color: var(--r-menu-color) !important; width: var(--r-menu-item-width) !important; height: var(--r-menu-item-height) !important; appearance: none !important; background: transparent !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; margin: 0 !important; padding: 0 !important; display: flex !important; align-items: center !important; justify-content: center !important; transition: none !important; will-change: background, color; filter: none !important; position: relative !important; } .").concat(this._classMenu," button:hover { background: rgba(150,150,150,.2) !important; } .").concat(this._classMenu," button:active { background: var(--r-menu-active) !important; } .").concat(this._classMenu," button:active *, .").concat(this._classMenu," button:active:before { opacity: .8 !important; } .").concat(this._classMenu," button[hidden='true'] { display: none !important; } .").concat(this._classMenu," button[data-badge]:before { content: \"\" !important; width: 12px !important; height: 12px !important; border-radius: 6px !important; display: flex !important; align-items: center !important; justify-content: center !important; background: red !important; color: white !important; position: absolute !important; top: 3px !important; right: 2px !important; font-size: 11px !important; line-height: 11px !important; font-weight: 600 !important; } @media (pointer: fine) { .").concat(this._classMenu," button[data-active='true'] { order: -1 !important; } } @media (pointer: coarse) { .").concat(this._classMenu," button[data-active='true'] { display: none !important; } } .").concat(this._classMenu," * { fill: var(--r-menu-color) !important; } /* Color */ .").concat(this._classMenu," button[").concat(this._attrColor,"]:before { content: '' !important; display: block !important; width: 18px !important; height: 18px !important; border-radius: 18px !important; background-image: linear-gradient(to bottom, rgba(255,255,255,.4) 0, rgba(255,255,255,.4) 100%) !important; } button[").concat(this._attrColor,"=yellow]:before { box-shadow: 0 0 0 .5px #999900 !important; } ").concat(this._colors.map(a=>" .".concat(this._classMenu," button[").concat(this._attrColor,"=").concat(a,"]:before { background-color: ").concat(a," !important; } ")).join("")," "),this._parent._container.appendChild(a)}}}class RdSelection{constructor(a){_defineProperty(this,"_parent",null),_defineProperty(this,"_tooltip",null),this._parent=a,this._tooltip=new RdTooltip(a,{onColorClick:a=>this._parent.addSelection({color:a}),onNoteClick:(a,b)=>this._parent.noteSelection(a,b)}),this.render=this.render.bind(this),this._onSelectionChange=this._onSelectionChange.bind(this),this._parent._document.removeEventListener("selectionchange",this._onSelectionChange),this._parent._document.addEventListener("selectionchange",this._onSelectionChange),this._parent._window.removeEventListener("focus",this.render),this._parent._window.addEventListener("focus",this.render),this._parent._window.removeEventListener("blur",this.render),this._parent._window.addEventListener("blur",this.render),this._onSelectionChange()}have(){var a=this._parent._window.getSelection();return a&&0{}),_defineProperty(this,"onRemove",()=>{}),_defineProperty(this,"onAdd",()=>{}),this._container=a,this._document=this._container.ownerDocument,this._window=this._document.defaultView,this._markClick=this._markClick.bind(this),this._markColorClick=this._markColorClick.bind(this),this._markNoteClick=this._markNoteClick.bind(this),this._markRemoveClick=this._markRemoveClick.bind(this),this._navClick=this._navClick.bind(this),this._selection=new RdSelection(this),this._tooltip=new RdTooltip(this,{onColorClick:this._markColorClick,onNoteClick:this._markNoteClick,onRemoveClick:this._markRemoveClick})}apply(){var a=0a.outerHTML=a.innerText),this._container.querySelectorAll(".".concat(this._classNav)).forEach(a=>a.remove())}scrollToId(a){if(a){var b=this._container.querySelector("mark[".concat(this._attrId,"=\"").concat(a+"","\"]"));b&&b.scrollIntoView((navigator.vendor||"").includes("Apple")?{}:{behavior:"smooth",block:"center"})}}addSelection(){var a=0{(a||"").trim()&&(this.onAdd({note:a,text:c}),this._window.getSelection().removeAllRanges())})}copySelection(){this._document.execCommand("copy")}mark(a,b){var{_id:c,color:d,note:e}=b;a.forEach((b,f)=>{var g=this._document.createElement("mark");if(g.setAttribute(this._attrId,c),d&&"yellow"!=d&&g.setAttribute("style","".concat(this._cssColorVar,": ").concat(d)),e&&g.setAttribute("title",e),g.addEventListener("click",this._markClick),g.addEventListener("contextmenu",this._markClick),b.surroundContents(g),f==a.length-1&&e&&g.insertAdjacentHTML("beforeend"," ")),this.nav&&0==f){var h=this._document.createElement("a");h.className=this._classNav,h.setAttribute(this._attrId,c);var i=b.getBoundingClientRect();h.setAttribute("style"," ".concat(d&&"yellow"!=d?"".concat(this._cssColorVar,": ").concat(d,";"):""," top: ").concat(100/this._document.documentElement.scrollHeight*(this._window.scrollY+i.top-10),"%; ").trim()),h.addEventListener("click",this._navClick),this._container.appendChild(h)}b.detach()})}_markClick(a){if("A"!=a.currentTarget.parentElement.tagName){a.preventDefault(),a.stopPropagation();var b=a.currentTarget,c=b.getAttribute(this._attrId),d=(getComputedStyle(b).getPropertyValue(this._cssColorVar)||"yellow").trim(),e=b.hasAttribute("title");this._activeMarkId=c,this._tooltip.show(a.pageX+5,a.pageY+5,d,e,!0)}}_markColorClick(a){this._activeMarkId&&(this.onUpdate({_id:this._activeMarkId,color:a}),this._tooltip.hide())}_markNoteClick(a,b){if(!this.pro)return alert("Annotations available in Raindrop.io Pro");if(this._activeMarkId){var c=this._container.querySelector("[".concat(this._attrId,"=\"").concat(this._activeMarkId,"\"]")),d=c.getAttribute("title")||"";RdPrompt(a,b,"Note...",d,a=>{d!=a&&this.onUpdate({_id:this._activeMarkId,note:a})}),this._tooltip.hide()}}_markRemoveClick(){if(this._activeMarkId){var a=this._container.querySelector("[".concat(this._attrId,"=\"").concat(this._activeMarkId,"\"]")),b=!0;if(a.hasAttribute("title"))try{b=confirm("Remove highlight?")}catch(a){}b&&(this.onRemove({_id:this._activeMarkId}),this._tooltip.hide())}}_navClick(a){a.preventDefault(),a.stopPropagation();var b=a.currentTarget,c=b.getAttribute(this._attrId);this.scrollToId(c)}_initStyles(){if(!this._container.querySelector("#".concat(this._idCss))){var a=this._document.createElement("style");a.id=this._idCss,a.innerHTML=" mark[".concat(this._attrId,"], .").concat(this._classNav,":before { background: var(").concat(this._cssColorVar,", #ffee00) !important; user-select: none !important; -webkit-user-select: none !important; } mark[").concat(this._attrId,"] { background-image: linear-gradient(to bottom, rgba(255,255,255,.7) 0, rgba(255,255,255,.7) 100%) !important; color: black !important; -webkit-text-fill-color: black !important; cursor: pointer !important; } .").concat(this._classNoteIcon," { display: inline !important; margin: 0 !important; padding: 0 !important; border: 0 !important; color: inherit !important; opacity: 0.5 !important; fill: currentColor !important; background: transparent !important; border-radius: 0 !important; margin-left: 0.3em !important; margin-right: 0.3em !important; width: 0.85em !important; height: 0.85em !important; } .").concat(this._classNav," { position: fixed !important; right: 0px !important; padding: 10px !important; padding-right: 6px !important; cursor: pointer !important; } .").concat(this._classNav,":before { content: '' !important; display: block !important; width: 10px !important; height: 10px !important; border-radius: 10px !important; box-shadow: 0 0 0 0.5px ButtonShadow, 0 5px 30px rgb(0 0 0 / 30%) !important; background-image: linear-gradient(to bottom, rgba(255,255,255,.2) 0, rgba(255,255,255,.2) 100%) !important; } .").concat(this._classNav,":hover:before { background-image: linear-gradient(to bottom, rgba(255,255,255,.5) 0, rgba(255,255,255,.5) 100%) !important; } .").concat(this._classNav,":active { filter: brightness(50%) !important; } "),this._container.appendChild(a)}}_getRanges(a,b){var d=b.replace(/\s+/g,""),e="",f=[],g=function(){for(var i in h.textContent){var c=h.textContent[i];"string"==typeof c&&c.trim()&&(f[e.length]=[h,parseInt(i)],e+=c)}var a=e.indexOf(d);if(-1==a)return"continue";var b=f.slice(a,a+d.length),g=new Map;return b.forEach((a,c)=>{var d=g.get(a[0])||[-1,-1];-1==d[0]&&(d[0]=a[1]),c==b.length-1?d[1]=a[1]+1:-1==d[1]&&(d[1]=a[0].textContent.length),g.set(a[0],d)}),{v:Array.from(g).map(a=>{var b=new Range;return b.setStart(a[0],a[1][0]),b.setEnd(a[0],a[1][1]),b})}};for(var h of a){var i=g();if("continue"!==i&&"object"==typeof i)return i.v}return[]}_getTextNodes(a){if(a&&a.childNodes){var b=[];for(var c of a.childNodes)switch(c.nodeType){case 1:c.offsetParent&&!c.hasAttribute(this._attrId)&&b.push(...this._getTextNodes(c));break;case 3:b.push(c);}return b}}}var rdh,rdhEmbed={enabled:!1,wait:[],send:()=>{},receive:()=>{}};if("object"==typeof chrome&&chrome.runtime&&chrome.runtime.onMessage||"object"==typeof browser&&browser.runtime&&browser.runtime.onMessage){var{runtime}="object"==typeof browser?browser:chrome;rdhEmbed.enabled=!0,rdhEmbed.send=(a,b)=>runtime.sendMessage(null,{type:a,payload:b});var onMessage=(a,b)=>{var{type:c,payload:d}=a;b.id!=runtime.id||"string"!=typeof c||"undefined"!=typeof d&&"object"!=typeof d||rdhEmbed.receive(c,d)};runtime.onMessage.removeListener(onMessage),runtime.onMessage.addListener(onMessage)}else if("function"==typeof require){rdhEmbed.enabled=!0;var{ipcRenderer}=require("electron");rdhEmbed.send=(a,b)=>ipcRenderer.sendToHost("RDH",{type:a,payload:b});var _onMessage=(a,b)=>rdhEmbed.receive(b.type,b.payload);ipcRenderer.removeListener("RDH",_onMessage),ipcRenderer.on("RDH",_onMessage)}else if("ReactNativeWebView"in window)rdhEmbed.enabled=!0,rdhEmbed.send=(a,b)=>window.ReactNativeWebView.postMessage(JSON.stringify({type:a,payload:b})),window.ReactNativeWebViewSendMessage=a=>rdhEmbed.receive(a.type,a.payload);else if(window.self!==window.top){rdhEmbed.enabled=!0,rdhEmbed.send=(a,b)=>window.parent.postMessage({type:a,payload:b},"*");var _onMessage2=a=>{var{data:b,source:c}=a;c!==window.parent||"object"!=typeof b||"string"!=typeof b.type||"undefined"!=typeof b.payload&&"object"!=typeof b.payload||rdhEmbed.receive(b.type,b.payload)};window.removeEventListener("message",_onMessage2),window.addEventListener("message",_onMessage2)}if(rdhEmbed.enabled){function a(){function b(){if(window.removeEventListener("DOMContentLoaded",a),rdh=new RdHighlight(document.body),rdh.onUpdate=a=>rdhEmbed.send("RDH_UPDATE",a),rdh.onRemove=a=>rdhEmbed.send("RDH_REMOVE",a),rdh.onAdd=a=>rdhEmbed.send("RDH_ADD",a),rdhEmbed.wait.length){for(var{type:b,payload:c}of rdhEmbed.wait)rdhEmbed.receive(b,c);rdhEmbed.enabled=[]}rdhEmbed.send("RDH_READY",{url:location.href})}clearTimeout(_delay),_delay=setTimeout(b,150)}rdhEmbed.receive=(a,b)=>rdh?void("RDH_APPLY"===a?rdh.apply(b):"RDH_CONFIG"===a?("boolean"==typeof b.enabled&&(rdh.enabled=b.enabled),"boolean"==typeof b.pro&&(rdh.pro=b.pro),"boolean"==typeof b.nav&&(rdh.nav=b.nav)):"RDH_SCROLL"===a?rdh.scrollToId(b._id):"RDH_ADD_SELECTION"===a?rdh.addSelection(b):"RDH_NOTE_SELECTION"===a?rdh.noteSelection():void 0):void rdhEmbed.wait.push({type:a,payload:b});var _delay;"loading"==document.readyState?(window.removeEventListener("DOMContentLoaded",a),window.addEventListener("DOMContentLoaded",a)):a()} diff --git a/yarn.lock b/yarn.lock index 3ded3a1..f03b235 100644 --- a/yarn.lock +++ b/yarn.lock @@ -612,10 +612,10 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.22.tgz#38b6c4b9b2f3ed9f2e376cce42a298fb2375251e" integrity sha512-8FwbVoG4fy+ykY86XCAclKZDORttqE5/s7dyWZKLXTdv3vRy5HozBEinG5IqhvPXXzIZEcTVbuHlQEI6iuwcmw== -"@types/node@^14.6.2": - version "14.18.12" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.12.tgz#0d4557fd3b94497d793efd4e7d92df2f83b4ef24" - integrity sha512-q4jlIR71hUpWTnGhXWcakgkZeHa3CCjcQcnuzU8M891BAWA2jHiziiWEPEkdS5pFsz7H9HJiy8BrK7tBRNrY7A== +"@types/node@^16.11.26": + version "16.11.26" + resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.26.tgz#63d204d136c9916fb4dcd1b50f9740fe86884e47" + integrity sha512-GZ7bu5A6+4DtG7q9GsoHXy3ALcgeIHP4NnL0Vv2wu0uUB/yQex26v0tf6/na1mm0+bS9Uw+0DFex7aaKr2qawQ== "@types/responselike@*", "@types/responselike@^1.0.0": version "1.0.0" @@ -1506,13 +1506,13 @@ electron-winstaller@^5.0.0: lodash.template "^4.2.2" temp "^0.9.0" -electron@17.1.x: - version "17.1.2" - resolved "https://registry.yarnpkg.com/electron/-/electron-17.1.2.tgz#b4e4a0df883d9a9854cf865efa2bb00b12d55b1d" - integrity sha512-hqKQaUIRWX5Y2eAD8FZINWD/e5TKdpkbBYbkcZmJS4Bd1PKQsaDVc9h5xoA8zZQkPymE9rss+swjRpAFurOPGQ== +electron@18.0.x: + version "18.0.1" + resolved "https://registry.yarnpkg.com/electron/-/electron-18.0.1.tgz#70653ecee008bea8a4240da78d0f5a426bb24d50" + integrity sha512-8y3nxmK+v/tiuaR8yd4K83ApHxgomMIPAEl3J+2Jfv/D5G6M3KnvxNlNiNoTXI8uOegfmoqiDm5/2xlWFLzfLQ== dependencies: "@electron/get" "^1.13.0" - "@types/node" "^14.6.2" + "@types/node" "^16.11.26" extract-zip "^1.0.3" emoji-regex@^8.0.0: