@novaprose/core 0.6.0 → 0.8.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/README.md +20 -4
- package/dist/a11y.cjs +314 -0
- package/dist/a11y.cjs.map +1 -0
- package/dist/a11y.d.cts +51 -0
- package/dist/a11y.d.ts +51 -0
- package/dist/a11y.js +11 -0
- package/dist/a11y.js.map +1 -0
- package/dist/a11ychecker-7KQU7DD3.js +449 -0
- package/dist/a11ychecker-7KQU7DD3.js.map +1 -0
- package/dist/accordion-ui-FGN3I5UF.js +201 -0
- package/dist/accordion-ui-FGN3I5UF.js.map +1 -0
- package/dist/advcode-65Z2ELUB.js +51 -0
- package/dist/advcode-65Z2ELUB.js.map +1 -0
- package/dist/advcode-editor-WIOCY552.js +257 -0
- package/dist/advcode-editor-WIOCY552.js.map +1 -0
- package/dist/{advlist-K2U3VPH2.js → advlist-CEHE6YXS.js} +14 -20
- package/dist/advlist-CEHE6YXS.js.map +1 -0
- package/dist/advtable-ui-5CBOPTHW.js +364 -0
- package/dist/advtable-ui-5CBOPTHW.js.map +1 -0
- package/dist/ai-IRQYZHRK.js +1485 -0
- package/dist/ai-IRQYZHRK.js.map +1 -0
- package/dist/anchor-ui-NWIIRKGY.js +81 -0
- package/dist/anchor-ui-NWIIRKGY.js.map +1 -0
- package/dist/autocorrect-6GFLVDPC.js +851 -0
- package/dist/autocorrect-6GFLVDPC.js.map +1 -0
- package/dist/{autolink-XWDTLY37.js → autolink-N427KVQO.js} +13 -7
- package/dist/autolink-N427KVQO.js.map +1 -0
- package/dist/{autoresize-UB3GOA6D.js → autoresize-YRZAVCNO.js} +2 -2
- package/dist/autoresize-YRZAVCNO.js.map +1 -0
- package/dist/{autosave-MWNRUNU3.js → autosave-L7OZ3KLK.js} +9 -13
- package/dist/autosave-L7OZ3KLK.js.map +1 -0
- package/dist/casechange-5G6RAJ7K.js +201 -0
- package/dist/casechange-5G6RAJ7K.js.map +1 -0
- package/dist/{charmap-ADLYOIB3.js → charmap-5CBBDWOP.js} +9 -14
- package/dist/charmap-5CBBDWOP.js.map +1 -0
- package/dist/checklist-HM4VXZKY.js +189 -0
- package/dist/checklist-HM4VXZKY.js.map +1 -0
- package/dist/chunk-23ZLVT5D.js +163 -0
- package/dist/chunk-23ZLVT5D.js.map +1 -0
- package/dist/chunk-3BOK3S3T.js +26 -0
- package/dist/chunk-3BOK3S3T.js.map +1 -0
- package/dist/chunk-4I4AYH2K.js +101 -0
- package/dist/chunk-4I4AYH2K.js.map +1 -0
- package/dist/chunk-4VPDY3LF.js +27 -0
- package/dist/chunk-4VPDY3LF.js.map +1 -0
- package/dist/chunk-53AY5NAF.js +214 -0
- package/dist/chunk-53AY5NAF.js.map +1 -0
- package/dist/chunk-5VCESSQB.js +137 -0
- package/dist/chunk-5VCESSQB.js.map +1 -0
- package/dist/chunk-66INZHZ2.js +79 -0
- package/dist/chunk-66INZHZ2.js.map +1 -0
- package/dist/chunk-6LQM7G4V.js +159 -0
- package/dist/chunk-6LQM7G4V.js.map +1 -0
- package/dist/chunk-6YSQGFV7.js +893 -0
- package/dist/chunk-6YSQGFV7.js.map +1 -0
- package/dist/{chunk-GHEFKKRC.js → chunk-AC3YCAX4.js} +108 -29
- package/dist/chunk-AC3YCAX4.js.map +1 -0
- package/dist/{chunk-NPKAIW34.js → chunk-ADRPQLZ2.js} +50 -1
- package/dist/chunk-ADRPQLZ2.js.map +1 -0
- package/dist/chunk-ANE5ASXG.js +26 -0
- package/dist/chunk-ANE5ASXG.js.map +1 -0
- package/dist/{chunk-Z3ELZ77W.js → chunk-AP2PJFLB.js} +5 -2
- package/dist/chunk-AP2PJFLB.js.map +1 -0
- package/dist/chunk-AQV6FIKK.js +259 -0
- package/dist/chunk-AQV6FIKK.js.map +1 -0
- package/dist/chunk-AUQSATWL.js +322 -0
- package/dist/chunk-AUQSATWL.js.map +1 -0
- package/dist/chunk-C326LHHU.js +143 -0
- package/dist/chunk-C326LHHU.js.map +1 -0
- package/dist/chunk-DEYYVZ7O.js +393 -0
- package/dist/chunk-DEYYVZ7O.js.map +1 -0
- package/dist/chunk-EOJ5XHKA.js +160 -0
- package/dist/chunk-EOJ5XHKA.js.map +1 -0
- package/dist/chunk-EXX2S352.js +3642 -0
- package/dist/chunk-EXX2S352.js.map +1 -0
- package/dist/chunk-FTEA6L2Q.js +47 -0
- package/dist/chunk-FTEA6L2Q.js.map +1 -0
- package/dist/chunk-G74HNSB6.js +9 -0
- package/dist/chunk-G74HNSB6.js.map +1 -0
- package/dist/chunk-GHVB6SV4.js +177 -0
- package/dist/chunk-GHVB6SV4.js.map +1 -0
- package/dist/chunk-GTLE2HEW.js +108 -0
- package/dist/chunk-GTLE2HEW.js.map +1 -0
- package/dist/chunk-GXXXLPDQ.js +67 -0
- package/dist/chunk-GXXXLPDQ.js.map +1 -0
- package/dist/chunk-HC6RMBAD.js +163 -0
- package/dist/chunk-HC6RMBAD.js.map +1 -0
- package/dist/chunk-HNEAVVBC.js +98 -0
- package/dist/chunk-HNEAVVBC.js.map +1 -0
- package/dist/chunk-I7Y4KSM2.js +165 -0
- package/dist/chunk-I7Y4KSM2.js.map +1 -0
- package/dist/chunk-IG2BL4ON.js +127 -0
- package/dist/chunk-IG2BL4ON.js.map +1 -0
- package/dist/chunk-J6W2CDRF.js +425 -0
- package/dist/chunk-J6W2CDRF.js.map +1 -0
- package/dist/chunk-LVEQBNLX.js +207 -0
- package/dist/chunk-LVEQBNLX.js.map +1 -0
- package/dist/chunk-MZGNOHSY.js +176 -0
- package/dist/chunk-MZGNOHSY.js.map +1 -0
- package/dist/chunk-N32H37AJ.js +373 -0
- package/dist/chunk-N32H37AJ.js.map +1 -0
- package/dist/chunk-NTGEKGXU.js +263 -0
- package/dist/chunk-NTGEKGXU.js.map +1 -0
- package/dist/chunk-OFHGXYG3.js +140 -0
- package/dist/chunk-OFHGXYG3.js.map +1 -0
- package/dist/chunk-OOVNE6MB.js +28 -0
- package/dist/chunk-OOVNE6MB.js.map +1 -0
- package/dist/chunk-OQMMHWMZ.js +7 -0
- package/dist/chunk-OQMMHWMZ.js.map +1 -0
- package/dist/chunk-P2UU2NLT.js +1149 -0
- package/dist/chunk-P2UU2NLT.js.map +1 -0
- package/dist/{chunk-HZRIBOPW.js → chunk-QU3KXMYT.js} +45 -3
- package/dist/chunk-QU3KXMYT.js.map +1 -0
- package/dist/chunk-S2XZRKHA.js +29 -0
- package/dist/chunk-S2XZRKHA.js.map +1 -0
- package/dist/chunk-SCIRO4XK.js +144 -0
- package/dist/chunk-SCIRO4XK.js.map +1 -0
- package/dist/chunk-T3IRLTKK.js +158 -0
- package/dist/chunk-T3IRLTKK.js.map +1 -0
- package/dist/chunk-TABIUD2L.js +66 -0
- package/dist/chunk-TABIUD2L.js.map +1 -0
- package/dist/{chunk-7ON7PR5R.js → chunk-TAM2FHKG.js} +374 -52
- package/dist/chunk-TAM2FHKG.js.map +1 -0
- package/dist/chunk-UTMS2P2K.js +288 -0
- package/dist/chunk-UTMS2P2K.js.map +1 -0
- package/dist/{chunk-HPLT3XRZ.js → chunk-V7WUHUHM.js} +13 -1
- package/dist/chunk-V7WUHUHM.js.map +1 -0
- package/dist/chunk-VK6YF2AA.js +359 -0
- package/dist/chunk-VK6YF2AA.js.map +1 -0
- package/dist/chunk-WAOU5NGN.js +430 -0
- package/dist/chunk-WAOU5NGN.js.map +1 -0
- package/dist/chunk-XIH4SCO6.js +112 -0
- package/dist/chunk-XIH4SCO6.js.map +1 -0
- package/dist/chunk-XR7CY4NI.js +11 -0
- package/dist/chunk-XR7CY4NI.js.map +1 -0
- package/dist/chunk-YDF55N6Z.js +164 -0
- package/dist/chunk-YDF55N6Z.js.map +1 -0
- package/dist/chunk-YDPZCVXS.js +923 -0
- package/dist/chunk-YDPZCVXS.js.map +1 -0
- package/dist/chunk-YG5V7POU.js +137 -0
- package/dist/chunk-YG5V7POU.js.map +1 -0
- package/dist/chunk-YVSUR7E5.js +151 -0
- package/dist/chunk-YVSUR7E5.js.map +1 -0
- package/dist/codesample-GHWIC7PT.js +546 -0
- package/dist/codesample-GHWIC7PT.js.map +1 -0
- package/dist/{comments-panel-FYJE3U64.js → comments-panel-SOLBZ46Q.js} +12 -6
- package/dist/comments-panel-SOLBZ46Q.js.map +1 -0
- package/dist/{directionality-XOHJFSL6.js → directionality-EGQKGDZA.js} +16 -11
- package/dist/directionality-EGQKGDZA.js.map +1 -0
- package/dist/document-0ft41E6d.d.ts +39 -0
- package/dist/document-IQqDDT4v.d.cts +39 -0
- package/dist/docx.cjs +23518 -0
- package/dist/docx.cjs.map +1 -0
- package/dist/docx.d.cts +83 -0
- package/dist/docx.d.ts +83 -0
- package/dist/docx.js +1821 -0
- package/dist/docx.js.map +1 -0
- package/dist/draghandle-U6CYZHPA.js +389 -0
- package/dist/draghandle-U6CYZHPA.js.map +1 -0
- package/dist/editimage-5EWPSM22.js +683 -0
- package/dist/editimage-5EWPSM22.js.map +1 -0
- package/dist/editor-BCMxe1M4.d.cts +2888 -0
- package/dist/editor-Dmtwjw2u.d.ts +2888 -0
- package/dist/email-ELNMEQ6E.js +177 -0
- package/dist/email-ELNMEQ6E.js.map +1 -0
- package/dist/email.cjs +588 -0
- package/dist/email.cjs.map +1 -0
- package/dist/email.d.cts +7 -0
- package/dist/email.d.ts +7 -0
- package/dist/email.js +21 -0
- package/dist/email.js.map +1 -0
- package/dist/{emoticons-TP4N4ZGY.js → emoticons-EGHNZKSA.js} +9 -14
- package/dist/emoticons-EGHNZKSA.js.map +1 -0
- package/dist/exportpdf-4P7X3NY2.js +91 -0
- package/dist/exportpdf-4P7X3NY2.js.map +1 -0
- package/dist/exportword-JFJ3KTYZ.js +16 -0
- package/dist/exportword-JFJ3KTYZ.js.map +1 -0
- package/dist/footnotes-ui-FV6QRGDA.js +449 -0
- package/dist/footnotes-ui-FV6QRGDA.js.map +1 -0
- package/dist/form-dialog-SNWFPM2K.js +379 -0
- package/dist/form-dialog-SNWFPM2K.js.map +1 -0
- package/dist/formatpainter-IEXX27OJ.js +209 -0
- package/dist/formatpainter-IEXX27OJ.js.map +1 -0
- package/dist/fullpagehtml-ui-RE4C2NO5.js +220 -0
- package/dist/fullpagehtml-ui-RE4C2NO5.js.map +1 -0
- package/dist/html-rules-api-BLDDW9MO.d.cts +42 -0
- package/dist/html-rules-api-BLDDW9MO.d.ts +42 -0
- package/dist/html-rules.cjs +482 -0
- package/dist/html-rules.cjs.map +1 -0
- package/dist/html-rules.d.cts +89 -0
- package/dist/html-rules.d.ts +89 -0
- package/dist/html-rules.js +417 -0
- package/dist/html-rules.js.map +1 -0
- package/dist/i18n/de.cjs +670 -0
- package/dist/i18n/de.cjs.map +1 -0
- package/dist/i18n/de.d.cts +9 -0
- package/dist/i18n/de.d.ts +9 -0
- package/dist/i18n/de.js +649 -0
- package/dist/i18n/de.js.map +1 -0
- package/dist/i18n/es.cjs +670 -0
- package/dist/i18n/es.cjs.map +1 -0
- package/dist/i18n/es.d.cts +9 -0
- package/dist/i18n/es.d.ts +9 -0
- package/dist/i18n/es.js +649 -0
- package/dist/i18n/es.js.map +1 -0
- package/dist/i18n/fr.cjs +670 -0
- package/dist/i18n/fr.cjs.map +1 -0
- package/dist/i18n/fr.d.cts +9 -0
- package/dist/i18n/fr.d.ts +9 -0
- package/dist/i18n/fr.js +649 -0
- package/dist/i18n/fr.js.map +1 -0
- package/dist/i18n/it.cjs +670 -0
- package/dist/i18n/it.cjs.map +1 -0
- package/dist/i18n/it.d.cts +9 -0
- package/dist/i18n/it.d.ts +9 -0
- package/dist/i18n/it.js +649 -0
- package/dist/i18n/it.js.map +1 -0
- package/dist/i18n/pt-BR.cjs +670 -0
- package/dist/i18n/pt-BR.cjs.map +1 -0
- package/dist/i18n/pt-BR.d.cts +9 -0
- package/dist/i18n/pt-BR.d.ts +9 -0
- package/dist/i18n/pt-BR.js +649 -0
- package/dist/i18n/pt-BR.js.map +1 -0
- package/dist/i18n/ru.cjs +670 -0
- package/dist/i18n/ru.cjs.map +1 -0
- package/dist/i18n/ru.d.cts +10 -0
- package/dist/i18n/ru.d.ts +10 -0
- package/dist/i18n/ru.js +649 -0
- package/dist/i18n/ru.js.map +1 -0
- package/dist/importcss-JLNIRKGH.js +127 -0
- package/dist/importcss-JLNIRKGH.js.map +1 -0
- package/dist/importword-D7Z6RXGQ.js +73 -0
- package/dist/importword-D7Z6RXGQ.js.map +1 -0
- package/dist/index-CZ9yDvmQ.d.cts +235 -0
- package/dist/index-CZ9yDvmQ.d.ts +235 -0
- package/dist/index.cjs +29531 -10134
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +160 -1828
- package/dist/index.d.ts +160 -1828
- package/dist/index.js +212 -1480
- package/dist/index.js.map +1 -1
- package/dist/{insertdatetime-T4SEMQWP.js → insertdatetime-YW2VHYZH.js} +10 -16
- package/dist/insertdatetime-YW2VHYZH.js.map +1 -0
- package/dist/linkchecker-3S3MCPOS.js +287 -0
- package/dist/linkchecker-3S3MCPOS.js.map +1 -0
- package/dist/markdown-26O3N3T2.js +136 -0
- package/dist/markdown-26O3N3T2.js.map +1 -0
- package/dist/markdown.cjs +356 -0
- package/dist/markdown.cjs.map +1 -0
- package/dist/markdown.d.cts +25 -0
- package/dist/markdown.d.ts +25 -0
- package/dist/markdown.js +10 -0
- package/dist/markdown.js.map +1 -0
- package/dist/math-ui-RUTCHTRY.js +157 -0
- package/dist/math-ui-RUTCHTRY.js.map +1 -0
- package/dist/media-ui-36TE3CJD.js +123 -0
- package/dist/media-ui-36TE3CJD.js.map +1 -0
- package/dist/mediaembed-ui-ZNTGZ2SQ.js +207 -0
- package/dist/mediaembed-ui-ZNTGZ2SQ.js.map +1 -0
- package/dist/mentions-ui-O4IPWQT4.js +58 -0
- package/dist/mentions-ui-O4IPWQT4.js.map +1 -0
- package/dist/mergetags-ui-HS3Q2R36.js +73 -0
- package/dist/mergetags-ui-HS3Q2R36.js.map +1 -0
- package/dist/{nonbreaking-HG5HV6AL.js → nonbreaking-GYRUH4UO.js} +10 -9
- package/dist/nonbreaking-GYRUH4UO.js.map +1 -0
- package/dist/pagebreak-ui-I4ZPYK3U.js +50 -0
- package/dist/pagebreak-ui-I4ZPYK3U.js.map +1 -0
- package/dist/pageembed-ui-WOY6VWRJ.js +172 -0
- package/dist/pageembed-ui-WOY6VWRJ.js.map +1 -0
- package/dist/pagelayout-ui-Y2IM7FJQ.js +236 -0
- package/dist/pagelayout-ui-Y2IM7FJQ.js.map +1 -0
- package/dist/paste-office-3A6KWKCV.js +520 -0
- package/dist/paste-office-3A6KWKCV.js.map +1 -0
- package/dist/permanentpen-6D5LLKFX.js +206 -0
- package/dist/permanentpen-6D5LLKFX.js.map +1 -0
- package/dist/print-MZMLQIQX.js +178 -0
- package/dist/print-MZMLQIQX.js.map +1 -0
- package/dist/{quickbars-4NU4SIPL.js → quickbars-UZ2Q67TX.js} +24 -12
- package/dist/quickbars-UZ2Q67TX.js.map +1 -0
- package/dist/{revisionhistory-3YQPLPLM.js → revisionhistory-ACRB23HL.js} +48 -173
- package/dist/revisionhistory-ACRB23HL.js.map +1 -0
- package/dist/save-72ZLF6AO.js +120 -0
- package/dist/save-72ZLF6AO.js.map +1 -0
- package/dist/search-bar-HTZQNPD3.js +212 -0
- package/dist/search-bar-HTZQNPD3.js.map +1 -0
- package/dist/spellchecker-DJ7SP5JY.js +474 -0
- package/dist/spellchecker-DJ7SP5JY.js.map +1 -0
- package/dist/suggestions-panel-RJXC4LCM.js +596 -0
- package/dist/suggestions-panel-RJXC4LCM.js.map +1 -0
- package/dist/suggestions-ui-PODMNH7D.js +395 -0
- package/dist/suggestions-ui-PODMNH7D.js.map +1 -0
- package/dist/table-OBHE465Y.js +54 -0
- package/dist/table-OBHE465Y.js.map +1 -0
- package/dist/table-dialogs-UMIIZQYE.js +119 -0
- package/dist/table-dialogs-UMIIZQYE.js.map +1 -0
- package/dist/tableofcontents-ui-U2PYNPX6.js +167 -0
- package/dist/tableofcontents-ui-U2PYNPX6.js.map +1 -0
- package/dist/template-YYC2MGVH.js +278 -0
- package/dist/template-YYC2MGVH.js.map +1 -0
- package/dist/typography-EQUXUXIN.js +399 -0
- package/dist/typography-EQUXUXIN.js.map +1 -0
- package/dist/upload.cjs +160 -0
- package/dist/upload.cjs.map +1 -0
- package/dist/upload.d.cts +72 -0
- package/dist/upload.d.ts +72 -0
- package/dist/upload.js +132 -0
- package/dist/upload.js.map +1 -0
- package/dist/{visualblocks-RTAYJOGR.js → visualblocks-O5QW7ZDT.js} +10 -9
- package/dist/visualblocks-O5QW7ZDT.js.map +1 -0
- package/dist/visualchars-UQFRWQPE.js +134 -0
- package/dist/visualchars-UQFRWQPE.js.map +1 -0
- package/package.json +96 -6
- package/src/style.css +440 -508
- package/dist/advlist-K2U3VPH2.js.map +0 -1
- package/dist/autolink-XWDTLY37.js.map +0 -1
- package/dist/autoresize-UB3GOA6D.js.map +0 -1
- package/dist/autosave-MWNRUNU3.js.map +0 -1
- package/dist/charmap-ADLYOIB3.js.map +0 -1
- package/dist/chunk-435CRWKA.js +0 -983
- package/dist/chunk-435CRWKA.js.map +0 -1
- package/dist/chunk-46RIM5KP.js +0 -5949
- package/dist/chunk-46RIM5KP.js.map +0 -1
- package/dist/chunk-6RJENZXT.js +0 -104
- package/dist/chunk-6RJENZXT.js.map +0 -1
- package/dist/chunk-7ON7PR5R.js.map +0 -1
- package/dist/chunk-GHEFKKRC.js.map +0 -1
- package/dist/chunk-HPLT3XRZ.js.map +0 -1
- package/dist/chunk-HZRIBOPW.js.map +0 -1
- package/dist/chunk-NPKAIW34.js.map +0 -1
- package/dist/chunk-Z3ELZ77W.js.map +0 -1
- package/dist/comments-panel-FYJE3U64.js.map +0 -1
- package/dist/directionality-XOHJFSL6.js.map +0 -1
- package/dist/emoticons-TP4N4ZGY.js.map +0 -1
- package/dist/insertdatetime-T4SEMQWP.js.map +0 -1
- package/dist/nonbreaking-HG5HV6AL.js.map +0 -1
- package/dist/quickbars-4NU4SIPL.js.map +0 -1
- package/dist/revisionhistory-3YQPLPLM.js.map +0 -1
- package/dist/visualblocks-RTAYJOGR.js.map +0 -1
|
@@ -0,0 +1,851 @@
|
|
|
1
|
+
import {
|
|
2
|
+
pickLabels
|
|
3
|
+
} from "./chunk-DEYYVZ7O.js";
|
|
4
|
+
import {
|
|
5
|
+
definePlugin
|
|
6
|
+
} from "./chunk-V7WUHUHM.js";
|
|
7
|
+
import "./chunk-QU3KXMYT.js";
|
|
8
|
+
|
|
9
|
+
// src/plugins/autocorrect.ts
|
|
10
|
+
import { closeHistory } from "prosemirror-history";
|
|
11
|
+
import { Plugin, PluginKey } from "prosemirror-state";
|
|
12
|
+
import { Decoration, DecorationSet } from "prosemirror-view";
|
|
13
|
+
|
|
14
|
+
// nova-raw-css:/home/runner/work/novaprose/novaprose/packages/core/src/plugins/autocorrect.css?raw
|
|
15
|
+
var autocorrect_default = ".nova-autocorrected{text-decoration:underline dotted var(--nova-accent);text-decoration-thickness:2px;text-underline-offset:3px}@media(forced-colors:active){.nova-autocorrected{text-decoration-color:Highlight}}";
|
|
16
|
+
|
|
17
|
+
// src/plugins/autocorrect-rules.ts
|
|
18
|
+
var ENGLISH_LIST = {
|
|
19
|
+
// Letters swapped while typing fast.
|
|
20
|
+
teh: "the",
|
|
21
|
+
hte: "the",
|
|
22
|
+
tje: "the",
|
|
23
|
+
tyhe: "the",
|
|
24
|
+
adn: "and",
|
|
25
|
+
taht: "that",
|
|
26
|
+
thta: "that",
|
|
27
|
+
waht: "what",
|
|
28
|
+
whta: "what",
|
|
29
|
+
wiht: "with",
|
|
30
|
+
wtih: "with",
|
|
31
|
+
thsi: "this",
|
|
32
|
+
tihs: "this",
|
|
33
|
+
htis: "this",
|
|
34
|
+
thier: "their",
|
|
35
|
+
theri: "their",
|
|
36
|
+
jsut: "just",
|
|
37
|
+
konw: "know",
|
|
38
|
+
knwo: "know",
|
|
39
|
+
nkow: "know",
|
|
40
|
+
wnat: "want",
|
|
41
|
+
watn: "want",
|
|
42
|
+
woudl: "would",
|
|
43
|
+
wuold: "would",
|
|
44
|
+
owuld: "would",
|
|
45
|
+
coudl: "could",
|
|
46
|
+
cuold: "could",
|
|
47
|
+
shoudl: "should",
|
|
48
|
+
shuold: "should",
|
|
49
|
+
becuase: "because",
|
|
50
|
+
becasue: "because",
|
|
51
|
+
beacuse: "because",
|
|
52
|
+
bceause: "because",
|
|
53
|
+
abotu: "about",
|
|
54
|
+
aobut: "about",
|
|
55
|
+
baout: "about",
|
|
56
|
+
abuot: "about",
|
|
57
|
+
yuo: "you",
|
|
58
|
+
oyu: "you",
|
|
59
|
+
yuor: "your",
|
|
60
|
+
yoru: "your",
|
|
61
|
+
frmo: "from",
|
|
62
|
+
thne: "then",
|
|
63
|
+
tehn: "then",
|
|
64
|
+
tehm: "them",
|
|
65
|
+
thme: "them",
|
|
66
|
+
htem: "them",
|
|
67
|
+
wehn: "when",
|
|
68
|
+
whne: "when",
|
|
69
|
+
hwen: "when",
|
|
70
|
+
whihc: "which",
|
|
71
|
+
whcih: "which",
|
|
72
|
+
wihch: "which",
|
|
73
|
+
agian: "again",
|
|
74
|
+
aginst: "against",
|
|
75
|
+
againt: "against",
|
|
76
|
+
alwasy: "always",
|
|
77
|
+
alwyas: "always",
|
|
78
|
+
anohter: "another",
|
|
79
|
+
anwser: "answer",
|
|
80
|
+
asnwer: "answer",
|
|
81
|
+
befroe: "before",
|
|
82
|
+
beofre: "before",
|
|
83
|
+
brigde: "bridge",
|
|
84
|
+
certian: "certain",
|
|
85
|
+
chnage: "change",
|
|
86
|
+
comapny: "company",
|
|
87
|
+
compnay: "company",
|
|
88
|
+
comptuer: "computer",
|
|
89
|
+
contian: "contain",
|
|
90
|
+
doign: "doing",
|
|
91
|
+
eariler: "earlier",
|
|
92
|
+
everythign: "everything",
|
|
93
|
+
exmaple: "example",
|
|
94
|
+
exapmle: "example",
|
|
95
|
+
fianlly: "finally",
|
|
96
|
+
fisrt: "first",
|
|
97
|
+
gerat: "great",
|
|
98
|
+
goign: "going",
|
|
99
|
+
gonig: "going",
|
|
100
|
+
haev: "have",
|
|
101
|
+
hvae: "have",
|
|
102
|
+
ahve: "have",
|
|
103
|
+
hting: "thing",
|
|
104
|
+
htink: "think",
|
|
105
|
+
idae: "idea",
|
|
106
|
+
improtant: "important",
|
|
107
|
+
importnat: "important",
|
|
108
|
+
informatoin: "information",
|
|
109
|
+
langauge: "language",
|
|
110
|
+
liek: "like",
|
|
111
|
+
likley: "likely",
|
|
112
|
+
littel: "little",
|
|
113
|
+
lookign: "looking",
|
|
114
|
+
mkae: "make",
|
|
115
|
+
mroe: "more",
|
|
116
|
+
mysefl: "myself",
|
|
117
|
+
ohter: "other",
|
|
118
|
+
otehr: "other",
|
|
119
|
+
onyl: "only",
|
|
120
|
+
olny: "only",
|
|
121
|
+
peopel: "people",
|
|
122
|
+
poeple: "people",
|
|
123
|
+
pepole: "people",
|
|
124
|
+
perhpas: "perhaps",
|
|
125
|
+
porblem: "problem",
|
|
126
|
+
probelm: "problem",
|
|
127
|
+
problme: "problem",
|
|
128
|
+
questoin: "question",
|
|
129
|
+
raelly: "really",
|
|
130
|
+
rememebr: "remember",
|
|
131
|
+
restuarant: "restaurant",
|
|
132
|
+
rigth: "right",
|
|
133
|
+
rihgt: "right",
|
|
134
|
+
smae: "same",
|
|
135
|
+
soem: "some",
|
|
136
|
+
somethign: "something",
|
|
137
|
+
sotry: "story",
|
|
138
|
+
studnet: "student",
|
|
139
|
+
systme: "system",
|
|
140
|
+
tahn: "than",
|
|
141
|
+
thna: "than",
|
|
142
|
+
thign: "thing",
|
|
143
|
+
thigns: "things",
|
|
144
|
+
thikn: "think",
|
|
145
|
+
thoguht: "thought",
|
|
146
|
+
thougth: "thought",
|
|
147
|
+
throuhg: "through",
|
|
148
|
+
tiem: "time",
|
|
149
|
+
togehter: "together",
|
|
150
|
+
tonigth: "tonight",
|
|
151
|
+
udpate: "update",
|
|
152
|
+
uesd: "used",
|
|
153
|
+
veyr: "very",
|
|
154
|
+
vrey: "very",
|
|
155
|
+
wokr: "work",
|
|
156
|
+
wrok: "work",
|
|
157
|
+
wrogn: "wrong",
|
|
158
|
+
yera: "year",
|
|
159
|
+
yeras: "years",
|
|
160
|
+
// Letters missing, doubled or out of order.
|
|
161
|
+
accomodate: "accommodate",
|
|
162
|
+
accomodation: "accommodation",
|
|
163
|
+
acommodate: "accommodate",
|
|
164
|
+
accross: "across",
|
|
165
|
+
acess: "access",
|
|
166
|
+
acheive: "achieve",
|
|
167
|
+
acheived: "achieved",
|
|
168
|
+
acheivement: "achievement",
|
|
169
|
+
adress: "address",
|
|
170
|
+
allready: "already",
|
|
171
|
+
alredy: "already",
|
|
172
|
+
allways: "always",
|
|
173
|
+
apparant: "apparent",
|
|
174
|
+
apparantly: "apparently",
|
|
175
|
+
appearence: "appearance",
|
|
176
|
+
arguement: "argument",
|
|
177
|
+
basicly: "basically",
|
|
178
|
+
beatiful: "beautiful",
|
|
179
|
+
beautifull: "beautiful",
|
|
180
|
+
begining: "beginning",
|
|
181
|
+
beggining: "beginning",
|
|
182
|
+
beleive: "believe",
|
|
183
|
+
belive: "believe",
|
|
184
|
+
beleif: "belief",
|
|
185
|
+
buisness: "business",
|
|
186
|
+
bussiness: "business",
|
|
187
|
+
carribean: "Caribbean",
|
|
188
|
+
cemetary: "cemetery",
|
|
189
|
+
changable: "changeable",
|
|
190
|
+
cheif: "chief",
|
|
191
|
+
choosen: "chosen",
|
|
192
|
+
cieling: "ceiling",
|
|
193
|
+
collegue: "colleague",
|
|
194
|
+
comming: "coming",
|
|
195
|
+
commited: "committed",
|
|
196
|
+
commitee: "committee",
|
|
197
|
+
comittee: "committee",
|
|
198
|
+
completly: "completely",
|
|
199
|
+
concensus: "consensus",
|
|
200
|
+
concieve: "conceive",
|
|
201
|
+
concious: "conscious",
|
|
202
|
+
decieve: "deceive",
|
|
203
|
+
definately: "definitely",
|
|
204
|
+
definatly: "definitely",
|
|
205
|
+
definetly: "definitely",
|
|
206
|
+
definitly: "definitely",
|
|
207
|
+
diffrent: "different",
|
|
208
|
+
differnt: "different",
|
|
209
|
+
dilemna: "dilemma",
|
|
210
|
+
dissapear: "disappear",
|
|
211
|
+
dissapoint: "disappoint",
|
|
212
|
+
dissapointed: "disappointed",
|
|
213
|
+
embarass: "embarrass",
|
|
214
|
+
embarassed: "embarrassed",
|
|
215
|
+
embarassing: "embarrassing",
|
|
216
|
+
enviroment: "environment",
|
|
217
|
+
enviromental: "environmental",
|
|
218
|
+
excercise: "exercise",
|
|
219
|
+
exersize: "exercise",
|
|
220
|
+
existance: "existence",
|
|
221
|
+
expecially: "especially",
|
|
222
|
+
experiance: "experience",
|
|
223
|
+
evrything: "everything",
|
|
224
|
+
familar: "familiar",
|
|
225
|
+
finaly: "finally",
|
|
226
|
+
flourescent: "fluorescent",
|
|
227
|
+
folowing: "following",
|
|
228
|
+
follwing: "following",
|
|
229
|
+
foriegn: "foreign",
|
|
230
|
+
fourty: "forty",
|
|
231
|
+
foward: "forward",
|
|
232
|
+
freind: "friend",
|
|
233
|
+
freinds: "friends",
|
|
234
|
+
feild: "field",
|
|
235
|
+
garantee: "guarantee",
|
|
236
|
+
guarentee: "guarantee",
|
|
237
|
+
gaurd: "guard",
|
|
238
|
+
geting: "getting",
|
|
239
|
+
goverment: "government",
|
|
240
|
+
grammer: "grammar",
|
|
241
|
+
hapen: "happen",
|
|
242
|
+
hapened: "happened",
|
|
243
|
+
happend: "happened",
|
|
244
|
+
harrass: "harass",
|
|
245
|
+
harrased: "harassed",
|
|
246
|
+
helpfull: "helpful",
|
|
247
|
+
hieght: "height",
|
|
248
|
+
humourous: "humorous",
|
|
249
|
+
ignorence: "ignorance",
|
|
250
|
+
imediately: "immediately",
|
|
251
|
+
immediatly: "immediately",
|
|
252
|
+
immediatley: "immediately",
|
|
253
|
+
imporant: "important",
|
|
254
|
+
independant: "independent",
|
|
255
|
+
infomation: "information",
|
|
256
|
+
interupt: "interrupt",
|
|
257
|
+
intresting: "interesting",
|
|
258
|
+
intrest: "interest",
|
|
259
|
+
knowlege: "knowledge",
|
|
260
|
+
laguage: "language",
|
|
261
|
+
lenght: "length",
|
|
262
|
+
liason: "liaison",
|
|
263
|
+
libary: "library",
|
|
264
|
+
liesure: "leisure",
|
|
265
|
+
maintainance: "maintenance",
|
|
266
|
+
maintenence: "maintenance",
|
|
267
|
+
makeing: "making",
|
|
268
|
+
millenium: "millennium",
|
|
269
|
+
minature: "miniature",
|
|
270
|
+
mischievious: "mischievous",
|
|
271
|
+
mispell: "misspell",
|
|
272
|
+
mispelled: "misspelled",
|
|
273
|
+
necesarily: "necessarily",
|
|
274
|
+
necesary: "necessary",
|
|
275
|
+
neccesary: "necessary",
|
|
276
|
+
neccessary: "necessary",
|
|
277
|
+
neice: "niece",
|
|
278
|
+
nieghbor: "neighbor",
|
|
279
|
+
nieghbour: "neighbour",
|
|
280
|
+
noticable: "noticeable",
|
|
281
|
+
occassion: "occasion",
|
|
282
|
+
occassionally: "occasionally",
|
|
283
|
+
ocassion: "occasion",
|
|
284
|
+
occured: "occurred",
|
|
285
|
+
occurence: "occurrence",
|
|
286
|
+
occurance: "occurrence",
|
|
287
|
+
occuring: "occurring",
|
|
288
|
+
oportunity: "opportunity",
|
|
289
|
+
oppurtunity: "opportunity",
|
|
290
|
+
paralel: "parallel",
|
|
291
|
+
parliment: "parliament",
|
|
292
|
+
peice: "piece",
|
|
293
|
+
percieve: "perceive",
|
|
294
|
+
posess: "possess",
|
|
295
|
+
posession: "possession",
|
|
296
|
+
potatos: "potatoes",
|
|
297
|
+
preceeding: "preceding",
|
|
298
|
+
prefered: "preferred",
|
|
299
|
+
presense: "presence",
|
|
300
|
+
privelege: "privilege",
|
|
301
|
+
priviledge: "privilege",
|
|
302
|
+
probaly: "probably",
|
|
303
|
+
probly: "probably",
|
|
304
|
+
propably: "probably",
|
|
305
|
+
proffesional: "professional",
|
|
306
|
+
progam: "program",
|
|
307
|
+
pronounciation: "pronunciation",
|
|
308
|
+
publically: "publicly",
|
|
309
|
+
questionaire: "questionnaire",
|
|
310
|
+
realy: "really",
|
|
311
|
+
reciept: "receipt",
|
|
312
|
+
recieve: "receive",
|
|
313
|
+
recieved: "received",
|
|
314
|
+
recieving: "receiving",
|
|
315
|
+
recomend: "recommend",
|
|
316
|
+
reccomend: "recommend",
|
|
317
|
+
reccommend: "recommend",
|
|
318
|
+
recomendation: "recommendation",
|
|
319
|
+
recurrance: "recurrence",
|
|
320
|
+
refered: "referred",
|
|
321
|
+
refering: "referring",
|
|
322
|
+
relevent: "relevant",
|
|
323
|
+
religous: "religious",
|
|
324
|
+
remeber: "remember",
|
|
325
|
+
rember: "remember",
|
|
326
|
+
repitition: "repetition",
|
|
327
|
+
resistence: "resistance",
|
|
328
|
+
resturant: "restaurant",
|
|
329
|
+
rythm: "rhythm",
|
|
330
|
+
saftey: "safety",
|
|
331
|
+
scedule: "schedule",
|
|
332
|
+
schedual: "schedule",
|
|
333
|
+
seige: "siege",
|
|
334
|
+
sentance: "sentence",
|
|
335
|
+
seperate: "separate",
|
|
336
|
+
seperated: "separated",
|
|
337
|
+
seperately: "separately",
|
|
338
|
+
sieze: "seize",
|
|
339
|
+
similiar: "similar",
|
|
340
|
+
simliar: "similar",
|
|
341
|
+
sincerly: "sincerely",
|
|
342
|
+
somthing: "something",
|
|
343
|
+
speach: "speech",
|
|
344
|
+
stoped: "stopped",
|
|
345
|
+
strenght: "strength",
|
|
346
|
+
succeded: "succeeded",
|
|
347
|
+
succesful: "successful",
|
|
348
|
+
succesfully: "successfully",
|
|
349
|
+
sucessful: "successful",
|
|
350
|
+
successfull: "successful",
|
|
351
|
+
sucess: "success",
|
|
352
|
+
sucessfully: "successfully",
|
|
353
|
+
supose: "suppose",
|
|
354
|
+
suprise: "surprise",
|
|
355
|
+
sytem: "system",
|
|
356
|
+
temperture: "temperature",
|
|
357
|
+
tendancy: "tendency",
|
|
358
|
+
theif: "thief",
|
|
359
|
+
threshhold: "threshold",
|
|
360
|
+
toghether: "together",
|
|
361
|
+
tommorow: "tomorrow",
|
|
362
|
+
tomorow: "tomorrow",
|
|
363
|
+
tommorrow: "tomorrow",
|
|
364
|
+
tounge: "tongue",
|
|
365
|
+
truely: "truly",
|
|
366
|
+
twelth: "twelfth",
|
|
367
|
+
tyrany: "tyranny",
|
|
368
|
+
unforseen: "unforeseen",
|
|
369
|
+
unfortunatly: "unfortunately",
|
|
370
|
+
unfortunatley: "unfortunately",
|
|
371
|
+
unneccessary: "unnecessary",
|
|
372
|
+
untill: "until",
|
|
373
|
+
upate: "update",
|
|
374
|
+
usally: "usually",
|
|
375
|
+
usualy: "usually",
|
|
376
|
+
vaccum: "vacuum",
|
|
377
|
+
vacume: "vacuum",
|
|
378
|
+
vehical: "vehicle",
|
|
379
|
+
visable: "visible",
|
|
380
|
+
wierd: "weird",
|
|
381
|
+
withold: "withhold",
|
|
382
|
+
writen: "written",
|
|
383
|
+
writting: "writing",
|
|
384
|
+
yeild: "yield",
|
|
385
|
+
// Two words written as one.
|
|
386
|
+
alot: "a lot",
|
|
387
|
+
aswell: "as well",
|
|
388
|
+
atleast: "at least",
|
|
389
|
+
eachother: "each other",
|
|
390
|
+
everytime: "every time",
|
|
391
|
+
infact: "in fact",
|
|
392
|
+
inspite: "in spite",
|
|
393
|
+
noone: "no one",
|
|
394
|
+
ofcourse: "of course",
|
|
395
|
+
thankyou: "thank you",
|
|
396
|
+
// Apostrophes left out (only where the word without one doesn't exist).
|
|
397
|
+
arent: "aren't",
|
|
398
|
+
couldnt: "couldn't",
|
|
399
|
+
couldve: "could've",
|
|
400
|
+
didnt: "didn't",
|
|
401
|
+
doesnt: "doesn't",
|
|
402
|
+
dosent: "doesn't",
|
|
403
|
+
hadnt: "hadn't",
|
|
404
|
+
hasnt: "hasn't",
|
|
405
|
+
havent: "haven't",
|
|
406
|
+
heres: "here's",
|
|
407
|
+
isnt: "isn't",
|
|
408
|
+
itll: "it'll",
|
|
409
|
+
mustnt: "mustn't",
|
|
410
|
+
neednt: "needn't",
|
|
411
|
+
shes: "she's",
|
|
412
|
+
shouldnt: "shouldn't",
|
|
413
|
+
shouldve: "should've",
|
|
414
|
+
thatll: "that'll",
|
|
415
|
+
thats: "that's",
|
|
416
|
+
theres: "there's",
|
|
417
|
+
theyd: "they'd",
|
|
418
|
+
theyll: "they'll",
|
|
419
|
+
theyre: "they're",
|
|
420
|
+
theyve: "they've",
|
|
421
|
+
wasnt: "wasn't",
|
|
422
|
+
werent: "weren't",
|
|
423
|
+
weve: "we've",
|
|
424
|
+
whats: "what's",
|
|
425
|
+
wheres: "where's",
|
|
426
|
+
wouldnt: "wouldn't",
|
|
427
|
+
wouldve: "would've",
|
|
428
|
+
youd: "you'd",
|
|
429
|
+
youll: "you'll",
|
|
430
|
+
youre: "you're",
|
|
431
|
+
youve: "you've",
|
|
432
|
+
"dosen't": "doesn't",
|
|
433
|
+
"coudn't": "couldn't",
|
|
434
|
+
// The pronoun I, and names of days and months (not "may", "march" or "august": they are words too).
|
|
435
|
+
i: "I",
|
|
436
|
+
ive: "I've",
|
|
437
|
+
"i'm": "I'm",
|
|
438
|
+
"i've": "I've",
|
|
439
|
+
"i'll": "I'll",
|
|
440
|
+
"i'd": "I'd",
|
|
441
|
+
monday: "Monday",
|
|
442
|
+
tuesday: "Tuesday",
|
|
443
|
+
wednesday: "Wednesday",
|
|
444
|
+
thursday: "Thursday",
|
|
445
|
+
friday: "Friday",
|
|
446
|
+
saturday: "Saturday",
|
|
447
|
+
sunday: "Sunday",
|
|
448
|
+
january: "January",
|
|
449
|
+
february: "February",
|
|
450
|
+
april: "April",
|
|
451
|
+
june: "June",
|
|
452
|
+
july: "July",
|
|
453
|
+
september: "September",
|
|
454
|
+
october: "October",
|
|
455
|
+
november: "November",
|
|
456
|
+
december: "December"
|
|
457
|
+
};
|
|
458
|
+
var ENGLISH = new Map(Object.entries(ENGLISH_LIST));
|
|
459
|
+
var TWO_CAPITALS_KEPT = /* @__PURE__ */ new Set([
|
|
460
|
+
"MHz",
|
|
461
|
+
"GHz",
|
|
462
|
+
"THz",
|
|
463
|
+
"KHz",
|
|
464
|
+
"MBps",
|
|
465
|
+
"KBps",
|
|
466
|
+
"GBps",
|
|
467
|
+
"TBps",
|
|
468
|
+
"MSc",
|
|
469
|
+
"BSc",
|
|
470
|
+
"DSc",
|
|
471
|
+
"MSci",
|
|
472
|
+
"OAuth",
|
|
473
|
+
"IPsec",
|
|
474
|
+
"VMware",
|
|
475
|
+
"CMake",
|
|
476
|
+
"MPlayer",
|
|
477
|
+
"DBeaver",
|
|
478
|
+
"GHub",
|
|
479
|
+
"PEFTs",
|
|
480
|
+
"SQLite"
|
|
481
|
+
]);
|
|
482
|
+
var ABBREVIATIONS = new Set(
|
|
483
|
+
"mr mrs ms dr prof sr jr st vs etc cf al approx incl excl no nos fig figs vol vols ch sec p pp ed eds dept est inc ltd co corp jan feb mar apr jun jul aug sep sept oct nov dec mon tue tues wed thu thur thurs fri sat sun min max avg tel ext ca resp ref nr bzw usw vgl ggf evtl sra srta pag pags mme mlle".split(" ")
|
|
484
|
+
);
|
|
485
|
+
var WORD = "([\\p{L}\\p{M}]+(?:['\u2019][\\p{L}\\p{M}]+)*)";
|
|
486
|
+
var ENDS = `[\\s.,;:!?\u2026)\\]}"'\u201D\u2019\xBB]`;
|
|
487
|
+
var WORD_THEN_END = new RegExp(`${WORD}(${ENDS}{1,4})$`, "u");
|
|
488
|
+
var WORD_AT_END = new RegExp(`${WORD}$`, "u");
|
|
489
|
+
var BEFORE_WORD = /[\s(«"'“‘„¿¡—–]/u;
|
|
490
|
+
var SENTENCE_END = /([.!?]+)[)\]"'”’»]*\s+[(«"'“‘„¿¡]*$/u;
|
|
491
|
+
var BLOCK_START = /^[\s(«"'“‘„¿¡]*$/u;
|
|
492
|
+
function wordKey(word) {
|
|
493
|
+
return word.toLowerCase().replace(/’/g, "'");
|
|
494
|
+
}
|
|
495
|
+
function matchCase(typed, target) {
|
|
496
|
+
const letters = typed.replace(/[^\p{L}]/gu, "");
|
|
497
|
+
if (letters.length > 1 && letters === letters.toUpperCase() && letters !== letters.toLowerCase())
|
|
498
|
+
return target.toUpperCase();
|
|
499
|
+
const first = Array.from(typed)[0] ?? "";
|
|
500
|
+
if (first !== first.toLowerCase()) return capitalizeFirst(target);
|
|
501
|
+
return target;
|
|
502
|
+
}
|
|
503
|
+
function capitalizeFirst(word) {
|
|
504
|
+
const [first = "", ...rest] = Array.from(word);
|
|
505
|
+
return first.toUpperCase() + rest.join("");
|
|
506
|
+
}
|
|
507
|
+
function twoCapitals(word) {
|
|
508
|
+
if (!/^\p{Lu}\p{Lu}\p{Ll}+$/u.test(word)) return false;
|
|
509
|
+
const rest = Array.from(word).slice(2).join("");
|
|
510
|
+
return rest !== "s" && rest !== "es" && !TWO_CAPITALS_KEPT.has(word);
|
|
511
|
+
}
|
|
512
|
+
function canCapitalize(word) {
|
|
513
|
+
const first = Array.from(word)[0] ?? "";
|
|
514
|
+
return first !== first.toUpperCase() && word === word.toLowerCase();
|
|
515
|
+
}
|
|
516
|
+
function sentenceStart(before, blockStart, learned) {
|
|
517
|
+
if (BLOCK_START.test(before)) return blockStart ? {} : null;
|
|
518
|
+
const end = SENTENCE_END.exec(before);
|
|
519
|
+
if (!end) return null;
|
|
520
|
+
const marks = end[1];
|
|
521
|
+
if (marks.includes("!") || marks.includes("?")) return {};
|
|
522
|
+
if (marks.length > 1) return null;
|
|
523
|
+
const token = /(\S*)$/u.exec(before.slice(0, end.index))[1].replace(/^[(«"'“‘„¿¡]+/u, "");
|
|
524
|
+
if (!token || token.includes(".") || Array.from(token).length === 1) return null;
|
|
525
|
+
const key2 = token.toLowerCase();
|
|
526
|
+
if (ABBREVIATIONS.has(key2) || learned.has(key2)) return null;
|
|
527
|
+
return { after: token };
|
|
528
|
+
}
|
|
529
|
+
function findCorrection(text, settings, { blockStart = true, trailer = true } = {}) {
|
|
530
|
+
if (!settings.autocorrect && !settings.capitalize) return null;
|
|
531
|
+
const match = (trailer ? WORD_THEN_END : WORD_AT_END).exec(text);
|
|
532
|
+
if (!match) return null;
|
|
533
|
+
const word = match[1];
|
|
534
|
+
const start = match.index;
|
|
535
|
+
if (start > 0 && !BEFORE_WORD.test(text[start - 1])) return null;
|
|
536
|
+
const key2 = wordKey(word);
|
|
537
|
+
if (settings.ignore.has(key2)) return null;
|
|
538
|
+
let replacement = word;
|
|
539
|
+
let kind = null;
|
|
540
|
+
let after;
|
|
541
|
+
const shouted = Array.from(word).length > 1 && word === word.toUpperCase() && word !== key2;
|
|
542
|
+
if (settings.autocorrect && !shouted) {
|
|
543
|
+
const listed = settings.replacements.get(key2) ?? (settings.english ? ENGLISH.get(key2) : void 0);
|
|
544
|
+
if (listed !== void 0) {
|
|
545
|
+
const fixed = apostrophes(matchCase(word, listed), word, text);
|
|
546
|
+
if (fixed !== word) {
|
|
547
|
+
replacement = fixed;
|
|
548
|
+
kind = "typo";
|
|
549
|
+
}
|
|
550
|
+
} else if (twoCapitals(word)) {
|
|
551
|
+
replacement = Array.from(word)[0] + Array.from(word).slice(1).join("").toLowerCase();
|
|
552
|
+
kind = "capitals";
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
if (settings.capitalize && canCapitalize(replacement)) {
|
|
556
|
+
const sentence = sentenceStart(text.slice(0, start), blockStart, settings.abbreviations);
|
|
557
|
+
if (sentence) {
|
|
558
|
+
replacement = capitalizeFirst(replacement);
|
|
559
|
+
kind ??= "sentence";
|
|
560
|
+
after = sentence.after;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
if (!kind || replacement === word) return null;
|
|
564
|
+
return { start, end: start + word.length, word, replacement, kind, ...after ? { after } : {} };
|
|
565
|
+
}
|
|
566
|
+
function apostrophes(replacement, word, text) {
|
|
567
|
+
if (!replacement.includes("'")) return replacement;
|
|
568
|
+
const curly = word.includes("\u2019") || !word.includes("'") && text.includes("\u2019");
|
|
569
|
+
return curly ? replacement.replace(/'/g, "\u2019") : replacement;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// src/plugins/autocorrect.ts
|
|
573
|
+
var LABELS = {
|
|
574
|
+
en: {
|
|
575
|
+
title: "Autocorrect",
|
|
576
|
+
spelling: "Correct typos as you type",
|
|
577
|
+
capitalize: "Capitalize the first letter of sentences",
|
|
578
|
+
changed: "{word} changed to {replacement}",
|
|
579
|
+
reverted: "{word} put back"
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
var key = new PluginKey("nova-autocorrect");
|
|
583
|
+
var STORAGE = "novaprose-autocorrect";
|
|
584
|
+
var leafText = (node) => node.type.name === "hard_break" ? "\n" : "\uFFFC";
|
|
585
|
+
var CONTEXT = 400;
|
|
586
|
+
var ENDS_WORD = /[\s.,;:!?…)\]}"'”’»]$/u;
|
|
587
|
+
var ICON = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3 18 5-13 5 13"/><path d="M5 13h6"/><path d="m19 4-3 7h4l-3 7"/></svg>';
|
|
588
|
+
var editors = /* @__PURE__ */ new WeakMap();
|
|
589
|
+
var autocorrect_default2 = definePlugin({
|
|
590
|
+
name: "autocorrect",
|
|
591
|
+
// A button to switch it off, with the capitals option in its menu.
|
|
592
|
+
toolbar: "autocorrect",
|
|
593
|
+
prosemirrorPlugins: (editor) => {
|
|
594
|
+
const ac = editors.get(editor) ?? createAutocorrect(editor);
|
|
595
|
+
editors.set(editor, ac);
|
|
596
|
+
return [ac.plugin];
|
|
597
|
+
},
|
|
598
|
+
setup(editor) {
|
|
599
|
+
const ac = editors.get(editor);
|
|
600
|
+
const { labels } = ac;
|
|
601
|
+
editor.ui.addStyles("nova-autocorrect", autocorrect_default);
|
|
602
|
+
const toggles = () => [
|
|
603
|
+
{
|
|
604
|
+
id: "autocorrect",
|
|
605
|
+
label: labels.spelling,
|
|
606
|
+
checkbox: true,
|
|
607
|
+
active: ac.settings.autocorrect,
|
|
608
|
+
onSelect: () => ac.set("autocorrect", !ac.settings.autocorrect)
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
id: "capitalize",
|
|
612
|
+
label: labels.capitalize,
|
|
613
|
+
checkbox: true,
|
|
614
|
+
active: ac.settings.capitalize,
|
|
615
|
+
onSelect: () => ac.set("capitalize", !ac.settings.capitalize)
|
|
616
|
+
}
|
|
617
|
+
];
|
|
618
|
+
editor.ui.registry.addSplitButton("autocorrect", {
|
|
619
|
+
icon: ICON,
|
|
620
|
+
tooltip: labels.title,
|
|
621
|
+
isActive: () => ac.settings.autocorrect,
|
|
622
|
+
onAction: () => ac.set("autocorrect", !ac.settings.autocorrect),
|
|
623
|
+
items: toggles
|
|
624
|
+
});
|
|
625
|
+
editor.ui.registry.addMenuItem("autocorrect", {
|
|
626
|
+
text: labels.spelling,
|
|
627
|
+
icon: ICON,
|
|
628
|
+
isActive: () => ac.settings.autocorrect,
|
|
629
|
+
onAction: () => ac.set("autocorrect", !ac.settings.autocorrect)
|
|
630
|
+
});
|
|
631
|
+
editor.ui.registry.addMenuItem("capitalization", {
|
|
632
|
+
text: labels.capitalize,
|
|
633
|
+
isActive: () => ac.settings.capitalize,
|
|
634
|
+
onAction: () => ac.set("capitalize", !ac.settings.capitalize)
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
function createAutocorrect(editor) {
|
|
639
|
+
const options = editor.options.pluginOptions?.autocorrect ?? {};
|
|
640
|
+
const labels = pickLabels(editor, "autocorrect", LABELS);
|
|
641
|
+
const remember = options.remember !== false;
|
|
642
|
+
const saved = remember ? readSaved() : {};
|
|
643
|
+
const settings = {
|
|
644
|
+
autocorrect: saved.autocorrect ?? options.autocorrect !== false,
|
|
645
|
+
capitalize: saved.capitalize ?? options.capitalize === true
|
|
646
|
+
};
|
|
647
|
+
const replacements = /* @__PURE__ */ new Map();
|
|
648
|
+
if (options.replacements && typeof options.replacements === "object") {
|
|
649
|
+
for (const [typo, right] of Object.entries(options.replacements)) {
|
|
650
|
+
if (typeof right === "string" && right && typo.trim()) replacements.set(wordKey(typo), right);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
const spellIgnore = editor.options.pluginOptions?.spellchecker?.ignore;
|
|
654
|
+
const ignore = new Set(
|
|
655
|
+
[options.ignore, spellIgnore].flatMap((list) => Array.isArray(list) ? list : []).filter((word) => typeof word === "string").map(wordKey)
|
|
656
|
+
);
|
|
657
|
+
const abbreviations = /* @__PURE__ */ new Set();
|
|
658
|
+
let pending = null;
|
|
659
|
+
const english = () => {
|
|
660
|
+
const spell = editor.options.pluginOptions?.spellchecker?.language;
|
|
661
|
+
let language = options.language ?? (typeof spell === "string" && spell !== "auto" ? spell : "");
|
|
662
|
+
if (!language) {
|
|
663
|
+
const dom = editor.view?.dom;
|
|
664
|
+
language = dom?.closest("[lang]")?.getAttribute("lang") ?? dom?.ownerDocument.documentElement.lang ?? "";
|
|
665
|
+
}
|
|
666
|
+
return !language || /^en\b/i.test(language);
|
|
667
|
+
};
|
|
668
|
+
const rules = () => ({
|
|
669
|
+
autocorrect: settings.autocorrect,
|
|
670
|
+
capitalize: settings.capitalize,
|
|
671
|
+
replacements,
|
|
672
|
+
english: options.builtInList !== false && english(),
|
|
673
|
+
ignore,
|
|
674
|
+
abbreviations
|
|
675
|
+
});
|
|
676
|
+
const correct = (view, trailer) => {
|
|
677
|
+
if (view.isDestroyed || !editor.isEditable()) return;
|
|
678
|
+
const { state } = view;
|
|
679
|
+
const { selection } = state;
|
|
680
|
+
if (!selection.empty) return;
|
|
681
|
+
const $head = selection.$head;
|
|
682
|
+
const block = $head.parent;
|
|
683
|
+
if (!block.isTextblock || block.type.spec.code) return;
|
|
684
|
+
const offset = $head.parentOffset;
|
|
685
|
+
const start = Math.max(0, offset - CONTEXT);
|
|
686
|
+
const text = block.textBetween(start, offset, void 0, leafText);
|
|
687
|
+
const found = findCorrection(text, rules(), { blockStart: start === 0, trailer });
|
|
688
|
+
if (!found) return;
|
|
689
|
+
const from = $head.pos - (text.length - found.start);
|
|
690
|
+
const to = from + found.word.length;
|
|
691
|
+
if (from < $head.start() || state.doc.textBetween(from, to) !== found.word) return;
|
|
692
|
+
let code = false;
|
|
693
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
694
|
+
if (node.isInline && node.marks.some((mark) => mark.type.spec.code)) code = true;
|
|
695
|
+
});
|
|
696
|
+
if (code) return;
|
|
697
|
+
const tr = replaceChanged(state.tr, from, found.word, found.replacement);
|
|
698
|
+
closeHistory(tr);
|
|
699
|
+
const last = {
|
|
700
|
+
from,
|
|
701
|
+
to: from + found.replacement.length,
|
|
702
|
+
word: found.word,
|
|
703
|
+
replacement: found.replacement,
|
|
704
|
+
kind: found.kind,
|
|
705
|
+
...found.after ? { after: found.after } : {},
|
|
706
|
+
cursor: tr.selection.head
|
|
707
|
+
};
|
|
708
|
+
view.dispatch(tr.setMeta(key, last));
|
|
709
|
+
view.dispatch(closeHistory(view.state.tr));
|
|
710
|
+
editor.ui.announce(
|
|
711
|
+
labels.changed.replace("{word}", found.word).replace("{replacement}", found.replacement)
|
|
712
|
+
);
|
|
713
|
+
notify(last, false);
|
|
714
|
+
};
|
|
715
|
+
const revert = (view) => {
|
|
716
|
+
const last = key.getState(view.state);
|
|
717
|
+
const { selection, doc } = view.state;
|
|
718
|
+
if (!last || !selection.empty || selection.head !== last.cursor) return false;
|
|
719
|
+
if (doc.textBetween(last.from, last.to) !== last.replacement) return false;
|
|
720
|
+
view.dispatch(
|
|
721
|
+
replaceChanged(view.state.tr, last.from, last.replacement, last.word).setMeta(key, null).scrollIntoView()
|
|
722
|
+
);
|
|
723
|
+
if (last.kind === "sentence" && last.after) abbreviations.add(last.after.toLowerCase());
|
|
724
|
+
else ignore.add(wordKey(last.word));
|
|
725
|
+
editor.ui.announce(labels.reverted.replace("{word}", last.word));
|
|
726
|
+
notify(last, true);
|
|
727
|
+
return true;
|
|
728
|
+
};
|
|
729
|
+
const notify = (last, reverted) => {
|
|
730
|
+
if (typeof options.onCorrect !== "function") return;
|
|
731
|
+
try {
|
|
732
|
+
options.onCorrect({
|
|
733
|
+
word: last.word,
|
|
734
|
+
replacement: last.replacement,
|
|
735
|
+
kind: last.kind,
|
|
736
|
+
reverted
|
|
737
|
+
});
|
|
738
|
+
} catch (error) {
|
|
739
|
+
console.error("[novaprose] autocorrect onCorrect failed", error);
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
const plugin = new Plugin({
|
|
743
|
+
key,
|
|
744
|
+
state: {
|
|
745
|
+
init: () => null,
|
|
746
|
+
apply(tr, last) {
|
|
747
|
+
const meta = tr.getMeta(key);
|
|
748
|
+
if (meta !== void 0) return meta;
|
|
749
|
+
return tr.docChanged || tr.selectionSet ? null : last;
|
|
750
|
+
}
|
|
751
|
+
},
|
|
752
|
+
props: {
|
|
753
|
+
handleTextInput(view, _from, _to, text) {
|
|
754
|
+
if (!view.composing && ENDS_WORD.test(text)) pending = text;
|
|
755
|
+
return false;
|
|
756
|
+
},
|
|
757
|
+
handleDOMEvents: {
|
|
758
|
+
keydown(view, event) {
|
|
759
|
+
if (event.ctrlKey || event.metaKey || event.altKey || event.isComposing) return false;
|
|
760
|
+
if (event.key === "Backspace" && !event.shiftKey) {
|
|
761
|
+
if (!revert(view)) return false;
|
|
762
|
+
event.preventDefault();
|
|
763
|
+
return true;
|
|
764
|
+
}
|
|
765
|
+
if (event.key === "Enter" && !view.dom.hasAttribute("aria-activedescendant"))
|
|
766
|
+
correct(view, false);
|
|
767
|
+
return false;
|
|
768
|
+
},
|
|
769
|
+
compositionend(view) {
|
|
770
|
+
setTimeout(() => {
|
|
771
|
+
if (!view.isDestroyed && ENDS_WORD.test(textBeforeCursor(view))) correct(view, true);
|
|
772
|
+
});
|
|
773
|
+
return false;
|
|
774
|
+
}
|
|
775
|
+
},
|
|
776
|
+
decorations(state) {
|
|
777
|
+
const last = key.getState(state);
|
|
778
|
+
if (!last) return null;
|
|
779
|
+
return DecorationSet.create(state.doc, [
|
|
780
|
+
Decoration.inline(last.from, last.to, { class: "nova-autocorrected" })
|
|
781
|
+
]);
|
|
782
|
+
}
|
|
783
|
+
},
|
|
784
|
+
view: () => ({
|
|
785
|
+
update(view, previous) {
|
|
786
|
+
if (pending === null) return;
|
|
787
|
+
const typed = pending;
|
|
788
|
+
pending = null;
|
|
789
|
+
if (view.state.doc === previous.doc || !textBeforeCursor(view).endsWith(typed.slice(-1)))
|
|
790
|
+
return;
|
|
791
|
+
queueMicrotask(() => correct(view, true));
|
|
792
|
+
}
|
|
793
|
+
})
|
|
794
|
+
});
|
|
795
|
+
const set = (feature, on) => {
|
|
796
|
+
settings[feature] = on;
|
|
797
|
+
if (remember) save(settings);
|
|
798
|
+
editor.ui.announce(
|
|
799
|
+
editor.ui.t(on ? "announce.on" : "announce.off").replace("{name}", feature === "autocorrect" ? labels.spelling : labels.capitalize)
|
|
800
|
+
);
|
|
801
|
+
editor.root.dispatchEvent(
|
|
802
|
+
new CustomEvent("nova-autocorrect-toggle", { detail: { feature, on } })
|
|
803
|
+
);
|
|
804
|
+
editor.updateUI();
|
|
805
|
+
};
|
|
806
|
+
return { plugin, labels, settings, set };
|
|
807
|
+
}
|
|
808
|
+
function textBeforeCursor(view) {
|
|
809
|
+
const { $head } = view.state.selection;
|
|
810
|
+
return $head.parent.textBetween(
|
|
811
|
+
Math.max(0, $head.parentOffset - 8),
|
|
812
|
+
$head.parentOffset,
|
|
813
|
+
void 0,
|
|
814
|
+
leafText
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
function replaceChanged(tr, from, before, after) {
|
|
818
|
+
let head = 0;
|
|
819
|
+
while (head < before.length && head < after.length && before[head] === after[head]) head++;
|
|
820
|
+
let tail = 0;
|
|
821
|
+
while (tail < before.length - head && tail < after.length - head && before[before.length - 1 - tail] === after[after.length - 1 - tail])
|
|
822
|
+
tail++;
|
|
823
|
+
const start = from + head;
|
|
824
|
+
const end = from + before.length - tail;
|
|
825
|
+
const text = after.slice(head, after.length - tail);
|
|
826
|
+
return text ? tr.insertText(text, start, end) : tr.delete(start, end);
|
|
827
|
+
}
|
|
828
|
+
function readSaved() {
|
|
829
|
+
try {
|
|
830
|
+
const value = JSON.parse(globalThis.localStorage?.getItem(STORAGE) ?? "{}");
|
|
831
|
+
if (!value || typeof value !== "object") return {};
|
|
832
|
+
const { autocorrect, capitalize } = value;
|
|
833
|
+
return {
|
|
834
|
+
...typeof autocorrect === "boolean" ? { autocorrect } : {},
|
|
835
|
+
...typeof capitalize === "boolean" ? { capitalize } : {}
|
|
836
|
+
};
|
|
837
|
+
} catch {
|
|
838
|
+
return {};
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
function save(settings) {
|
|
842
|
+
try {
|
|
843
|
+
globalThis.localStorage?.setItem(STORAGE, JSON.stringify(settings));
|
|
844
|
+
} catch {
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
export {
|
|
848
|
+
LABELS,
|
|
849
|
+
autocorrect_default2 as default
|
|
850
|
+
};
|
|
851
|
+
//# sourceMappingURL=autocorrect-6GFLVDPC.js.map
|