1 |
- System.register(["./index-legacy-9cb9141d-1724234378139.js"],(function(e,t){"use strict";var o,n,s,c;return{setters:[e=>{o=e.e,n=e.q,s=e.T,c=e.aO}],execute:function(){e("i","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAAXNSR0IArs4c6QAAAQJJREFUWEftmD0PAUEQhmdWcw0aLjlR+fhbOtHQoFQq7xQaEZ2/RVRESBTCiUjsiER19nZOKE4y197s7jvPO7tze+j5miBFD4ogxg0hxJXrfxBSiAMNsLdloxByWpNvilEKu5rgbB0P4GqiYTTGSCijsL7u4tI2YW1MxfBGRtHKwcKmjQfb+PKIandNi/QLKvnUiap0sjBftfBoy7A6IfcS0s5oWQJClSnlrydovBHiqj7u/beWxc2LIog7qYWQEAKAJAej7DKudQghISS9jGspQkgIvQj85weaF1AzaqECyGqi4JNr0LaHM64UEhH61Q+JbV+x67EBz4xEEOerEEoToQcvexD4nAzBpwAAAABJRU5ErkJggg=="),e("a","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAA4CAYAAACohjseAAAAAXNSR0IArs4c6QAAAodJREFUaEPtmz9oFFEQxn+zhSnuzs4gQcFLxMLCTkghEivFQtDWXjClhY2YImJjYWcE+7QKgmCXIBaBlIKgmD3BEES7271Cix15m+xxSe7cP9m97D3etjc7M983376dt29OyHip6onvPa6pcgu4iDKjMAM0M7ooahYK7CDsAJ9FeHuuwZqI/M3iUNKMOqGejpQllLvAyTT7Mf3eRVj1hOV2U37+L+ZIgKo61Ql5hPJAoTGmxHOFEeghPG83eSoif4bdPBSgqZpGvFGYzxXxmIwFNsTj9rBqHgLoh3pJlXcoZ44p32JhhW2Em3NN+TToYB/Avedtc+LAJYiEbU+4PFjJPsD4mQtYnxRZjiqzkWu7xULyTPYB+oEuq/K4mD7qdZcIT2ZbsmSyigHuLSrf6rpa5qXPrK7icd5INQa4FegKyv28jmptL7yca8mimA7FD/hdo5d4Wbx1Z1uckk6o16OI92V5rZMf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tC9Cpxri/hVYPOsXSW/A2+tHD5cjOcgX7lzd46kBxwUt+hT1yJaZdPFO0Zl46zFoDegRtKC61AoGJYeHM7WCHkELqkutYFByeDgT+8FvGv/RffyXL7Ffn0V/ARr9FbZbeaMuQnCA0ZeROMioC4EcYPSlXHmq9o04i/Hy17yoyylzyKgLYnPIqEuah3cl0Ral/731qupnBb8BLD56cQ63aRAAAAAASUVORK5CYII="),e("u",((e,t)=>{const l=e?"#"+e:"#musicContent",r=t||"selectionCouser",a=o({showDom:!1,synth:null,selectOptions:{startIndex:0,anchorOffset:0,endIndex:0,focusOffset:0},isSpeak:!1}),i=e=>{const t=document.createDocumentFragment();return e.childNodes?.forEach((e=>{if(e.nodeType===Node.TEXT_NODE){const o=e.textContent.split(/(?<=[,,;;。])\s*/);o?.forEach((e=>{if(e.trim()){const o=document.createElement("label");o.textContent=e.trim(),o.classList.add("speak-label"),t.appendChild(o)}}))}else if(e.nodeType===Node.ELEMENT_NODE){const o=document.createElement(e.nodeName.toLowerCase());Array.from(e.attributes).forEach((e=>{o.setAttribute(e.name,e.value)}));const n=i(e);o.appendChild(n),t.appendChild(o)}})),t},A=e=>{if(e.rangeCount>0){const t=e.anchorNode,o=e.anchorOffset,n=e.focusNode,s=e.focusOffset;if(t===n)return o<s?"up":"down";{const o=e.getRangeAt(0),s=o.startContainer,c=o.endContainer;return s===t&&c===n?"up":"down"}}return"up"},d=()=>{const e=window.getSelection(),t=e.rangeCount>0?e.getRangeAt(0):null;if(e.toString().length>0){a.showDom=!0;const t=document.querySelector(l),o=t?.querySelectorAll("label.speak-label");let n=0,s=0,c=0,r=0;if(console.log(e,"selection"),0===e.focusOffset&&0===e.anchorOffset){const t=e.anchorNode.parentNode.parentElement,l=t.childNodes[0],a=t.childNodes[t.childNodes.length-1];o?.forEach(((e,t)=>{e===l&&(n=t,s=0),e===a&&(c=t,r=a.textContent.length)}))}else{const t="up"===A(e)?e.anchorNode.parentNode:e.focusNode.parentNode,l="down"===A(e)?e.anchorNode.parentNode:e.focusNode.parentNode;"up"===A(e)?(s=e.anchorOffset,r=e.focusOffset):(s=e.focusOffset,r=e.anchorOffset),o?.forEach(((o,a)=>{o===t&&(n=a,s="up"===A(e)?e.anchorOffset:e.focusOffset),o===l&&(c=a,r="down"===A(e)?e.anchorOffset:e.focusOffset)}))}a.selectOptions.startIndex=n,a.selectOptions.anchorOffset=s,a.selectOptions.endIndex=c,a.selectOptions.focusOffset=r}else a.showDom=!1;if(setTimeout((()=>{"Range"!==e.type&&(a.showDom=!1)}),200),t&&!e.isCollapsed){const e=t.getClientRects();if(e.length>0){const t=e[0],o=t.left,n=t.top,s=t.bottom,c=t.height,a=document.querySelector(l),i=a?.getBoundingClientRect(),A=document.getElementById(r),d=A?.getBoundingClientRect();console.log({parentRect:i,showDomRect:d,firstRect:t,dom:document.querySelector(l)}),console.log(!1,i?.bottom-s+(d.height+c/2)+a?.scrollTop),A.style.top=(n-i?.top+(d.height+c/2)+a?.scrollTop).toFixed(2)+"px",i?.width-(o-i?.left)>d.width?(A.style.left=(o-i?.left).toFixed(2)+"px",A.style.right="auto"):(A.style.right="0px",A.style.left="auto")}}};function h(){window.getSelection?window.getSelection()?.removeAllRanges():document.selection&&document.selection.empty(),a.showDom=!1}const f=()=>{a.synth?.cancel(),a.isSpeak=!1;const e=document.querySelector(l),t=e?.querySelectorAll("label.speak-label");t?.forEach(((e,t)=>{e.classList.toggle("highlight",-1===t)})),h()},u=e=>{const t=document.querySelector(l),o=t?.querySelectorAll("label.speak-label");let n=e.startIndex||0;const s=void 0===e.endIndex?o.length-1:e.endIndex,c=e=>{o?.forEach(((t,o)=>{t.classList.toggle("highlight",o===e)}));const n=t?.querySelector(".highlight");n?.scrollIntoView({behavior:"smooth",block:"center"})},r=()=>{try{a.synth=window.speechSynthesis,a.synth.speaking&&a.synth.cancel();let t=o[n].textContent;if(t.length<=0)return void console.error("暂无播放内容");e.startIndex===e.endIndex&&void 0!==e.endIndex?t=t.substr(e.anchorOffset,(e.focusOffset||0)-(e.anchorOffset||0)):(e.startIndex===n&&(t=t.substr(e.anchorOffset,t.length)),e.endIndex===n&&(t=t.substr(0,e.focusOffset)));const l=["尝笛","打击月","月取","取"];t&&["长笛","打击乐","乐曲","曲"].forEach(((e,o)=>{if(t.includes(e)){const n=new RegExp(e,"g");t=t.replace(n,l[o])}})),console.log(t,n,s,"---------");const i=new SpeechSynthesisUtterance(t);i.lang="zh-CN",i.volume=1,i.rate=.8,i.pitch=1.5,i&&(i.onstart=null,i.onend=null,i.onerror=null),i.onstart=()=>{a.isSpeak=!0,c(n)},i.onend=()=>{console.log("朗读结束"),n++,n<=s&&a.isSpeak?r():(n=0,c(-1),a.isSpeak=!1)},i.onerror=()=>{n++,n<=s&&a.isSpeak?r():a.isSpeak=!1},setTimeout((()=>{a.synth.speak(i)}),80)}catch(t){console.log(t,"e")}};r()},g=()=>{document.removeEventListener("mouseup",d),document.addEventListener("touchend",d),f()};return n((async()=>{document.addEventListener("mouseup",d),document.addEventListener("touchend",d)})),s((()=>{g()})),{...c(a),onAllSpeak:()=>{h();try{u({startIndex:0})}catch(e){console.log(e,"12")}},onTextStart:()=>{f(),u({startIndex:a.selectOptions.startIndex,anchorOffset:a.selectOptions.anchorOffset})},onDestory:g,onCloseSpeak:f,onTextReadOnly:()=>{f(),u(a.selectOptions)},processNode:i}}))}}}));
|