@ohos-ports/advanced-mark.js 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +107 -0
- package/LICENSE +21 -0
- package/README.md +25 -0
- package/dist/jquery.mark.d.ts +235 -0
- package/dist/jquery.mark.es6.d.ts +235 -0
- package/dist/jquery.mark.es6.js +1281 -0
- package/dist/jquery.mark.es6.min.js +8 -0
- package/dist/jquery.mark.js +1681 -0
- package/dist/jquery.mark.min.js +8 -0
- package/dist/mark.d.ts +210 -0
- package/dist/mark.es6.d.ts +210 -0
- package/dist/mark.es6.js +1284 -0
- package/dist/mark.es6.min.js +8 -0
- package/dist/mark.js +1682 -0
- package/dist/mark.min.js +8 -0
- package/package.json +72 -0
- package/src/jquery.js +24 -0
- package/src/jquery_es6.js +23 -0
- package/src/lib/domiterator.js +419 -0
- package/src/lib/mark.js +1817 -0
- package/src/lib/regexpcreator.js +397 -0
- package/src/types/jquery.mark.d.ts +235 -0
- package/src/types/mark.d.ts +210 -0
- package/src/vanilla.js +25 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*!***************************************************
|
|
2
|
+
* advanced-mark.js v3.0.0
|
|
3
|
+
* https://github.com/angezid/advanced-mark.js
|
|
4
|
+
* MIT licensed
|
|
5
|
+
* Copyright (c) 2022–2026, angezid
|
|
6
|
+
* Based on 'mark.js', license https://git.io/vwTVl
|
|
7
|
+
*****************************************************/
|
|
8
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).Mark=e(t.jQuery)}(this,(function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t);function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(o=r.key,i=void 0,"symbol"==typeof(i=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(o,"string"))?i:String(i)),r)}var o,i}function a(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(){return s=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},s.apply(this,arguments)}var c=function(){function t(e,n){o(this,t),this.ctx=e,this.opt=n,this.map=new Map}return a(t,[{key:"getContexts",value:function(){var t=this.ctx,e=this.opt.window,n=!1;if(!t)return[];Array.isArray(t)?n=!0:"string"==typeof t?t=e.document.querySelectorAll(t):void 0===t.length&&(t=[t]);for(var r=[],o=function(e){r.includes(t[e])||r.some((function(n){return n.contains(t[e])}))||r.push(t[e])},i=0;i<t.length;i++)o(i);return n&&r.sort((function(t,n){return(t.compareDocumentPosition(n)&e.Node.DOCUMENT_POSITION_FOLLOWING)>0?-1:1})),r}},{key:"getIframeContents",value:function(t,e,n){try{var r=t.contentWindow.document;r&&(this.map.set(t,"ready"),e({iframe:t,context:r}))}catch(e){n({iframe:t,error:e})}}},{key:"observeIframeLoad",value:function(t,e,n){var r=this;if(!this.map.has(t)){var o=null,i=function i(){clearTimeout(o),t.removeEventListener("load",i),r.getIframeContents(t,e,n)};t.addEventListener("load",i),this.map.set(t,!0),o=setTimeout(i,this.opt.iframesTimeout)}}},{key:"onIframeReady",value:function(t,e,n){var r="about:blank",o=t.getAttribute("src"),i=t.contentWindow;try{"complete"!==i.document.readyState||o&&o.trim()!==r&&i.location.href===r?this.observeIframeLoad(t,e,n):this.getIframeContents(t,e,n)}catch(t){n(t)}}},{key:"waitForIframes",value:function(t,e){var n,r,o=this,i=this.opt.shadowDOM,a=0,s=0,c=function t(e){for(var a=o.createIterator(e,o.opt.window.NodeFilter.SHOW_ELEMENT);r=a.nextNode();)o.isIframe(r)&&!o.map.has(r)&&(n.push(r),s++),i&&r.shadowRoot&&"open"===r.shadowRoot.mode&&t(r.shadowRoot)};!function t(r){n=[],r.iframe&&"about:blank"===r.context.location.href||(c(r.context),r.iframe||n.length)?n.length?n.forEach((function(n){o.onIframeReady(n,(function(e){a++,t(e)}),(function(t){o.opt.debug&&console.log(t.error||t),++a===s&&e()}))})):a===s&&e():e()}({context:t})}},{key:"createIterator",value:function(t,e){var n=this.opt.window;return n.document.createNodeIterator(t,e,(function(){return n.NodeFilter.FILTER_ACCEPT}),!1)}},{key:"addRemoveStyle",value:function(t,e,n){if(!n||e){var r=t.querySelector("style[data-markjs]");n?(r||((r=this.opt.window.document.createElement("style")).setAttribute("data-markjs","true"),t.appendChild(r)),r.textContent=e):r&&t.removeChild(r)}}},{key:"isIframe",value:function(e){return"IFRAME"===e.tagName&&!t.matches(e,this.opt.exclude)}},{key:"iterateThroughNodes",value:function(t,e,n,r,o){var i=this,a=this.opt.window.NodeFilter,s=this.opt.shadowDOM,c=this.opt.iframes;if(c||s){var u=(e&a.SHOW_ELEMENT)>0,h=(e&a.SHOW_TEXT)>0;!function t(o){for(var l,f=i.createIterator(o,e|a.SHOW_ELEMENT);o=f.nextNode();)if(1===o.nodeType){if(u&&n(o)&&r(o),c&&i.isIframe(o)&&"ready"===i.map.get(o)){var d=o.contentWindow.document;d&&(i.opt.highlight&&h&&o.contentWindow.CSS.highlights.set(i.opt.highlightName,i.opt.highlight),i.addRemoveStyle(d.head,c.style,h),t(d))}s&&(l=o.shadowRoot)&&"open"===l.mode&&(i.addRemoveStyle(l,s.style,h),t(l))}else h&&3===o.nodeType&&n(o)&&r(o)}(t)}else for(var l,f=this.createIterator(t,e);l=f.nextNode();)n(l)&&r(l);o()}},{key:"forEachNode",value:function(t,e,n){var r=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},i=this.getContexts(),a=i.length;a||o();var s=function(){i.forEach((function(i){r.iterateThroughNodes(i,t,n,e,(function(){--a<=0&&o()}))}))};if(this.opt.iframes){var c=a;i.forEach((function(t){r.waitForIframes(t,(function(){--c<=0&&s()}))}))}else s()}}],[{key:"matches",value:function(t,e){if(!e||!e.length)return!1;var n="string"==typeof e?[e]:e,r=t.matches;return r&&n.some((function(e){return r.call(t,e)}))}}]),t}(),u=function(){function t(e){o(this,t),this.opt=s({},{diacritics:!0,synonyms:{},accuracy:"partially",caseSensitive:!1,ignoreJoiners:!1,ignorePunctuation:[],wildcards:"disabled"},e)}return a(t,[{key:"chars",get:function(){var t=this;return this._chars||(this._chars=[],["aàáảãạăằắẳẵặâầấẩẫậäåāą","cçćč","dđď","eèéẻẽẹêềếểễệëěēę","iìíỉĩịîïī","lł","nñňń","oòóỏõọôồốổỗộơởỡớờợöøōő","rř","sšśșş","tťțţ","uùúủũụưừứửữựûüůūű","yýỳỷỹỵÿ","zžżź"].forEach((function(e){t._chars.push(e,e.toUpperCase())}))),this._chars}},{key:"create",value:function(t){var e=this,n="g".concat(this.opt.caseSensitive?"":"i");t=t.map((function(t){return"("+e.createPattern(t,n)+")"}));var r=this.createAccuracy(t.join("|"));return new RegExp("".concat(r.lookbehind,"(").concat(r.pattern,")").concat(r.lookahead),n)}},{key:"createPattern",value:function(t,e){t=this.checkWildcardsEscape(t),t=this.createSynonyms(t,e);var n=this.getJoinersPunctuation();return n&&(t=this.setupIgnoreJoiners(t)),this.opt.diacritics&&(t=this.createDiacritics(t)),t=t.replace(/\s+/g,"[\\s]+"),n&&(t=this.createJoiners(t,n)),"disabled"!==this.opt.wildcards&&(t=this.createWildcards(t)),t}},{key:"escape",value:function(t){return t.replace(/[[\]/{}()*+?.\\^$|]/g,"\\$&")}},{key:"preprocess",value:function(t){return t&&t.length?this.distinct("string"==typeof t?t.split(""):t).join("").replace(/[-^\]\\]/g,"\\$&"):""}},{key:"distinct",value:function(t){var e=[];return t.forEach((function(t){t.trim()&&!e.includes(t)&&e.push(t)})),e}},{key:"createSynonyms",value:function(t,e){var n=this,r=this.opt.synonyms;for(var o in r)if(r.hasOwnProperty(o)){var i=Array.isArray(r[o])?r[o]:[r[o]];if(i.unshift(o),(i=this.distinct(i)).length>1){i.sort((function(t,e){return e.length-t.length}));var a=(i=i.map((function(t){return n.checkWildcardsEscape(t)}))).map((function(t){return n.escape(t)})).join("|");t=t.replace(new RegExp(a,e),"(?:".concat(i.join("|"),")"))}}return t}},{key:"checkWildcardsEscape",value:function(t){return"disabled"!==this.opt.wildcards&&(t=t.replace(/(\\.)+|[?*]/g,(function(t,e){return e?t:"?"===t?"":""})).replace(/\\(?=[?*\x01\x02])/g,"")),this.escape(t)}},{key:"createWildcards",value:function(t){var e="withSpaces"===this.opt.wildcards,n=this.opt.blockElementsBoundary,r="[^".concat(e&&n?"":"","]*?");return t.replace(/\x01/g,e?"[^]?":"\\S?").replace(/\x02/g,e?r:"\\S*")}},{key:"setupIgnoreJoiners",value:function(t){return t.replace(/((?:\\\\)+|\x02|\(\?:|\|)|\\?(?:[\uD800-\uDBFF][\uDC00-\uDFFF]|.)(?=([|)\x02]|$)|.)/g,(function(t,e,n){return e||void 0!==n?t:t+"\0"}))}},{key:"createJoiners",value:function(t,e){return t.split(/\x00+/).join("[".concat(e,"]*"))}},{key:"getJoinersPunctuation",value:function(){var t=this.preprocess(this.opt.ignorePunctuation),e=t||"";return this.opt.ignoreJoiners&&(e+="\\u00ad\\u200b\\u200c\\u200d"),e}},{key:"createDiacritics",value:function(t){var e=this,n=this.chars;return t.split("").map((function(t){for(var r=0;r<n.length;r+=2){var o=n[r].includes(t);if(e.opt.caseSensitive){if(o)return"["+n[r]+"]";if(n[r+1].includes(t))return"["+n[r+1]+"]"}else if(o||n[r+1].includes(t))return"["+n[r]+n[r+1]+"]"}return t})).join("")}},{key:"createAccuracy",value:function(t){var e,n=this.opt.accuracy,r="()",o=t,i="";if("partially"!==n)if("string"!=typeof n&&(e=this.preprocess(n.limiters),n=n.value),"exactly"===n){var a=e?"[\\s"+e+"]":"\\s";r="(^|".concat(a,")"),i="(?=$|".concat(a,")")}else{var s=e||"!-/:-@[-`{-~¡¿",c="[^\\s".concat(s,"]*");o="(?:".concat(t,")"),"complementary"===n?o=c+o+c:"startsWith"===n&&(r="(^|[\\s".concat(s,"])"),o=o.split(/\[\\s\]\+/).join(c+"[\\s]+")+c)}return{lookbehind:r,pattern:o,lookahead:i}}}]),t}(),h=function(){function t(e){o(this,t),this.ctx=e,this.nodeNames=["script","style","title","head","html"]}return a(t,[{key:"opt",get:function(){return this._opt},set:function(t){if(!(t&&t.window&&t.window.document)&&"undefined"==typeof window)throw new Error("Mark.js: please provide a window object as an option.");var e=t&&t.window||window,n=t&&t.highlight&&t.highlight instanceof Highlight;this._opt=s({},{window:e,element:"",className:"",exclude:[],iframes:!1,iframesTimeout:5e3,separateWordSearch:!0,staticRanges:!0,rangeAcrossElements:!0,acrossElements:!1,ignoreGroups:0,each:function(){},noMatch:function(){},filter:function(){return!0},done:function(){},debug:!1,log:e.console},t),this._opt.element||(this._opt.element="mark"),this.filter=e.NodeFilter,this.empty=e.document.createTextNode(""),this._opt.highlightName||(this._opt.highlightName="advanced-markjs"),n?this.rangeArray=[]:this._opt.highlight=null}},{key:"iterator",get:function(){return new c(this.ctx,this.opt)}},{key:"log",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"debug";if(this.opt.debug){var n=this.opt.log;"object"===r(n)&&"function"==typeof n[e]&&n[e]("mark.js: ".concat(t))}}},{key:"report",value:function(t){var e=this;t.forEach((function(t){e.log("".concat(t.text," ").concat(JSON.stringify(t.obj)),t.level||"debug"),t.skip||e.opt.noMatch(t.obj)}))}},{key:"getSeachTerms",value:function(t){var e="string"==typeof t?[t]:t,n=this.opt.separateWordSearch,r=[],o={},i=function(t){t.split(/ +/).forEach((function(t){return a(t)}))},a=function(t){t.trim()&&!r.includes(t)&&(r.push(t),o[t]=0)};return e.forEach((function(t){n?"preserveTerms"===n?t.split(/"("*[^"]+"*)"/).forEach((function(t,e){e%2>0?a(t):i(t)})):i(t):a(t)})),r.sort((function(t,e){return e.length-t.length})),{terms:r,termStats:o}}},{key:"isNumeric",value:function(t){return Number(parseFloat(t))==t}},{key:"checkRanges",value:function(t,e,n,r){var o=this,i="error",a=t.filter((function(t){return!!(o.isNumeric(t.start)&&o.isNumeric(t.length)&&(t.start=parseInt(t.start),t.length=parseInt(t.length),t.start>=n&&t.start<r&&t.length>0))||(e.push({text:"Invalid range: ",obj:t,level:i}),!1)})).sort((function(t,e){return t.start-e.start}));if(this.opt.wrapAllRanges)return a;var s,c=0;return a.filter((function(t){return s=t.start+t.length,t.start>=c?(c=s,!0):(e.push({text:(s<c?"Nest":"Overlapp")+"ing range: ",obj:t,level:i}),!1)}))}},{key:"setType",value:function(t,e){var n=Array.isArray(e.tagNames)&&e.tagNames.length;if(n&&e.tagNames.forEach((function(e){return t[e.toLowerCase()]=2})),!n||e.extend)for(var r in t)t[r]=2;t.br=3}},{key:"getTextNodesAcross",value:function(t){var e,n,r,o=this,i={div:1,p:1,li:1,td:1,tr:1,th:1,ul:1,ol:1,dd:1,dl:1,dt:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,blockquote:1,figcaption:1,figure:1,pre:1,table:1,thead:1,tbody:1,tfoot:1,input:1,img:1,nav:1,details:1,label:1,form:1,select:1,menu:1,br:3,menuitem:1,main:1,section:1,article:1,aside:1,picture:1,output:1,button:1,header:1,footer:1,address:1,area:1,canvas:1,map:1,fieldset:1,textarea:1,track:1,video:1,audio:1,body:1,iframe:1,meter:1,object:1,svg:1},a=[],s=this.opt.blockElementsBoundary,c=s?2:1,u="";s&&(this.setType(i,s),s.char&&(u=s.char.charAt(0)));var h={text:"",regex:/\s/,tags:i,boundary:s,str:"",ch:u};this.iterator.forEachNode(this.filter.SHOW_ELEMENT|this.filter.SHOW_TEXT,(function(t){r&&a.push(o.getNodeInfo(r,t,n,h)),n=null,r=t}),(function(t){return 1===t.nodeType?(3===(e=i[t.nodeName.toLowerCase()])&&(h.str+="\n"),n&&e!==c||(n=e),!1):!o.excluded(t.parentNode)}),(function(){r&&a.push(o.getNodeInfo(r,null,n,h)),t({text:h.text,nodes:a,lastIndex:0})}))}},{key:"getNodeInfo",value:function(t,e,n,r){var o=r.text.length,i=r.ch,a=0,s=r.str,c=t.textContent;if(e){var u=r.regex.test(e.textContent[0]),h=u&&r.regex.test(c[c.length-1]);if(r.boundary||!h){var l=n;if(!n)for(var f=t.parentNode;f;){if(n=r.tags[f.nodeName.toLowerCase()]){l=!(f===e.parentNode||f.contains(e));break}f=f.parentNode}l&&(h?2===n&&(s+=h?i:u?" "+i:i+" "):s+=1===n?" ":2===n?" "+i+" ":"")}}return s&&(c+=s,a=s.length,r.str=""),r.text+=c,this.createInfo(t,o,r.text.length-a,a)}},{key:"getRangesTextNodes",value:function(t,e){var n,r=this,o=[],i=/\n/g,a=[0],s=this.filter.SHOW_TEXT|(e?this.filter.SHOW_ELEMENT:0),c="",u=0;this.iterator.forEachNode(s,(function(t){if(e)for(;null!==(n=i.exec(t.textContent));)a.push(u+n.index);c+=t.textContent,o.push({start:u,end:u=c.length,offset:0,node:t})}),(function(t){return e&&1===t.nodeType?("br"===t.tagName.toLowerCase()&&a.push(u),!1):!r.excluded(t.parentNode)}),(function(){var n={text:c,nodes:o,lastIndex:0};e&&(a.push(u),n.newLines=a),t(n)}))}},{key:"getTextNodes",value:function(t){var e=this,n=[],r=0;this.iterator.forEachNode(this.filter.SHOW_TEXT,(function(t){n.push({node:t,start:r}),r+=t.textContent.length}),(function(t){return!e.excluded(t.parentNode)}),(function(){t({nodes:n,lastIndex:0})}))}},{key:"excluded",value:function(t){return this.nodeNames.includes(t.nodeName.toLowerCase())||c.matches(t,this.opt.exclude)}},{key:"wrapRangeInsert",value:function(t,e,n,r,o,i){var a=r===e.node.textContent.length,s=e.end,c=1,u=r,h=e.node;0!==n?(h=h.splitText(n),u=r-n,c=a?2:3):a&&(c=0);var l=a?this.empty:h.splitText(u),f=this.createElement(h),d=f.childNodes[0],p=this.createInfo(l,0===c||2===c?s:e.start+r,s,e.offset);if(0===c)return e.node=d,{mark:f,nodeInfo:p,increment:0};var g=this.createInfo(d,1===c?e.start:o,e.start+r,0);return 1===c?t.nodes.splice(i,1,g,p):(2===c?t.nodes.splice(i+1,0,g):t.nodes.splice(i+1,0,g,p),e.end=o,e.offset=0),{mark:f,nodeInfo:p,increment:c<3?1:2}}},{key:"createInfo",value:function(t,e,n,r){return{node:t,start:e,end:n,offset:r}}},{key:"wrapRange",value:function(t,e,n,r){var o,i=t.node;if(this.rangeArray)this.createRange(i,e,i,n,t.start+e,r),o=i;else{var a=n===i.textContent.length,s=n;0!==e&&(i=i.splitText(e),s=n-e),o=a?this.empty:i.splitText(s),r(this.createElement(i))}return o}},{key:"createRange",value:function(t,e,n,r,o,i){var a;this.opt.staticRanges?a=new StaticRange({startContainer:t,startOffset:e,endContainer:n,endOffset:r}):((a=new Range).setStart(t,e),a.setEnd(n,r)),a.absoluteOffset=o,i(a,!0),a&&this.rangeArray.push(a)}},{key:"createElement",value:function(t){var e=this.opt.window.document.createElement(this.opt.element);return e.setAttribute("data-markjs","true"),this.opt.className&&e.setAttribute("class",this.opt.className),e.textContent=t.textContent,t.parentNode.replaceChild(e,t),e}},{key:"wrapRangeAcross",value:function(t,e,n,r,o){var i,a,s=t.lastIndex,c=!0,u=[],h=this.opt.wrapAllRanges,l=!!this.opt.highlight,f=l&&this.opt.rangeAcrossElements;if(h)for(;s>0&&t.nodes[s].start>e;)s--;for(;s<t.nodes.length;s++)if(s+1===t.nodes.length||t.nodes[s+1].start>e){var d=t.nodes[s];if(f)u.push(d.node);else if(!r(d.node))break;var p=e-d.start;if(a=(n>d.end?d.end:n)-d.start,p>=0&&a>p){if(f)c&&(i=[d.node,p,d.start+p]);else if(!l&&h){var g=this.wrapRangeInsert(t,d,p,a,e,s);d=g.nodeInfo,o(g.mark,c)}else d.node=this.wrapRange(d,p,a,(function(t){o(t,c)})),l||(d.start+=a);c=!1}if(!(n>d.end)){i&&r(u)&&this.createRange(i[0],i[1],d.node,a,i[2],o);break}e=d.end+d.offset}t.lastIndex=s}},{key:"wrapGroups",value:function(t,e,n,r,o){for(var i,a,s=0,c=0,u=0,h=this.opt.highlight,l=!1,f=0;++u<e.length;)(i=e[u])&&(a=e.indices[u][0])>=s&&(f=e.indices[u][1],r(t.node,i,u)&&(t.node=this.wrapRange(t,a-c,f-c,(function(t){o(t)})),f>s&&(s=f),h||(c=f),l=!0));l?h||(n.lastIndex=0):0===e[0].length&&this.setLastIndex(n,f)}},{key:"wrapGroupsAcross",value:function(t,e,n,r,o){for(var i,a,s,c=0,u=0,h=0;++u<e.length;)(a=e[u])&&(i=e.indices[u][0],(this.opt.wrapAllRanges||i>=c)&&(h=e.indices[u][1],s=!1,this.wrapRangeAcross(t,i,h,(function(t){return r(t,a,u)}),(function(t,e){s=!0,o(t,e)})),s&&h>c&&(c=h)));0===e[0].length&&this.setLastIndex(n,h)}},{key:"setLastIndex",value:function(t,e){var n=t.lastIndex;t.lastIndex=e>n?e:e>0?n+1:1/0}},{key:"processGroups",value:function(t,e,n,r,o,i){var a,s,c,u=this,h=n.count;this.getTextNodes((function(e){e.nodes.every((function(e){for(;null!==(a=t.exec(e.node.textContent))&&(n.match=a,s=c=!0,u.wrapGroups(e,a,t,(function(t,e,o){return n.matchStart=s,n.groupIndex=o,s=!1,r(t,e,n)}),(function(t){c&&h++,n.count=h,n.matchStart=c,c=!1,o(t,n)})),!n.abort););return!n.abort})),i(h)}))}},{key:"processGroupsAcross",value:function(t,e,n,r,o,i){var a,s,c,u=this,h=n.count;this.getTextNodesAcross((function(e){for(;null!==(a=t.exec(e.text))&&(n.match=a,s=c=!0,u.wrapGroupsAcross(e,a,t,(function(t,e,o){return n.groupStart=void 0,n.matchStart=s,n.groupIndex=o,s=!1,r(t,e,n)}),(function(t,e){c&&h++,n.count=h,n.matchStart=c,n.groupStart=e,o(t,n),c=!1})),!n.abort););i(h)}))}},{key:"processMatches",value:function(t,e,n,r,o,i){var a,s,c=this,u=0===e?0:e+1,h=n.count;this.getTextNodes((function(e){e.nodes.every((function(e){for(;null!==(a=t.exec(e.node.textContent));)if(""!==(s=a[u])){if(n.match=a,r(e.node,s,n)){for(var i=0,l=a.index;++i<u;)a[i]&&(l+=a[i].length);if(e.node=c.wrapRange(e,l,l+s.length,(function(t){n.count=++h,o(t,n)})),c.opt.highlight||(t.lastIndex=0),n.abort)break}}else t.lastIndex++;return!n.abort})),i(h)}))}},{key:"processMatchesAcross",value:function(t,e,n,r,o,i){var a,s,c,u=this,h=0===e?0:e+1,l=n.count;this.getTextNodesAcross((function(e){for(;null!==(a=t.exec(e.text));)if(""!==(s=a[h])){n.match=a,c=!0;for(var f=0,d=a.index;++f<h;)a[f]&&(d+=a[f].length);if(u.wrapRangeAcross(e,d,d+s.length,(function(t){return n.matchStart=c,c=!1,r(t,s,n)}),(function(t,e){e&&l++,n.count=l,n.matchStart=e,o(t,n)})),n.abort)break}else t.lastIndex++;i(l)}))}},{key:"processRanges",value:function(t,e,n,r){var o=this,i=this.opt.markLines,a=[],s=[],c="warn",u=0;this.getRangesTextNodes((function(h){var l=i?h.newLines.length:h.text.length,f=o.checkRanges(t,a,i?1:0,l);f.forEach((function(t,r){var f=t.start,d=f+t.length;d>l&&(a.push({text:"Range was limited to: ".concat(l),obj:t,skip:!0,level:c}),d=l),i&&(f=h.newLines[f-1],"\n"===h.text[f]&&f++,d=h.newLines[d-1]);var p=h.text.slice(f,d);p.trim()?o.wrapRangeAcross(h,f,d,(function(n){return e(n,t,p,r)}),(function(e,r){r&&u++,n(e,t,{matchStart:r,count:u})})):(a.push({text:"Skipping whitespace only range: ",obj:t,level:c}),s.push(t))})),o.log("Valid ranges: ".concat(JSON.stringify(f.filter((function(t){return!s.includes(t)}))))),r(u,a)}),i)}},{key:"unwrapMatches",value:function(t){var e=t.parentNode,n=t.firstChild;if(1===t.childNodes.length)if(3===n.nodeType){var r=t.previousSibling,o=t.nextSibling;if(r&&3===r.nodeType)o&&3===o.nodeType?(r.nodeValue+=n.nodeValue+o.nodeValue,e.removeChild(o)):r.nodeValue+=n.nodeValue;else{if(!o||3!==o.nodeType)return void e.replaceChild(t.firstChild,t);o.nodeValue=n.nodeValue+o.nodeValue}e.removeChild(t)}else e.replaceChild(t.firstChild,t);else{if(n){for(var i=this.opt.window.document.createDocumentFragment();t.firstChild;)i.appendChild(t.removeChild(t.firstChild));e.replaceChild(i,t)}else e.removeChild(t);e.normalize()}}},{key:"markRegExp",value:function(t,e){var n=this;this.opt=e;var r=0,o=0,i=this.opt.acrossElements,a="processMatches";if(this.opt.separateGroups){if(!t.hasIndices)throw new Error("Mark.js: RegExp must have a `d` flag");a=i?"processGroupsAcross":"processGroups"}else i&&(a="processMatchesAcross");if(!t.global&&!t.sticky){var s=t.toString().split("/");t=new RegExp(t.source,"g"+s[s.length-1]),this.log("RegExp is recompiled - it must have a `g` flag","warn")}this.log('RegExp "'.concat(t,'"')),this[a](t,this.opt.ignoreGroups,{count:0,abort:!1},(function(t,e,r){return n.opt.filter(t,e,o,r)}),(function(t,e){o=e.count,r++,n.opt.each(t,e)}),(function(e){0===e&&n.opt.noMatch(t),n.registerHighlight(),n.opt.done(r,e)}))}},{key:"mark",value:function(t,e){var n=this;this.opt=e;var r=this.getSeachTerms(t),o=r.terms,i=r.termStats;if(o.length){var a,s=0,c=0,u=0,h=this.opt.acrossElements,l=h?"processMatchesAcross":"processMatches",f=this.getRegExps(o),d={count:0,abort:!1};!function t(e){var r=e.regex,o=e.regTerms;n.log("RegExp ".concat(r)),n[l](r,1,d,(function(t,e,r){return h&&!r.matchStart||(a=n.getCurrentTerm(r.match,o)),n.opt.filter(t,a,u,i[a],r)}),(function(t,e){c++,u=e.count,h&&!e.matchStart||(i[a]+=1),n.opt.each(t,e)}),(function(e){var r=o.filter((function(t){return 0===i[t]}));r.length&&n.opt.noMatch(r),!d.abort&&++s<f.length?t(f[s]):(n.registerHighlight(),n.opt.done(c,e,i))}))}(f[0])}else this.opt.done(0,0,i)}},{key:"getCurrentTerm",value:function(t,e){for(var n=t.length;--n>2;)if(t[n])return e[n-3];return" "}},{key:"getRegExps",value:function(t){var e,n=new u(this.opt),r=this.opt.combineBy||this.opt.combinePatterns,o=t.length,i=[],a=100;r===1/0?a=o:!isNaN(+r)&&(e=parseInt(r))>0&&(a=e);for(var s=0;s<o;s+=a){var c=t.slice(s,Math.min(s+a,o));i.push({regex:n.create(c),regTerms:c})}return i}},{key:"markRanges",value:function(t,e){var n=this;if(this.opt=e,Array.isArray(t)){var r=0;this.processRanges(t,(function(t,e,r,o){return n.opt.filter(t,e,r,o)}),(function(t,e,o){r++,n.opt.each(t,e,o)}),(function(t,e){n.report(e),n.registerHighlight(),n.opt.done(r,t)}))}else this.report([{text:"markRanges() accept an array of objects: ",obj:t,level:"error"}]),this.opt.done(0,0)}},{key:"unmark",value:function(t){var e=this;this.opt=t;var n=CSS.highlights,r=this.opt.exclude&&this.opt.exclude.length;if(n){var o,i=this.opt.highlightName;"string"==typeof i&&(i=[i]),i.forEach((function(t){(o=n.get(t))&&o.size&&(n.delete(t),r?o.forEach((function(t){var n=t.startContainer;3===n.nodeType&&(n=n.parentNode),e.excluded(n)||o.delete(t)})):o.clear(),o.size&&n.set(t,o))}))}if(this.opt.highlight)this.opt.done();else{var a=this.opt.element+"[data-markjs]";this.opt.className&&(a+=".".concat(this.opt.className)),this.log('Removal selector "'.concat(a,'"')),this.iterator.forEachNode(this.filter.SHOW_ELEMENT,(function(t){e.unwrapMatches(t)}),(function(t){return c.matches(t,a)&&!(r&&e.excluded(t))}),this.opt.done)}}},{key:"registerHighlight",value:function(){var t=this,e=this.opt.highlight;if(e){var n=this.opt.highlightName,r=CSS.highlights;this.rangeArray.length&&(r.delete(n),e.size&&(e.forEach((function(e){t.rangeArray.push(e)})),e.clear()),this.rangeArray.sort((function(t,e){return t.absoluteOffset-e.absoluteOffset})),this.rangeArray.forEach((function(t){e.add(t)})),this.rangeArray=[]),e.size&&r.set(n,e)}}}]),t}();return n.default.fn.mark=function(t,e){return new h(this.get()).mark(t,e),this},n.default.fn.markRegExp=function(t,e){return new h(this.get()).markRegExp(t,e),this},n.default.fn.markRanges=function(t,e){return new h(this.get()).markRanges(t,e),this},n.default.fn.unmark=function(t){return new h(this.get()).unmark(t),this},n.default.fn.getVersion=function(){return"3.0.0"},n.default}));
|
package/dist/mark.d.ts
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
|
|
2
|
+
// Type definitions for advanced-mark.js v3.0.0
|
|
3
|
+
// Based on "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mark.js"
|
|
4
|
+
|
|
5
|
+
declare namespace Mark {
|
|
6
|
+
|
|
7
|
+
interface BoundaryObject {
|
|
8
|
+
tags?: string[];
|
|
9
|
+
extend?: boolean;
|
|
10
|
+
char?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface ShadowObject {
|
|
14
|
+
style: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface IframesObject {
|
|
18
|
+
style: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface AccuracyObject {
|
|
22
|
+
value: 'exactly' | 'startsWith' | 'complementary';
|
|
23
|
+
limiters: string | string[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface MarkOptions {
|
|
27
|
+
element?: string;
|
|
28
|
+
window?: Window;
|
|
29
|
+
className?: string;
|
|
30
|
+
exclude?: string | string[];
|
|
31
|
+
separateWordSearch?: boolean | 'preserveTerms';
|
|
32
|
+
acrossElements?: boolean;
|
|
33
|
+
accuracy?: 'partially' | 'exactly' | 'startsWith' | 'complementary' | AccuracyObject;
|
|
34
|
+
diacritics?: boolean;
|
|
35
|
+
synonyms?: { [index: string] : string | string[] };
|
|
36
|
+
caseSensitive?: boolean;
|
|
37
|
+
ignoreJoiners?: boolean;
|
|
38
|
+
ignorePunctuation?: string | string[];
|
|
39
|
+
wildcards?: 'disabled' | 'enabled' | 'withSpaces';
|
|
40
|
+
iframes?: boolean | IframesObject;
|
|
41
|
+
iframesTimeout?: number;
|
|
42
|
+
|
|
43
|
+
highlight?: Highlight;
|
|
44
|
+
highlightName?: string;
|
|
45
|
+
staticRanges?: boolean;
|
|
46
|
+
rangeAcrossElements?: boolean;
|
|
47
|
+
combineby?: number;
|
|
48
|
+
blockElementsBoundary?: boolean | BoundaryObject;
|
|
49
|
+
shadowDOM?: boolean | ShadowObject;
|
|
50
|
+
|
|
51
|
+
filter?(
|
|
52
|
+
nodeOrArray: Text | Text[], term: string, totalMatchesSoFar: number, termMatchesSoFar: number, filterInfo: MarkFilterInfo
|
|
53
|
+
) : boolean;
|
|
54
|
+
each?(elementOrRange: Element | StaticRange | Range, eachInfo: MarkEachInfo) : void;
|
|
55
|
+
done?(totalMarks: number, totalMatches: number, termStats: TermStats) : void;
|
|
56
|
+
|
|
57
|
+
noMatch?(term: string[]) : void;
|
|
58
|
+
debug?: boolean;
|
|
59
|
+
log?: object;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface MarkFilterInfo {
|
|
63
|
+
match: RegExpExecArray;
|
|
64
|
+
matchStart?: boolean;
|
|
65
|
+
count: number;
|
|
66
|
+
abort: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface MarkEachInfo {
|
|
70
|
+
match: RegExpExecArray;
|
|
71
|
+
matchStart?: boolean;
|
|
72
|
+
count: number;
|
|
73
|
+
abort: boolean;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface TermStats {
|
|
77
|
+
[index: string] : number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface RegExpOptions {
|
|
81
|
+
element?: string;
|
|
82
|
+
className?: string;
|
|
83
|
+
exclude?: string | string[];
|
|
84
|
+
acrossElements?: boolean;
|
|
85
|
+
ignoreGroups?: number;
|
|
86
|
+
iframes?: boolean | IframesObject;
|
|
87
|
+
iframesTimeout?: number;
|
|
88
|
+
|
|
89
|
+
highlight?: Highlight;
|
|
90
|
+
highlightName?: string;
|
|
91
|
+
staticRanges?: boolean;
|
|
92
|
+
rangeAcrossElements?: boolean;
|
|
93
|
+
separateGroups?: boolean;
|
|
94
|
+
wrapAllRanges?: boolean;
|
|
95
|
+
blockElementsBoundary?: boolean | BoundaryObject;
|
|
96
|
+
shadowDOM?: boolean | ShadowObject;
|
|
97
|
+
|
|
98
|
+
filter?(nodeOrArray: Text | Text[], regexp: string, matchesSoFar: number, filterInfo: RegExpFilterInfo) : boolean;
|
|
99
|
+
each?(elementOrRange: Element | StaticRange | Range, eachInfo: RegExpEachInfo) : void;
|
|
100
|
+
done?(totalMarks: number, totalMatches: number) : void;
|
|
101
|
+
|
|
102
|
+
noMatch?(regexp: string) : void;
|
|
103
|
+
debug?: boolean;
|
|
104
|
+
log?: object;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
interface RegExpFilterInfo {
|
|
108
|
+
match: RegExpExecArray;
|
|
109
|
+
matchStart?: boolean;
|
|
110
|
+
count: number;
|
|
111
|
+
groupIndex?: number;
|
|
112
|
+
abort: boolean;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
interface RegExpEachInfo {
|
|
116
|
+
match: RegExpExecArray;
|
|
117
|
+
matchStart?: boolean;
|
|
118
|
+
count: number;
|
|
119
|
+
groupIndex?: number;
|
|
120
|
+
groupStart?: boolean;
|
|
121
|
+
abort: boolean;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
interface RangesOptions {
|
|
125
|
+
element?: string;
|
|
126
|
+
className?: string;
|
|
127
|
+
exclude?: string | string[];
|
|
128
|
+
iframes?: boolean | IframesObject;
|
|
129
|
+
iframesTimeout?: number;
|
|
130
|
+
|
|
131
|
+
highlight?: Highlight;
|
|
132
|
+
highlightName?: string;
|
|
133
|
+
staticRanges?: boolean;
|
|
134
|
+
rangeAcrossElements?: boolean;
|
|
135
|
+
wrapAllRanges?: boolean;
|
|
136
|
+
markLines?: boolean;
|
|
137
|
+
shadowDOM?: boolean | ShadowObject;
|
|
138
|
+
|
|
139
|
+
filter?(nodeOrArray: Text | Text[], range: MarkRange, matchingString: string, currentIndex: number) : boolean;
|
|
140
|
+
each?(elementOrRange: Element | StaticRange | Range, range: MarkRange, eachInfo: RangeEachInfo) : void;
|
|
141
|
+
done?(totalMarks: number, totalRanges: number) : void;
|
|
142
|
+
|
|
143
|
+
noMatch?(range: MarkRange) : void;
|
|
144
|
+
debug?: boolean;
|
|
145
|
+
log?: object;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
interface MarkRange {
|
|
149
|
+
start: number;
|
|
150
|
+
length: number;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
interface RangeEachInfo {
|
|
154
|
+
matchStart?: boolean;
|
|
155
|
+
count: number;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface UnmarkOptions {
|
|
159
|
+
element?: string;
|
|
160
|
+
className?: string;
|
|
161
|
+
exclude?: string | string[];
|
|
162
|
+
iframes?: boolean | IframesObject;
|
|
163
|
+
iframesTimeout?: number;
|
|
164
|
+
shadowDOM?: boolean;
|
|
165
|
+
highlight?: Highlight;
|
|
166
|
+
highlightName?: string | string[];
|
|
167
|
+
|
|
168
|
+
done?() : void;
|
|
169
|
+
debug?: boolean;
|
|
170
|
+
log?: object;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
declare class Mark {
|
|
175
|
+
constructor(context: string | HTMLElement | ReadonlyArray<HTMLElement> | NodeList | null);
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Highlights the specified search terms.
|
|
179
|
+
* @param term The string to be marked. Can also be an array with multiple strings.
|
|
180
|
+
* Note that keywords will be escaped. If you need to mark unescaped keywords (e.g. containing a pattern),
|
|
181
|
+
* have a look at the `markRegExp()`
|
|
182
|
+
* @param options Optional options
|
|
183
|
+
*/
|
|
184
|
+
mark(term: string | ReadonlyArray<string>, options?: Mark.MarkOptions) : void;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Highlights a custom regular expression.
|
|
188
|
+
* @param regexp The regular expression to be marked. Example: /Lor[^]?m/gmi.
|
|
189
|
+
* Note that the `g` flag must be present when `acrossElements : true`, otherwise the RegExp is recompiled.
|
|
190
|
+
* @param options Optional options
|
|
191
|
+
*/
|
|
192
|
+
markRegExp(regexp: RegExp, options?: Mark.RegExpOptions) : void;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* A method to mark ranges with a start position and length. They will be applied
|
|
196
|
+
* to text nodes in the specified context.
|
|
197
|
+
* @param ranges An array of objects with a start and length property.
|
|
198
|
+
* Note that the start positions must be specified including whitespace characters.
|
|
199
|
+
* @param options Optional options
|
|
200
|
+
*/
|
|
201
|
+
markRanges(ranges: ReadonlyArray<Mark.MarkRange>, options?: Mark.RangesOptions) : void;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* A method to remove mark elements created by mark.js and normalize text nodes.
|
|
205
|
+
* @param options Optional options
|
|
206
|
+
*/
|
|
207
|
+
unmark(options?: Mark.UnmarkOptions) : void;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export = Mark;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
|
|
2
|
+
// Type definitions for advanced-mark.js v3.0.0
|
|
3
|
+
// Based on "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mark.js"
|
|
4
|
+
|
|
5
|
+
declare namespace Mark {
|
|
6
|
+
|
|
7
|
+
interface BoundaryObject {
|
|
8
|
+
tags?: string[];
|
|
9
|
+
extend?: boolean;
|
|
10
|
+
char?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface ShadowObject {
|
|
14
|
+
style: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface IframesObject {
|
|
18
|
+
style: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface AccuracyObject {
|
|
22
|
+
value: 'exactly' | 'startsWith' | 'complementary';
|
|
23
|
+
limiters: string | string[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface MarkOptions {
|
|
27
|
+
element?: string;
|
|
28
|
+
window?: Window;
|
|
29
|
+
className?: string;
|
|
30
|
+
exclude?: string | string[];
|
|
31
|
+
separateWordSearch?: boolean | 'preserveTerms';
|
|
32
|
+
acrossElements?: boolean;
|
|
33
|
+
accuracy?: 'partially' | 'exactly' | 'startsWith' | 'complementary' | AccuracyObject;
|
|
34
|
+
diacritics?: boolean;
|
|
35
|
+
synonyms?: { [index: string] : string | string[] };
|
|
36
|
+
caseSensitive?: boolean;
|
|
37
|
+
ignoreJoiners?: boolean;
|
|
38
|
+
ignorePunctuation?: string | string[];
|
|
39
|
+
wildcards?: 'disabled' | 'enabled' | 'withSpaces';
|
|
40
|
+
iframes?: boolean | IframesObject;
|
|
41
|
+
iframesTimeout?: number;
|
|
42
|
+
|
|
43
|
+
highlight?: Highlight;
|
|
44
|
+
highlightName?: string;
|
|
45
|
+
staticRanges?: boolean;
|
|
46
|
+
rangeAcrossElements?: boolean;
|
|
47
|
+
combineby?: number;
|
|
48
|
+
blockElementsBoundary?: boolean | BoundaryObject;
|
|
49
|
+
shadowDOM?: boolean | ShadowObject;
|
|
50
|
+
|
|
51
|
+
filter?(
|
|
52
|
+
nodeOrArray: Text | Text[], term: string, totalMatchesSoFar: number, termMatchesSoFar: number, filterInfo: MarkFilterInfo
|
|
53
|
+
) : boolean;
|
|
54
|
+
each?(elementOrRange: Element | StaticRange | Range, eachInfo: MarkEachInfo) : void;
|
|
55
|
+
done?(totalMarks: number, totalMatches: number, termStats: TermStats) : void;
|
|
56
|
+
|
|
57
|
+
noMatch?(term: string[]) : void;
|
|
58
|
+
debug?: boolean;
|
|
59
|
+
log?: object;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface MarkFilterInfo {
|
|
63
|
+
match: RegExpExecArray;
|
|
64
|
+
matchStart?: boolean;
|
|
65
|
+
count: number;
|
|
66
|
+
abort: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface MarkEachInfo {
|
|
70
|
+
match: RegExpExecArray;
|
|
71
|
+
matchStart?: boolean;
|
|
72
|
+
count: number;
|
|
73
|
+
abort: boolean;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface TermStats {
|
|
77
|
+
[index: string] : number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface RegExpOptions {
|
|
81
|
+
element?: string;
|
|
82
|
+
className?: string;
|
|
83
|
+
exclude?: string | string[];
|
|
84
|
+
acrossElements?: boolean;
|
|
85
|
+
ignoreGroups?: number;
|
|
86
|
+
iframes?: boolean | IframesObject;
|
|
87
|
+
iframesTimeout?: number;
|
|
88
|
+
|
|
89
|
+
highlight?: Highlight;
|
|
90
|
+
highlightName?: string;
|
|
91
|
+
staticRanges?: boolean;
|
|
92
|
+
rangeAcrossElements?: boolean;
|
|
93
|
+
separateGroups?: boolean;
|
|
94
|
+
wrapAllRanges?: boolean;
|
|
95
|
+
blockElementsBoundary?: boolean | BoundaryObject;
|
|
96
|
+
shadowDOM?: boolean | ShadowObject;
|
|
97
|
+
|
|
98
|
+
filter?(nodeOrArray: Text | Text[], regexp: string, matchesSoFar: number, filterInfo: RegExpFilterInfo) : boolean;
|
|
99
|
+
each?(elementOrRange: Element | StaticRange | Range, eachInfo: RegExpEachInfo) : void;
|
|
100
|
+
done?(totalMarks: number, totalMatches: number) : void;
|
|
101
|
+
|
|
102
|
+
noMatch?(regexp: string) : void;
|
|
103
|
+
debug?: boolean;
|
|
104
|
+
log?: object;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
interface RegExpFilterInfo {
|
|
108
|
+
match: RegExpExecArray;
|
|
109
|
+
matchStart?: boolean;
|
|
110
|
+
count: number;
|
|
111
|
+
groupIndex?: number;
|
|
112
|
+
abort: boolean;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
interface RegExpEachInfo {
|
|
116
|
+
match: RegExpExecArray;
|
|
117
|
+
matchStart?: boolean;
|
|
118
|
+
count: number;
|
|
119
|
+
groupIndex?: number;
|
|
120
|
+
groupStart?: boolean;
|
|
121
|
+
abort: boolean;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
interface RangesOptions {
|
|
125
|
+
element?: string;
|
|
126
|
+
className?: string;
|
|
127
|
+
exclude?: string | string[];
|
|
128
|
+
iframes?: boolean | IframesObject;
|
|
129
|
+
iframesTimeout?: number;
|
|
130
|
+
|
|
131
|
+
highlight?: Highlight;
|
|
132
|
+
highlightName?: string;
|
|
133
|
+
staticRanges?: boolean;
|
|
134
|
+
rangeAcrossElements?: boolean;
|
|
135
|
+
wrapAllRanges?: boolean;
|
|
136
|
+
markLines?: boolean;
|
|
137
|
+
shadowDOM?: boolean | ShadowObject;
|
|
138
|
+
|
|
139
|
+
filter?(nodeOrArray: Text | Text[], range: MarkRange, matchingString: string, currentIndex: number) : boolean;
|
|
140
|
+
each?(elementOrRange: Element | StaticRange | Range, range: MarkRange, eachInfo: RangeEachInfo) : void;
|
|
141
|
+
done?(totalMarks: number, totalRanges: number) : void;
|
|
142
|
+
|
|
143
|
+
noMatch?(range: MarkRange) : void;
|
|
144
|
+
debug?: boolean;
|
|
145
|
+
log?: object;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
interface MarkRange {
|
|
149
|
+
start: number;
|
|
150
|
+
length: number;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
interface RangeEachInfo {
|
|
154
|
+
matchStart?: boolean;
|
|
155
|
+
count: number;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface UnmarkOptions {
|
|
159
|
+
element?: string;
|
|
160
|
+
className?: string;
|
|
161
|
+
exclude?: string | string[];
|
|
162
|
+
iframes?: boolean | IframesObject;
|
|
163
|
+
iframesTimeout?: number;
|
|
164
|
+
shadowDOM?: boolean;
|
|
165
|
+
highlight?: Highlight;
|
|
166
|
+
highlightName?: string | string[];
|
|
167
|
+
|
|
168
|
+
done?() : void;
|
|
169
|
+
debug?: boolean;
|
|
170
|
+
log?: object;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
declare class Mark {
|
|
175
|
+
constructor(context: string | HTMLElement | ReadonlyArray<HTMLElement> | NodeList | null);
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Highlights the specified search terms.
|
|
179
|
+
* @param term The string to be marked. Can also be an array with multiple strings.
|
|
180
|
+
* Note that keywords will be escaped. If you need to mark unescaped keywords (e.g. containing a pattern),
|
|
181
|
+
* have a look at the `markRegExp()`
|
|
182
|
+
* @param options Optional options
|
|
183
|
+
*/
|
|
184
|
+
mark(term: string | ReadonlyArray<string>, options?: Mark.MarkOptions) : void;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Highlights a custom regular expression.
|
|
188
|
+
* @param regexp The regular expression to be marked. Example: /Lor[^]?m/gmi.
|
|
189
|
+
* Note that the `g` flag must be present when `acrossElements : true`, otherwise the RegExp is recompiled.
|
|
190
|
+
* @param options Optional options
|
|
191
|
+
*/
|
|
192
|
+
markRegExp(regexp: RegExp, options?: Mark.RegExpOptions) : void;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* A method to mark ranges with a start position and length. They will be applied
|
|
196
|
+
* to text nodes in the specified context.
|
|
197
|
+
* @param ranges An array of objects with a start and length property.
|
|
198
|
+
* Note that the start positions must be specified including whitespace characters.
|
|
199
|
+
* @param options Optional options
|
|
200
|
+
*/
|
|
201
|
+
markRanges(ranges: ReadonlyArray<Mark.MarkRange>, options?: Mark.RangesOptions) : void;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* A method to remove mark elements created by mark.js and normalize text nodes.
|
|
205
|
+
* @param options Optional options
|
|
206
|
+
*/
|
|
207
|
+
unmark(options?: Mark.UnmarkOptions) : void;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export = Mark;
|