@vector-im/matrix-wysiwyg 2.40.0 → 2.42.1
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/dist/lib/constants.d.ts +2 -0
- package/dist/lib/conversion.d.ts +4 -0
- package/dist/lib/types.d.ts +36 -0
- package/dist/lib/useComposerModel.d.ts +11 -0
- package/dist/lib/useListeners/types.d.ts +27 -0
- package/dist/lib/useTestCases/types.d.ts +5 -0
- package/dist/lib/useWysiwyg.d.ts +26 -0
- package/dist/matrix-wysiwyg.js +814 -996
- package/dist/matrix-wysiwyg.umd.cjs +4 -11
- package/node_modules/@vector-im/matrix-wysiwyg-wasm/package.json +7 -6
- package/package.json +22 -21
- package/dist/index.d.ts +0 -98
- package/node_modules/@vector-im/matrix-wysiwyg-wasm/pkg/wysiwyg.d.ts +0 -265
- package/node_modules/@vector-im/matrix-wysiwyg-wasm/pkg/wysiwyg_bg.cjs +0 -1838
- package/node_modules/@vector-im/matrix-wysiwyg-wasm/pkg/wysiwyg_bg.js +0 -1849
- package/node_modules/@vector-im/matrix-wysiwyg-wasm/pkg/wysiwyg_bg.wasm +0 -0
- package/node_modules/@vector-im/matrix-wysiwyg-wasm/pkg/wysiwyg_bg.wasm.d.ts +0 -136
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
(function(g,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("react"),require("@vector-im/matrix-wysiwyg-wasm")):typeof define=="function"&&define.amd?define(["exports","react","@vector-im/matrix-wysiwyg-wasm"],_):(g=typeof globalThis<"u"?globalThis:g||self,_(g["Matrix wysiwyg"]={},g.React,g.matrixWysiwygWasm))})(this,function(g,_,y){"use strict";function k(e){return"inputType"in e}function A(e){return"clipboardData"in e}function M(e){return k(e)&&e.inputType==="insertSuggestion"}function ee(e){return k(e)&&e.inputType==="insertAtRoomSuggestion"}function te(e){return k(e)&&e.inputType=="insertLink"}function I(e,t,n,s){return s?s(e,t,n):e}function ne(e,t,n,s,r,o,u,l){const a=I(e,{actions:s,content:()=>t.get_content_as_html(),messageContent:()=>t.get_content_as_message_html()},r,u);if(!a)return;if(A(a)){const i=a.clipboardData,f=i?.getData("text/html"),m=i?.getData("text/plain")??"";if(f&&f!==m){const d=i?.types.includes("application/x-vnd.google-docs-document-slice-clip+wrapped")?y.HtmlSource.GoogleDoc:y.HtmlSource.UnknownExternal;return n(t.replace_html(f,d),"replace_html_paste")}return n(t.replace_text(m),"replace_text_paste")}switch(a.inputType){case"insertAtRoomSuggestion":{if(o&&ee(a)){const{attributes:i}=a.data;return i.has("data-mention-type")&&i.delete("data-mention-type"),n(t.insert_at_room_mention_at_suggestion(o,i),"insert_at_room_mention_at_suggestion")}break}case"insertSuggestion":{if(o&&M(a)){const{text:i,url:f,attributes:m}=a.data;return m.has("data-mention-type")&&m.delete("data-mention-type"),n(t.insert_mention_at_suggestion(f,i,o,m),"insert_mention_at_suggestion")}break}case"insertCommand":case"insertEmoji":{if(o&&a.data){const i=a.inputType==="insertCommand";return n(t.replace_text_suggestion(a.data,o,i),"replace_text_suggestion")}break}case"clear":return n(t.clear(),"clear");case"deleteContentBackward":return n(t.backspace(),"backspace");case"deleteWordBackward":return n(t.backspace_word(),"backspace_word");case"deleteSoftLineBackward":{const i=document.getSelection();return i&&(i.modify("extend","backward","lineboundary"),document.dispatchEvent(new CustomEvent("selectionchange"))),n(t.delete(),"backspace_line")}case"deleteContentForward":return n(t.delete(),"delete");case"deleteWordForward":return n(t.delete_word(),"delete_word");case"deleteByCut":return n(t.delete(),"delete");case"formatBold":return n(t.bold(),"bold");case"formatItalic":return n(t.italic(),"italic");case"formatStrikeThrough":return n(t.strike_through(),"strike_through");case"formatUnderline":return n(t.underline(),"underline");case"formatInlineCode":return n(t.inline_code(),"inline_code");case"historyRedo":return n(t.redo(),"redo");case"historyUndo":return n(t.undo(),"undo");case"insertCodeBlock":return n(t.code_block(),"code_block");case"insertQuote":return n(t.quote(),"quote");case"insertFromPaste":return;case"insertOrderedList":return n(t.ordered_list(),"ordered_list");case"insertLineBreak":case"insertParagraph":return c(t,o,l),n(t.enter(),"enter");case"insertReplacementText":{const i=r.innerHTML.slice(0,r.innerHTML.length-4);return n(t.set_content_from_html(i),"set_content_from_html",i)}case"insertCompositionText":case"insertFromComposition":case"insertText":if(a.data)return a.data==" "&&c(t,o,l),n(t.replace_text(a.data),"replace_text",a.data);break;case"insertUnorderedList":return n(t.unordered_list(),"unordered_list");case"insertLink":if(te(a)){const{text:i,url:f}=a.data;return n(i?t.set_link_with_text(f,i,new Map):t.set_link(f,new Map),"insertLink")}break;case"removeLinks":return n(t.remove_links(),"remove_links");case"formatIndent":return n(t.indent(),"indent");case"formatOutdent":return n(t.unindent(),"unindent");case"sendMessage":return null;default:return console.error(`Unknown input type: ${a.inputType}`),console.error(e),null}function c(i,f,m){if(m&&f&&f.key.key_type==3&&f.key.custom_key_value){const d=m.get(f.key.custom_key_value);d&&i.replace_text_suggestion(d,f,!1)}}}function se(e,t){e.innerHTML="";const n=t.document();let s=0;function r(u,l,a,c){const i=document.createElement(l);if(a&&(i.innerText=a.replace("","~")),c)for(const[f,m]of c.entries()){const d=document.createAttribute(f);m!==null&&(d.value=m),i.setAttributeNode(d)}return u.appendChild(i),i}function o(u,l){const a=r(l,"ul");a.className=`group_${s%10}`;const c=u.children(t);let i;for(;i=c.next_child();){const f=i.node_type(t);if(f==="container"){const d=`dom_${s}`;s++;const h=r(a,"li");r(h,"input",null,new Map([["type","checkbox"],["id",d],["checked",null]])),r(h,"label",i.tag(t),new Map([["for",d]])),o(i,h)}else if(f==="line_break")r(a,"li","br");else if(f==="text"){const m=r(a,"li");r(m,"span",'"',new Map([["class","quote"]])),r(m,"span",`${i.text(t)}`),r(m,"span",'"',new Map([["class","quote"]]))}else if(f==="mention"){const m=r(a,"li");r(m,"span",'"Mention - ',new Map([["class","quote"]])),r(m,"span",`${i.text(t)}`),r(m,"span",'"',new Map([["class","quote"]]))}else console.error(`Unknown node type: ${f}`)}}o(n,e)}function re(e,t,n){const s=document.createRange();let r=L(e,t),o=L(e,n);if(r.node&&o.node){const l=r.node.compareDocumentPosition(o.node)&Node.DOCUMENT_POSITION_PRECEDING,a=r.node===o.node&&o.offset<r.offset;if((l||a)&&([r,o]=[o,r],!r.node||!o.node))throw new Error;s.setStart(r.node,r.offset),s.setEnd(o.node,o.offset)}else s.selectNodeContents(e),s.collapse();const u=document.getSelection();u&&(u.removeAllRanges(),u.addRange(s))}function O(e,t,n,s){e.innerHTML=t+"<br />",re(e,n,s)}function L(e,t,n){const s=e.nodeName==="LI"&&!e.hasChildNodes(),r=e.nodeType===Node.TEXT_NODE;if(r&&e.parentElement?.hasAttribute("data-mention-type")){const l=x(e)?1:0,a=t-l;return a<=1?a===0?e.previousSibling?{node:e.previousSibling,offset:S(e.previousSibling,1/0)}:{node:e.parentNode?.parentNode??null,offset:0}:{node:null,offset:0}:{node:null,offset:t-l-1}}else if(r){const l=x(e)?1:0;return P(e)?t===0?{node:e,offset:t}:{node:null,offset:t-l}:t<=(e.textContent?.length||0)?{node:e,offset:t}:{node:null,offset:t-(e.textContent?.length||0)-l}}else{if(s)return t<=(e.textContent?.length||0)?{node:e,offset:t}:{node:null,offset:t-(e.textContent?.length||0)};if(e.nodeName==="BR")return t===0?{node:e,offset:0}:{node:null,offset:t-1};if(ie(e)&&t===0)return{node:e,offset:t};for(const u of e.childNodes){const l=L(u,t);if(l.node)return{node:l.node,offset:l.offset};t=l.offset}return{node:null,offset:t}}}function R(e,t){const n=e.childNodes.length===1&&e.firstChild?.nodeName==="BR";if(!t||n)return[0,0];const s=t.anchorNode&&D(e,t.anchorNode,t.anchorOffset)||0,r=t.focusNode&&D(e,t.focusNode,t.focusOffset)||0;return[s,r]}function S(e,t){if(e.nodeType===Node.TEXT_NODE){const s=x(e)?1:0;return(e.textContent?.length??0)+s}else{if(e.nodeName==="BR")return t===0?0:1;{let n=0,s=0;for(const r of e.childNodes){if(s===t)break;n+=S(r,-1),s++}return n}}}function B(e,t,n){const s=e.nodeType===Node.TEXT_NODE,r=e.parentElement?.hasAttribute("data-mention-type");if(e===t)return s?n>(e.textContent?.length??0)?{found:!1,offset:0}:r?{found:!0,offset:n===0?0:1}:{found:!0,offset:n}:{found:!0,offset:S(e,n)};if(s){const u=x(e)?1:0;return P(e)?{found:!1,offset:u}:r?{found:!1,offset:1+u}:{found:!1,offset:(e.textContent?.length??0)+u}}else{if(e.nodeName==="BR")return{found:!1,offset:1};{let o=0;for(const u of e.childNodes){const l=B(u,t,n);if(l.found)return{found:!0,offset:o+l.offset};o+=l.offset}return{found:!1,offset:o}}}}function D(e,t,n){if(t===e&&n===e.childNodes.length-1)return S(e,-1)-1;const s=new Range;s.setStart(e,0),s.setEnd(e,e.childNodes.length);const r=s.comparePoint(t,0);if(r===-1)return 0;if(r===1)return S(e,-1)-1;const o=B(e,t,n);return o.found?o.offset:-1}function x(e){if(e===null)return!1;let t=e;const n=H(t.parentNode);for(;t;){const s=t.nextSibling;if(s&&H(s)||n&&s&&!U(s)||s&&s.nodeName==="BR")break;if(U(t))return!0;t=t.parentNode}return!1}const $=["EM","U","STRONG","DEL","CODE","A"],oe=["OL","UL","LI","PRE","BLOCKQUOTE","P"];function H(e){return e===null?!1:$.includes(e.nodeName||"")}function U(e){return oe.includes(e.nodeName||"")}function ie(e){return $.includes(e.nodeName)&&e.textContent?.length===0}function P(e){const t=e.parentNode?.childNodes.length===1,n=e.parentNode?.nodeName==="P",s=e.textContent===" ";return n&&t&&s}const ae=["bold","italic","strikeThrough","underline","undo","redo","orderedList","unorderedList","inlineCode","clear","link","codeBlock","quote","indent","unindent"],ue=["@","#","/","",":"];function ce(){return ae.reduce((e,t)=>(e[t]="enabled",e),{})}function F(e){const t={};for(const[n,s]of e)t[n.substring(0,1).toLowerCase()+n.substring(1)]=s.toLowerCase();return t}function le(){const e=navigator.userAgent.toLowerCase();return e.includes("iphone")||e.includes("ipad")?"iOS":e.includes("android")?"Android":e.includes("win")?"Windows":e.includes("mac")?"macOS":e.includes("linux")?"Linux":null}function j(e,t,n,s){n?.preventDefault(),n?.stopPropagation(),e.dispatchEvent(new CustomEvent("wysiwygInput",{detail:{blockType:t,data:s}}))}function fe(e,t,n,s,r){if(e.shiftKey&&e.altKey)switch(e.key){case"5":return"formatStrikeThrough"}const o=le();if((o==="Windows"||o==="Linux")&&e.ctrlKey)switch(e.key){case"Backspace":return"deleteWordBackward"}if(e.ctrlKey||e.metaKey)switch(e.key){case"b":return"formatBold";case"i":return"formatItalic";case"u":return"formatUnderline";case"e":return"formatInlineCode";case"y":return"historyRedo";case"z":return"historyUndo";case"Z":return"historyRedo";case"Enter":return"sendMessage";case"Backspace":return"deleteSoftLineBackward"}return I(e,{actions:n,content:()=>t.get_content_as_html(),messageContent:()=>t.get_content_as_message_html()},s,r),null}function de(e,t,n,s,r){const o=fe(e,n,s,t,r);o&&j(t,o,e)}function q(e){return F(e.action_states)}function me(e,t,n,s,r,o,u,l,a){const c=ne(e,n,r.traceAction,o,t,u,l,a);if(c){const i=c.text_update().replace_all;i&&(O(t,i.replacement_html,i.start_utf16_codeunit,i.end_utf16_codeunit),r.setEditorHtml(i.replacement_html)),t.focus(),s&&se(s,n);const f=c.menu_state().update(),m=c.menu_action().suggestion()?.suggestion_pattern,d=f?q(f):null,h=m||null;return{content:i?.replacement_html,actionStates:d,suggestion:h}}}function _e(e,t,{traceAction:n,getSelectionAccordingToActions:s}){const[r,o]=R(e,document.getSelection()),u=t.selection_start(),l=t.selection_end(),[a,c]=s();if(r===u&&r===a&&o===l&&o===c||r===l&&r===c&&o===u&&o===a)return;const i=t.select(r,o);n(null,"select",r,o);const f=i.menu_state().update();if(f)return q(f)}function pe(e,t,n,s,r,o,u,l){const[a,c]=_.useState({content:null,actionStates:ce(),suggestion:null}),i=_.useRef(void 0),[f,m]=_.useState(!1);return _.useEffect(()=>{n&&(c({content:n.get_content_as_html(),actionStates:F(n.action_states()),suggestion:null}),i.current=n.get_content_as_plain_text())},[n]),_.useEffect(()=>{const d=e.current;if(!n||!d)return;const h=p=>{try{const E=me(p,d,n,t.current,s,r,a.suggestion,u,l);E&&(c(T=>{const He=E.content!==void 0?E.content:T.content,Ue=E.actionStates||T.actionStates,Pe=E.suggestion;return{content:He,actionStates:Ue,suggestion:Pe}}),i.current=n.get_content_as_plain_text())}catch{o(i.current)}},b=p=>{k(p)&&!p.isComposing&&h(p)};d.addEventListener("input",b);const N=p=>{const E=k(p)&&p.inputType==="insertFromPaste"&&p.dataTransfer!==null;(A(p)||E)&&(p.preventDefault(),p.stopPropagation(),h(p))};d.addEventListener("paste",N);const Q=p=>{h({inputType:p.detail.blockType,data:p.detail.data})};d.addEventListener("wysiwygInput",Q);const Y=p=>{de(p,d,n,r,u)};d.addEventListener("keydown",Y);const J=()=>{try{const p=_e(d,n,s);p&&c(({content:E,suggestion:T})=>({content:E,actionStates:p,suggestion:T})),i.current=n.get_content_as_plain_text()}catch{o(i.current)}};document.addEventListener("selectionchange",J);const Z=p=>{if(!(k(p)&&p.isComposing))return N(p)};d.addEventListener("beforeinput",Z);const W=p=>{const E=new InputEvent("input",{data:p.data,inputType:"insertCompositionText"});b(E)};return d.addEventListener("compositionend",W),m(!0),()=>{m(!1),d.removeEventListener("input",b),d.removeEventListener("paste",N),d.removeEventListener("wysiwygInput",Q),d.removeEventListener("keydown",Y),d.removeEventListener("beforeinput",Z),d.removeEventListener("compositionend",W),document.removeEventListener("selectionchange",J)}},[e,l,n,r,t,s,u,o,i,a.suggestion]),{areListenersReady:f,...a}}function ge(e,t){return _.useMemo(()=>{const s=(r,o)=>{e.current&&j(e.current,r,void 0,o)};return{bold:()=>s("formatBold"),italic:()=>s("formatItalic"),strikeThrough:()=>s("formatStrikeThrough"),underline:()=>s("formatUnderline"),undo:()=>s("historyUndo"),redo:()=>s("historyRedo"),orderedList:()=>s("insertOrderedList"),unorderedList:()=>s("insertUnorderedList"),inlineCode:()=>s("formatInlineCode"),clear:()=>s("clear"),insertText:r=>s("insertText",r),link:(r,o)=>s("insertLink",{url:r,text:o}),removeLinks:()=>s("removeLinks"),getLink:()=>t?.get_link_action()?.edit_link?.url||"",codeBlock:()=>s("insertCodeBlock"),quote:()=>s("insertQuote"),indent:()=>s("formatIndent"),unindent:()=>s("formatOutdent"),mention:(r,o,u)=>s("insertSuggestion",{url:r,text:o,attributes:u}),command:r=>s("insertCommand",r),emoji:r=>s("insertEmoji",r),mentionAtRoom:r=>s("insertAtRoomSuggestion",{attributes:r})}},[e,t])}let K=!1,v=!1;async function w(){if(v)return Promise.resolve();if(K)return new Promise(e=>{function t(){v&&e(),setTimeout(t,200)}t()});K=!0,await y.initAsync(),v=!0}function he(e,t,n){const[s,r]=_.useState(null),o=_.useCallback(async u=>{await w();let l;if(u)try{const a=y.new_composer_model_from_html(u,0,u.length);if(l=a,e.current){const c=a.get_content_as_html();O(e.current,c,0,c.length)}}catch{l=y.new_composer_model()}else l=y.new_composer_model();r(l)},[r,e]);return _.useEffect(()=>{s&&n&&s.set_custom_suggestion_patterns(n)},[s,n]),_.useEffect(()=>{e.current&&o(t)},[e,o,t]),{composerModel:s,onError:o}}function G(e){return e[0]==="select"}function Ee(e,t,n){return(s,r,o,u)=>(!e||!n||(console.debug(u!==void 0?`composer_model.${r}(${o}, ${u})`:o!==void 0?`composer_model.${r}(${o})`:`composer_model.${r}()`),t.push([r,o,u]),V(e,n,s,t)),s)}function ye(e){return()=>{for(let t=e.length-1;t>=0;t--){const n=e[t];if(G(n))return[n[1],n[2]]}return[-1,-1]}}function V(e,t,n,s){n&&n.text_update(),e.innerText=ke(s,t.to_example_format()),e.scrollTo(0,e.scrollHeight-e.clientHeight)}function ke(e,t){let n="";function s(c,i,f){c==="select"?n+=`model.select(Location::from(${i}), Location::from(${f}));
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
`:n+=`model.${c}(${i??""});
|
|
6
|
-
`}function r(){const c=Se(l,a[0],a[1]);n+=`let mut model = cm("${c}");
|
|
7
|
-
`}let o=null,u=!0,l="",a=[0,0];for(const c of e){const[i,f,m]=c;if(u)i==="replace_text"?l+=Te(f):G(c)?a=[c[1],c[2]]:(u=!1,r(),s(i,f,m));else if(o==="select"&&i==="select"){const d=n.lastIndexOf(`
|
|
8
|
-
`,n.length-2);d>-1&&(n=n.substring(0,d)+`
|
|
9
|
-
`,s(i,f,m))}else s(i,f,m);o=i}return u&&r(),n+=`assert_eq!(tx(&model), "${t}");
|
|
10
|
-
`,n}function Se(e,t,n){const s=y.new_composer_model_from_html(e,-1,-1);return s.select(t,n),s.to_example_format()}function Ce(e,t,n,s){const[r,o]=R(e,document.getSelection()),u=[["replace_text",s],["select",r,o]];return V(t,n,null,u),u}function Te(e){if(!e)return"";const t=document.createElement("p");return t.appendChild(document.createTextNode(e.toString())),t.innerHTML}function xe(e,t){const n=_.useRef(null),[s,r]=_.useState([]),[o,u]=_.useState(""),l=_.useCallback(m=>{n.current&&u(m)},[n]),a=_.useMemo(()=>Ee(n.current,s,t),[n,s,t]),c=_.useMemo(()=>ye(s),[s]),i=_.useCallback(()=>e.current&&n.current&&t&&r(Ce(e.current,n.current,t,o)),[e,n,t,o]),f=_.useMemo(()=>({traceAction:a,getSelectionAccordingToActions:c,onResetTestCase:i,setEditorHtml:l}),[a,c,i,l]);return{testRef:n,utilities:f}}function we(e){return ue[e.key.key_type]||""}function be(e){switch(e.key.key_type){case 0:case 1:return"mention";case 2:return"command";case 3:return"custom";case 4:return"emoji";default:return"unknown"}}function Le(e){return e===null?e:{text:e.text,keyChar:we(e),type:be(e)}}const C=`
|
|
11
|
-
`,ve=e=>{let t=e;return t.endsWith(C)&&(t=t.slice(0,-1)),t.replaceAll(/\\/g,"")};async function Ne(e,t){if(e.length===0)return"";await w();const n=y.new_composer_model();n.set_content_from_html(e);const s=t?n.get_content_as_message_markdown():n.get_content_as_markdown();return ve(s)}async function Ae(e,t){if(e.length===0)return"";await w();const n=Ie(e),s=y.new_composer_model();return s.set_content_from_markdown(n),t?s.get_content_as_message_html():s.get_content_as_html()}function Ie(e){const{body:t}=new DOMParser().parseFromString(e,"text/html"),n=document.createNodeIterator(t,void 0,Re);let s=n.nextNode(),r="";for(;s!==null;){const o=s.nodeName==="#text",u=s.nodeName==="A",l=s.nodeName==="DIV"&&s.childNodes.length===1&&s.firstChild?.nodeName==="BR",a=!Oe.includes(s.nodeName);if(l)r+=C;else if(o){let c=s.textContent;X(s)&&(c+=C),r+=c}else if(u){let c=s.firstChild?.parentElement?.outerHTML??"";X(s)&&(c+=C),r+=c}else a&&console.debug(`Converting unexpected node type ${s.nodeName}`);s=n.nextNode()}return r.endsWith(C.repeat(2))&&(r=r.slice(0,-1)),r}const Oe=["#text","BR","A","DIV","BODY"];function X(e){return(e.nextSibling||e.parentElement?.nextSibling)?.nodeName==="DIV"}function Re(e){return e.nodeName==="#text"&&e.parentElement?.hasAttribute("data-mention-type")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function Be(e,t=!1){_.useEffect(()=>{if(t){const n=setTimeout(()=>e.current?.focus(),200);return()=>clearTimeout(n)}},[e,t])}function De(){const e=_.useRef(null);return _.useEffect(()=>{e.current?.childElementCount||e.current?.appendChild(document.createElement("br"))},[e]),e}function z(e){const t=e?.keys();return t?Array.from(t):[]}function $e(e){const t=De(),n=_.useRef(null),[s,r]=_.useState(z(e?.emojiSuggestions));_.useEffect(()=>{r(z(e?.emojiSuggestions))},[e?.emojiSuggestions]);const{composerModel:o,onError:u}=he(t,e?.initialContent,s),{testRef:l,utilities:a}=xe(t,o),c=ge(t,o),{content:i,actionStates:f,areListenersReady:m,suggestion:d}=pe(t,n,o,a,c,u,e?.inputEventProcessor,e?.emojiSuggestions);Be(t,e?.isAutoFocusEnabled);const h=_.useMemo(()=>Le(d),[d]);return{ref:t,isWysiwygReady:m,wysiwyg:c,content:i,actionStates:f,debug:{modelRef:n,testRef:l,resetTestCase:a.onResetTestCase,traceAction:a.traceAction},suggestion:h,messageContent:o?.get_content_as_message_html()??null}}g.initOnce=w,g.plainToRich=Ae,g.richToPlain=Ne,g.useWysiwyg=$e,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("@vector-im/matrix-wysiwyg-wasm")):typeof define==`function`&&define.amd?define([`exports`,`react`,`@vector-im/matrix-wysiwyg-wasm`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`Matrix wysiwyg`]={},e.React,e._vector_im_matrix_wysiwyg_wasm))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function r(e){return`inputType`in e}function i(e){return`clipboardData`in e}function a(e){return r(e)&&e.inputType===`insertSuggestion`}function o(e){return r(e)&&e.inputType===`insertAtRoomSuggestion`}function s(e){return r(e)&&e.inputType==`insertLink`}function c(e,t,n,r){return r?r(e,t,n):e}function l(e,t,r,l,u,d,f,p){let m=c(e,{actions:l,content:()=>t.get_content_as_html(),messageContent:()=>t.get_content_as_message_html()},u,f);if(!m)return;if(i(m)){let e=m.clipboardData,i=e?.getData(`text/html`),a=e?.getData(`text/plain`)??``;if(i&&i!==a){let a=e?.types.includes(`application/x-vnd.google-docs-document-slice-clip+wrapped`)?n.HtmlSource.GoogleDoc:n.HtmlSource.UnknownExternal;return r(t.replace_html(i,a),`replace_html_paste`)}return r(t.replace_text(a),`replace_text_paste`)}switch(m.inputType){case`insertAtRoomSuggestion`:if(d&&o(m)){let{attributes:e}=m.data;return e.has(`data-mention-type`)&&e.delete(`data-mention-type`),r(t.insert_at_room_mention_at_suggestion(d,e),`insert_at_room_mention_at_suggestion`)}break;case`insertSuggestion`:if(d&&a(m)){let{text:e,url:n,attributes:i}=m.data;return i.has(`data-mention-type`)&&i.delete(`data-mention-type`),r(t.insert_mention_at_suggestion(n,e,d,i),`insert_mention_at_suggestion`)}break;case`insertCommand`:case`insertEmoji`:if(d&&m.data){let e=m.inputType===`insertCommand`;return r(t.replace_text_suggestion(m.data,d,e),`replace_text_suggestion`)}break;case`clear`:return r(t.clear(),`clear`);case`deleteContentBackward`:return r(t.backspace(),`backspace`);case`deleteWordBackward`:return r(t.backspace_word(),`backspace_word`);case`deleteSoftLineBackward`:{let e=document.getSelection();return e&&(e.modify(`extend`,`backward`,`lineboundary`),document.dispatchEvent(new CustomEvent(`selectionchange`))),r(t.delete(),`backspace_line`)}case`deleteContentForward`:return r(t.delete(),`delete`);case`deleteWordForward`:return r(t.delete_word(),`delete_word`);case`deleteByCut`:return r(t.delete(),`delete`);case`formatBold`:return r(t.bold(),`bold`);case`formatItalic`:return r(t.italic(),`italic`);case`formatStrikeThrough`:return r(t.strike_through(),`strike_through`);case`formatUnderline`:return r(t.underline(),`underline`);case`formatInlineCode`:return r(t.inline_code(),`inline_code`);case`historyRedo`:return r(t.redo(),`redo`);case`historyUndo`:return r(t.undo(),`undo`);case`insertCodeBlock`:return r(t.code_block(),`code_block`);case`insertQuote`:return r(t.quote(),`quote`);case`insertFromPaste`:return;case`insertOrderedList`:return r(t.ordered_list(),`ordered_list`);case`insertLineBreak`:case`insertParagraph`:return h(t,d,p),r(t.enter(),`enter`);case`insertReplacementText`:{let e=u.innerHTML.slice(0,u.innerHTML.length-4);return r(t.set_content_from_html(e),`set_content_from_html`,e)}case`insertCompositionText`:case`insertFromComposition`:case`insertText`:if(m.data)return m.data==` `&&h(t,d,p),r(t.replace_text(m.data),`replace_text`,m.data);break;case`insertUnorderedList`:return r(t.unordered_list(),`unordered_list`);case`insertLink`:if(s(m)){let{text:e,url:n}=m.data;return r(e?t.set_link_with_text(n,e,new Map):t.set_link(n,new Map),`insertLink`)}break;case`removeLinks`:return r(t.remove_links(),`remove_links`);case`formatIndent`:return r(t.indent(),`indent`);case`formatOutdent`:return r(t.unindent(),`unindent`);case`sendMessage`:return null;default:return console.error(`Unknown input type: ${m.inputType}`),console.error(e),null}function h(e,t,n){if(n&&t&&t.key.key_type==3&&t.key.custom_key_value){let r=n.get(t.key.custom_key_value);r&&e.replace_text_suggestion(r,t,!1)}}}function u(e,t){e.innerHTML=``;let n=t.document(),r=0;function i(e,t,n,r){let i=document.createElement(t);if(n&&(i.innerText=n.replace(``,`~`)),r)for(let[e,t]of r.entries()){let n=document.createAttribute(e);t!==null&&(n.value=t),i.setAttributeNode(n)}return e.appendChild(i),i}function a(e,n){let o=i(n,`ul`);o.className=`group_${r%10}`;let s=e.children(t),c;for(;c=s.next_child();){let e=c.node_type(t);if(e===`container`){let e=`dom_${r}`;r++;let n=i(o,`li`);i(n,`input`,null,new Map([[`type`,`checkbox`],[`id`,e],[`checked`,null]])),i(n,`label`,c.tag(t),new Map([[`for`,e]])),a(c,n)}else if(e===`line_break`)i(o,`li`,`br`);else if(e===`text`){let e=i(o,`li`);i(e,`span`,`"`,new Map([[`class`,`quote`]])),i(e,`span`,`${c.text(t)}`),i(e,`span`,`"`,new Map([[`class`,`quote`]]))}else if(e===`mention`){let e=i(o,`li`);i(e,`span`,`"Mention - `,new Map([[`class`,`quote`]])),i(e,`span`,`${c.text(t)}`),i(e,`span`,`"`,new Map([[`class`,`quote`]]))}else console.error(`Unknown node type: ${e}`)}}a(n,e)}function d(e,t,n){let r=document.createRange(),i=p(e,t),a=p(e,n);if(i.node&&a.node){let e=i.node.compareDocumentPosition(a.node)&Node.DOCUMENT_POSITION_PRECEDING,t=i.node===a.node&&a.offset<i.offset;if((e||t)&&([i,a]=[a,i],!i.node||!a.node))throw Error();r.setStart(i.node,i.offset),r.setEnd(a.node,a.offset)}else r.selectNodeContents(e),r.collapse();let o=document.getSelection();o&&(o.removeAllRanges(),o.addRange(r))}function f(e,t,n,r){e.innerHTML=t+`<br />`,d(e,n,r)}function p(e,t,n){let r=e.nodeName===`LI`&&!e.hasChildNodes(),i=e.nodeType===Node.TEXT_NODE;if(i&&e.parentElement?.hasAttribute(`data-mention-type`)){let n=+!!v(e),r=t-n;return r<=1?r===0?e.previousSibling?{node:e.previousSibling,offset:h(e.previousSibling,1/0)}:{node:e.parentNode?.parentNode??null,offset:0}:{node:null,offset:0}:{node:null,offset:t-n-1}}else if(i){let n=+!!v(e);return w(e)?t===0?{node:e,offset:t}:{node:null,offset:t-n}:t<=(e.textContent?.length||0)?{node:e,offset:t}:{node:null,offset:t-(e.textContent?.length||0)-n}}else if(r)return t<=(e.textContent?.length||0)?{node:e,offset:t}:{node:null,offset:t-(e.textContent?.length||0)};else if(e.nodeName===`BR`)return t===0?{node:e,offset:0}:{node:null,offset:t-1};else{if(C(e)&&t===0)return{node:e,offset:t};for(let r of e.childNodes){let i=p(r,t,n||e);if(i.node)return{node:i.node,offset:i.offset};t=i.offset}return{node:null,offset:t}}}function m(e,t){let n=e.childNodes.length===1&&e.firstChild?.nodeName===`BR`;return!t||n?[0,0]:[t.anchorNode&&_(e,t.anchorNode,t.anchorOffset)||0,t.focusNode&&_(e,t.focusNode,t.focusOffset)||0]}function h(e,t){if(e.nodeType===Node.TEXT_NODE){let t=+!!v(e);return(e.textContent?.length??0)+t}else if(e.nodeName===`BR`)return t===0?0:1;else{let n=0,r=0;for(let i of e.childNodes){if(r===t)break;n+=h(i,-1),r++}return n}}function g(e,t,n){let r=e.nodeType===Node.TEXT_NODE,i=e.parentElement?.hasAttribute(`data-mention-type`);if(e===t)return r?n>(e.textContent?.length??0)?{found:!1,offset:0}:i?{found:!0,offset:n===0?0:1}:{found:!0,offset:n}:{found:!0,offset:h(e,n)};if(r){let t=+!!v(e);return w(e)?{found:!1,offset:t}:i?{found:!1,offset:1+t}:{found:!1,offset:(e.textContent?.length??0)+t}}else if(e.nodeName===`BR`)return{found:!1,offset:1};else{let r=0;for(let i of e.childNodes){let e=g(i,t,n);if(e.found)return{found:!0,offset:r+e.offset};r+=e.offset}return{found:!1,offset:r}}}function _(e,t,n){if(t===e&&n===e.childNodes.length-1)return h(e,-1)-1;let r=new Range;r.setStart(e,0),r.setEnd(e,e.childNodes.length);let i=r.comparePoint(t,0);if(i===-1)return 0;if(i===1)return h(e,-1)-1;let a=g(e,t,n);return a.found?a.offset:-1}function v(e){if(e===null)return!1;let t=e,n=x(t.parentNode);for(;t;){let e=t.nextSibling;if(e&&x(e)||n&&e&&!S(e)||e&&e.nodeName===`BR`)break;if(S(t))return!0;t=t.parentNode}return!1}var y=[`EM`,`U`,`STRONG`,`DEL`,`CODE`,`A`],b=[`OL`,`UL`,`LI`,`PRE`,`BLOCKQUOTE`,`P`];function x(e){return e===null?!1:y.includes(e.nodeName||``)}function S(e){return b.includes(e.nodeName||``)}function C(e){return y.includes(e.nodeName)&&e.textContent?.length===0}function w(e){let t=e.parentNode?.childNodes.length===1,n=e.parentNode?.nodeName===`P`,r=e.textContent===`\xA0`;return n&&t&&r}var T=[`bold`,`italic`,`strikeThrough`,`underline`,`undo`,`redo`,`orderedList`,`unorderedList`,`inlineCode`,`clear`,`link`,`codeBlock`,`quote`,`indent`,`unindent`],ee=[`@`,`#`,`/`,``,`:`];function E(){return T.reduce((e,t)=>(e[t]=`enabled`,e),{})}function D(e){let t={};for(let[n,r]of e)t[n.substring(0,1).toLowerCase()+n.substring(1)]=r.toLowerCase();return t}function O(){let e=navigator.userAgent.toLowerCase();return e.includes(`iphone`)||e.includes(`ipad`)?`iOS`:e.includes(`android`)?`Android`:e.includes(`win`)?`Windows`:e.includes(`mac`)?`macOS`:e.includes(`linux`)?`Linux`:null}function k(e,t,n,r){n?.preventDefault(),n?.stopPropagation(),e.dispatchEvent(new CustomEvent(`wysiwygInput`,{detail:{blockType:t,data:r}}))}function A(e,t,n,r,i){if(e.shiftKey&&e.altKey)switch(e.key){case`5`:return`formatStrikeThrough`}let a=O();if((a===`Windows`||a===`Linux`)&&e.ctrlKey)switch(e.key){case`Backspace`:return`deleteWordBackward`}if(e.ctrlKey||e.metaKey)switch(e.key){case`b`:return`formatBold`;case`i`:return`formatItalic`;case`u`:return`formatUnderline`;case`e`:return`formatInlineCode`;case`y`:return`historyRedo`;case`z`:return`historyUndo`;case`Z`:return`historyRedo`;case`Enter`:return`sendMessage`;case`Backspace`:return`deleteSoftLineBackward`}return c(e,{actions:n,content:()=>t.get_content_as_html(),messageContent:()=>t.get_content_as_message_html()},r,i),null}function te(e,t,n,r,i){let a=A(e,n,r,t,i);a&&k(t,a,e)}function j(e){return D(e.action_states)}function ne(e,t,n,r,i,a,o,s,c){let d=l(e,n,i.traceAction,a,t,o,s,c);if(d){let e=d.text_update().replace_all;e&&(f(t,e.replacement_html,e.start_utf16_codeunit,e.end_utf16_codeunit),i.setEditorHtml(e.replacement_html)),t.focus(),r&&u(r,n);let a=d.menu_state().update(),o=d.menu_action().suggestion()?.suggestion_pattern,s=a?j(a):null,c=o||null;return{content:e?.replacement_html,actionStates:s,suggestion:c}}}function M(e,t,{traceAction:n,getSelectionAccordingToActions:r}){let[i,a]=m(e,document.getSelection()),o=t.selection_start(),s=t.selection_end(),[c,l]=r();if(i===o&&i===c&&a===s&&a===l||i===s&&i===l&&a===o&&a===c)return;let u=t.select(i,a);n(null,`select`,i,a);let d=u.menu_state().update();if(d)return j(d)}function N(e,n,a,o,s,c,l,u){let[d,f]=(0,t.useState)({content:null,actionStates:E(),suggestion:null}),p=(0,t.useRef)(void 0),[m,h]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{a&&(f({content:a.get_content_as_html(),actionStates:D(a.action_states()),suggestion:null}),p.current=a.get_content_as_plain_text())},[a]),(0,t.useEffect)(()=>{let t=e.current;if(!a||!t)return;let m=e=>{try{let r=ne(e,t,a,n.current,o,s,d.suggestion,l,u);r&&(f(e=>({content:r.content===void 0?e.content:r.content,actionStates:r.actionStates||e.actionStates,suggestion:r.suggestion})),p.current=a.get_content_as_plain_text())}catch{c(p.current)}},g=e=>{r(e)&&!e.isComposing&&m(e)};t.addEventListener(`input`,g);let _=e=>{let t=r(e)&&e.inputType===`insertFromPaste`&&e.dataTransfer!==null;(i(e)||t)&&(e.preventDefault(),e.stopPropagation(),m(e))};t.addEventListener(`paste`,_);let v=(e=>{m({inputType:e.detail.blockType,data:e.detail.data})});t.addEventListener(`wysiwygInput`,v);let y=e=>{te(e,t,a,s,l)};t.addEventListener(`keydown`,y);let b=()=>{try{let e=M(t,a,o);e&&f(({content:t,suggestion:n})=>({content:t,actionStates:e,suggestion:n})),p.current=a.get_content_as_plain_text()}catch{c(p.current)}};document.addEventListener(`selectionchange`,b);let x=e=>{if(!(r(e)&&e.isComposing))return _(e)};t.addEventListener(`beforeinput`,x);let S=e=>{g(new InputEvent(`input`,{data:e.data,inputType:`insertCompositionText`}))};return t.addEventListener(`compositionend`,S),h(!0),()=>{h(!1),t.removeEventListener(`input`,g),t.removeEventListener(`paste`,_),t.removeEventListener(`wysiwygInput`,v),t.removeEventListener(`keydown`,y),t.removeEventListener(`beforeinput`,x),t.removeEventListener(`compositionend`,S),document.removeEventListener(`selectionchange`,b)}},[e,u,a,s,n,o,l,c,p,d.suggestion]),{areListenersReady:m,...d}}function P(e,n){return(0,t.useMemo)(()=>{let t=(t,n)=>{e.current&&k(e.current,t,void 0,n)};return{bold:()=>t(`formatBold`),italic:()=>t(`formatItalic`),strikeThrough:()=>t(`formatStrikeThrough`),underline:()=>t(`formatUnderline`),undo:()=>t(`historyUndo`),redo:()=>t(`historyRedo`),orderedList:()=>t(`insertOrderedList`),unorderedList:()=>t(`insertUnorderedList`),inlineCode:()=>t(`formatInlineCode`),clear:()=>t(`clear`),insertText:e=>t(`insertText`,e),link:(e,n)=>t(`insertLink`,{url:e,text:n}),removeLinks:()=>t(`removeLinks`),getLink:()=>n?.get_link_action()?.edit_link?.url||``,codeBlock:()=>t(`insertCodeBlock`),quote:()=>t(`insertQuote`),indent:()=>t(`formatIndent`),unindent:()=>t(`formatOutdent`),mention:(e,n,r)=>t(`insertSuggestion`,{url:e,text:n,attributes:r}),command:e=>t(`insertCommand`,e),emoji:e=>t(`insertEmoji`,e),mentionAtRoom:e=>t(`insertAtRoomSuggestion`,{attributes:e})}},[e,n])}var F=null;async function I(){return F||=(0,n.initAsync)(),F}function L(e,r,i){let[a,o]=(0,t.useState)(null),s=(0,t.useCallback)(async t=>{await I();let r;if(t)try{let i=(0,n.new_composer_model_from_html)(t,0,t.length);if(r=i,e.current){let t=i.get_content_as_html();f(e.current,t,0,t.length)}}catch{r=(0,n.new_composer_model)()}else r=(0,n.new_composer_model)();o(r)},[o,e]);return(0,t.useEffect)(()=>{a&&i&&a.set_custom_suggestion_patterns(i)},[a,i]),(0,t.useEffect)(()=>{e.current&&s(r)},[e,s,r]),{composerModel:a,onError:s}}function R(e){return e[0]===`select`}function z(e,t,n){return(r,i,a,o)=>!e||!n?r:(console.debug(o===void 0?a===void 0?`composer_model.${i}()`:`composer_model.${i}(${a})`:`composer_model.${i}(${a}, ${o})`),t.push([i,a,o]),V(e,n,r,t),r)}function B(e){return()=>{for(let t=e.length-1;t>=0;t--){let n=e[t];if(R(n))return[n[1],n[2]]}return[-1,-1]}}function V(e,t,n,r){n&&n.text_update(),e.innerText=H(r,t.to_example_format()),e.scrollTo(0,e.scrollHeight-e.clientHeight)}function H(e,t){let n=``;function r(e,t,r){e===`select`?n+=`model.select(Location::from(${t}), Location::from(${r}));\n`:r===void 0?e===`replace_text`?n+=`model.${e}("${t??``}");\n`:e===`send`?n+=`// Send: ${t??``}\n`:n+=`model.${e}(${t??``});\n`:n+=`model.${e}(${t??``}, ${r});\n`}function i(){let e=U(s,c[0],c[1]);n+=`let mut model = cm("${e}");\n`}let a=null,o=!0,s=``,c=[0,0];for(let t of e){let[e,l,u]=t;if(o)e===`replace_text`?s+=G(l):R(t)?c=[t[1],t[2]]:(o=!1,i(),r(e,l,u));else if(a===`select`&&e===`select`){let t=n.lastIndexOf(`
|
|
2
|
+
`,n.length-2);t>-1&&(n=n.substring(0,t)+`
|
|
3
|
+
`,r(e,l,u))}else r(e,l,u);a=e}return o&&i(),n+=`assert_eq!(tx(&model), "${t}");\n`,n}function U(e,t,r){let i=(0,n.new_composer_model_from_html)(e,-1,-1);return i.select(t,r),i.to_example_format()}function W(e,t,n,r){let[i,a]=m(e,document.getSelection()),o=[[`replace_text`,r],[`select`,i,a]];return V(t,n,null,o),o}function G(e){if(!e)return``;let t=document.createElement(`p`);return t.appendChild(document.createTextNode(e.toString())),t.innerHTML}function K(e,n){let r=(0,t.useRef)(null),[i,a]=(0,t.useState)([]),[o,s]=(0,t.useState)(``),c=(0,t.useCallback)(e=>{r.current&&s(e)},[r]),l=(0,t.useMemo)(()=>z(r.current,i,n),[r,i,n]),u=(0,t.useMemo)(()=>B(i),[i]),d=(0,t.useCallback)(()=>e.current&&r.current&&n&&a(W(e.current,r.current,n,o)),[e,r,n,o]);return{testRef:r,utilities:(0,t.useMemo)(()=>({traceAction:l,getSelectionAccordingToActions:u,onResetTestCase:d,setEditorHtml:c}),[l,u,d,c])}}function q(e){return ee[e.key.key_type]||``}function J(e){switch(e.key.key_type){case 0:case 1:return`mention`;case 2:return`command`;case 3:return`custom`;case 4:return`emoji`;default:return`unknown`}}function Y(e){return e===null?e:{text:e.text,keyChar:q(e),type:J(e)}}var X=`
|
|
4
|
+
`,re=e=>{let t=e;return t.endsWith(X)&&(t=t.slice(0,-1)),t.replaceAll(/\\/g,``)};async function ie(e,t){if(e.length===0)return``;await I();let r=(0,n.new_composer_model)();return r.set_content_from_html(e),re(t?r.get_content_as_message_markdown():r.get_content_as_markdown())}async function ae(e,t){if(e.length===0)return``;await I();let r=oe(e),i=(0,n.new_composer_model)();return i.set_content_from_markdown(r),t?i.get_content_as_message_html():i.get_content_as_html()}function oe(e){let{body:t}=new DOMParser().parseFromString(e,`text/html`),n=document.createNodeIterator(t,void 0,Q),r=n.nextNode(),i=``;for(;r!==null;){let e=r.nodeName===`#text`,t=r.nodeName===`A`,a=r.nodeName===`DIV`&&r.childNodes.length===1&&r.firstChild?.nodeName===`BR`,o=!se.includes(r.nodeName);if(a)i+=X;else if(e){let e=r.textContent;Z(r)&&(e+=X),i+=e}else if(t){let e=r.firstChild?.parentElement?.outerHTML??``;Z(r)&&(e+=X),i+=e}else o&&console.debug(`Converting unexpected node type ${r.nodeName}`);r=n.nextNode()}return i.endsWith(X.repeat(2))&&(i=i.slice(0,-1)),i}var se=[`#text`,`BR`,`A`,`DIV`,`BODY`];function Z(e){return(e.nextSibling||e.parentElement?.nextSibling)?.nodeName===`DIV`}function Q(e){return e.nodeName===`#text`&&e.parentElement?.hasAttribute(`data-mention-type`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function ce(e,n=!1){(0,t.useEffect)(()=>{if(n){let t=setTimeout(()=>e.current?.focus(),200);return()=>clearTimeout(t)}},[e,n])}function le(){let e=(0,t.useRef)(null);return(0,t.useEffect)(()=>{e.current?.childElementCount||e.current?.appendChild(document.createElement(`br`))},[e]),e}function $(e){let t=e?.keys();return t?Array.from(t):[]}function ue(e){let n=le(),r=(0,t.useRef)(null),[i,a]=(0,t.useState)($(e?.emojiSuggestions));(0,t.useEffect)(()=>{a($(e?.emojiSuggestions))},[e?.emojiSuggestions]);let{composerModel:o,onError:s}=L(n,e?.initialContent,i),{testRef:c,utilities:l}=K(n,o),u=P(n,o),{content:d,actionStates:f,areListenersReady:p,suggestion:m}=N(n,r,o,l,u,s,e?.inputEventProcessor,e?.emojiSuggestions);ce(n,e?.isAutoFocusEnabled);let h=(0,t.useMemo)(()=>Y(m),[m]);return{ref:n,isWysiwygReady:p,wysiwyg:u,content:d,actionStates:f,debug:{modelRef:r,testRef:c,resetTestCase:l.onResetTestCase,traceAction:l.traceAction},suggestion:h,messageContent:o?.get_content_as_message_html()??null}}e.initOnce=I,e.plainToRich=ae,e.richToPlain=ie,e.useWysiwyg=ue});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vector-im/matrix-wysiwyg-wasm",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.42.1",
|
|
4
4
|
"homepage": "https://gitlab.com/andybalaam/wysiwyg-rust",
|
|
5
5
|
"description": "WASM bindings for wysiwyg-rust",
|
|
6
6
|
"license": "SEE LICENSE IN README.md",
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@babel/cli": "^7.23.5",
|
|
54
54
|
"@babel/plugin-transform-modules-commonjs": "^7.25.9",
|
|
55
|
-
"@types/node": "^
|
|
56
|
-
"jest": "^
|
|
55
|
+
"@types/node": "^24.0.0",
|
|
56
|
+
"jest": "^30.0.0",
|
|
57
57
|
"typedoc": "^0.28.0",
|
|
58
|
-
"typescript": "^
|
|
59
|
-
"wasm-pack": "^0.
|
|
58
|
+
"typescript": "^6.0.0",
|
|
59
|
+
"wasm-pack": "^0.15.0"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">= 10"
|
|
@@ -69,5 +69,6 @@
|
|
|
69
69
|
"lint": "tsc --noEmit",
|
|
70
70
|
"test": "jest --verbose",
|
|
71
71
|
"doc": "typedoc --tsconfig ."
|
|
72
|
-
}
|
|
72
|
+
},
|
|
73
|
+
"packageManager": "yarn@4.16.0"
|
|
73
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vector-im/matrix-wysiwyg",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.42.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Wysiwyg composer for Element Web using React",
|
|
6
6
|
"author": "New Vector Ltd.",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"license": "SEE LICENSE IN README.md",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
14
15
|
"import": "./dist/matrix-wysiwyg.js",
|
|
15
16
|
"require": "./dist/matrix-wysiwyg.umd.cjs"
|
|
16
17
|
}
|
|
@@ -30,8 +31,7 @@
|
|
|
30
31
|
"typecheck": "tsc --noEmit",
|
|
31
32
|
"lint": "eslint .",
|
|
32
33
|
"test": "vitest --run --pool=forks",
|
|
33
|
-
"test:
|
|
34
|
-
"test:cypress:open": "cypress open",
|
|
34
|
+
"test:e2e": "playwright test",
|
|
35
35
|
"test:watch": "vitest --pool=forks",
|
|
36
36
|
"test:ui": "vitest --ui",
|
|
37
37
|
"coverage": "vitest run --coverage --pool=forks",
|
|
@@ -41,45 +41,46 @@
|
|
|
41
41
|
"react": "^18.2.0 || ^19.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
+
"@playwright/test": "^1.58.0",
|
|
44
45
|
"@stylistic/eslint-plugin": "^5.0.0",
|
|
45
46
|
"@testing-library/dom": "^10.0.0",
|
|
46
47
|
"@testing-library/jest-dom": "^6.0.0",
|
|
47
48
|
"@testing-library/react": "^16.0.0",
|
|
48
49
|
"@testing-library/user-event": "^14.4.3",
|
|
49
|
-
"@types/jest": "^
|
|
50
|
+
"@types/jest": "^30.0.0",
|
|
50
51
|
"@types/react": "^19.0.0",
|
|
51
52
|
"@types/react-dom": "^19.0.0",
|
|
52
53
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
53
54
|
"@typescript-eslint/parser": "^8.0.0",
|
|
54
|
-
"@vitejs/plugin-react": "^
|
|
55
|
-
"@vitest/coverage-v8": "^
|
|
56
|
-
"@vitest/ui": "^
|
|
57
|
-
"
|
|
58
|
-
"eslint": "^9.20.0",
|
|
55
|
+
"@vitejs/plugin-react": "^6.0.0",
|
|
56
|
+
"@vitest/coverage-v8": "^4.0.0",
|
|
57
|
+
"@vitest/ui": "^4.0.0",
|
|
58
|
+
"eslint": "^8.57.0",
|
|
59
59
|
"eslint-config-google": "^0.14.0",
|
|
60
60
|
"eslint-config-prettier": "^10.0.0",
|
|
61
|
-
"eslint-plugin-deprecate": "^0.
|
|
61
|
+
"eslint-plugin-deprecate": "^0.9.0",
|
|
62
62
|
"eslint-plugin-import": "^2.26.0",
|
|
63
63
|
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
64
|
-
"eslint-plugin-matrix-org": "^
|
|
64
|
+
"eslint-plugin-matrix-org": "^3.0.0",
|
|
65
65
|
"eslint-plugin-prettier": "^5.0.0",
|
|
66
66
|
"eslint-plugin-react": "^7.31.8",
|
|
67
|
-
"eslint-plugin-react-hooks": "^
|
|
68
|
-
"eslint-plugin-unicorn": "^
|
|
69
|
-
"jest-environment-jsdom": "^
|
|
70
|
-
"prettier": "3.
|
|
67
|
+
"eslint-plugin-react-hooks": "^7.0.0",
|
|
68
|
+
"eslint-plugin-unicorn": "^56.0.0",
|
|
69
|
+
"jest-environment-jsdom": "^30.0.0",
|
|
70
|
+
"prettier": "3.8.4",
|
|
71
71
|
"react": "^19.0.0",
|
|
72
72
|
"react-dom": "^19.0.0",
|
|
73
|
-
"typescript": "^
|
|
74
|
-
"vite": "
|
|
75
|
-
"vite-plugin-dts": "^
|
|
76
|
-
"vitest": "^
|
|
77
|
-
"vitest-sonar-reporter": "^
|
|
73
|
+
"typescript": "^6.0.0",
|
|
74
|
+
"vite": "^8.0.0",
|
|
75
|
+
"vite-plugin-dts": "^5.0.0",
|
|
76
|
+
"vitest": "^4.0.0",
|
|
77
|
+
"vitest-sonar-reporter": "^3.0.0"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@vector-im/matrix-wysiwyg-wasm": "link:../../bindings/wysiwyg-wasm"
|
|
81
81
|
},
|
|
82
82
|
"bundledDependencies": [
|
|
83
83
|
"@vector-im/matrix-wysiwyg-wasm"
|
|
84
|
-
]
|
|
84
|
+
],
|
|
85
|
+
"packageManager": "yarn@4.16.0"
|
|
85
86
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { ComposerUpdate } from '@vector-im/matrix-wysiwyg-wasm';
|
|
2
|
-
import { RefObject } from 'react';
|
|
3
|
-
|
|
4
|
-
export declare const ACTION_TYPES: readonly ["bold", "italic", "strikeThrough", "underline", "undo", "redo", "orderedList", "unorderedList", "inlineCode", "clear", "link", "codeBlock", "quote", "indent", "unindent"];
|
|
5
|
-
|
|
6
|
-
export declare type ActionState = 'enabled' | 'reversed' | 'disabled';
|
|
7
|
-
|
|
8
|
-
export declare type ActionTypes = (typeof ACTION_TYPES)[number];
|
|
9
|
-
|
|
10
|
-
export declare type AllActionStates = Record<ActionTypes, ActionState>;
|
|
11
|
-
|
|
12
|
-
export declare type AllowedMentionAttributes = Map<'style' | 'data-mention-type', string>;
|
|
13
|
-
|
|
14
|
-
export declare type BlockType = InputEvent['inputType'] | 'formatInlineCode' | 'clear';
|
|
15
|
-
|
|
16
|
-
export declare type FormattingFunctions = Record<Exclude<ActionTypes, 'link'>, () => void> & {
|
|
17
|
-
insertText: (text: string) => void;
|
|
18
|
-
link: (url: string, text?: string) => void;
|
|
19
|
-
mention: (url: string, text: string, attributes: AllowedMentionAttributes) => void;
|
|
20
|
-
mentionAtRoom: (attributes: AllowedMentionAttributes) => void;
|
|
21
|
-
command: (text: string) => void;
|
|
22
|
-
emoji: (text: string) => void;
|
|
23
|
-
removeLinks: () => void;
|
|
24
|
-
getLink: () => string;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Initialise the WASM module, or do nothing if it is already initialised.
|
|
29
|
-
*/
|
|
30
|
-
export declare function initOnce(): Promise<void>;
|
|
31
|
-
|
|
32
|
-
export declare type InputEventProcessor = (event: WysiwygEvent, wysiwyg: Wysiwyg, editor: HTMLElement) => WysiwygEvent | null;
|
|
33
|
-
|
|
34
|
-
export declare type LinkEvent = Omit<InputEvent, 'data'> & {
|
|
35
|
-
inputType: 'insertLink';
|
|
36
|
-
data: {
|
|
37
|
-
url: string;
|
|
38
|
-
text?: string;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export declare type MappedSuggestion = {
|
|
43
|
-
keyChar: SuggestionChar;
|
|
44
|
-
text: string;
|
|
45
|
-
type: SuggestionType;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export declare function plainToRich(plainText: string, inMessageFormat: boolean): Promise<string>;
|
|
49
|
-
|
|
50
|
-
export declare function richToPlain(richText: string, inMessageFormat: boolean): Promise<string>;
|
|
51
|
-
|
|
52
|
-
export declare type SuggestionChar = (typeof SUGGESTIONS)[number] | '';
|
|
53
|
-
|
|
54
|
-
export declare const SUGGESTIONS: readonly ["@", "#", "/", "", ":"];
|
|
55
|
-
|
|
56
|
-
export declare type SuggestionType = 'mention' | 'command' | 'custom' | 'emoji' | 'unknown';
|
|
57
|
-
|
|
58
|
-
export declare type TraceAction = (update: ComposerUpdate | null, name: string, value1?: string | number, value2?: string | number) => ComposerUpdate | null;
|
|
59
|
-
|
|
60
|
-
export declare type UseWysiwyg = {
|
|
61
|
-
ref: RefObject<HTMLDivElement | null>;
|
|
62
|
-
isWysiwygReady: boolean;
|
|
63
|
-
wysiwyg: FormattingFunctions;
|
|
64
|
-
content: string | null;
|
|
65
|
-
actionStates: AllActionStates;
|
|
66
|
-
debug: {
|
|
67
|
-
modelRef: RefObject<HTMLDivElement | null>;
|
|
68
|
-
testRef: RefObject<HTMLDivElement | null>;
|
|
69
|
-
resetTestCase: () => void | null;
|
|
70
|
-
traceAction: TraceAction;
|
|
71
|
-
};
|
|
72
|
-
suggestion: MappedSuggestion | null;
|
|
73
|
-
messageContent: string | null;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export declare function useWysiwyg(wysiwygProps?: WysiwygProps): UseWysiwyg;
|
|
77
|
-
|
|
78
|
-
export declare type Wysiwyg = {
|
|
79
|
-
actions: FormattingFunctions;
|
|
80
|
-
content: () => string;
|
|
81
|
-
messageContent: () => string;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export declare type WysiwygEvent = WysiwygInputEvent | KeyboardEvent;
|
|
85
|
-
|
|
86
|
-
export declare type WysiwygInputEvent = ClipboardEvent | LinkEvent | (InputEvent & {
|
|
87
|
-
inputType: BlockType;
|
|
88
|
-
data?: string | null;
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
export declare type WysiwygProps = {
|
|
92
|
-
isAutoFocusEnabled?: boolean;
|
|
93
|
-
inputEventProcessor?: InputEventProcessor;
|
|
94
|
-
initialContent?: string;
|
|
95
|
-
emojiSuggestions?: Map<string, string>;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export { }
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
export function start(): void;
|
|
4
|
-
export function new_composer_model(): ComposerModel;
|
|
5
|
-
export function new_composer_model_from_html(html: string, start_utf16_codeunit: number, end_utf16_codeunit: number): ComposerModel;
|
|
6
|
-
export enum ActionState {
|
|
7
|
-
/**
|
|
8
|
-
* The button can be clicked, and will perform its normal action
|
|
9
|
-
* e.g. make something bold
|
|
10
|
-
*/
|
|
11
|
-
Enabled = 0,
|
|
12
|
-
/**
|
|
13
|
-
* The button can be clicked, and will perform the reverse of its
|
|
14
|
-
* normal action e.g. stop something being bold
|
|
15
|
-
*/
|
|
16
|
-
Reversed = 1,
|
|
17
|
-
/**
|
|
18
|
-
* The button cannot be clicked
|
|
19
|
-
*/
|
|
20
|
-
Disabled = 2,
|
|
21
|
-
}
|
|
22
|
-
export enum ComposerAction {
|
|
23
|
-
Bold = 0,
|
|
24
|
-
Italic = 1,
|
|
25
|
-
StrikeThrough = 2,
|
|
26
|
-
Underline = 3,
|
|
27
|
-
InlineCode = 4,
|
|
28
|
-
Link = 5,
|
|
29
|
-
Undo = 6,
|
|
30
|
-
Redo = 7,
|
|
31
|
-
OrderedList = 8,
|
|
32
|
-
UnorderedList = 9,
|
|
33
|
-
Indent = 10,
|
|
34
|
-
Unindent = 11,
|
|
35
|
-
CodeBlock = 12,
|
|
36
|
-
Quote = 13,
|
|
37
|
-
}
|
|
38
|
-
export enum DomCreationError {
|
|
39
|
-
HtmlParseError = 0,
|
|
40
|
-
MarkdownParseError = 1,
|
|
41
|
-
}
|
|
42
|
-
export enum HtmlSource {
|
|
43
|
-
Matrix = 0,
|
|
44
|
-
GoogleDoc = 1,
|
|
45
|
-
UnknownExternal = 2,
|
|
46
|
-
}
|
|
47
|
-
export enum PatternKeyType {
|
|
48
|
-
At = 0,
|
|
49
|
-
Hash = 1,
|
|
50
|
-
Slash = 2,
|
|
51
|
-
Custom = 3,
|
|
52
|
-
Colon = 4,
|
|
53
|
-
}
|
|
54
|
-
export class ComposerModel {
|
|
55
|
-
private constructor();
|
|
56
|
-
free(): void;
|
|
57
|
-
static new(): ComposerModel;
|
|
58
|
-
static from_example_format(text: string): ComposerModel;
|
|
59
|
-
to_example_format(): string;
|
|
60
|
-
get_content_as_html(): string;
|
|
61
|
-
get_content_as_message_html(): string;
|
|
62
|
-
get_content_as_markdown(): string;
|
|
63
|
-
get_content_as_message_markdown(): string;
|
|
64
|
-
get_content_as_plain_text(): string;
|
|
65
|
-
document(): DomHandle;
|
|
66
|
-
action_states(): Map<any, any>;
|
|
67
|
-
select(start_utf16_codeunit: number, end_utf16_codeunit: number): ComposerUpdate;
|
|
68
|
-
selection_start(): number;
|
|
69
|
-
selection_end(): number;
|
|
70
|
-
replace_text(new_text: string): ComposerUpdate;
|
|
71
|
-
replace_html(new_html: string, external_source: HtmlSource): ComposerUpdate;
|
|
72
|
-
replace_text_suggestion(new_text: string, suggestion: SuggestionPattern, append_space: boolean): ComposerUpdate;
|
|
73
|
-
set_content_from_html(text: string): ComposerUpdate;
|
|
74
|
-
set_content_from_markdown(text: string): ComposerUpdate;
|
|
75
|
-
clear(): ComposerUpdate;
|
|
76
|
-
enter(): ComposerUpdate;
|
|
77
|
-
backspace(): ComposerUpdate;
|
|
78
|
-
backspace_word(): ComposerUpdate;
|
|
79
|
-
delete(): ComposerUpdate;
|
|
80
|
-
delete_word(): ComposerUpdate;
|
|
81
|
-
bold(): ComposerUpdate;
|
|
82
|
-
italic(): ComposerUpdate;
|
|
83
|
-
strike_through(): ComposerUpdate;
|
|
84
|
-
underline(): ComposerUpdate;
|
|
85
|
-
quote(): ComposerUpdate;
|
|
86
|
-
inline_code(): ComposerUpdate;
|
|
87
|
-
code_block(): ComposerUpdate;
|
|
88
|
-
undo(): ComposerUpdate;
|
|
89
|
-
redo(): ComposerUpdate;
|
|
90
|
-
ordered_list(): ComposerUpdate;
|
|
91
|
-
unordered_list(): ComposerUpdate;
|
|
92
|
-
indent(): ComposerUpdate;
|
|
93
|
-
unindent(): ComposerUpdate;
|
|
94
|
-
get_link_action(): LinkAction;
|
|
95
|
-
set_link(url: string, attributes: Map<any, any>): ComposerUpdate;
|
|
96
|
-
set_link_with_text(url: string, text: string, attributes: Map<any, any>): ComposerUpdate;
|
|
97
|
-
set_custom_suggestion_patterns(custom_suggestion_patterns: Array<any>): void;
|
|
98
|
-
/**
|
|
99
|
-
* Creates an at-room mention node and inserts it into the composer at the current selection
|
|
100
|
-
*/
|
|
101
|
-
insert_at_room_mention(attributes: Map<any, any>): ComposerUpdate;
|
|
102
|
-
/**
|
|
103
|
-
* Creates a mention node and inserts it into the composer at the current selection
|
|
104
|
-
*/
|
|
105
|
-
insert_mention(url: string, text: string, attributes: Map<any, any>): ComposerUpdate;
|
|
106
|
-
/**
|
|
107
|
-
* Creates an at-room mention node and inserts it into the composer, replacing the
|
|
108
|
-
* text content defined by the suggestion
|
|
109
|
-
*/
|
|
110
|
-
insert_at_room_mention_at_suggestion(suggestion: SuggestionPattern, attributes: Map<any, any>): ComposerUpdate;
|
|
111
|
-
/**
|
|
112
|
-
* Creates a mention node and inserts it into the composer, replacing the
|
|
113
|
-
* text content defined by the suggestion
|
|
114
|
-
*/
|
|
115
|
-
insert_mention_at_suggestion(url: string, text: string, suggestion: SuggestionPattern, attributes: Map<any, any>): ComposerUpdate;
|
|
116
|
-
remove_links(): ComposerUpdate;
|
|
117
|
-
}
|
|
118
|
-
export class ComposerUpdate {
|
|
119
|
-
private constructor();
|
|
120
|
-
free(): void;
|
|
121
|
-
text_update(): TextUpdate;
|
|
122
|
-
menu_state(): MenuState;
|
|
123
|
-
menu_action(): MenuAction;
|
|
124
|
-
}
|
|
125
|
-
export class Create {
|
|
126
|
-
private constructor();
|
|
127
|
-
free(): void;
|
|
128
|
-
}
|
|
129
|
-
export class CreateWithText {
|
|
130
|
-
private constructor();
|
|
131
|
-
free(): void;
|
|
132
|
-
}
|
|
133
|
-
export class Disabled {
|
|
134
|
-
private constructor();
|
|
135
|
-
free(): void;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* An iterator-like view of a DomHandle's children, written to work around
|
|
139
|
-
* the lack of support for returning Vec<T> in wasm_bindgen.
|
|
140
|
-
*/
|
|
141
|
-
export class DomChildren {
|
|
142
|
-
private constructor();
|
|
143
|
-
free(): void;
|
|
144
|
-
next_child(): DomHandle | undefined;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Refers to a node in the composer model.
|
|
148
|
-
*/
|
|
149
|
-
export class DomHandle {
|
|
150
|
-
private constructor();
|
|
151
|
-
free(): void;
|
|
152
|
-
/**
|
|
153
|
-
* Returns "container", "line_break", "text" or "zwsp" depending on the type of
|
|
154
|
-
* node we refer to.
|
|
155
|
-
* Panics if we are not a valid reference (because the model has changed
|
|
156
|
-
* since we were created, or because you passed in a different model
|
|
157
|
-
* from the one that created us.)
|
|
158
|
-
*/
|
|
159
|
-
node_type(model: ComposerModel): string;
|
|
160
|
-
/**
|
|
161
|
-
* Returns a list of our children nodes, or an empty list if we refer
|
|
162
|
-
* to a text or line break node.
|
|
163
|
-
* Panics if we are not a valid reference (because the model has changed
|
|
164
|
-
* since we were created, or because you passed in a different model
|
|
165
|
-
* from the one that created us.)
|
|
166
|
-
*/
|
|
167
|
-
children(model: ComposerModel): DomChildren;
|
|
168
|
-
/**
|
|
169
|
-
* Returns the text of this node, or an empty string if this is a
|
|
170
|
-
* container or line break.
|
|
171
|
-
* Panics if we are not a valid reference (because the model has changed
|
|
172
|
-
* since we were created, or because you passed in a different model
|
|
173
|
-
* from the one that created us.)
|
|
174
|
-
*/
|
|
175
|
-
text(model: ComposerModel): string;
|
|
176
|
-
/**
|
|
177
|
-
* Returns our tagname, or "-text-"/"-zwsp-" if we are a text/zwsp node.
|
|
178
|
-
* Panics if we are not a valid reference (because the model has changed
|
|
179
|
-
* since we were created, or because you passed in a different model
|
|
180
|
-
* from the one that created us.)
|
|
181
|
-
*/
|
|
182
|
-
tag(model: ComposerModel): string;
|
|
183
|
-
}
|
|
184
|
-
export class Edit {
|
|
185
|
-
private constructor();
|
|
186
|
-
free(): void;
|
|
187
|
-
url: string;
|
|
188
|
-
}
|
|
189
|
-
export class Keep {
|
|
190
|
-
private constructor();
|
|
191
|
-
free(): void;
|
|
192
|
-
}
|
|
193
|
-
export class LinkAction {
|
|
194
|
-
private constructor();
|
|
195
|
-
free(): void;
|
|
196
|
-
get create_with_text(): CreateWithText | undefined;
|
|
197
|
-
set create_with_text(value: CreateWithText | null | undefined);
|
|
198
|
-
get create(): Create | undefined;
|
|
199
|
-
set create(value: Create | null | undefined);
|
|
200
|
-
get edit_link(): Edit | undefined;
|
|
201
|
-
set edit_link(value: Edit | null | undefined);
|
|
202
|
-
get disabled(): Disabled | undefined;
|
|
203
|
-
set disabled(value: Disabled | null | undefined);
|
|
204
|
-
}
|
|
205
|
-
export class MenuAction {
|
|
206
|
-
private constructor();
|
|
207
|
-
free(): void;
|
|
208
|
-
keep(): boolean;
|
|
209
|
-
none(): boolean;
|
|
210
|
-
suggestion(): MenuActionSuggestion | undefined;
|
|
211
|
-
}
|
|
212
|
-
export class MenuActionSuggestion {
|
|
213
|
-
private constructor();
|
|
214
|
-
free(): void;
|
|
215
|
-
suggestion_pattern: SuggestionPattern;
|
|
216
|
-
}
|
|
217
|
-
export class MenuState {
|
|
218
|
-
private constructor();
|
|
219
|
-
free(): void;
|
|
220
|
-
keep(): boolean;
|
|
221
|
-
update(): MenuStateUpdate | undefined;
|
|
222
|
-
}
|
|
223
|
-
export class MenuStateUpdate {
|
|
224
|
-
private constructor();
|
|
225
|
-
free(): void;
|
|
226
|
-
action_states: Map<any, any>;
|
|
227
|
-
}
|
|
228
|
-
export class PatternKey {
|
|
229
|
-
private constructor();
|
|
230
|
-
free(): void;
|
|
231
|
-
key_type: PatternKeyType;
|
|
232
|
-
get custom_key_value(): string | undefined;
|
|
233
|
-
set custom_key_value(value: string | null | undefined);
|
|
234
|
-
}
|
|
235
|
-
export class ReplaceAll {
|
|
236
|
-
private constructor();
|
|
237
|
-
free(): void;
|
|
238
|
-
replacement_html: string;
|
|
239
|
-
start_utf16_codeunit: number;
|
|
240
|
-
end_utf16_codeunit: number;
|
|
241
|
-
}
|
|
242
|
-
export class Selection {
|
|
243
|
-
private constructor();
|
|
244
|
-
free(): void;
|
|
245
|
-
start_utf16_codeunit: number;
|
|
246
|
-
end_utf16_codeunit: number;
|
|
247
|
-
}
|
|
248
|
-
export class SuggestionPattern {
|
|
249
|
-
private constructor();
|
|
250
|
-
free(): void;
|
|
251
|
-
key: PatternKey;
|
|
252
|
-
text: string;
|
|
253
|
-
start: number;
|
|
254
|
-
end: number;
|
|
255
|
-
}
|
|
256
|
-
export class TextUpdate {
|
|
257
|
-
private constructor();
|
|
258
|
-
free(): void;
|
|
259
|
-
get keep(): Keep | undefined;
|
|
260
|
-
set keep(value: Keep | null | undefined);
|
|
261
|
-
get replace_all(): ReplaceAll | undefined;
|
|
262
|
-
set replace_all(value: ReplaceAll | null | undefined);
|
|
263
|
-
get select(): Selection | undefined;
|
|
264
|
-
set select(value: Selection | null | undefined);
|
|
265
|
-
}
|