@panphora/clayjs 1.15.2 → 1.16.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 +4 -5
- package/THIRD-PARTY-NOTICES.md +16 -0
- package/compat/highlight-11.9.0.min.js +1213 -0
- package/compat/highlight-LICENSE +29 -0
- package/compat/journal-assets.lock.json +22 -0
- package/compat/overtype-2.6.1.min.js +116 -0
- package/compat/overtype-LICENSE +21 -0
- package/dist/all.js +90 -0
- package/dist/clay-dom.js +84 -0
- package/dist/clay-events.js +103 -0
- package/dist/clay-internals.js +85 -0
- package/dist/clay-options.js +93 -0
- package/dist/clay-router.js +98 -0
- package/dist/clay-ui.js +95 -0
- package/dist/clay-utils.js +84 -0
- package/dist/clay.js +146 -0
- package/dist/clay.standalone.js +83090 -58706
- package/dist/m/attrs/add-from-T5LJXFFI.js +1 -0
- package/dist/m/attrs/onaftersave-OKSWEJQF.js +1 -0
- package/dist/m/attrs/refetch-on-save-NWPPXOCZ.js +1 -0
- package/dist/m/attrs/save-freeze-FUP4Q4X3.js +1 -0
- package/dist/m/c-2AZDZWCK.js +1 -0
- package/dist/m/c-2JL6E75N.js +1 -0
- package/dist/m/c-2M73252O.js +1 -0
- package/dist/m/c-2SPVQSHC.js +1 -0
- package/dist/m/c-33HUYEDI.js +1 -0
- package/dist/m/c-33JJ6CBX.js +2 -0
- package/dist/m/c-35NBGMZB.js +1 -0
- package/dist/m/c-3GJ4SDE2.js +1 -0
- package/dist/m/c-3IQRECYS.js +1 -0
- package/dist/m/c-3OWDMNJR.js +2 -0
- package/dist/m/c-46XYM55L.js +1 -0
- package/dist/m/c-4B6H4G5V.js +1 -0
- package/dist/m/c-4DRMS4QG.js +9 -0
- package/dist/m/c-4FFHZM32.js +1 -0
- package/dist/m/c-4JZDZFF6.js +1 -0
- package/dist/m/c-4L3BTFRK.js +1 -0
- package/dist/m/c-4Q2XTQ2N.js +2 -0
- package/dist/m/c-4WKFKEKF.js +1 -0
- package/dist/m/c-4YSCRICO.js +1 -0
- package/dist/m/c-54RCDCBU.js +1 -0
- package/dist/m/c-5M4YEKCX.js +4 -0
- package/dist/m/c-5R4PTRG2.js +1 -0
- package/dist/m/c-5V3MOVJT.js +1 -0
- package/dist/m/c-5VYOWDTI.js +1 -0
- package/dist/m/c-5Y6TNX5W.js +34 -0
- package/dist/m/c-5YIHJ3TJ.js +1 -0
- package/dist/m/c-66O32MV3.js +28 -0
- package/dist/m/c-6HMB24EV.js +1 -0
- package/dist/m/c-7DJDKPGL.js +1 -0
- package/dist/m/c-7O6AFR65.js +1 -0
- package/dist/m/c-7SWMYKAI.js +1 -0
- package/dist/m/c-7VGZ7RU5.js +1 -0
- package/dist/m/c-A7LS5UZW.js +1 -0
- package/dist/m/c-ANQTJ3B5.js +2 -0
- package/dist/m/c-AQLFEATB.js +1 -0
- package/dist/m/c-AYVOREBE.js +1 -0
- package/dist/m/c-B2ZXPOS3.js +3 -0
- package/dist/m/c-BBVGTQG7.js +1 -0
- package/dist/m/c-BMIZKMPV.js +1 -0
- package/dist/m/c-BTDI4Y23.js +1 -0
- package/dist/m/c-BWFVSBDF.js +1 -0
- package/dist/m/c-BYTKL6UX.js +1 -0
- package/dist/m/c-CFHW5AMY.js +6 -0
- package/dist/m/c-CJZSLMVQ.js +1 -0
- package/dist/m/c-CYWLPPUS.js +1 -0
- package/dist/m/c-CZUSOB7V.js +1 -0
- package/dist/m/c-DBE6ORSI.js +1 -0
- package/dist/m/c-DCFSEJZG.js +1 -0
- package/dist/m/c-DNZ5IFM6.js +1 -0
- package/dist/m/c-EDHUR4MX.js +1 -0
- package/dist/m/c-EJTGYSLN.js +1 -0
- package/dist/m/c-EY6UOM54.js +1 -0
- package/dist/m/c-F3CKJTJS.js +1 -0
- package/dist/m/c-F7Y6FLPY.js +1 -0
- package/dist/m/c-FA4DZVTC.js +1 -0
- package/dist/m/c-FILLTJA7.js +1 -0
- package/dist/m/c-G2BUZITR.js +1 -0
- package/dist/m/c-GB3JTV6E.js +1 -0
- package/dist/m/c-GBGWXTX4.js +1 -0
- package/dist/m/c-GHBCCVG4.js +1 -0
- package/dist/m/c-GJAEGGXY.js +1 -0
- package/dist/m/c-GOWBDM6J.js +1 -0
- package/dist/m/c-GQ6F6IDK.js +1 -0
- package/dist/m/c-H4LG442Q.js +1 -0
- package/dist/m/c-HA6INT6J.js +1 -0
- package/dist/m/c-HPURYVZS.js +2 -0
- package/dist/m/c-HRDCD3WN.js +67 -0
- package/dist/m/c-HT33EQRN.js +1 -0
- package/dist/m/c-HVYXIS72.js +1 -0
- package/dist/m/c-IB52R237.js +1 -0
- package/dist/m/c-IJUK2GPW.js +1 -0
- package/dist/m/c-IKWNE4R4.js +1 -0
- package/dist/m/c-IU3IYEU6.js +1 -0
- package/dist/m/c-IZ2EBRAJ.js +1 -0
- package/dist/m/c-J7CA54IP.js +1 -0
- package/dist/m/c-JAX2667S.js +6 -0
- package/dist/m/c-KI7M4AY3.js +1 -0
- package/dist/m/c-KIPQJX4B.js +1 -0
- package/dist/m/c-KKWLDOPM.js +1 -0
- package/dist/m/c-KR4UW4KW.js +1 -0
- package/dist/m/c-KY3VJGUA.js +8 -0
- package/dist/m/c-L4WQSC27.js +1 -0
- package/dist/m/c-LFPHCXY3.js +1 -0
- package/dist/m/c-LR4CGEPT.js +91 -0
- package/dist/m/c-LRPUO2MX.js +1 -0
- package/dist/m/c-LTGMXXKO.js +1 -0
- package/dist/m/c-LXENEBV7.js +1 -0
- package/dist/m/c-LZJPNR2W.js +1 -0
- package/dist/m/c-MMUIUUZG.js +2 -0
- package/dist/m/c-MTQHWQC3.js +1 -0
- package/dist/m/c-N326R2JD.js +1 -0
- package/dist/m/c-N7JPUPGC.js +1 -0
- package/dist/m/c-NMJRXKPC.js +8 -0
- package/dist/m/c-NRPJEVJS.js +1 -0
- package/dist/m/c-NUHP2XDB.js +1 -0
- package/dist/m/c-NZMNXVF6.js +1 -0
- package/dist/m/c-OCSZ4QGN.js +1 -0
- package/dist/m/c-OIBUTDXI.js +1 -0
- package/dist/m/c-OIDRZKAF.js +1 -0
- package/dist/m/c-OYTFP5QN.js +1 -0
- package/dist/m/c-P7KNDG34.js +1 -0
- package/dist/m/c-PPOSCAQD.js +1 -0
- package/dist/m/c-PQ5LK6QE.js +993 -0
- package/dist/m/c-PZ4XEPUP.js +2 -0
- package/dist/m/c-QHIWXHRO.js +1 -0
- package/dist/m/c-QHWJ5ZIJ.js +1 -0
- package/dist/m/c-QIX5BJYN.js +1 -0
- package/dist/m/c-QNKREOL6.js +1 -0
- package/dist/m/c-QQHEX6HA.js +1 -0
- package/dist/m/c-R7RMANJI.js +9 -0
- package/dist/m/c-RI4NT75Y.js +1 -0
- package/dist/m/c-RM7J7BV2.js +1 -0
- package/dist/m/c-RUJKSUQW.js +1 -0
- package/dist/m/c-RVMWGXEJ.js +1 -0
- package/dist/m/c-S7H2DRCB.js +1 -0
- package/dist/m/c-S7LK4KUE.js +1 -0
- package/dist/m/c-SGCCC4FW.js +25 -0
- package/dist/m/c-SGIA4IEQ.js +188 -0
- package/dist/m/c-SWRJFCNN.js +1 -0
- package/dist/m/c-T4VO4OCB.js +1 -0
- package/dist/m/c-TCCA5BZN.js +2 -0
- package/dist/m/c-TQEMVJCS.js +1 -0
- package/dist/m/c-TQZ2JYHD.js +1 -0
- package/dist/m/c-TR6RMDQ7.js +3 -0
- package/dist/m/c-TRS6TM6O.js +1 -0
- package/dist/m/c-UGHH4MB3.js +1 -0
- package/dist/m/c-UKHTLWUW.js +1 -0
- package/dist/m/c-UL2YUY52.js +1 -0
- package/dist/m/c-UNN7LWCT.js +1 -0
- package/dist/m/c-UXBMRDZB.js +235 -0
- package/dist/m/c-V7PZZRG7.js +1 -0
- package/dist/m/c-VAK7SG37.js +1 -0
- package/dist/m/c-VDSS4K3Z.js +1 -0
- package/dist/m/c-VFX45IZQ.js +1 -0
- package/dist/m/c-VHNSBD2M.js +1 -0
- package/dist/m/c-VKEDWYDF.js +1 -0
- package/dist/m/c-VL52ADDR.js +1 -0
- package/dist/m/c-WN5AY3OZ.js +1 -0
- package/dist/m/c-WNYBLIOZ.js +1 -0
- package/dist/m/c-WRBKEJD4.js +1 -0
- package/dist/m/c-WWDBYXLK.js +1 -0
- package/dist/m/c-WYFDLITL.js +1 -0
- package/dist/m/c-XN6MBKI6.js +67 -0
- package/dist/m/c-XNNW2CWK.js +1 -0
- package/dist/m/c-XPELB6E5.js +1 -0
- package/dist/m/c-XQXZAO7N.js +1 -0
- package/dist/m/c-Y6USGTS5.js +5 -0
- package/dist/m/c-YDH7Q3NY.js +1 -0
- package/dist/m/c-YG2NJYS6.js +135 -0
- package/dist/m/c-Z36J63PP.js +1 -0
- package/dist/m/c-Z4VRC7GU.js +7 -0
- package/dist/m/c-Z6K52OLP.js +19 -0
- package/dist/m/c-ZDY2MDAA.js +21 -0
- package/dist/m/c-ZE46QDIH.js +1 -0
- package/dist/m/c-ZUCOKOHT.js +1 -0
- package/dist/m/core/admin-attrs-VGNLAUDK.js +1 -0
- package/dist/m/core/autosave-E4PEFPZ6.js +1 -0
- package/dist/m/core/conflict-notice-VQ6Y64PH.js +1 -0
- package/dist/m/core/draft-mode-WSQAT67S.js +1 -0
- package/dist/m/core/host-permission-XN3K2IW3.js +1 -0
- package/dist/m/core/is-edit-mode-JXHDVGUL.js +1 -0
- package/dist/m/core/persist-HKHA66IY.js +3 -0
- package/dist/m/core/recovery-TBBSICE2.js +1 -0
- package/dist/m/core/save-WUCHTQBE.js +1 -0
- package/dist/m/core/save-core-FJVHT5M3.js +1 -0
- package/dist/m/core/snapshot-F3SWDZMM.js +1 -0
- package/dist/m/core/unsaved-warning-STKBHE6G.js +1 -0
- package/dist/m/dom/all-APS5ZSKP.js +1 -0
- package/dist/m/dom/dom-helpers-L7OSR6S4.js +1 -0
- package/dist/m/events/index-23DPTUT4.js +1 -0
- package/dist/m/internals/index-WOVAP3RU.js +1 -0
- package/dist/m/lib/cache-bust-CGWT6ZJI.js +1 -0
- package/dist/m/lib/region-policy-SB2AWVG5.js +1 -0
- package/dist/m/loader-HXX6YNH5.js +1 -0
- package/dist/m/manifest-F22DEDAC.js +1 -0
- package/dist/m/manifest-edit-C3C7376B.js +1 -0
- package/dist/m/manifest.json +3491 -0
- package/dist/m/options/options-2LH76JQ3.js +1 -0
- package/dist/m/page/editor-XUTB2HB2.js +189 -0
- package/dist/m/plugins/ai-edit-ZQ4CGWIP.js +6 -0
- package/dist/m/plugins/bind-text-NX46N5UV.js +1 -0
- package/dist/m/plugins/cms-HP3LSTPN.js +2293 -0
- package/dist/m/plugins/demo-ZIBFAA3R.js +1 -0
- package/dist/m/plugins/derive-UAAA4V4S.js +1 -0
- package/dist/m/plugins/indicator-PV4YW2ID.js +1 -0
- package/dist/m/plugins/live-NUTTXSBS.js +1 -0
- package/dist/m/plugins/menu-HCKO3DSP.js +138 -0
- package/dist/m/plugins/message-LQ6EDH4V.js +1 -0
- package/dist/m/plugins/page-KSUH7G6J.js +2 -0
- package/dist/m/plugins/page-view-W73OW7WI.js +1 -0
- package/dist/m/plugins/people-AJJ32YCG.js +1 -0
- package/dist/m/plugins/quickcrop-QNY3PKLD.js +26 -0
- package/dist/m/plugins/quickcrop-QNY3PKLD.js.LEGAL.txt +7 -0
- package/dist/m/plugins/richclay-RC3L2F6X.js +517 -0
- package/dist/m/plugins/richclay-RC3L2F6X.js.LEGAL.txt +1 -0
- package/dist/m/plugins/sortable-YRMQX3ZU.js +1 -0
- package/dist/m/plugins/source-KHK5UUSK.js +1 -0
- package/dist/m/plugins/undo-OF2L3CXU.js +1 -0
- package/dist/m/plugins/unsent-HJFLQJ2O.js +1 -0
- package/dist/m/plugins/upgrade-ZNYODP5Y.js +1 -0
- package/dist/m/plugins/upload-XSGNILUY.js +1 -0
- package/dist/m/plugins/visitor-drafts-XK5GW55Q.js +21 -0
- package/dist/m/plugins/visitor-drafts-owner-KSSH75EV.js +1 -0
- package/dist/m/plugins/wire-ZWVWKF76.js +1 -0
- package/dist/m/reader-core-ILWLXVMP.js +68 -0
- package/dist/m/route/route-KOCZSEGN.js +1 -0
- package/dist/m/sync/live-sync-4AUVXVJU.js +1 -0
- package/dist/m/ui/index-EVHKMKBL.js +1 -0
- package/dist/m/utils/index-4TJCVLT7.js +1 -0
- package/dist/m/vendor/Sortable.vendor-A755ITLN.js +3 -0
- package/dist/m/vendor/Sortable.vendor-A755ITLN.js.LEGAL.txt +1 -0
- package/dist/m/vendor/sap-core.vendor-A7BMUYZT.js +6 -0
- package/dist/offline-manifest.json +3800 -0
- package/dist/page/themes/light-1.css +406 -0
- package/dist/server/core.cjs +23662 -22860
- package/dist/server/offline-runtime.cjs +4954 -0
- package/dist/server/offline-runtime.mjs +4923 -0
- package/dist/server/rooms.mjs +9 -0
- package/docs/guide.md +1078 -669
- package/entries/all.js +2 -0
- package/entries/clay-data.js +1 -1
- package/entries/clay-dom.js +2 -0
- package/entries/clay-events.js +2 -0
- package/entries/clay-internals.js +2 -0
- package/entries/clay-options.js +2 -0
- package/entries/clay-router.js +2 -0
- package/entries/clay-ui.js +2 -0
- package/entries/clay-utils.js +2 -0
- package/entries/clay.js +2 -0
- package/entries/sap.js +6 -6
- package/fonts/ibm-plex-mono-LICENSE +93 -0
- package/fonts/ibm-plex-mono-latin-300-normal.woff2 +0 -0
- package/fonts/ibm-plex-mono-latin-400-italic.woff2 +0 -0
- package/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- package/fonts/ibm-plex-mono-latin-500-normal.woff2 +0 -0
- package/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
- package/fonts/ibm-plex-sans-LICENSE +93 -0
- package/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
- package/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
- package/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
- package/fonts/ibm-plex.css +71 -0
- package/fonts/inter-LICENSE +93 -0
- package/fonts/inter-cyrillic-ext-wght-normal.woff2 +0 -0
- package/fonts/inter-cyrillic-wght-normal.woff2 +0 -0
- package/fonts/inter-greek-ext-wght-normal.woff2 +0 -0
- package/fonts/inter-greek-wght-normal.woff2 +0 -0
- package/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
- package/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/fonts/inter-vietnamese-wght-normal.woff2 +0 -0
- package/fonts/inter.css +62 -0
- package/fonts/newsreader-LICENSE +93 -0
- package/fonts/newsreader-latin-ext-opsz-normal.woff2 +0 -0
- package/fonts/newsreader-latin-opsz-normal.woff2 +0 -0
- package/fonts/newsreader-vietnamese-opsz-normal.woff2 +0 -0
- package/fonts/newsreader.css +26 -0
- package/fonts/work-sans-LICENSE +93 -0
- package/fonts/work-sans-latin-wght-normal.woff2 +0 -0
- package/fonts/work-sans.css +8 -0
- package/package.json +20 -3
- package/packed-contract.json +1 -0
- package/src/attrs/add-from.js +27 -4
- package/src/attrs/save-freeze.js +7 -52
- package/src/core/admin-attrs.js +119 -12
- package/src/core/admin-contenteditable.js +12 -10
- package/src/core/admin-inputs.js +14 -15
- package/src/core/admin-onclick.js +2 -0
- package/src/core/autosave.js +74 -21
- package/src/core/conflict-download.js +22 -0
- package/src/core/conflict-notice-ui.js +1173 -0
- package/src/core/conflict-notice.js +140 -697
- package/src/core/edit-mode.js +147 -14
- package/src/core/etag.js +30 -12
- package/src/core/host-meta.js +72 -8
- package/src/core/host-permission.js +29 -0
- package/src/core/is-edit-mode.js +145 -12
- package/src/core/mode-key.js +125 -0
- package/src/core/mode-lifecycle.js +544 -0
- package/src/core/mode-receipt.js +30 -0
- package/src/core/mode-refusal.js +13 -0
- package/src/core/mode-resources.js +52 -0
- package/src/core/mode-support.js +82 -0
- package/src/core/mode-switch.js +259 -0
- package/src/core/mode-transition.js +112 -0
- package/src/core/page-data-write.js +305 -0
- package/src/core/page-data.js +26 -227
- package/src/core/page-format-wire.js +4 -0
- package/src/core/page-format.js +58 -0
- package/src/core/persist.js +37 -9
- package/src/core/preserve-authored.js +114 -0
- package/src/core/recovery.js +772 -0
- package/src/core/runtime-url.js +105 -0
- package/src/core/save-core.js +109 -12
- package/src/core/save-replace.js +72 -0
- package/src/core/save-size-notice.js +134 -0
- package/src/core/save-size.js +140 -0
- package/src/core/save.js +805 -118
- package/src/core/snapshot.js +121 -11
- package/src/core/source-map.js +157 -9
- package/src/core/unsaved-warning.js +14 -4
- package/src/core/upgrade-run.js +408 -0
- package/src/core/version.js +18 -0
- package/src/lib/assets.js +30 -0
- package/src/lib/autosave-debug-gate.js +50 -0
- package/src/lib/autosave-scheduler.js +141 -0
- package/src/lib/boot-imports.js +8 -0
- package/src/lib/derived.js +3 -1
- package/src/lib/dirty-gate.js +15 -0
- package/src/lib/doc-storage.js +33 -0
- package/src/lib/effect.js +9 -4
- package/src/lib/mutation.js +4 -2
- package/src/lib/offline-runtime.js +226 -0
- package/src/lib/preload.js +48 -0
- package/src/lib/root-attrs.js +1 -1
- package/src/lib/trash.js +18 -0
- package/src/lib/undo/capture-move.js +152 -0
- package/src/live/local-channel.js +61 -0
- package/src/live/local-lane.js +60 -9
- package/src/live/server-lane.js +6 -3
- package/src/loader-logic.js +76 -15
- package/src/loader.js +218 -30
- package/src/page/adopt-boot.js +76 -22
- package/src/page/adopt.js +25 -4
- package/src/page/awareness.js +230 -0
- package/src/page/blocks.js +79 -5
- package/src/page/blocksel.js +20 -4
- package/src/page/board-face.js +13 -0
- package/src/page/board-panel.js +5 -17
- package/src/page/board-style.js +2 -13
- package/src/page/board-view.js +1 -11
- package/src/page/board-views.js +17 -0
- package/src/page/board.js +2 -2
- package/src/page/boot-pack.js +26 -0
- package/src/page/boot.js +237 -0
- package/src/page/checklist.js +1 -1
- package/src/page/chrome.js +411 -61
- package/src/page/csv-import.js +17 -2
- package/src/page/document-title-dom.js +40 -0
- package/src/page/document-title-runtime.js +76 -0
- package/src/page/document-title.js +9 -0
- package/src/page/drag.js +48 -13
- package/src/page/drop.js +2 -1
- package/src/page/editor.js +330 -86
- package/src/page/feature-loader.js +72 -0
- package/src/page/features/board.js +12 -0
- package/src/page/features/code.js +13 -0
- package/src/page/features/media.js +290 -0
- package/src/page/features/registry.js +23 -0
- package/src/page/features/table.js +383 -0
- package/src/page/{tool-view.js → features/tool.js} +33 -2
- package/src/page/format-codec.js +215 -0
- package/src/page/format-gate.js +179 -0
- package/src/page/format-level.js +157 -0
- package/src/page/highlight-slot.js +23 -0
- package/src/page/highlight.js +30 -16
- package/src/page/history-intent.js +78 -0
- package/src/page/inline.js +18 -25
- package/src/page/items.js +52 -11
- package/src/page/link.js +1 -0
- package/src/page/markdown.js +86 -1
- package/src/page/media-views.js +3 -0
- package/src/page/media.js +33 -245
- package/src/page/outline-cache.js +11 -0
- package/src/page/placeholder.js +27 -7
- package/src/page/projection.js +196 -50
- package/src/page/reader-patch.js +306 -0
- package/src/page/recover.js +1 -1
- package/src/page/rich/page-tool.js +1 -4
- package/src/page/runtime-owner.js +27 -0
- package/src/page/save-projection.js +7 -4
- package/src/page/schema.js +14 -0
- package/src/page/table-rect-key.js +3 -0
- package/src/page/table-select.js +4 -3
- package/src/page/table-style.js +1 -1
- package/src/page/table-views.js +3 -0
- package/src/page/table.js +8 -293
- package/src/page/themes/light-1.css +139 -2
- package/src/page/themes/light-1.source.css +269 -0
- package/src/page/tool-capability.js +3 -0
- package/src/page/tool-views.js +3 -0
- package/src/page/view.js +390 -107
- package/src/page/ybind/awareness.js +172 -0
- package/src/page/ybind/binding.js +9 -1
- package/src/page/ybind/bridge.js +50 -47
- package/src/page/ybind/decode.js +52 -19
- package/src/page/ybind/doc.js +27 -2
- package/src/page/ybind/group.js +12 -3
- package/src/page/ybind/index.js +2 -0
- package/src/page/ybind/lineage.js +71 -0
- package/src/page/ybind/marks.js +25 -1
- package/src/page/ybind/migrate.js +48 -13
- package/src/page/ybind/moves.js +32 -21
- package/src/page/ybind/positions.js +50 -0
- package/src/page/ybind/provider.js +84 -22
- package/src/page/ybind/recovery-proof.js +191 -0
- package/src/page/ybind/recovery-replay.js +130 -0
- package/src/page/ybind/tokens.js +15 -6
- package/src/page/ybind/walk.js +10 -3
- package/src/page/ybind/writer.js +48 -4
- package/src/plugins/ai-edit.js +167 -32
- package/src/plugins/bind-text.js +218 -0
- package/src/plugins/cms.js +93 -0
- package/src/plugins/indicator.js +57 -5
- package/src/plugins/live.js +282 -34
- package/src/plugins/menu/claygoo.svg.js +1 -0
- package/src/plugins/menu/seo-head.js +323 -0
- package/src/plugins/menu/seo.js +849 -0
- package/src/plugins/menu.js +425 -0
- package/src/plugins/page-view.js +131 -0
- package/src/plugins/page.js +1022 -275
- package/src/plugins/people.js +158 -31
- package/src/plugins/richclay.js +119 -9
- package/src/plugins/sortable.js +370 -60
- package/src/plugins/source.js +189 -366
- package/src/plugins/undo.js +289 -19
- package/src/plugins/unsent.js +132 -0
- package/src/plugins/upgrade-run.js +1 -0
- package/src/plugins/upgrade.js +210 -0
- package/src/plugins/upload-task.js +571 -0
- package/src/plugins/upload-ui.js +265 -0
- package/src/plugins/upload.js +34 -153
- package/src/plugins/visitor-drafts/inert.js +32 -0
- package/src/plugins/visitor-drafts/owner-chip.js +3 -0
- package/src/plugins/visitor-drafts/prompt.js +2 -2
- package/src/plugins/visitor-drafts-owner.js +85 -0
- package/src/plugins/visitor-drafts.js +31 -42
- package/src/plugins/wire.js +82 -1
- package/src/reader-core.js +26 -0
- package/src/recovery/conflicts.js +287 -0
- package/src/recovery/identity.js +154 -0
- package/src/recovery/store.js +792 -0
- package/src/recovery/undo.js +257 -0
- package/src/server/checkpoint/index.js +68 -4
- package/src/server/offline-runtime/index.js +214 -0
- package/src/server/rooms/index.js +2 -1
- package/src/server/rooms/live-data-rooms.js +2 -2
- package/src/server/rooms/page-admission.js +33 -0
- package/src/server/rooms/page-lineage.js +56 -0
- package/src/server/rooms/page-rebase.js +11 -5
- package/src/server/rooms/page-state.js +2 -0
- package/src/server/rooms/page-write-admission.js +9 -3
- package/src/source/session.js +705 -0
- package/src/sync/conflict-revert.js +5 -4
- package/src/sync/conflicts-edit.js +119 -0
- package/src/sync/conflicts-facade.js +49 -0
- package/src/sync/conflicts.js +99 -1
- package/src/sync/editing-marker.js +37 -6
- package/src/sync/editing-sender.js +8 -1
- package/src/sync/live-sync-edit.js +63 -0
- package/src/sync/live-sync.js +364 -119
- package/src/sync/local-presence.js +187 -0
- package/src/sync/merge-declarations.js +10 -0
- package/src/sync/merge-engine.js +12 -0
- package/src/sync/presence-store.js +412 -0
- package/src/sync/presence-target.js +243 -0
- package/src/sync/presence.js +72 -41
- package/src/sync/saved-handoff.js +200 -0
- package/src/sync/saved-stream.js +535 -0
- package/src/sync/version-guard.js +92 -0
- package/src/sync/wire-profile.js +81 -0
- package/src/ui/bevel-controls.js +2 -8
- package/src/ui/page-scheme.js +7 -0
- package/src/ui/skins/cms.js +1 -1
- package/src/ui/theme-config.js +150 -0
- package/src/ui/theme.js +6 -138
- package/src/ui/toast-lazy.js +11 -0
- package/src/vendor/LICENSES-optional.md +253 -0
- package/src/vendor/highlight.vendor.js +3 -0
- package/src/vendor/hljs-bash.vendor.js +2 -0
- package/src/vendor/hljs-css.vendor.js +2 -0
- package/src/vendor/hljs-javascript.vendor.js +2 -0
- package/src/vendor/hljs-json.vendor.js +2 -0
- package/src/vendor/hljs-python.vendor.js +2 -0
- package/src/vendor/hljs-xml.vendor.js +2 -0
- package/src/vendor/hyper-html-api-data.vendor.js +1 -1
- package/src/vendor/hyper-html-api-upgrade.vendor.js +5 -0
- package/src/vendor/hyper-morph-identity.vendor.js +2 -0
- package/src/vendor/hyper-morph-json.vendor.js +3 -0
- package/src/vendor/hyper-morph.vendor.js +6 -6
- package/src/vendor/hyper-undo.vendor.js +1 -1
- package/src/vendor/hypercms.vendor.js +169 -84
- package/src/vendor/marked.vendor.js +68 -0
- package/src/vendor/overtype.vendor.js +994 -0
- package/src/vendor/richclay.vendor.js +17 -17
- package/src/vendor/sap-core.vendor.js +5 -5
- package/src/vendor/sap-ownership.vendor.js +11 -7
|
@@ -0,0 +1,993 @@
|
|
|
1
|
+
import"./c-VHNSBD2M.js";var It=Object.defineProperty,ni=(e,t,i)=>t in e?It(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,oi=(e,t)=>{for(var i in t)It(e,i,{get:t[i],enumerable:!0})},C=(e,t,i)=>(ni(e,typeof t!="symbol"?t+"":t,i),i);function ct(e){var t,i;let r=/^( {0,3})(#{1,6})(?:([\t ]+)(.*)|$)/.exec(e);if(!r||r[2].length>3)return null;let n=r[1],o=r[2],a=(t=r[3])!=null?t:"",s=(i=r[4])!=null?i:"",p=/^(#+)[\t ]*$/.exec(s),l=/([\t ]+)(#+)([\t ]*)$/.exec(s),c=p||l;return{type:"heading",level:o.length,indent:n,marker:o,separator:a,content:p?"":c?s.slice(0,l.index):s,closing:p?s:c?l[0]:""}}function me(e){let t=/^( {0,3})([*_-])([\t *_-]*)$/.exec(e);if(!t)return null;let i=t[2],r=t[3];return[...r].some(n=>n!==i&&n!==" "&&n!==" ")||1+[...r].filter(n=>n===i).length<3?null:{type:"thematic-break",marker:i,source:e}}function dt(e){let t=/^( {0,3})>([\t ]?)(.*)$/.exec(e);return!t||t[2]===""&&t[3].startsWith(">")?null:{type:"blockquote",indent:t[1],marker:">",separator:t[2],content:t[3]}}function ve(e){let t=/^( *)([-*+])([\t ]+)(.*)$/.exec(e);if(t)return{type:"list-item",listType:"bullet",indent:t[1],marker:t[2],separator:t[3],content:t[4]};let i=/^( *)([-*+])$/.exec(e);if(i)return{type:"list-item",listType:"bullet",indent:i[1],marker:i[2],separator:"",content:""};let r=/^( *)(\d{1,9}\.)([\t ]+)(.*)$/.exec(e);if(r)return{type:"list-item",listType:"ordered",indent:r[1],marker:r[2],separator:r[3],content:r[4]};let n=/^( *)(\d{1,9}\.)$/.exec(e);return n?{type:"list-item",listType:"ordered",indent:n[1],marker:n[2],separator:"",content:""}:null}function le(e){let t=/^( {0,3})(`{3,})([^`]*)$/.exec(e);return t?{type:"fence-open",indent:t[1],marker:t[2],length:t[2].length,info:t[3].trim(),source:e}:null}function Ue(e,t){let i=/^( {0,3})(`{3,})[\t ]*$/.exec(e);return!i||i[2].length<t.length?null:{type:"fence-close",indent:i[1],marker:i[2],length:i[2].length,source:e}}var ye=/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]/,ai=/^&(?:amp|lt|gt|quot|#39);/,si={"&":"&","<":"<",">":">",""":'"',"'":"'"};function li(e,t){return function(i){if(i>=e.length)return[null,0];if(t&&e.charCodeAt(i)===38){let r=ai.exec(e.slice(i,i+6));if(r)return[si[r[0]],r[0].length]}return[e[i],1]}}function _t(e,t){let i=0;for(;t>0&&e[--t]==="\\";)i++;return i%2===1}var ge=e=>e===" "||e===" ",pi=e=>e!==null&&(e.charCodeAt(0)<32||e.charCodeAt(0)===127);function ci(e,t,i,r){let[n,o]=i(t);if(n!=="(")return null;for(t+=o;ge(n=i(t)[0]);)t+=i(t)[1];let a=null;if([n,o]=i(t),n==="<"){let l=t,c="";for(t+=o;;){if([n,o]=i(t),n===null||n==="<"||n===`
|
|
2
|
+
`)return null;if(n==="\\"){let[d,h]=i(t+o);if(d!==null&&ye.test(d)){c+=d,t+=o+h;continue}}if(n===">"){t+=o;break}c+=n,t+=o}a={start:l,end:t,raw:e.slice(l,t),value:c}}else if(n!==")"){let l=t,c=0,d="";for(;[n,o]=i(t),!(n===null||n===`
|
|
3
|
+
`||ge(n));){if(pi(n))return null;if(n==="\\"){let[h,u]=i(t+o);if(h!==null&&ye.test(h)){d+=h,t+=o+u;continue}d+=n,t+=o;continue}if(n==="("){if(c++,c>r)return null;d+=n,t+=o;continue}if(n===")"){if(c===0)break;c--,d+=n,t+=o;continue}d+=n,t+=o}if(c!==0)return null;a={start:l,end:t,raw:e.slice(l,t),value:d}}let s=t;for(;ge(n=i(t)[0]);)t+=i(t)[1];let p=null;if([n,o]=i(t),n==='"'||n==="'"||n==="("){if(a&&t===s)return null;let l=n==="("?")":n,c=t,d="";for(t+=o;;){if([n,o]=i(t),n===null||n===`
|
|
4
|
+
`)return null;if(n==="\\"){let[h,u]=i(t+o);if(h!==null&&ye.test(h)){d+=h,t+=o+u;continue}d+=n,t+=o;continue}if(n===l){t+=o;break}if(l===")"&&n==="(")return null;d+=n,t+=o}for(p={start:c,end:t,raw:e.slice(c,t),value:d,delimiter:l===")"?"(":l};ge(n=i(t)[0]);)t+=i(t)[1]}return[n,o]=i(t),n!==")"?null:{end:t+o,destination:a,title:p}}function di(e,t,i){for(;i<e.length&&e[i].end<=t;)i++;let r=e[i];return{range:r&&r.start<=t&&t<r.end?r:null,rangeIndex:i}}function Fe(e,{htmlEntities:t=!1,maxParenDepth:i=32,ignoreRanges:r=[]}={}){let n=li(e,t),o=[...r].sort((c,d)=>c.start-d.start),a=[],s=[],p=0,l=0;for(;l<e.length;){let c=di(o,l,p);if(p=c.rangeIndex,c.range){l=c.range.end;continue}let[d,h]=n(l);if(d==="\\"){let[u,f]=n(l+h);l+=u!==null&&ye.test(u)?h+f:h;continue}if(d===`
|
|
5
|
+
`){s.length=0,l+=h;continue}if(d==="["){let u=l>0&&e[l-1]==="!"&&!_t(e,l-1);s.push({index:l,image:u}),l+=h;continue}if(d==="]"){let u=s.pop();if(u){let f=ci(e,l+h,n,i);if(f){a.push({start:u.index,end:f.end,image:u.image,text:{start:u.index+1,end:l,raw:e.slice(u.index+1,l)},destination:f.destination,title:f.title}),s.length=0,l=f.end;continue}}}l+=h}return a}function Re(e,t=[]){let i=[],r=[],n=0;for(;n<e.length;){if(e[n]!=="`"){n++;continue}let s=n;for(;e[n]==="`";)n++;i.push({start:s,end:n,length:n-s})}let o=new Array(i.length),a=new Map;for(let s=i.length-1;s>=0;s--){let p=i[s];o[s]=a.get(p.length),a.set(p.length,s)}for(let s=0;s<i.length;){let p=i[s],l=_t(e,p.start)||t.some(h=>p.start>=h.start&&p.start<h.end),c=o[s];if(l||c===void 0){s++;continue}let d=i[c];r.push({start:p.start,end:d.end,raw:e.slice(p.start,d.end),openTicks:e.slice(p.start,p.end),content:e.slice(p.end,d.start),closeTicks:e.slice(d.start,d.end)}),s=c+1}return r}function ui(e,t){return{...e,start:e.start+t,end:e.end+t,text:{...e.text,start:e.text.start+t,end:e.text.end+t},destination:e.destination&&{...e.destination,start:e.destination.start+t,end:e.destination.end+t},title:e.title&&{...e.title,start:e.title.start+t,end:e.title.end+t}}}function hi(e,t){if(!e.includes("["))return[];let i=Fe(e,t),r=new Set;for(;;){let n=i.map(p=>`${p.start}:${p.end}`).join(",");if(r.has(n))return i;r.add(n);let o=i.map(p=>({start:p.text.end,end:p.end})),a=Re(e,o),s=Fe(e,{...t,ignoreRanges:a});if(s.map(p=>`${p.start}:${p.end}`).join(",")===n)return s;i=s}}function fi(e,t={}){let i=[],r=e.split(`
|
|
6
|
+
`),n=null,o=0;for(let a of r){if(n)Ue(a,n)&&(n=null);else{let s=le(a);s?n=s:i.push(...hi(a,t).map(p=>ui(p,o)))}o+=a.length+1}return i}var mi={"&":"&","<":"<",">":">",""":'"',"'":"'"},vi=/^&(amp|lt|gt|quot|#39);/,gi=/^[!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~]$/,yi=/^[\u00a1-\u00a9\u00ab-\u00ac\u00ae-\u00b1\u00b4\u00b6-\u00b8\u00bb\u00bf\u00d7\u00f7\u02c2-\u02c5\u02d2-\u02df\u02e5-\u02eb\u02ed\u02ef-\u02ff\u0375\u037e\u0384-\u0385\u0387\u03f6\u0482\u055a-\u055f\u0589-\u058a\u058d-\u058f\u05be\u05c0\u05c3\u05c6\u05f3-\u05f4\u0606-\u060f\u061b\u061d-\u061f\u066a-\u066d\u06d4\u06de\u06e9\u06fd-\u06fe\u0700-\u070d\u07f6-\u07f9\u07fe-\u07ff\u0830-\u083e\u085e\u0888\u0964-\u0965\u0970\u09f2-\u09f3\u09fa-\u09fb\u09fd\u0a76\u0af0-\u0af1\u0b70\u0bf3-\u0bfa\u0c77\u0c7f\u0c84\u0d4f\u0d79\u0df4\u0e3f\u0e4f\u0e5a-\u0e5b\u0f01-\u0f17\u0f1a-\u0f1f\u0f34\u0f36\u0f38\u0f3a-\u0f3d\u0f85\u0fbe-\u0fc5\u0fc7-\u0fcc\u0fce-\u0fda\u104a-\u104f\u109e-\u109f\u10fb\u1360-\u1368\u1390-\u1399\u1400\u166d-\u166e\u169b-\u169c\u16eb-\u16ed\u1735-\u1736\u17d4-\u17d6\u17d8-\u17db\u1800-\u180a\u1940\u1944-\u1945\u19de-\u19ff\u1a1e-\u1a1f\u1aa0-\u1aa6\u1aa8-\u1aad\u1b4e-\u1b4f\u1b5a-\u1b6a\u1b74-\u1b7f\u1bfc-\u1bff\u1c3b-\u1c3f\u1c7e-\u1c7f\u1cc0-\u1cc7\u1cd3\u1fbd\u1fbf-\u1fc1\u1fcd-\u1fcf\u1fdd-\u1fdf\u1fed-\u1fef\u1ffd-\u1ffe\u2010-\u2027\u2030-\u205e\u207a-\u207e\u208a-\u208e\u20a0-\u20c0\u2100-\u2101\u2103-\u2106\u2108-\u2109\u2114\u2116-\u2118\u211e-\u2123\u2125\u2127\u2129\u212e\u213a-\u213b\u2140-\u2144\u214a-\u214d\u214f\u218a-\u218b\u2190-\u2429\u2440-\u244a\u249c-\u24e9\u2500-\u2775\u2794-\u2b73\u2b76-\u2b95\u2b97-\u2bff\u2ce5-\u2cea\u2cf9-\u2cfc\u2cfe-\u2cff\u2d70\u2e00-\u2e2e\u2e30-\u2e5d\u2e80-\u2e99\u2e9b-\u2ef3\u2f00-\u2fd5\u2ff0-\u2fff\u3001-\u3004\u3008-\u3020\u3030\u3036-\u3037\u303d-\u303f\u309b-\u309c\u30a0\u30fb\u3190-\u3191\u3196-\u319f\u31c0-\u31e5\u31ef\u3200-\u321e\u322a-\u3247\u3250\u3260-\u327f\u328a-\u32b0\u32c0-\u33ff\u4dc0-\u4dff\ua490-\ua4c6\ua4fe-\ua4ff\ua60d-\ua60f\ua673\ua67e\ua6f2-\ua6f7\ua700-\ua716\ua720-\ua721\ua789-\ua78a\ua828-\ua82b\ua836-\ua839\ua874-\ua877\ua8ce-\ua8cf\ua8f8-\ua8fa\ua8fc\ua92e-\ua92f\ua95f\ua9c1-\ua9cd\ua9de-\ua9df\uaa5c-\uaa5f\uaa77-\uaa79\uaade-\uaadf\uaaf0-\uaaf1\uab5b\uab6a-\uab6b\uabeb\ufb29\ufbb2-\ufbc2\ufd3e-\ufd4f\ufdcf\ufdfc-\ufdff\ufe10-\ufe19\ufe30-\ufe52\ufe54-\ufe66\ufe68-\ufe6b\uff01-\uff0f\uff1a-\uff20\uff3b-\uff40\uff5b-\uff65\uffe0-\uffe6\uffe8-\uffee\ufffc-\ufffd]$/,bi=/^\uE000\d+\uE001/;function wi(){try{return new RegExp("^[\\p{P}\\p{S}]$","u")}catch{return yi}}var xi=wi();function ut(e){return e!==null&&(gi.test(e)||xi.test(e))}function Mt(e,t,i){if(t>=e.length)return[null,0];if(e[t]==="\uE000"){let n=bi.exec(e.slice(t));if(n)return["`",n[0].length]}if(i&&e[t]==="&"){let n=vi.exec(e.slice(t,t+6));if(n)return[mi[n[0]],n[0].length]}let r=String.fromCodePoint(e.codePointAt(t));return[r,r.length]}function ht(e,t){let i=0;for(;t>0&&e[--t]==="\\";)i++;return i%2===1}function Dt(e,t){if(e[t]!=="<")return t;let i=e.indexOf(">",t+1);return i===-1?t:i+1}function ki(e,t,i){let r=t;for(;r<e.length;){let n=Dt(e,r);if(n!==r){r=n;continue}return Mt(e,r,i)[0]}return`
|
|
7
|
+
`}function Ei(e,t,i){let r=/\s/u.test(t),n=/\s/u.test(i),o=ut(t),a=ut(i),s=!n&&(!a||r||o),p=!r&&(!o||n||a);return e==="_"?{canOpen:s&&(!p||o),canClose:p&&(!s||a)}:{canOpen:s,canClose:p}}function Si(e,t){let i=[],r=`
|
|
8
|
+
`,n=0;for(;n<e.length;){let o=Dt(e,n);if(o!==n){n=o;continue}let[a,s]=Mt(e,n,t);if((a==="*"||a==="_")&&!ht(e,n)){let p=n,l=0;for(;e[n]===a&&!ht(e,n);)l++,n++;let c=Ei(a,r,ki(e,n,t)),d={marker:a,start:p,original:l,remaining:l,usedAsOpener:0,usedAsCloser:0,...c,previous:i.length>0?i[i.length-1]:null,next:null};d.previous&&(d.previous.next=d),i.push(d),r=a;continue}r=a,n+=s}return i}function _e(e,t){t.previous?t.previous.next=t.next:e.head=t.next,t.next&&(t.next.previous=t.previous),t.previous=null,t.next=null}function Li(e,t){let i=e.next;for(;i&&i!==t;){let r=i.next;i.previous=null,i.next=null,i=r}e.next=t,t.previous=e}function Ti(e,{htmlEntities:t=!1}={}){var i;let r={head:(i=Si(e,t)[0])!=null?i:null},n=[],o=r.head;for(;o;){if(!o.canClose){o=o.next;continue}let a=o.previous;for(;a;){let d=(o.canOpen||a.canClose)&&(a.original%3!==0||o.original%3!==0)&&(a.original+o.original)%3===0;if(a.marker===o.marker&&a.canOpen&&!d)break;a=a.previous}if(!a){let d=o.next;o.canOpen||_e(r,o),o=d;continue}let s=a.remaining>=2&&o.remaining>=2?2:1,p=a.start+a.original-a.usedAsOpener-s,l=o.start+o.usedAsCloser;n.push({type:s===2?"strong":"em",openStart:p,openEnd:p+s,closeStart:l,closeEnd:l+s}),a.remaining-=s,o.remaining-=s,a.usedAsOpener+=s,o.usedAsCloser+=s,Li(a,o);let c=o.next;a.remaining===0&&_e(r,a),o.remaining===0&&(_e(r,o),o=c)}return n.sort((a,s)=>a.openStart-s.openStart||s.closeEnd-a.closeEnd)}function Me(e,t={}){let{includeEm:i=!0,includeStrong:r=!0}=t,n=Ti(e,t).filter(l=>l.type==="em"?i:r);if(n.length===0)return e;let o=new Map,a=l=>(o.has(l)||o.set(l,{openEnd:[],closeEnd:[],openStart:[],closeStart:[]}),o.get(l));for(let l of n){let c=l.type;a(l.openStart).openStart.push(`<${c}><span class="syntax-marker">`),a(l.openEnd).openEnd.push("</span>"),a(l.closeStart).closeStart.push('<span class="syntax-marker">'),a(l.closeEnd).closeEnd.push(`</span></${c}>`)}let s="",p=0;for(let l of[...o.keys()].sort((c,d)=>c-d)){s+=e.slice(p,l);let c=o.get(l);s+=c.openEnd.join(""),s+=c.closeEnd.join(""),s+=c.openStart.join(""),s+=c.closeStart.join(""),p=l}return s+e.slice(p)}function Q(e){return e.replace(/ /g," ").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}var T=class{static resetLinkIndex(){this.linkIndex=0}static setCodeHighlighter(e){this.codeHighlighter=e}static setCustomSyntax(e){this.customSyntax=e}static applyCustomSyntax(e){return this.customSyntax?this.customSyntax(e):e}static escapeHtml(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,i=>t[i])}static preserveIndentation(e,t){let i=t.match(/^(\s*)/)[1].replace(/ /g," ");return e.replace(/^\s*/,i)}static parseHeader(e){let t=ct(Q(e));if(!t)return e;let i=t.indent.replace(/ /g," "),r=this.escapeHtml(t.marker+t.separator),n=this.parseInlineElements(this.escapeHtml(t.content)),o=t.closing?`<span class="syntax-marker">${this.escapeHtml(t.closing)}</span>`:"";return`<h${t.level}>${i}<span class="syntax-marker">${r}</span>${n}${o}</h${t.level}>`}static parseHorizontalRule(e){let t=Q(e);return me(t)?`<div><span class="hr-marker">${this.preserveIndentation(this.escapeHtml(t),t)}</span></div>`:null}static parseBlockquote(e){let t=dt(Q(e));if(!t)return e;let i=t.indent.replace(/ /g," "),r=this.escapeHtml(t.marker),n=this.escapeHtml(t.separator),o=this.parseInlineElements(this.escapeHtml(t.content));return`${i}<span class="blockquote"><span class="syntax-marker">${r}</span>${n}${o}</span>`}static parseBulletList(e){let t=Q(e);if(me(t))return e;let i=ve(t);if(!i||i.listType!=="bullet")return e;let r=i.indent.replace(/ /g," "),n=this.escapeHtml(i.marker+i.separator),o=this.parseInlineElements(this.escapeHtml(i.content));return`${r}<li class="bullet-list"><span class="syntax-marker">${n}</span>${o}</li>`}static parseTaskList(e,t=!1){return e.replace(/^((?: )*)-(\s+)\[([ xX])\](\s*)(.*)$/,(i,r,n,o,a,s)=>{if(a===""&&s!=="")return i;if(s=this.parseInlineElements(s),t){let p=o.toLowerCase()==="x";return`<li class="task-list">${r}<input type="checkbox" ${p?"checked":""}> ${s}</li>`}else return`<li class="task-list">${r}<span class="syntax-marker">-${n}[${o}]${a}</span>${s}</li>`})}static parseNumberedList(e){let t=ve(Q(e));if(!t||t.listType!=="ordered")return e;let i=t.indent.replace(/ /g," "),r=this.escapeHtml(t.marker+t.separator),n=this.parseInlineElements(this.escapeHtml(t.content));return`${i}<li class="ordered-list"><span class="syntax-marker">${r}</span>${n}</li>`}static parseCodeBlock(e){let t=le(Q(e));return t?this.renderFence(t):null}static renderFence(e,t=!1){let i=this.preserveIndentation(this.escapeHtml(e.source),e.source);return`<div${t?' class="raw-line"':""}><span class="code-fence">${i}</span></div>`}static renderCodeContent(e,t,i,r=0,n=-1){let o=e.map(u=>{let f=0;for(;f<r&&u[f]===" ";)f++;return{source:u,prefix:u.slice(0,f),content:u.slice(f)}}),a=o.map(u=>u.content).join(`
|
|
9
|
+
`),s=u=>u?`<span class="syntax-marker">${this.escapeHtml(u)}</span>`:"",p=o.map((u,f)=>f===n?`<span class="raw-line">${this.escapeHtml(u.source)||" "}</span>`:u.prefix===""&&u.content===""?'<span class="syntax-marker"> </span>':s(u.prefix)+this.escapeHtml(u.content)).join(`
|
|
10
|
+
`),l=t.split(/[\t ]/,1)[0],c=l?` class="language-${this.escapeHtml(l)}"`:"",d=i||this.codeHighlighter,h=p;if(d)try{let u=d(a,l);if(u&&typeof u.then=="function")console.warn("Async highlighters are not supported in parse() because it returns an HTML string. Use synchronous highlighters only.");else if(u&&typeof u=="string"&&u.trim()){let f=u.split(`
|
|
11
|
+
`);f.length===o.length+1&&f[f.length-1]===""&&f.pop(),f.length===o.length?h=f.map((m,v)=>v===n?`<span class="raw-line">${this.escapeHtml(o[v].source)||" "}</span>`:s(o[v].prefix)+m).join(`
|
|
12
|
+
`):console.warn("Code highlighter output line count does not match the source. Using unhighlighted code to preserve alignment.")}}catch(u){console.warn("Code highlighting failed:",u)}return`<pre class="code-block"><code${c}>${h}</code></pre>`}static parseBold(e){return Me(e,{htmlEntities:!0,includeEm:!1})}static parseItalic(e){return Me(e,{htmlEntities:!0,includeStrong:!1})}static parseEmphasis(e){return Me(e,{htmlEntities:!0})}static parseStrikethrough(e){return e=e.replace(new RegExp("(?<!~)~~(?!~)(.+?)(?<!~)~~(?!~)","g"),'<del><span class="syntax-marker">~~</span>$1<span class="syntax-marker">~~</span></del>'),e=e.replace(new RegExp("(?<!~)~(?!~)(.+?)(?<!~)~(?!~)","g"),'<del><span class="syntax-marker">~</span>$1<span class="syntax-marker">~</span></del>'),e}static parseInlineCode(e){let t=Re(e);for(let i of t.reverse()){let r=`<code><span class="syntax-marker">${i.openTicks}</span>${i.content}<span class="syntax-marker">${i.closeTicks}</span></code>`;e=e.slice(0,i.start)+r+e.slice(i.end)}return e}static sanitizeUrl(e){let t=e.trim(),i=t.toLowerCase(),r=["http://","https://","mailto:","ftp://","ftps://"].some(o=>i.startsWith(o)),n=t.startsWith("/")||t.startsWith("#")||t.startsWith("?")||t.startsWith(".")||!t.includes(":")&&!t.includes("//");return r||n?e:"#"}static findLinks(e,t={}){let{allowEmptyText:i=!1,...r}=t;return Fe(e,r).filter(n=>(i||n.text.raw.length>0)&&n.destination!==null&&n.destination.value.length>0)}static findRenderableLinks(e,t={}){let{allowEmptyText:i=!1,...r}=t;return fi(e,r).filter(n=>(i||n.text.raw.length>0)&&n.destination!==null&&n.destination.value.length>0)}static parseLinks(e){let t=this.findLinks(e,{htmlEntities:!0});t.forEach(i=>{i.anchorName=`--link-${this.linkIndex++}`});for(let i of t.reverse()){let r=this.escapeHtml(this.sanitizeUrl(i.destination.value)),n=i.title===null?"":` title="${this.escapeHtml(i.title.value)}"`,o=e.slice(i.text.start,i.text.end),a=e.slice(i.text.end,i.end),s=`<a href="${r}"${n} style="anchor-name: ${i.anchorName}"><span class="syntax-marker">[</span>${o}<span class="syntax-marker url-part">${a}</span></a>`;e=e.slice(0,i.start)+s+e.slice(i.end)}return e}static identifyAndProtectSanctuaries(e){let t=new Map,i=0,r=e,n=(e.includes("[")?this.findRenderableLinks(e,{htmlEntities:!0}):[]).map(s=>({start:s.text.end,end:s.end})),o=Re(e,n);o.sort((s,p)=>p.start-s.start),o.forEach(s=>{let p=`\uE000${i++}\uE001`;t.set(p,{type:"code",original:s.raw,openTicks:s.openTicks,content:s.content,closeTicks:s.closeTicks}),r=r.substring(0,s.start)+p+r.substring(s.end)});let a=[...t.keys()];return(r.includes("[")?this.findLinks(r,{htmlEntities:!0}):[]).filter(s=>{let p=r.slice(s.text.end,s.end);return a.every(l=>!p.includes(l))}).sort((s,p)=>p.start-s.start).forEach(s=>{var p,l;let c=`\uE000${i++}\uE001`;t.set(c,{type:"link",original:r.slice(s.start,s.end),linkText:r.slice(s.text.start,s.text.end),tail:r.slice(s.text.end,s.end),url:s.destination.value,title:(l=(p=s.title)==null?void 0:p.value)!=null?l:null}),r=r.slice(0,s.start)+c+r.slice(s.end)}),{protectedText:r,sanctuaries:t}}static restoreAndTransformSanctuaries(e,t){return Array.from(t.keys()).sort((i,r)=>{let n=e.indexOf(i),o=e.indexOf(r);return n-o}).forEach(i=>{let r=t.get(i),n;if(r.type==="code")n=`<code><span class="syntax-marker">${r.openTicks}</span>${r.content}<span class="syntax-marker">${r.closeTicks}</span></code>`;else if(r.type==="link"){let o=r.linkText;o=this.parseStrikethrough(o),o=this.parseEmphasis(o),t.forEach((l,c)=>{if(o.includes(c)&&l.type==="code"){let d=`<code><span class="syntax-marker">${l.openTicks}</span>${l.content}<span class="syntax-marker">${l.closeTicks}</span></code>`;o=o.replace(c,()=>d)}});let a=`--link-${this.linkIndex++}`,s=this.escapeHtml(this.sanitizeUrl(r.url)),p=r.title===null?"":` title="${this.escapeHtml(r.title)}"`;n=`<a href="${s}"${p} style="anchor-name: ${a}"><span class="syntax-marker">[</span>${o}<span class="syntax-marker url-part">${r.tail}</span></a>`}e=e.replace(i,()=>n)}),e}static parseInlineElements(e){let{protectedText:t,sanctuaries:i}=this.identifyAndProtectSanctuaries(e),r=t;return r=this.parseStrikethrough(r),r=this.parseEmphasis(r),r=this.restoreAndTransformSanctuaries(r,i),r}static parseLine(e,t=!1){if(e==="")return"<div> </div>";if(me(e))return`<div><span class="hr-marker">${this.preserveIndentation(this.escapeHtml(e),e)}</span></div>`;let i=le(e);if(i)return this.renderFence(i);let r=ct(e);if(r){let l=r.indent.replace(/ /g," "),c=this.escapeHtml(r.marker+r.separator),d=this.parseInlineElements(this.escapeHtml(r.content)),h=r.closing?`<span class="syntax-marker">${this.escapeHtml(r.closing)}</span>`:"";return`<div><h${r.level}>${l}<span class="syntax-marker">${c}</span>${d}${h}</h${r.level}></div>`}let n=dt(e);if(n){let l=n.indent.replace(/ /g," "),c=this.escapeHtml(n.marker),d=this.escapeHtml(n.separator),h=this.parseInlineElements(this.escapeHtml(n.content));return`<div>${l}<span class="blockquote"><span class="syntax-marker">${c}</span>${d}${h}</span></div>`}let o=this.preserveIndentation(this.escapeHtml(e),e),a=this.parseTaskList(o,t);if(a!==o)return`<div>${a}</div>`;let s=ve(e);if(s){let l=s.indent.replace(/ /g," "),c=this.escapeHtml(s.marker+s.separator),d=this.parseInlineElements(this.escapeHtml(s.content)),h=s.listType==="bullet"?"bullet-list":"ordered-list";return`<div>${l}<li class="${h}"><span class="syntax-marker">${c}</span>${d}</li></div>`}let p=/^[\t ]*/.exec(e)[0];return o=p.replace(/ /g," ")+this.parseInlineElements(this.escapeHtml(e.slice(p.length))),`<div>${o}</div>`}static parse(e,t=-1,i=!1,r,n=!1){this.resetLinkIndex();let o=e.split(`
|
|
13
|
+
`),a=[],s=null,p=[],l=-1;for(let d=0;d<o.length;d++){let h=o[d],u=i&&d===t;if(s){let m=Ue(h,s);if(m){a.push(this.renderCodeContent(p,s.info,r,s.indent.length,l));let v=this.renderFence(m,u);a.push(u?v:this.applyCustomSyntax(v)),s=null,p=[],l=-1}else u&&(l=p.length),p.push(h);continue}let f=le(h);if(f){s=f;let m=this.renderFence(f,u);a.push(u?m:this.applyCustomSyntax(m));continue}if(u){let m=this.escapeHtml(h)||" ";a.push(`<div class="raw-line">${m}</div>`);continue}a.push(this.applyCustomSyntax(this.parseLine(h,n)))}s&&p.length>0&&a.push(this.renderCodeContent(p,s.info,r,s.indent.length,l));let c=a.join("");return this.postProcessHTML(c,r,!1)}static postProcessHTML(e,t,i=!0){return this.postProcessHTMLManual(e,t,i)}static postProcessHTMLManual(e,t,i=!0){let r=e;r=r.replace(/((?:<div(?:\s[^>]*)?>(?: )*<li class="bullet-list">.*?<\/li><\/div>\s*)+)/gs,o=>{let a=o.match(/<div(?:\s[^>]*)?>(?: )*<li class="bullet-list">.*?<\/li><\/div>/gs)||[];return a.length>0?"<ul>"+a.map(s=>{let p=s.match(/<div(?:\s[^>]*)?>((?: )*)<li/),l=s.match(/<li class="bullet-list">.*?<\/li>/);if(p&&l){let c=p[1];return l[0].replace(/<li class="bullet-list">/,`<li class="bullet-list">${c}`)}return l?l[0]:""}).filter(Boolean).join("")+"</ul>":o}),r=r.replace(/((?:<div(?:\s[^>]*)?>(?: )*<li class="ordered-list">.*?<\/li><\/div>\s*)+)/gs,o=>{let a=o.match(/<div(?:\s[^>]*)?>(?: )*<li class="ordered-list">.*?<\/li><\/div>/gs)||[];if(a.length>0){let s=a.map(c=>{let d=c.match(/<div(?:\s[^>]*)?>((?: )*)<li/),h=c.match(/<li class="ordered-list">.*?<\/li>/);if(d&&h){let u=d[1];return h[0].replace(/<li class="ordered-list">/,`<li class="ordered-list">${u}`)}return h?h[0]:""}).filter(Boolean),p=a[0].match(/<span class="syntax-marker">(\d+)\./),l=p?Number.parseInt(p[1],10):1;return`<ol${l===1?"":` start="${l}"`}>`+s.join("")+"</ol>"}return o});let n=/<div><span class="code-fence">(```[^<]*)<\/span><\/div>(.*?)<div><span class="code-fence">(```)<\/span><\/div>/gs;return i&&(r=r.replace(n,(o,a,s,p)=>{if(s.includes('<pre class="code-block">'))return o;let l=(s.match(/<div>(.*?)<\/div>/gs)||[]).map(y=>y.replace(/<div>(.*?)<\/div>/s,"$1")),c=l.map(y=>y===" "?"":y.replace(/ /g," ")).join(`
|
|
14
|
+
`),d=l.join(`
|
|
15
|
+
`),h=a.slice(3).trim(),u=h?` class="language-${h}"`:"",f=d,m=t||this.codeHighlighter;if(m)try{let y=c.replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"),b=m(y,h);b&&typeof b.then=="function"?console.warn("Async highlighters are not supported in Node.js (non-DOM) context. Use synchronous highlighters for server-side rendering."):b&&typeof b=="string"&&b.trim()&&(f=b)}catch(y){console.warn("Code highlighting failed:",y)}let v=`<div><span class="code-fence">${a}</span></div>`;return v+=`<pre class="code-block"><code${u}>${f}</code></pre>`,v+=`<div><span class="code-fence">${p}</span></div>`,v})),r}static getListContext(e,t){let i=e.split(`
|
|
16
|
+
`),r=0,n=0,o=0;for(let d=0;d<i.length;d++){let h=i[d].length;if(r+h>=t){n=d,o=r;break}r+=h+1}let a=i[n],s=o+a.length,p={inList:!1,listType:null,indent:"",marker:null,content:a,lineStart:o,lineEnd:s,markerEndPos:o};if(me(a))return p;let l=ve(a);if(!l)return p;let c=l.listType==="bullet"&&l.marker==="-"?/^\[([ xX])\]([\t ]*)(.*)$/.exec(l.content):null;return c&&(c[2]!==""||c[3]==="")?{inList:!0,listType:"checkbox",indent:l.indent,marker:"-",checked:c[1].toLowerCase()==="x",content:c[3],lineStart:o,lineEnd:s,markerEndPos:o+l.indent.length+l.marker.length+l.separator.length+3+c[2].length}:l.listType==="bullet"?{inList:!0,listType:"bullet",indent:l.indent,marker:l.marker,content:l.content,lineStart:o,lineEnd:s,markerEndPos:o+l.indent.length+l.marker.length+l.separator.length}:{inList:!0,listType:"numbered",indent:l.indent,marker:Number.parseInt(l.marker,10),content:l.content,lineStart:o,lineEnd:s,markerEndPos:o+l.indent.length+l.marker.length+l.separator.length}}static createNewListItem(e){switch(e.listType){case"bullet":return`${e.indent}${e.marker} `;case"numbered":return`${e.indent}${e.marker+1}. `;case"checkbox":return`${e.indent}- [ ] `;default:return""}}static renumberLists(e){let t=e.split(`
|
|
17
|
+
`),i=new Map,r=!1;return t.map(n=>{let o=n.match(this.LIST_PATTERNS.numbered);if(o){let a=o[1],s=a.length,p=o[3];r||i.clear();let l=(i.get(s)||0)+1;i.set(s,l);for(let[c]of i)c>s&&i.delete(c);return r=!0,`${a}${l}. ${p}`}else return(n.trim()===""||!n.match(/^\s/))&&(r=!1,i.clear()),n}).join(`
|
|
18
|
+
`)}};C(T,"linkIndex",0);C(T,"codeHighlighter",null);C(T,"customSyntax",null);C(T,"LIST_PATTERNS",{bullet:/^( *)([-*+])[\t ]+(.*)$/,numbered:/^( *)(\d{1,9})\.[\t ]+(.*)$/,checkbox:/^( *)-[\t ]+\[([ xX])\][\t ]+(.*)$/});var Pt=class{constructor(e){this.editor=e}handleKeydown(e){if(!(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey))return!1;if(e.key==="]")return e.preventDefault(),this.editor.indentSelection(),!0;if(e.key==="[")return e.preventDefault(),this.editor.outdentSelection(),!0;let t=null;switch(e.key.toLowerCase()){case"b":e.shiftKey||(t="toggleBold");break;case"i":e.shiftKey||(t="toggleItalic");break;case"k":e.shiftKey||(t="insertLink");break;case"7":e.shiftKey&&(t="toggleNumberedList");break;case"8":e.shiftKey&&(t="toggleBulletList");break}return t?(e.preventDefault(),this.editor.performAction(t,e),!0):!1}destroy(){}},U={name:"solar",colors:{bgPrimary:"#faf0ca",bgSecondary:"#ffffff",text:"#0d3b66",textPrimary:"#0d3b66",textSecondary:"#5a7a9b",h1:"#f95738",h2:"#ee964b",h3:"#3d8a51",strong:"#ee964b",em:"#f95738",del:"#ee964b",link:"#0d3b66",code:"#0d3b66",codeBg:"rgba(244, 211, 94, 0.4)",blockquote:"#5a7a9b",hr:"#5a7a9b",syntaxMarker:"rgba(13, 59, 102, 0.52)",syntax:"#999999",cursor:"#f95738",selection:"rgba(244, 211, 94, 0.4)",listMarker:"#ee964b",rawLine:"#5a7a9b",border:"#e0e0e0",hoverBg:"#f0f0f0",primary:"#0d3b66",toolbarBg:"#ffffff",toolbarIcon:"#0d3b66",toolbarHover:"#f5f5f5",toolbarActive:"#faf0ca",placeholder:"#999999"},previewColors:{text:"#0d3b66",h1:"inherit",h2:"inherit",h3:"inherit",strong:"inherit",em:"inherit",link:"#0d3b66",code:"#0d3b66",codeBg:"rgba(244, 211, 94, 0.4)",blockquote:"#5a7a9b",hr:"#5a7a9b",bg:"transparent"}},ft={name:"cave",colors:{bgPrimary:"#141E26",bgSecondary:"#1D2D3E",text:"#c5dde8",textPrimary:"#c5dde8",textSecondary:"#9fcfec",h1:"#d4a5ff",h2:"#f6ae2d",h3:"#9fcfec",strong:"#f6ae2d",em:"#9fcfec",del:"#f6ae2d",link:"#9fcfec",code:"#c5dde8",codeBg:"#1a232b",blockquote:"#9fcfec",hr:"#c5dde8",syntaxMarker:"rgba(159, 207, 236, 0.73)",syntax:"#7a8c98",cursor:"#f26419",selection:"rgba(51, 101, 138, 0.4)",listMarker:"#f6ae2d",rawLine:"#9fcfec",border:"#2a3f52",hoverBg:"#243546",primary:"#9fcfec",toolbarBg:"#1D2D3E",toolbarIcon:"#c5dde8",toolbarHover:"#243546",toolbarActive:"#2a3f52",placeholder:"#6a7a88"},previewColors:{text:"#c5dde8",h1:"inherit",h2:"inherit",h3:"inherit",strong:"inherit",em:"inherit",link:"#9fcfec",code:"#c5dde8",codeBg:"#1a232b",blockquote:"#9fcfec",hr:"#c5dde8",bg:"transparent"}},mt={solar:U,cave:ft,auto:U,light:U,dark:ft};function K(e){return typeof e=="string"?{...mt[e]||mt.solar,name:e}:e}function vt(e){return e!=="auto"?e:(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)"))?.matches?"cave":"solar"}function se(e,t){let i=[];for(let[r,n]of Object.entries(e)){let o=r.replace(/([A-Z])/g,"-$1").toLowerCase();i.push(`--${o}: ${n};`)}if(t)for(let[r,n]of Object.entries(t)){let o=r.replace(/([A-Z])/g,"-$1").toLowerCase();i.push(`--preview-${o}-default: ${n};`)}return i.join(`
|
|
19
|
+
`)}function Ci(e,t={},i={}){return{...e,colors:{...e.colors,...t},previewColors:{...e.previewColors,...i}}}var N={fontSize:"14px",lineHeight:1.6,fontFamily:'"SF Mono", SFMono-Regular, Menlo, Monaco, "Cascadia Code", Consolas, "Roboto Mono", "Noto Sans Mono", "Droid Sans Mono", "Ubuntu Mono", "DejaVu Sans Mono", "Liberation Mono", "Courier New", Courier, monospace',padding:"20px"};function Ai(e={}){let{fontSize:t=N.fontSize,lineHeight:i=N.lineHeight,fontFamily:r=N.fontFamily,padding:n=N.padding,theme:o=null,mobile:a={}}=e,s=Object.keys(a).length>0?`
|
|
20
|
+
@media (max-width: 640px) {
|
|
21
|
+
.overtype-wrapper .overtype-input,
|
|
22
|
+
.overtype-wrapper .overtype-preview {
|
|
23
|
+
${Object.entries(a).map(([l,c])=>`${l.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${c} !important;`).join(`
|
|
24
|
+
`)}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`:"",p=o&&o.colors?se(o.colors,o.previewColors):"";return`
|
|
28
|
+
/* OverType Editor Styles */
|
|
29
|
+
|
|
30
|
+
/* Middle-ground CSS Reset - Prevent parent styles from leaking in */
|
|
31
|
+
.overtype-container * {
|
|
32
|
+
/* Box model - these commonly leak */
|
|
33
|
+
margin: 0 !important;
|
|
34
|
+
padding: 0 !important;
|
|
35
|
+
border: 0 !important;
|
|
36
|
+
|
|
37
|
+
/* Layout - these can break our layout */
|
|
38
|
+
/* Don't reset position - it breaks dropdowns */
|
|
39
|
+
float: none !important;
|
|
40
|
+
clear: none !important;
|
|
41
|
+
|
|
42
|
+
/* Typography - only reset decorative aspects */
|
|
43
|
+
text-decoration: none !important;
|
|
44
|
+
text-transform: none !important;
|
|
45
|
+
letter-spacing: normal !important;
|
|
46
|
+
|
|
47
|
+
/* Visual effects that can interfere */
|
|
48
|
+
box-shadow: none !important;
|
|
49
|
+
text-shadow: none !important;
|
|
50
|
+
|
|
51
|
+
/* Ensure box-sizing is consistent */
|
|
52
|
+
box-sizing: border-box !important;
|
|
53
|
+
|
|
54
|
+
/* Keep inheritance for these */
|
|
55
|
+
/* font-family, color, line-height, font-size - inherit */
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Container base styles after reset */
|
|
59
|
+
.overtype-container {
|
|
60
|
+
display: flex !important;
|
|
61
|
+
flex-direction: column !important;
|
|
62
|
+
width: 100% !important;
|
|
63
|
+
height: 100% !important;
|
|
64
|
+
position: relative !important; /* Override reset - needed for absolute children */
|
|
65
|
+
overflow: visible !important; /* Allow dropdown to overflow container */
|
|
66
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
|
|
67
|
+
text-align: left !important;
|
|
68
|
+
${p?`
|
|
69
|
+
/* Theme Variables */
|
|
70
|
+
${p}`:""}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Force left alignment for all elements in the editor */
|
|
74
|
+
.overtype-container .overtype-wrapper * {
|
|
75
|
+
text-align: left !important;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* Auto-resize mode styles */
|
|
79
|
+
.overtype-container.overtype-auto-resize {
|
|
80
|
+
height: auto !important;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.overtype-container.overtype-auto-resize .overtype-wrapper {
|
|
84
|
+
flex: 0 0 auto !important; /* Don't grow/shrink, use explicit height */
|
|
85
|
+
height: auto !important;
|
|
86
|
+
min-height: 60px !important;
|
|
87
|
+
overflow: visible !important;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.overtype-wrapper {
|
|
91
|
+
position: relative !important; /* Override reset - needed for absolute children */
|
|
92
|
+
width: 100% !important;
|
|
93
|
+
flex: 1 1 0 !important; /* Grow to fill remaining space, with flex-basis: 0 */
|
|
94
|
+
min-height: 60px !important; /* Minimum usable height */
|
|
95
|
+
overflow: hidden !important;
|
|
96
|
+
background: var(--bg-secondary, #ffffff) !important;
|
|
97
|
+
z-index: 1; /* Below toolbar and dropdown */
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* Critical alignment styles - must be identical for both layers */
|
|
101
|
+
.overtype-wrapper .overtype-input,
|
|
102
|
+
.overtype-wrapper .overtype-preview {
|
|
103
|
+
/* Positioning - must be identical */
|
|
104
|
+
position: absolute !important; /* Override reset - required for overlay */
|
|
105
|
+
top: 0 !important;
|
|
106
|
+
left: 0 !important;
|
|
107
|
+
width: 100% !important;
|
|
108
|
+
height: 100% !important;
|
|
109
|
+
|
|
110
|
+
/* Font properties - any difference breaks alignment */
|
|
111
|
+
font-family: var(--instance-font-family, ${r}) !important;
|
|
112
|
+
font-variant-ligatures: none !important; /* keep metrics stable for code */
|
|
113
|
+
font-size: var(--instance-font-size, ${t}) !important;
|
|
114
|
+
line-height: var(--instance-line-height, ${i}) !important;
|
|
115
|
+
font-weight: normal !important;
|
|
116
|
+
font-style: normal !important;
|
|
117
|
+
font-variant: normal !important;
|
|
118
|
+
font-stretch: normal !important;
|
|
119
|
+
font-kerning: none !important;
|
|
120
|
+
font-feature-settings: normal !important;
|
|
121
|
+
|
|
122
|
+
/* Box model - must match exactly */
|
|
123
|
+
padding: var(--instance-padding, ${n}) !important;
|
|
124
|
+
margin: 0 !important;
|
|
125
|
+
border: none !important;
|
|
126
|
+
outline: none !important;
|
|
127
|
+
box-sizing: border-box !important;
|
|
128
|
+
|
|
129
|
+
/* Text layout - critical for character positioning */
|
|
130
|
+
white-space: pre-wrap !important;
|
|
131
|
+
word-wrap: break-word !important;
|
|
132
|
+
word-break: normal !important;
|
|
133
|
+
overflow-wrap: break-word !important;
|
|
134
|
+
tab-size: 2 !important;
|
|
135
|
+
-moz-tab-size: 2 !important;
|
|
136
|
+
text-align: left !important;
|
|
137
|
+
text-indent: 0 !important;
|
|
138
|
+
letter-spacing: normal !important;
|
|
139
|
+
word-spacing: normal !important;
|
|
140
|
+
|
|
141
|
+
/* Text rendering */
|
|
142
|
+
text-transform: none !important;
|
|
143
|
+
text-rendering: auto !important;
|
|
144
|
+
-webkit-font-smoothing: auto !important;
|
|
145
|
+
-webkit-text-size-adjust: 100% !important;
|
|
146
|
+
|
|
147
|
+
/* Direction and writing */
|
|
148
|
+
direction: ltr !important;
|
|
149
|
+
writing-mode: horizontal-tb !important;
|
|
150
|
+
unicode-bidi: normal !important;
|
|
151
|
+
text-orientation: mixed !important;
|
|
152
|
+
|
|
153
|
+
/* Visual effects that could shift perception */
|
|
154
|
+
text-shadow: none !important;
|
|
155
|
+
filter: none !important;
|
|
156
|
+
transform: none !important;
|
|
157
|
+
zoom: 1 !important;
|
|
158
|
+
|
|
159
|
+
/* Vertical alignment */
|
|
160
|
+
vertical-align: baseline !important;
|
|
161
|
+
|
|
162
|
+
/* Size constraints */
|
|
163
|
+
min-width: 0 !important;
|
|
164
|
+
min-height: 0 !important;
|
|
165
|
+
max-width: none !important;
|
|
166
|
+
max-height: none !important;
|
|
167
|
+
|
|
168
|
+
/* Overflow */
|
|
169
|
+
overflow-y: auto !important;
|
|
170
|
+
overflow-x: auto !important;
|
|
171
|
+
/* overscroll-behavior removed to allow scroll-through to parent */
|
|
172
|
+
scrollbar-width: auto !important;
|
|
173
|
+
scrollbar-gutter: auto !important;
|
|
174
|
+
|
|
175
|
+
/* Animation/transition - disabled to prevent movement */
|
|
176
|
+
animation: none !important;
|
|
177
|
+
transition: none !important;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/* Input layer styles */
|
|
181
|
+
.overtype-wrapper .overtype-input {
|
|
182
|
+
/* Layer positioning */
|
|
183
|
+
z-index: 1 !important;
|
|
184
|
+
|
|
185
|
+
/* Text visibility */
|
|
186
|
+
color: transparent !important;
|
|
187
|
+
caret-color: var(--cursor, #f95738) !important;
|
|
188
|
+
background-color: transparent !important;
|
|
189
|
+
|
|
190
|
+
/* Textarea-specific */
|
|
191
|
+
resize: none !important;
|
|
192
|
+
appearance: none !important;
|
|
193
|
+
-webkit-appearance: none !important;
|
|
194
|
+
-moz-appearance: none !important;
|
|
195
|
+
|
|
196
|
+
/* Prevent mobile zoom on focus */
|
|
197
|
+
touch-action: manipulation !important;
|
|
198
|
+
|
|
199
|
+
/* Disable autofill */
|
|
200
|
+
autocomplete: off !important;
|
|
201
|
+
autocorrect: off !important;
|
|
202
|
+
autocapitalize: off !important;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.overtype-wrapper .overtype-input::selection {
|
|
206
|
+
background-color: var(--selection, rgba(244, 211, 94, 0.4));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.overtype-wrapper .overtype-input::placeholder {
|
|
210
|
+
color: transparent !important;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/* Placeholder shim - visible when textarea is empty */
|
|
214
|
+
.overtype-wrapper .overtype-placeholder {
|
|
215
|
+
position: absolute !important;
|
|
216
|
+
top: 0 !important;
|
|
217
|
+
left: 0 !important;
|
|
218
|
+
width: 100% !important;
|
|
219
|
+
z-index: 0 !important;
|
|
220
|
+
pointer-events: none !important;
|
|
221
|
+
user-select: none !important;
|
|
222
|
+
font-family: var(--instance-font-family, ${r}) !important;
|
|
223
|
+
font-size: var(--instance-font-size, ${t}) !important;
|
|
224
|
+
line-height: var(--instance-line-height, ${i}) !important;
|
|
225
|
+
padding: var(--instance-padding, ${n}) !important;
|
|
226
|
+
box-sizing: border-box !important;
|
|
227
|
+
color: var(--placeholder, #999) !important;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/* Preview layer styles */
|
|
231
|
+
.overtype-wrapper .overtype-preview {
|
|
232
|
+
/* Layer positioning */
|
|
233
|
+
z-index: 0 !important;
|
|
234
|
+
pointer-events: none !important;
|
|
235
|
+
color: var(--text, #0d3b66) !important;
|
|
236
|
+
background-color: transparent !important;
|
|
237
|
+
|
|
238
|
+
/* Prevent text selection */
|
|
239
|
+
user-select: none !important;
|
|
240
|
+
-webkit-user-select: none !important;
|
|
241
|
+
-moz-user-select: none !important;
|
|
242
|
+
-ms-user-select: none !important;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/* Prevent external resets (Tailwind, Bootstrap, etc.) from breaking alignment.
|
|
246
|
+
Any element whose font metrics differ from the textarea causes the CSS "strut"
|
|
247
|
+
to inflate line boxes, drifting the overlay. Force inheritance so every element
|
|
248
|
+
inside the preview matches the textarea exactly. */
|
|
249
|
+
.overtype-wrapper .overtype-preview * {
|
|
250
|
+
font-family: inherit !important;
|
|
251
|
+
font-size: inherit !important;
|
|
252
|
+
line-height: inherit !important;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/* Defensive styles for preview child divs */
|
|
256
|
+
.overtype-wrapper .overtype-preview div {
|
|
257
|
+
/* Reset any inherited styles */
|
|
258
|
+
margin: 0 !important;
|
|
259
|
+
padding: 0 !important;
|
|
260
|
+
border: none !important;
|
|
261
|
+
text-align: left !important;
|
|
262
|
+
text-indent: 0 !important;
|
|
263
|
+
display: block !important;
|
|
264
|
+
position: static !important;
|
|
265
|
+
transform: none !important;
|
|
266
|
+
min-height: 0 !important;
|
|
267
|
+
max-height: none !important;
|
|
268
|
+
line-height: inherit !important;
|
|
269
|
+
font-size: inherit !important;
|
|
270
|
+
font-family: inherit !important;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/* Markdown element styling - NO SIZE CHANGES */
|
|
274
|
+
.overtype-wrapper .overtype-preview .header {
|
|
275
|
+
font-weight: bold !important;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* Header colors */
|
|
279
|
+
.overtype-wrapper .overtype-preview .h1 {
|
|
280
|
+
color: var(--h1, #f95738) !important;
|
|
281
|
+
}
|
|
282
|
+
.overtype-wrapper .overtype-preview .h2 {
|
|
283
|
+
color: var(--h2, #ee964b) !important;
|
|
284
|
+
}
|
|
285
|
+
.overtype-wrapper .overtype-preview .h3 {
|
|
286
|
+
color: var(--h3, #3d8a51) !important;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/* Semantic headers - flatten in edit mode */
|
|
290
|
+
.overtype-wrapper .overtype-preview h1,
|
|
291
|
+
.overtype-wrapper .overtype-preview h2,
|
|
292
|
+
.overtype-wrapper .overtype-preview h3 {
|
|
293
|
+
font-size: inherit !important;
|
|
294
|
+
font-weight: bold !important;
|
|
295
|
+
margin: 0 !important;
|
|
296
|
+
padding: 0 !important;
|
|
297
|
+
display: inline !important;
|
|
298
|
+
line-height: inherit !important;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/* Header colors for semantic headers */
|
|
302
|
+
.overtype-wrapper .overtype-preview h1 {
|
|
303
|
+
color: var(--h1, #f95738) !important;
|
|
304
|
+
}
|
|
305
|
+
.overtype-wrapper .overtype-preview h2 {
|
|
306
|
+
color: var(--h2, #ee964b) !important;
|
|
307
|
+
}
|
|
308
|
+
.overtype-wrapper .overtype-preview h3 {
|
|
309
|
+
color: var(--h3, #3d8a51) !important;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/* Lists - remove styling in edit mode */
|
|
313
|
+
.overtype-wrapper .overtype-preview ul,
|
|
314
|
+
.overtype-wrapper .overtype-preview ol {
|
|
315
|
+
list-style: none !important;
|
|
316
|
+
margin: 0 !important;
|
|
317
|
+
padding: 0 !important;
|
|
318
|
+
display: block !important; /* Lists need to be block for line breaks */
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.overtype-wrapper .overtype-preview li {
|
|
322
|
+
display: block !important; /* Each item on its own line */
|
|
323
|
+
margin: 0 !important;
|
|
324
|
+
padding: 0 !important;
|
|
325
|
+
/* Don't set list-style here - let ul/ol control it */
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/* Bold text */
|
|
329
|
+
.overtype-wrapper .overtype-preview strong {
|
|
330
|
+
color: var(--strong, #ee964b) !important;
|
|
331
|
+
font-weight: bold !important;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/* Italic text */
|
|
335
|
+
.overtype-wrapper .overtype-preview em {
|
|
336
|
+
color: var(--em, #f95738) !important;
|
|
337
|
+
text-decoration-color: var(--em, #f95738) !important;
|
|
338
|
+
text-decoration-thickness: 1px !important;
|
|
339
|
+
font-style: italic !important;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/* Strikethrough text */
|
|
343
|
+
.overtype-wrapper .overtype-preview del {
|
|
344
|
+
color: var(--del, #ee964b) !important;
|
|
345
|
+
text-decoration: line-through !important;
|
|
346
|
+
text-decoration-color: var(--del, #ee964b) !important;
|
|
347
|
+
text-decoration-thickness: 1px !important;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/* Inline code */
|
|
351
|
+
.overtype-wrapper .overtype-preview code {
|
|
352
|
+
background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;
|
|
353
|
+
color: var(--code, #0d3b66) !important;
|
|
354
|
+
padding: 0 !important;
|
|
355
|
+
border-radius: 2px !important;
|
|
356
|
+
font-family: inherit !important;
|
|
357
|
+
font-size: inherit !important;
|
|
358
|
+
line-height: inherit !important;
|
|
359
|
+
font-weight: normal !important;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/* Code blocks - consolidated pre blocks */
|
|
363
|
+
.overtype-wrapper .overtype-preview pre {
|
|
364
|
+
padding: 0 !important;
|
|
365
|
+
margin: 0 !important;
|
|
366
|
+
border-radius: 4px !important;
|
|
367
|
+
overflow-x: auto !important;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/* Code block styling in normal mode - yellow background */
|
|
371
|
+
.overtype-wrapper .overtype-preview pre.code-block {
|
|
372
|
+
background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;
|
|
373
|
+
white-space: break-spaces !important; /* Prevent horizontal scrollbar that breaks alignment */
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/* Code inside pre blocks - remove background */
|
|
377
|
+
.overtype-wrapper .overtype-preview pre code {
|
|
378
|
+
background: transparent !important;
|
|
379
|
+
color: var(--code, #0d3b66) !important;
|
|
380
|
+
font-family: var(--instance-font-family, ${r}) !important; /* Match textarea font exactly for alignment */
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/* Blockquotes */
|
|
384
|
+
.overtype-wrapper .overtype-preview .blockquote {
|
|
385
|
+
color: var(--blockquote, #5a7a9b) !important;
|
|
386
|
+
padding: 0 !important;
|
|
387
|
+
margin: 0 !important;
|
|
388
|
+
border: none !important;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/* Links */
|
|
392
|
+
.overtype-wrapper .overtype-preview a {
|
|
393
|
+
color: var(--link, #0d3b66) !important;
|
|
394
|
+
text-decoration: underline !important;
|
|
395
|
+
font-weight: normal !important;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.overtype-wrapper .overtype-preview a:hover {
|
|
399
|
+
text-decoration: underline !important;
|
|
400
|
+
color: var(--link, #0d3b66) !important;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/* Lists - no list styling */
|
|
404
|
+
.overtype-wrapper .overtype-preview ul,
|
|
405
|
+
.overtype-wrapper .overtype-preview ol {
|
|
406
|
+
list-style: none !important;
|
|
407
|
+
margin: 0 !important;
|
|
408
|
+
padding: 0 !important;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
/* Horizontal rules */
|
|
413
|
+
.overtype-wrapper .overtype-preview hr {
|
|
414
|
+
border: none !important;
|
|
415
|
+
color: var(--hr, #5a7a9b) !important;
|
|
416
|
+
margin: 0 !important;
|
|
417
|
+
padding: 0 !important;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
.overtype-wrapper .overtype-preview .hr-marker {
|
|
421
|
+
color: var(--hr, #5a7a9b) !important;
|
|
422
|
+
opacity: 0.6 !important;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/* Code fence markers - with background when not in code block */
|
|
426
|
+
.overtype-wrapper .overtype-preview .code-fence {
|
|
427
|
+
color: var(--code, #0d3b66) !important;
|
|
428
|
+
background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/* Code block lines - background for entire code block */
|
|
432
|
+
.overtype-wrapper .overtype-preview .code-block-line {
|
|
433
|
+
background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/* Remove background from code fence when inside code block line */
|
|
437
|
+
.overtype-wrapper .overtype-preview .code-block-line .code-fence {
|
|
438
|
+
background: transparent !important;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/* Raw markdown line */
|
|
442
|
+
.overtype-wrapper .overtype-preview .raw-line {
|
|
443
|
+
color: var(--raw-line, #5a7a9b) !important;
|
|
444
|
+
font-style: normal !important;
|
|
445
|
+
font-weight: normal !important;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/* Syntax markers */
|
|
449
|
+
.overtype-wrapper .overtype-preview .syntax-marker {
|
|
450
|
+
color: var(--syntax-marker, rgba(13, 59, 102, 0.52)) !important;
|
|
451
|
+
opacity: 0.7 !important;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/* List markers */
|
|
455
|
+
.overtype-wrapper .overtype-preview .list-marker {
|
|
456
|
+
color: var(--list-marker, #ee964b) !important;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/* Stats bar */
|
|
460
|
+
|
|
461
|
+
/* Stats bar - positioned by flexbox */
|
|
462
|
+
.overtype-stats {
|
|
463
|
+
height: 40px !important;
|
|
464
|
+
padding: 0 20px !important;
|
|
465
|
+
background: var(--bg-secondary, #f8f9fa) !important;
|
|
466
|
+
border-top: 1px solid var(--border, #e0e0e0) !important;
|
|
467
|
+
display: flex !important;
|
|
468
|
+
justify-content: space-between !important;
|
|
469
|
+
align-items: center !important;
|
|
470
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
|
|
471
|
+
font-size: 0.85rem !important;
|
|
472
|
+
color: var(--text-secondary, #666) !important;
|
|
473
|
+
flex-shrink: 0 !important; /* Don't shrink */
|
|
474
|
+
z-index: 10001 !important; /* Above link tooltip */
|
|
475
|
+
position: relative !important; /* Enable z-index */
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
.overtype-stats .overtype-stat {
|
|
480
|
+
display: flex !important;
|
|
481
|
+
align-items: center !important;
|
|
482
|
+
gap: 5px !important;
|
|
483
|
+
white-space: nowrap !important;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
.overtype-stats .live-dot {
|
|
487
|
+
width: 8px !important;
|
|
488
|
+
height: 8px !important;
|
|
489
|
+
background: #4caf50 !important;
|
|
490
|
+
border-radius: 50% !important;
|
|
491
|
+
animation: overtype-pulse 2s infinite !important;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
@keyframes overtype-pulse {
|
|
495
|
+
0%, 100% { opacity: 1; transform: scale(1); }
|
|
496
|
+
50% { opacity: 0.6; transform: scale(1.2); }
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
/* Toolbar Styles */
|
|
501
|
+
.overtype-toolbar.overtype-toolbar-hidden {
|
|
502
|
+
display: none !important;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
.overtype-toolbar {
|
|
506
|
+
display: flex !important;
|
|
507
|
+
align-items: center !important;
|
|
508
|
+
gap: 4px !important;
|
|
509
|
+
padding: 8px !important; /* Override reset */
|
|
510
|
+
background: var(--toolbar-bg, var(--bg-primary, #f8f9fa)) !important; /* Override reset */
|
|
511
|
+
border-bottom: 1px solid var(--toolbar-border, transparent) !important; /* Override reset */
|
|
512
|
+
overflow-x: auto !important; /* Allow horizontal scrolling */
|
|
513
|
+
overflow-y: hidden !important; /* Hide vertical overflow */
|
|
514
|
+
-webkit-overflow-scrolling: touch !important;
|
|
515
|
+
flex-shrink: 0 !important;
|
|
516
|
+
height: auto !important;
|
|
517
|
+
position: relative !important; /* Override reset */
|
|
518
|
+
z-index: 100 !important; /* Ensure toolbar is above wrapper */
|
|
519
|
+
scrollbar-width: thin; /* Thin scrollbar on Firefox */
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/* Thin scrollbar styling */
|
|
523
|
+
.overtype-toolbar::-webkit-scrollbar {
|
|
524
|
+
height: 4px;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
.overtype-toolbar::-webkit-scrollbar-track {
|
|
528
|
+
background: transparent;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
.overtype-toolbar::-webkit-scrollbar-thumb {
|
|
532
|
+
background: rgba(0, 0, 0, 0.2);
|
|
533
|
+
border-radius: 2px;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
.overtype-toolbar-button {
|
|
537
|
+
display: flex;
|
|
538
|
+
align-items: center;
|
|
539
|
+
justify-content: center;
|
|
540
|
+
width: 32px;
|
|
541
|
+
height: 32px;
|
|
542
|
+
padding: 0;
|
|
543
|
+
border: none;
|
|
544
|
+
border-radius: 6px;
|
|
545
|
+
background: transparent;
|
|
546
|
+
color: var(--toolbar-icon, var(--text-secondary, #666));
|
|
547
|
+
cursor: pointer;
|
|
548
|
+
transition: all 0.2s ease;
|
|
549
|
+
flex-shrink: 0;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.overtype-toolbar-button svg {
|
|
553
|
+
width: 20px;
|
|
554
|
+
height: 20px;
|
|
555
|
+
fill: currentColor;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
.overtype-toolbar-button:hover {
|
|
559
|
+
background: var(--toolbar-hover, var(--bg-secondary, #e9ecef));
|
|
560
|
+
color: var(--toolbar-icon, var(--text-primary, #333));
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
.overtype-toolbar-button:active {
|
|
564
|
+
transform: scale(0.95);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
.overtype-toolbar-button.active {
|
|
568
|
+
background: var(--toolbar-active, var(--primary, #007bff));
|
|
569
|
+
color: var(--toolbar-icon, var(--text-primary, #333));
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
.overtype-toolbar-button:disabled {
|
|
573
|
+
opacity: 0.5;
|
|
574
|
+
cursor: not-allowed;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
.overtype-toolbar-separator {
|
|
578
|
+
width: 1px;
|
|
579
|
+
height: 24px;
|
|
580
|
+
background: var(--border, #e0e0e0);
|
|
581
|
+
margin: 0 4px;
|
|
582
|
+
flex-shrink: 0;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/* Adjust wrapper when toolbar is present */
|
|
586
|
+
/* Mobile toolbar adjustments */
|
|
587
|
+
@media (max-width: 640px) {
|
|
588
|
+
.overtype-toolbar {
|
|
589
|
+
padding: 6px;
|
|
590
|
+
gap: 2px;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
.overtype-toolbar-button {
|
|
594
|
+
width: 36px;
|
|
595
|
+
height: 36px;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
.overtype-toolbar-separator {
|
|
599
|
+
margin: 0 2px;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/* Plain mode - hide preview and show textarea text */
|
|
604
|
+
.overtype-container[data-mode="plain"] .overtype-preview {
|
|
605
|
+
display: none !important;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
.overtype-container[data-mode="plain"] .overtype-input {
|
|
609
|
+
color: var(--text, #0d3b66) !important;
|
|
610
|
+
/* Use system font stack for better plain text readability */
|
|
611
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
612
|
+
"Helvetica Neue", Arial, sans-serif !important;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/* Ensure textarea remains transparent in overlay mode */
|
|
616
|
+
.overtype-container:not([data-mode="plain"]) .overtype-input {
|
|
617
|
+
color: transparent !important;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/* Dropdown menu styles */
|
|
621
|
+
.overtype-toolbar-button {
|
|
622
|
+
position: relative !important; /* Override reset - needed for dropdown */
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
.overtype-toolbar-button.dropdown-active {
|
|
626
|
+
background: var(--toolbar-active, var(--hover-bg, #f0f0f0));
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
.overtype-dropdown-menu {
|
|
630
|
+
position: fixed !important; /* Fixed positioning relative to viewport */
|
|
631
|
+
background: var(--bg-secondary, white) !important; /* Override reset */
|
|
632
|
+
border: 1px solid var(--border, #e0e0e0) !important; /* Override reset */
|
|
633
|
+
border-radius: 6px;
|
|
634
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important; /* Override reset */
|
|
635
|
+
z-index: 10000; /* Very high z-index to ensure visibility */
|
|
636
|
+
min-width: 150px;
|
|
637
|
+
padding: 4px 0 !important; /* Override reset */
|
|
638
|
+
/* Position will be set via JavaScript based on button position */
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.overtype-dropdown-item {
|
|
642
|
+
display: flex;
|
|
643
|
+
align-items: center;
|
|
644
|
+
width: 100%;
|
|
645
|
+
padding: 8px 12px;
|
|
646
|
+
border: none;
|
|
647
|
+
background: none;
|
|
648
|
+
text-align: left;
|
|
649
|
+
cursor: pointer;
|
|
650
|
+
font-size: 14px;
|
|
651
|
+
color: var(--text, #333);
|
|
652
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
.overtype-dropdown-item:hover {
|
|
656
|
+
background: var(--hover-bg, #f0f0f0);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
.overtype-dropdown-item.active {
|
|
660
|
+
font-weight: 600;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
.overtype-dropdown-check {
|
|
664
|
+
width: 16px;
|
|
665
|
+
margin-right: 8px;
|
|
666
|
+
color: var(--h1, #007bff);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
.overtype-dropdown-icon {
|
|
670
|
+
width: 20px;
|
|
671
|
+
margin-right: 8px;
|
|
672
|
+
text-align: center;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/* Preview mode styles */
|
|
676
|
+
.overtype-container[data-mode="preview"] .overtype-input {
|
|
677
|
+
display: none !important;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
.overtype-container[data-mode="preview"] .overtype-preview {
|
|
681
|
+
pointer-events: auto !important;
|
|
682
|
+
user-select: text !important;
|
|
683
|
+
cursor: text !important;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
.overtype-container.overtype-auto-resize[data-mode="preview"] .overtype-preview {
|
|
687
|
+
position: static !important;
|
|
688
|
+
height: auto !important;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/* Hide syntax markers in preview mode */
|
|
692
|
+
.overtype-container[data-mode="preview"] .syntax-marker {
|
|
693
|
+
display: none !important;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/* Hide URL part of links in preview mode - extra specificity */
|
|
697
|
+
.overtype-container[data-mode="preview"] .syntax-marker.url-part,
|
|
698
|
+
.overtype-container[data-mode="preview"] .url-part {
|
|
699
|
+
display: none !important;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/* Hide all syntax markers inside links too */
|
|
703
|
+
.overtype-container[data-mode="preview"] a .syntax-marker {
|
|
704
|
+
display: none !important;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/* Headers - restore proper sizing in preview mode */
|
|
708
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1,
|
|
709
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2,
|
|
710
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 {
|
|
711
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
|
|
712
|
+
font-weight: 600 !important;
|
|
713
|
+
margin: 0 !important;
|
|
714
|
+
display: block !important;
|
|
715
|
+
line-height: 1 !important;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1 {
|
|
719
|
+
font-size: 2em !important;
|
|
720
|
+
color: var(--preview-h1, var(--preview-h1-default)) !important;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2 {
|
|
724
|
+
font-size: 1.5em !important;
|
|
725
|
+
color: var(--preview-h2, var(--preview-h2-default)) !important;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 {
|
|
729
|
+
font-size: 1.17em !important;
|
|
730
|
+
color: var(--preview-h3, var(--preview-h3-default)) !important;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/* Lists - restore list styling in preview mode */
|
|
734
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview ul {
|
|
735
|
+
display: block !important;
|
|
736
|
+
list-style: disc !important;
|
|
737
|
+
padding-left: 2em !important;
|
|
738
|
+
margin: 1em 0 !important;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview ol {
|
|
742
|
+
display: block !important;
|
|
743
|
+
list-style: decimal !important;
|
|
744
|
+
padding-left: 2em !important;
|
|
745
|
+
margin: 1em 0 !important;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li {
|
|
749
|
+
display: list-item !important;
|
|
750
|
+
margin: 0 !important;
|
|
751
|
+
padding: 0 !important;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/* Task list checkboxes - only in preview mode */
|
|
755
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li.task-list {
|
|
756
|
+
list-style: none !important;
|
|
757
|
+
position: relative !important;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li.task-list input[type="checkbox"] {
|
|
761
|
+
margin-right: 0.5em !important;
|
|
762
|
+
cursor: default !important;
|
|
763
|
+
vertical-align: middle !important;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/* Task list in normal mode - keep syntax visible */
|
|
767
|
+
.overtype-container:not([data-mode="preview"]) .overtype-wrapper .overtype-preview li.task-list {
|
|
768
|
+
list-style: none !important;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
.overtype-container:not([data-mode="preview"]) .overtype-wrapper .overtype-preview li.task-list .syntax-marker {
|
|
772
|
+
color: var(--syntax, #999999) !important;
|
|
773
|
+
font-weight: normal !important;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/* Links - make clickable in preview mode */
|
|
777
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview a {
|
|
778
|
+
pointer-events: auto !important;
|
|
779
|
+
cursor: pointer !important;
|
|
780
|
+
color: var(--preview-link, var(--preview-link-default)) !important;
|
|
781
|
+
text-decoration: underline !important;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/* Code blocks - proper pre/code styling in preview mode */
|
|
785
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block {
|
|
786
|
+
background: var(--preview-code-bg, var(--preview-code-bg-default)) !important;
|
|
787
|
+
color: var(--preview-code, var(--preview-code-default)) !important;
|
|
788
|
+
padding: 1.2em !important;
|
|
789
|
+
border-radius: 3px !important;
|
|
790
|
+
overflow-x: auto !important;
|
|
791
|
+
margin: 0 !important;
|
|
792
|
+
display: block !important;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block code {
|
|
796
|
+
background: transparent !important;
|
|
797
|
+
color: inherit !important;
|
|
798
|
+
padding: 0 !important;
|
|
799
|
+
font-family: ${r} !important;
|
|
800
|
+
font-size: 0.9em !important;
|
|
801
|
+
line-height: 1.4 !important;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/* Hide old code block lines and fences in preview mode */
|
|
805
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .code-block-line {
|
|
806
|
+
display: none !important;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .code-fence {
|
|
810
|
+
display: none !important;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/* Blockquotes - enhanced styling in preview mode */
|
|
814
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .blockquote {
|
|
815
|
+
display: block !important;
|
|
816
|
+
border-left: 4px solid var(--preview-blockquote, var(--preview-blockquote-default)) !important;
|
|
817
|
+
color: var(--preview-blockquote, var(--preview-blockquote-default)) !important;
|
|
818
|
+
padding-left: 1em !important;
|
|
819
|
+
margin: 1em 0 !important;
|
|
820
|
+
font-style: italic !important;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/* Typography improvements in preview mode */
|
|
824
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview {
|
|
825
|
+
font-family: Georgia, 'Times New Roman', serif !important;
|
|
826
|
+
font-size: 16px !important;
|
|
827
|
+
line-height: 1.8 !important;
|
|
828
|
+
color: var(--preview-text, var(--preview-text-default)) !important;
|
|
829
|
+
background: var(--preview-bg, var(--preview-bg-default)) !important;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
/* Inline code in preview mode - keep monospace */
|
|
833
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview code {
|
|
834
|
+
font-family: ${r} !important;
|
|
835
|
+
font-size: 0.9em !important;
|
|
836
|
+
background: var(--preview-code-bg, var(--preview-code-bg-default)) !important;
|
|
837
|
+
color: var(--preview-code, var(--preview-code-default)) !important;
|
|
838
|
+
padding: 0.2em 0.4em !important;
|
|
839
|
+
border-radius: 3px !important;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/* Strong and em elements in preview mode */
|
|
843
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview strong {
|
|
844
|
+
font-weight: 700 !important;
|
|
845
|
+
color: var(--preview-strong, var(--preview-strong-default)) !important;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview em {
|
|
849
|
+
font-style: italic !important;
|
|
850
|
+
color: var(--preview-em, var(--preview-em-default)) !important;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/* HR in preview mode */
|
|
854
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .hr-marker {
|
|
855
|
+
display: block !important;
|
|
856
|
+
border-top: 2px solid var(--preview-hr, var(--preview-hr-default)) !important;
|
|
857
|
+
text-indent: -9999px !important;
|
|
858
|
+
height: 2px !important;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
/* Link Tooltip */
|
|
862
|
+
.overtype-link-tooltip {
|
|
863
|
+
background: #333 !important;
|
|
864
|
+
color: white !important;
|
|
865
|
+
padding: 6px 10px !important;
|
|
866
|
+
border-radius: 16px !important;
|
|
867
|
+
font-size: 12px !important;
|
|
868
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
|
|
869
|
+
display: flex !important;
|
|
870
|
+
visibility: hidden !important;
|
|
871
|
+
pointer-events: none !important;
|
|
872
|
+
z-index: 10000 !important;
|
|
873
|
+
cursor: pointer !important;
|
|
874
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
|
|
875
|
+
max-width: 300px !important;
|
|
876
|
+
white-space: nowrap !important;
|
|
877
|
+
overflow: hidden !important;
|
|
878
|
+
text-overflow: ellipsis !important;
|
|
879
|
+
position: fixed;
|
|
880
|
+
top: 0;
|
|
881
|
+
left: 0;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
.overtype-link-tooltip.visible {
|
|
885
|
+
visibility: visible !important;
|
|
886
|
+
pointer-events: auto !important;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
${s}
|
|
890
|
+
`}var Hi={};oi(Hi,{applyCustomFormat:()=>qt,default:()=>ji,expandSelection:()=>Ut,getActiveFormats:()=>nt,getDebugMode:()=>qe,hasFormat:()=>Vt,insertHeader:()=>de,insertLink:()=>Qe,preserveSelection:()=>zt,setDebugMode:()=>Ft,setUndoMethod:()=>Ot,toggleBold:()=>Ze,toggleBulletList:()=>Xe,toggleCode:()=>Je,toggleH1:()=>tt,toggleH2:()=>it,toggleH3:()=>rt,toggleItalic:()=>Ge,toggleNumberedList:()=>Ye,toggleQuote:()=>et,toggleTaskList:()=>we});var $i=Object.defineProperty,gt=Object.getOwnPropertySymbols,Ii=Object.prototype.hasOwnProperty,_i=Object.prototype.propertyIsEnumerable,yt=(e,t,i)=>t in e?$i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,bt=(e,t)=>{for(var i in t||(t={}))Ii.call(t,i)&&yt(e,i,t[i]);if(gt)for(var i of gt(t))_i.call(t,i)&&yt(e,i,t[i]);return e},D={bold:{prefix:"**",suffix:"**",trimFirst:!0},italic:{prefix:"_",suffix:"_",trimFirst:!0},code:{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"},link:{prefix:"[",suffix:"](url)",replaceNext:"url",scanFor:"https?://"},bulletList:{prefix:"- ",multiline:!0,unorderedList:!0},numberedList:{prefix:"1. ",multiline:!0,orderedList:!0},quote:{prefix:"> ",multiline:!0,surroundWithNewlines:!0},taskList:{prefix:"- [ ] ",multiline:!0,surroundWithNewlines:!0},header1:{prefix:"# "},header2:{prefix:"## "},header3:{prefix:"### "},header4:{prefix:"#### "},header5:{prefix:"##### "},header6:{prefix:"###### "}};function Mi(){return{prefix:"",suffix:"",blockPrefix:"",blockSuffix:"",multiline:!1,replaceNext:"",prefixSpace:!1,scanFor:"",surroundWithNewlines:!1,orderedList:!1,unorderedList:!1,trimFirst:!1}}function F(e){return bt(bt({},Mi()),e)}var ce=!1;function Ft(e){ce=e}function qe(){return ce}function x(e,t,i){ce&&(console.group(`\u{1F50D} ${e}`),console.log(t),i&&console.log("Data:",i),console.groupEnd())}function be(e,t){if(!ce)return;let i=e.value.slice(e.selectionStart,e.selectionEnd);console.group(`\u{1F4CD} Selection: ${t}`),console.log("Position:",`${e.selectionStart}-${e.selectionEnd}`),console.log("Selected text:",JSON.stringify(i)),console.log("Length:",i.length);let r=e.value.slice(Math.max(0,e.selectionStart-10),e.selectionStart),n=e.value.slice(e.selectionEnd,Math.min(e.value.length,e.selectionEnd+10));console.log("Context:",JSON.stringify(r)+"[SELECTION]"+JSON.stringify(n)),console.groupEnd()}function Rt(e){ce&&(console.group("\u{1F4DD} Result"),console.log("Text to insert:",JSON.stringify(e.text)),console.log("New selection:",`${e.selectionStart}-${e.selectionEnd}`),console.groupEnd())}var H=null;function O(e,{text:t,selectionStart:i,selectionEnd:r}){let n=qe();n&&(console.group("\u{1F527} insertText"),console.log("Current selection:",`${e.selectionStart}-${e.selectionEnd}`),console.log("Text to insert:",JSON.stringify(t)),console.log("New selection to set:",i,"-",r)),e.focus();let o=e.selectionStart,a=e.selectionEnd,s=e.value.slice(0,o),p=e.value.slice(a);n&&(console.log("Before text (last 20):",JSON.stringify(s.slice(-20))),console.log("After text (first 20):",JSON.stringify(p.slice(0,20))),console.log("Selected text being replaced:",JSON.stringify(e.value.slice(o,a))));let l=e.value,c=o!==a;if(H===null||H===!0){e.contentEditable="true";try{H=document.execCommand("insertText",!1,t),n&&console.log("execCommand returned:",H,"for text with",t.split(`
|
|
891
|
+
`).length,"lines")}catch(d){H=!1,n&&console.log("execCommand threw error:",d)}e.contentEditable="false"}if(n&&(console.log("canInsertText before:",H),console.log("execCommand result:",H)),H){let d=s+t+p,h=e.value;n&&(console.log("Expected length:",d.length),console.log("Actual length:",h.length)),h!==d&&n&&(console.log("execCommand changed the value but not as expected"),console.log("Expected:",JSON.stringify(d.slice(0,100))),console.log("Actual:",JSON.stringify(h.slice(0,100))))}if(!H)if(n&&console.log("Using manual insertion"),e.value===l){n&&console.log("Value unchanged, doing manual replacement");try{document.execCommand("ms-beginUndoUnit")}catch{}e.value=s+t+p;try{document.execCommand("ms-endUndoUnit")}catch{}e.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0}))}else n&&console.log("Value was changed by execCommand, skipping manual insertion");n&&console.log("Setting selection range:",i,r),i!=null&&r!=null?e.setSelectionRange(i,r):e.setSelectionRange(o,e.selectionEnd),n&&(console.log("Final value length:",e.value.length),console.groupEnd())}function Ot(e){switch(e){case"native":H=!0;break;case"manual":H=!1;break;case"auto":H=null;break}}function Oe(e){return e.trim().split(`
|
|
892
|
+
`).length>1}function Di(e,t){let i=t;for(;e[i]&&e[i-1]!=null&&!e[i-1].match(/\s/);)i--;return i}function Pi(e,t,i){let r=t,n=i?/\n/:/\s/;for(;e[r]&&!e[r].match(n);)r++;return r}function Bt(e){let t=e.value.split(`
|
|
893
|
+
`),i=0;for(let r=0;r<t.length;r++){let n=t[r].length+1;e.selectionStart>=i&&e.selectionStart<i+n&&(e.selectionStart=i),e.selectionEnd>=i&&e.selectionEnd<i+n&&(r===t.length-1?e.selectionEnd=Math.min(i+t[r].length,e.value.length):e.selectionEnd=i+n-1),i+=n}}function Fi(e,t,i,r=!1){if(e.selectionStart===e.selectionEnd)e.selectionStart=Di(e.value,e.selectionStart),e.selectionEnd=Pi(e.value,e.selectionEnd,r);else{let n=e.selectionStart-t.length,o=e.selectionEnd+i.length,a=e.value.slice(n,e.selectionStart)===t,s=e.value.slice(e.selectionEnd,o)===i;a&&s&&(e.selectionStart=n,e.selectionEnd=o)}return e.value.slice(e.selectionStart,e.selectionEnd)}function We(e){let t=e.value.slice(0,e.selectionStart),i=e.value.slice(e.selectionEnd),r=t.match(/\n*$/),n=i.match(/^\n*/),o=r?r[0].length:0,a=n?n[0].length:0,s="",p="";return t.match(/\S/)&&o<2&&(s=`
|
|
894
|
+
`.repeat(2-o)),i.match(/\S/)&&a<2&&(p=`
|
|
895
|
+
`.repeat(2-a)),{newlinesToAppend:s,newlinesToPrepend:p}}function zt(e,t){let i=e.selectionStart,r=e.selectionEnd,n=e.scrollTop;t(),e.selectionStart=i,e.selectionEnd=r,e.scrollTop=n}function Se(e,t,i={}){let r=e.selectionStart,n=e.selectionEnd,o=r===n,a=e.value,s=r;for(;s>0&&a[s-1]!==`
|
|
896
|
+
`;)s--;if(o){let l=r;for(;l<a.length&&a[l]!==`
|
|
897
|
+
`;)l++;e.selectionStart=s,e.selectionEnd=l}else Bt(e);let p=t(e);if(i.adjustSelection){let l=e.value.slice(e.selectionStart,e.selectionEnd).startsWith(i.prefix),c=i.adjustSelection(l,r,n,s);p.selectionStart=c.start,p.selectionEnd=c.end}else if(i.prefix){let l=e.value.slice(e.selectionStart,e.selectionEnd).startsWith(i.prefix);o?l?(p.selectionStart=Math.max(r-i.prefix.length,s),p.selectionEnd=p.selectionStart):(p.selectionStart=r+i.prefix.length,p.selectionEnd=p.selectionStart):l?(p.selectionStart=Math.max(r-i.prefix.length,s),p.selectionEnd=Math.max(n-i.prefix.length,s)):(p.selectionStart=r+i.prefix.length,p.selectionEnd=n+i.prefix.length)}return p}function ee(e,t){let i,r,{prefix:n,suffix:o,blockPrefix:a,blockSuffix:s,replaceNext:p,prefixSpace:l,scanFor:c,surroundWithNewlines:d,trimFirst:h}=t,u=e.selectionStart,f=e.selectionEnd,m=e.value.slice(e.selectionStart,e.selectionEnd),v=Oe(m)&&a&&a.length>0?`${a}
|
|
898
|
+
`:n,y=Oe(m)&&s&&s.length>0?`
|
|
899
|
+
${s}`:o;if(l){let E=e.value[e.selectionStart-1];e.selectionStart!==0&&E!=null&&!E.match(/\s/)&&(v=` ${v}`)}m=Fi(e,v,y,t.multiline);let b=e.selectionStart,w=e.selectionEnd,k=p&&p.length>0&&y.indexOf(p)>-1&&m.length>0;if(d){let E=We(e);i=E.newlinesToAppend,r=E.newlinesToPrepend,v=i+n,y+=r}if(m.startsWith(v)&&m.endsWith(y)){let E=m.slice(v.length,m.length-y.length);if(u===f){let L=u-v.length;L=Math.max(L,b),L=Math.min(L,b+E.length),b=w=L}else w=b+E.length;return{text:E,selectionStart:b,selectionEnd:w}}else if(k)if(c&&c.length>0&&m.match(c)){y=y.replace(p,m);let E=v+y;return b=w=b+v.length,{text:E,selectionStart:b,selectionEnd:w}}else{let E=v+m+y;return b=b+v.length+m.length+y.indexOf(p),w=b+p.length,{text:E,selectionStart:b,selectionEnd:w}}else{let E=v+m+y;b=u+v.length,w=f+v.length;let L=m.match(/^\s*|\s*$/g);if(h&&L){let he=L[0]||"",G=L[1]||"";E=he+v+m.trim()+y+G,b+=he.length,w-=G.length}return{text:E,selectionStart:b,selectionEnd:w}}}function Ke(e,t){let{prefix:i,suffix:r,surroundWithNewlines:n}=t,o=e.value.slice(e.selectionStart,e.selectionEnd),a=e.selectionStart,s=e.selectionEnd,p=o.split(`
|
|
900
|
+
`);if(p.every(l=>l.startsWith(i)&&(!r||l.endsWith(r))))o=p.map(l=>{let c=l.slice(i.length);return r&&(c=c.slice(0,c.length-r.length)),c}).join(`
|
|
901
|
+
`),s=a+o.length;else if(o=p.map(l=>i+l+(r||"")).join(`
|
|
902
|
+
`),n){let{newlinesToAppend:l,newlinesToPrepend:c}=We(e);a+=l.length,s=a+o.length,o=l+o+c}return{text:o,selectionStart:a,selectionEnd:s}}function wt(e){let t=e.split(`
|
|
903
|
+
`),i=/^\d+\.\s+/,r=t.every(o=>i.test(o)),n=t;return r&&(n=t.map(o=>o.replace(i,""))),{text:n.join(`
|
|
904
|
+
`),processed:r}}function xt(e){let t=e.split(`
|
|
905
|
+
`),i="- ",r=t.every(o=>o.startsWith(i)),n=t;return r&&(n=t.map(o=>o.slice(i.length))),{text:n.join(`
|
|
906
|
+
`),processed:r}}function oe(e,t){return t?"- ":`${e+1}. `}function Ri(e,t){let i,r,n;return e.orderedList?(i=wt(t),r=xt(i.text),n=r.text):(i=xt(t),r=wt(i.text),n=r.text),[i,r,n]}function Oi(e,t){let i=e.selectionStart===e.selectionEnd,r=e.selectionStart,n=e.selectionEnd;Bt(e);let o=e.value.slice(e.selectionStart,e.selectionEnd),[a,s,p]=Ri(t,o),l=p.split(`
|
|
907
|
+
`).map((m,v)=>`${oe(v,t.unorderedList)}${m}`),c=l.reduce((m,v,y)=>m+oe(y,t.unorderedList).length,0),d=l.reduce((m,v,y)=>m+oe(y,!t.unorderedList).length,0);if(a.processed)return i?(r=Math.max(r-oe(0,t.unorderedList).length,0),n=r):(r=e.selectionStart,n=e.selectionEnd-c),{text:p,selectionStart:r,selectionEnd:n};let{newlinesToAppend:h,newlinesToPrepend:u}=We(e),f=h+l.join(`
|
|
908
|
+
`)+u;return i?(r=Math.max(r+oe(0,t.unorderedList).length+h.length,0),n=r):s.processed?(r=Math.max(e.selectionStart+h.length,0),n=e.selectionEnd+h.length+c-d):(r=Math.max(e.selectionStart+h.length,0),n=e.selectionEnd+h.length+c),{text:f,selectionStart:r,selectionEnd:n}}function jt(e,t){let i=Se(e,r=>Oi(r,t),{adjustSelection:(r,n,o,a)=>{let s=e.value.slice(a,e.selectionEnd),p=/^\d+\.\s+/,l=/^- /,c=p.test(s),d=l.test(s),h=t.orderedList&&c||t.unorderedList&&d;if(n===o)if(h){let u=s.match(t.orderedList?p:l),f=u?u[0].length:0;return{start:Math.max(n-f,a),end:Math.max(n-f,a)}}else if(c||d){let u=s.match(c?p:l),f=u?u[0].length:0,m=(t.unorderedList?2:3)-f;return{start:n+m,end:n+m}}else{let u=t.unorderedList?2:3;return{start:n+u,end:n+u}}else if(h){let u=s.match(t.orderedList?p:l),f=u?u[0].length:0;return{start:Math.max(n-f,a),end:Math.max(o-f,a)}}else if(c||d){let u=s.match(c?p:l),f=u?u[0].length:0,m=(t.unorderedList?2:3)-f;return{start:n+m,end:o+m}}else{let u=t.unorderedList?2:3;return{start:n+u,end:o+u}}}});O(e,i)}function Nt(e){if(!e)return[];let t=[],{selectionStart:i,selectionEnd:r,value:n}=e,o=n.split(`
|
|
909
|
+
`),a=0,s="";for(let d of o){if(i>=a&&i<=a+d.length){s=d;break}a+=d.length+1}s.startsWith("- ")&&(s.startsWith("- [ ] ")||s.startsWith("- [x] ")?t.push("task-list"):t.push("bullet-list")),/^\d+\.\s/.test(s)&&t.push("numbered-list"),s.startsWith("> ")&&t.push("quote"),s.startsWith("# ")&&t.push("header"),s.startsWith("## ")&&t.push("header-2"),s.startsWith("### ")&&t.push("header-3");let p=Math.max(0,i-10),l=Math.min(n.length,r+10),c=n.slice(p,l);if(c.includes("**")){let d=n.slice(Math.max(0,i-100),i),h=n.slice(r,Math.min(n.length,r+100)),u=d.lastIndexOf("**"),f=h.indexOf("**");u!==-1&&f!==-1&&t.push("bold")}if(c.includes("_")){let d=n.slice(Math.max(0,i-100),i),h=n.slice(r,Math.min(n.length,r+100)),u=d.lastIndexOf("_"),f=h.indexOf("_");u!==-1&&f!==-1&&t.push("italic")}if(c.includes("`")){let d=n.slice(Math.max(0,i-100),i),h=n.slice(r,Math.min(n.length,r+100));d.includes("`")&&h.includes("`")&&t.push("code")}if(c.includes("[")&&c.includes("]")){let d=n.slice(Math.max(0,i-100),i),h=n.slice(r,Math.min(n.length,r+100)),u=d.lastIndexOf("["),f=h.indexOf("]");u!==-1&&f!==-1&&n.slice(r+f+1,r+f+10).startsWith("(")&&t.push("link")}return t}function Bi(e,t){return Nt(e).includes(t)}function zi(e,t={}){if(!e)return;let{toWord:i,toLine:r,toFormat:n}=t,{selectionStart:o,selectionEnd:a,value:s}=e;if(r){let p=s.split(`
|
|
910
|
+
`),l=0,c=0,d=0;for(let h of p){if(o>=d&&o<=d+h.length){l=d,c=d+h.length;break}d+=h.length+1}e.selectionStart=l,e.selectionEnd=c}else if(i&&o===a){let p=o,l=a;for(;p>0&&!/\s/.test(s[p-1]);)p--;for(;l<s.length&&!/\s/.test(s[l]);)l++;e.selectionStart=p,e.selectionEnd=l}}function Ze(e){if(!e||e.disabled||e.readOnly)return;x("toggleBold","Starting"),be(e,"Before");let t=F(D.bold),i=ee(e,t);Rt(i),O(e,i),be(e,"After")}function Ge(e){if(!e||e.disabled||e.readOnly)return;let t=F(D.italic),i=ee(e,t);O(e,i)}function Je(e){if(!e||e.disabled||e.readOnly)return;let t=F(D.code),i=ee(e,t);O(e,i)}function Qe(e,t={}){if(!e||e.disabled||e.readOnly)return;let i=e.value.slice(e.selectionStart,e.selectionEnd),r=F(D.link);if(i&&i.match(/^https?:\/\//)&&!t.url?(r.suffix=`](${i})`,r.replaceNext=""):t.url&&(r.suffix=`](${t.url})`,r.replaceNext=""),t.text&&!i){let o=e.selectionStart;e.value=e.value.slice(0,o)+t.text+e.value.slice(o),e.selectionStart=o,e.selectionEnd=o+t.text.length}let n=ee(e,r);O(e,n)}function Xe(e){if(!e||e.disabled||e.readOnly)return;let t=F(D.bulletList);jt(e,t)}function Ye(e){if(!e||e.disabled||e.readOnly)return;let t=F(D.numberedList);jt(e,t)}function et(e){if(!e||e.disabled||e.readOnly)return;x("toggleQuote","Starting"),be(e,"Initial");let t=F(D.quote),i=Se(e,r=>Ke(r,t),{prefix:t.prefix});Rt(i),O(e,i),be(e,"Final")}function we(e){if(!e||e.disabled||e.readOnly)return;let t=F(D.taskList),i=Se(e,r=>Ke(r,t),{prefix:t.prefix});O(e,i)}function de(e,t=1,i=!1){if(!e||e.disabled||e.readOnly)return;(t<1||t>6)&&(t=1),x("insertHeader","============ START ============"),x("insertHeader",`Level: ${t}, Toggle: ${i}`),x("insertHeader",`Initial cursor: ${e.selectionStart}-${e.selectionEnd}`);let r=`header${t===1?"1":t}`,n=F(D[r]||D.header1);x("insertHeader",`Style prefix: "${n.prefix}"`);let o=e.value,a=e.selectionStart,s=e.selectionEnd,p=a;for(;p>0&&o[p-1]!==`
|
|
911
|
+
`;)p--;let l=s;for(;l<o.length&&o[l]!==`
|
|
912
|
+
`;)l++;let c=o.slice(p,l);x("insertHeader",`Current line (before): "${c}"`);let d=c.match(/^(#{1,6})\s*/),h=d?d[1].length:0,u=d?d[0].length:0;x("insertHeader","Existing header check:"),x("insertHeader",` - Match: ${d?`"${d[0]}"`:"none"}`),x("insertHeader",` - Existing level: ${h}`),x("insertHeader",` - Existing prefix length: ${u}`),x("insertHeader",` - Target level: ${t}`);let f=i&&h===t;x("insertHeader",`Should toggle OFF: ${f} (toggle=${i}, existingLevel=${h}, level=${t})`);let m=Se(e,v=>{let y=v.value.slice(v.selectionStart,v.selectionEnd);x("insertHeader",`Line in operation: "${y}"`);let b=y.replace(/^#{1,6}\s*/,"");x("insertHeader",`Cleaned line: "${b}"`);let w;return f?(x("insertHeader","ACTION: Toggling OFF - removing header"),w=b):h>0?(x("insertHeader",`ACTION: Replacing H${h} with H${t}`),w=n.prefix+b):(x("insertHeader","ACTION: Adding new header"),w=n.prefix+b),x("insertHeader",`New line: "${w}"`),{text:w,selectionStart:v.selectionStart,selectionEnd:v.selectionEnd}},{prefix:n.prefix,adjustSelection:(v,y,b,w)=>{if(x("insertHeader","Adjusting selection:"),x("insertHeader",` - isRemoving param: ${v}`),x("insertHeader",` - shouldToggleOff: ${f}`),x("insertHeader",` - selStart: ${y}, selEnd: ${b}`),x("insertHeader",` - lineStartPos: ${w}`),f){let k=Math.max(y-u,w);return x("insertHeader",` - Removing header, adjusting by -${u}`),{start:k,end:y===b?k:Math.max(b-u,w)}}else if(u>0){let k=n.prefix.length-u;return x("insertHeader",` - Replacing header, adjusting by ${k}`),{start:y+k,end:b+k}}else return x("insertHeader",` - Adding header, adjusting by +${n.prefix.length}`),{start:y+n.prefix.length,end:b+n.prefix.length}}});x("insertHeader",`Final result: text="${m.text}", cursor=${m.selectionStart}-${m.selectionEnd}`),x("insertHeader","============ END ============"),O(e,m)}function tt(e){de(e,1,!0)}function it(e){de(e,2,!0)}function rt(e){de(e,3,!0)}function nt(e){return Nt(e)}function Vt(e,t){return Bi(e,t)}function Ut(e,t={}){zi(e,t)}function qt(e,t){if(!e||e.disabled||e.readOnly)return;let i=F(t),r;if(i.multiline){let n=e.value.slice(e.selectionStart,e.selectionEnd);Oe(n)?r=Ke(e,i):r=ee(e,i)}else r=ee(e,i);O(e,r)}var ji={toggleBold:Ze,toggleItalic:Ge,toggleCode:Je,insertLink:Qe,toggleBulletList:Xe,toggleNumberedList:Ye,toggleQuote:et,toggleTaskList:we,insertHeader:de,toggleH1:tt,toggleH2:it,toggleH3:rt,getActiveFormats:nt,hasFormat:Vt,expandSelection:Ut,applyCustomFormat:qt,preserveSelection:zt,setUndoMethod:Ot,setDebugMode:Ft,getDebugMode:qe},Ni=class{constructor(e,t={}){this.editor=e,this.container=null,this.buttons={},this.currentItemIndex=0,this.handleDocumentClick=null,this.activeDropdown=null,this.activeDropdownButton=null,this.toolbarButtons=t.toolbarButtons||[]}create(){this.container=document.createElement("div"),this.container.className="overtype-toolbar",this.editor._markChrome(this.container),this.container.id=this.getInstanceElementId("toolbar"),this.container.setAttribute("role","toolbar"),this.container.setAttribute("aria-label","Formatting toolbar"),this.container.setAttribute("aria-controls",this.editor.textarea.id),this.toolbarButtons.forEach(e=>{if(e.name==="separator"){let t=this.createSeparator();this.container.appendChild(t)}else{let t=this.createButton(e);this.buttons[e.name]=t,this.container.appendChild(t)}}),this.setupRovingTabIndex(),this.updateButtonStates(),this.editor.container.insertBefore(this.container,this.editor.wrapper)}getInstanceElementId(e){return`overtype-${this.editor.instanceId}-${e}`}setupRovingTabIndex(){this.getToolbarItems().length!==0&&(this.currentItemIndex=this.getValidItemIndex(this.currentItemIndex),this.updateTabIndexes(),this.container.addEventListener("keydown",e=>{this.onToolbarKeydown(e)}),this.container.addEventListener("focusin",e=>{this.onToolbarFocusin(e)}))}getToolbarItems(){return this.container?Array.from(this.container.querySelectorAll(".overtype-toolbar-button")):[]}onToolbarKeydown(e){let t=this.getToolbarItems();if(t.includes(e.target))switch(e.key){case"ArrowRight":e.preventDefault(),this.focusItem(this.currentItemIndex+1);break;case"ArrowLeft":e.preventDefault(),this.focusItem(this.currentItemIndex-1);break;case"Home":e.preventDefault(),this.focusItem(0);break;case"End":e.preventDefault(),this.focusItem(t.length-1);break}}onToolbarFocusin(e){let t=this.getToolbarItems().indexOf(e.target);t!==-1&&(this.currentItemIndex=t,this.updateTabIndexes())}focusItem(e){let t=this.getToolbarItems();t.length!==0&&(this.currentItemIndex=this.getValidItemIndex(e,t),this.updateTabIndexes(),t[this.currentItemIndex].focus())}getValidItemIndex(e,t=this.getToolbarItems()){let i=t.length;return i===0?0:e<0?i-1:e>=i?0:e}updateTabIndexes(){this.getToolbarItems().forEach((e,t)=>{e.tabIndex=t===this.currentItemIndex?0:-1})}createSeparator(){let e=document.createElement("div");return e.className="overtype-toolbar-separator",e.setAttribute("role","separator"),e}createButton(e){let t=document.createElement("button");return t.className="overtype-toolbar-button",t.type="button",t.setAttribute("data-button",e.name),t.title=e.title||"",t.setAttribute("aria-label",e.title||e.name),t.innerHTML=this.sanitizeSVG(e.icon||""),e.name==="viewMode"?(t.classList.add("has-dropdown"),t.dataset.dropdown="true",t.setAttribute("aria-haspopup","menu"),t.setAttribute("aria-expanded","false"),t._clickHandler=i=>{i.preventDefault(),this.toggleViewModeDropdown(t)},t._keydownHandler=i=>{if(!["ArrowDown","ArrowUp","Enter"," "].includes(i.key))return;i.preventDefault();let r=i.key==="ArrowUp"?"last":"current";this.openViewModeDropdown(t,r)},t.addEventListener("click",t._clickHandler),t.addEventListener("keydown",t._keydownHandler),t):(t._clickHandler=i=>{i.preventDefault();let r=e.actionId||e.name;this.editor.performAction(r,i)},t.addEventListener("click",t._clickHandler),t)}async handleAction(e){if(e&&typeof e=="object"&&typeof e.action=="function"){this.editor.textarea.focus();try{return await e.action({editor:this.editor,getValue:()=>this.editor.getValue(),setValue:t=>this.editor.setValue(t),event:null}),!0}catch(t){return console.error(`Action "${e.name}" error:`,t),this.editor.wrapper.dispatchEvent(new CustomEvent("button-error",{detail:{buttonName:e.name,error:t}})),!1}}return typeof e=="string"?this.editor.performAction(e,null):!1}sanitizeSVG(e){return typeof e!="string"?"":e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/\son\w+\s*=\s*["'][^"']*["']/gi,"").replace(/\son\w+\s*=\s*[^\s>]*/gi,"")}toggleViewModeDropdown(e){if(this.activeDropdown){this.closeViewModeDropdown(e);return}this.openViewModeDropdown(e)}openViewModeDropdown(e,t=null){this.closeViewModeDropdown(e),e.classList.add("dropdown-active");let i=this.createViewModeDropdown(e),r=e.getBoundingClientRect();i.style.position="absolute",i.style.top=`${r.bottom+5}px`,i.style.left=`${r.left}px`,document.body.appendChild(i),this.activeDropdown=i,this.activeDropdownButton=e,e.setAttribute("aria-controls",i.id),e.setAttribute("aria-expanded","true"),this.handleDocumentClick=n=>{!i.contains(n.target)&&!e.contains(n.target)&&this.closeViewModeDropdown(e)},setTimeout(()=>{document.addEventListener("click",this.handleDocumentClick)},0),t&&this.focusViewModeMenuItem(i,t)}closeViewModeDropdown(e=this.activeDropdownButton,t=!1){this.activeDropdown&&(this.activeDropdown.remove(),this.activeDropdown=null),e&&(e.classList.remove("dropdown-active"),e.setAttribute("aria-expanded","false")),this.handleDocumentClick&&(document.removeEventListener("click",this.handleDocumentClick),this.handleDocumentClick=null),this.activeDropdownButton=null,t&&e&&e.focus()}createViewModeDropdown(e){let t=document.createElement("div");t.className="overtype-dropdown-menu",this.editor._markChrome(t),t.id=this.getInstanceElementId("toolbar-view-mode-menu"),t.setAttribute("role","menu"),t.setAttribute("aria-label","View mode"),t.addEventListener("keydown",n=>{this.onViewModeMenuKeydown(n,e)});let i=[{id:"normal",label:"Normal Edit",icon:"\u2713"},{id:"plain",label:"Plain Textarea",icon:"\u2713"},{id:"preview",label:"Preview Mode",icon:"\u2713"}],r=this.editor.container.dataset.mode||"normal";return i.forEach(n=>{let o=document.createElement("button");if(o.className="overtype-dropdown-item",o.type="button",o.tabIndex=-1,o.setAttribute("role","menuitemradio"),o.setAttribute("aria-checked",String(n.id===r)),o.textContent=n.label,n.id===r){o.classList.add("active");let a=document.createElement("span");a.className="overtype-dropdown-icon",a.setAttribute("aria-hidden","true"),a.textContent=n.icon,o.prepend(a)}o.addEventListener("click",a=>{switch(a.preventDefault(),n.id){case"plain":this.editor.showPlainTextarea();break;case"preview":this.editor.showPreviewMode();break;default:this.editor.showNormalEditMode();break}this.closeViewModeDropdown(e,!0)}),t.appendChild(o)}),t}onViewModeMenuKeydown(e,t){let i=this.getViewModeMenuItems().indexOf(e.target);if(i!==-1)switch(e.key){case"ArrowDown":e.preventDefault(),this.focusViewModeMenuItem(this.activeDropdown,i+1);break;case"ArrowUp":e.preventDefault(),this.focusViewModeMenuItem(this.activeDropdown,i-1);break;case"Home":e.preventDefault(),this.focusViewModeMenuItem(this.activeDropdown,"first");break;case"End":e.preventDefault(),this.focusViewModeMenuItem(this.activeDropdown,"last");break;case"Escape":e.preventDefault(),this.closeViewModeDropdown(t,!0);break}}focusViewModeMenuItem(e,t){let i=this.getViewModeMenuItems(e);if(i.length===0)return;let r=t;t==="first"?r=0:t==="last"?r=i.length-1:t==="current"&&(r=i.findIndex(n=>n.getAttribute("aria-checked")==="true")),r<0&&(r=i.length-1),r>=i.length&&(r=0),i[r].focus()}getViewModeMenuItems(e=this.activeDropdown){return e?Array.from(e.querySelectorAll('[role="menuitemradio"]')):[]}updateButtonStates(){var e;try{let t=((e=nt)==null?void 0:e(this.editor.textarea,this.editor.textarea.selectionStart))||[];Object.entries(this.buttons).forEach(([i,r])=>{if(i==="viewMode")return;let n=this.toolbarButtons.find(a=>a.name===i);if(!n?.isActive)return;let o=!!n.isActive({editor:this.editor,activeFormats:t});r.classList.toggle("active",o),r.setAttribute("aria-pressed",o.toString())})}catch{}}show(){this.container&&this.container.classList.remove("overtype-toolbar-hidden")}hide(){this.container&&this.container.classList.add("overtype-toolbar-hidden")}destroy(){this.container&&(this.activeDropdown?this.closeViewModeDropdown():this.handleDocumentClick&&(document.removeEventListener("click",this.handleDocumentClick),this.handleDocumentClick=null),Object.values(this.buttons).forEach(e=>{e._clickHandler&&(e.removeEventListener("click",e._clickHandler),delete e._clickHandler),e._keydownHandler&&(e.removeEventListener("keydown",e._keydownHandler),delete e._keydownHandler)}),this.container.remove(),this.container=null,this.buttons={})}},Be=Math.min,X=Math.max,xe=Math.round,M=e=>({x:e,y:e}),Vi={left:"right",right:"left",bottom:"top",top:"bottom"},Ui={start:"end",end:"start"};function kt(e,t,i){return X(e,Be(t,i))}function Le(e,t){return typeof e=="function"?e(t):e}function Z(e){return e.split("-")[0]}function Te(e){return e.split("-")[1]}function Wt(e){return e==="x"?"y":"x"}function Kt(e){return e==="y"?"height":"width"}var qi=new Set(["top","bottom"]);function V(e){return qi.has(Z(e))?"y":"x"}function Zt(e){return Wt(V(e))}function Wi(e,t,i){i===void 0&&(i=!1);let r=Te(e),n=Zt(e),o=Kt(n),a=n==="x"?r===(i?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=ke(a)),[a,ke(a)]}function Ki(e){let t=ke(e);return[ze(e),t,ze(t)]}function ze(e){return e.replace(/start|end/g,t=>Ui[t])}var Et=["left","right"],St=["right","left"],Zi=["top","bottom"],Gi=["bottom","top"];function Ji(e,t,i){switch(e){case"top":case"bottom":return i?t?St:Et:t?Et:St;case"left":case"right":return t?Zi:Gi;default:return[]}}function Qi(e,t,i,r){let n=Te(e),o=Ji(Z(e),i==="start",r);return n&&(o=o.map(a=>a+"-"+n),t&&(o=o.concat(o.map(ze)))),o}function ke(e){return e.replace(/left|right|bottom|top/g,t=>Vi[t])}function Xi(e){return{top:0,right:0,bottom:0,left:0,...e}}function Yi(e){return typeof e!="number"?Xi(e):{top:e,right:e,bottom:e,left:e}}function Ee(e){let{x:t,y:i,width:r,height:n}=e;return{width:r,height:n,top:i,left:t,right:t+r,bottom:i+n,x:t,y:i}}function Lt(e,t,i){let{reference:r,floating:n}=e,o=V(t),a=Zt(t),s=Kt(a),p=Z(t),l=o==="y",c=r.x+r.width/2-n.width/2,d=r.y+r.height/2-n.height/2,h=r[s]/2-n[s]/2,u;switch(p){case"top":u={x:c,y:r.y-n.height};break;case"bottom":u={x:c,y:r.y+r.height};break;case"right":u={x:r.x+r.width,y:d};break;case"left":u={x:r.x-n.width,y:d};break;default:u={x:r.x,y:r.y}}switch(Te(t)){case"start":u[a]-=h*(i&&l?-1:1);break;case"end":u[a]+=h*(i&&l?-1:1);break}return u}async function er(e,t){var i;t===void 0&&(t={});let{x:r,y:n,platform:o,rects:a,elements:s,strategy:p}=e,{boundary:l="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:h=!1,padding:u=0}=Le(t,e),f=Yi(u),m=s[h?d==="floating"?"reference":"floating":d],v=Ee(await o.getClippingRect({element:(i=await(o.isElement==null?void 0:o.isElement(m)))==null||i?m:m.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(s.floating)),boundary:l,rootBoundary:c,strategy:p})),y=d==="floating"?{x:r,y:n,width:a.floating.width,height:a.floating.height}:a.reference,b=await(o.getOffsetParent==null?void 0:o.getOffsetParent(s.floating)),w=await(o.isElement==null?void 0:o.isElement(b))?await(o.getScale==null?void 0:o.getScale(b))||{x:1,y:1}:{x:1,y:1},k=Ee(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:y,offsetParent:b,strategy:p}):y);return{top:(v.top-k.top+f.top)/w.y,bottom:(k.bottom-v.bottom+f.bottom)/w.y,left:(v.left-k.left+f.left)/w.x,right:(k.right-v.right+f.right)/w.x}}var tr=async(e,t,i)=>{let{placement:r="bottom",strategy:n="absolute",middleware:o=[],platform:a}=i,s=o.filter(Boolean),p=await(a.isRTL==null?void 0:a.isRTL(t)),l=await a.getElementRects({reference:e,floating:t,strategy:n}),{x:c,y:d}=Lt(l,r,p),h=r,u={},f=0;for(let v=0;v<s.length;v++){var m;let{name:y,fn:b}=s[v],{x:w,y:k,data:E,reset:L}=await b({x:c,y:d,initialPlacement:r,placement:h,strategy:n,middlewareData:u,rects:l,platform:{...a,detectOverflow:(m=a.detectOverflow)!=null?m:er},elements:{reference:e,floating:t}});c=w??c,d=k??d,u={...u,[y]:{...u[y],...E}},L&&f<=50&&(f++,typeof L=="object"&&(L.placement&&(h=L.placement),L.rects&&(l=L.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:n}):L.rects),{x:c,y:d}=Lt(l,h,p)),v=-1)}return{x:c,y:d,placement:h,strategy:n,middlewareData:u}},ir=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var i,r;let{placement:n,middlewareData:o,rects:a,initialPlacement:s,platform:p,elements:l}=t,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:m=!0,...v}=Le(e,t);if((i=o.arrow)!=null&&i.alignmentOffset)return{};let y=Z(n),b=V(s),w=Z(s)===s,k=await(p.isRTL==null?void 0:p.isRTL(l.floating)),E=h||(w||!m?[ke(s)]:Ki(s)),L=f!=="none";!h&&L&&E.push(...Qi(s,m,f,k));let he=[s,...E],G=await p.detectOverflow(t,v),fe=[],J=((r=o.flip)==null?void 0:r.overflows)||[];if(c&&fe.push(G[y]),d){let W=Wi(n,a,k);fe.push(G[W[0]],G[W[1]])}if(J=[...J,{placement:n,overflows:fe}],!fe.every(W=>W<=0)){var st,lt;let W=(((st=o.flip)==null?void 0:st.index)||0)+1,Ie=he[W];if(Ie&&(!(d==="alignment"&&b!==V(Ie))||J.every(R=>V(R.placement)===b?R.overflows[0]>0:!0)))return{data:{index:W,overflows:J},reset:{placement:Ie}};let ne=(lt=J.filter(R=>R.overflows[0]<=0).sort((R,z)=>R.overflows[1]-z.overflows[1])[0])==null?void 0:lt.placement;if(!ne)switch(u){case"bestFit":{var pt;let R=(pt=J.filter(z=>{if(L){let j=V(z.placement);return j===b||j==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(j=>j>0).reduce((j,ri)=>j+ri,0)]).sort((z,j)=>z[1]-j[1])[0])==null?void 0:pt[0];R&&(ne=R);break}case"initialPlacement":ne=s;break}if(n!==ne)return{reset:{placement:ne}}}return{}}}},rr=new Set(["left","top"]);async function nr(e,t){let{placement:i,platform:r,elements:n}=e,o=await(r.isRTL==null?void 0:r.isRTL(n.floating)),a=Z(i),s=Te(i),p=V(i)==="y",l=rr.has(a)?-1:1,c=o&&p?-1:1,d=Le(t,e),{mainAxis:h,crossAxis:u,alignmentAxis:f}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof f=="number"&&(u=s==="end"?f*-1:f),p?{x:u*c,y:h*l}:{x:h*l,y:u*c}}var or=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var i,r;let{x:n,y:o,placement:a,middlewareData:s}=t,p=await nr(t,e);return a===((i=s.offset)==null?void 0:i.placement)&&(r=s.arrow)!=null&&r.alignmentOffset?{}:{x:n+p.x,y:o+p.y,data:{...p,placement:a}}}}},ar=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:i,y:r,placement:n,platform:o}=t,{mainAxis:a=!0,crossAxis:s=!1,limiter:p={fn:y=>{let{x:b,y:w}=y;return{x:b,y:w}}},...l}=Le(e,t),c={x:i,y:r},d=await o.detectOverflow(t,l),h=V(Z(n)),u=Wt(h),f=c[u],m=c[h];if(a){let y=u==="y"?"top":"left",b=u==="y"?"bottom":"right",w=f+d[y],k=f-d[b];f=kt(w,f,k)}if(s){let y=h==="y"?"top":"left",b=h==="y"?"bottom":"right",w=m+d[y],k=m-d[b];m=kt(w,m,k)}let v=p.fn({...t,[u]:f,[h]:m});return{...v,data:{x:v.x-i,y:v.y-r,enabled:{[u]:a,[h]:s}}}}}};function Ce(){return typeof window<"u"}function ie(e){return Gt(e)?(e.nodeName||"").toLowerCase():"#document"}function A(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function B(e){var t;return(t=(Gt(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Gt(e){return Ce()?e instanceof Node||e instanceof A(e).Node:!1}function $(e){return Ce()?e instanceof Element||e instanceof A(e).Element:!1}function P(e){return Ce()?e instanceof HTMLElement||e instanceof A(e).HTMLElement:!1}function Tt(e){return!Ce()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof A(e).ShadowRoot}var sr=new Set(["inline","contents"]);function ue(e){let{overflow:t,overflowX:i,overflowY:r,display:n}=I(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+i)&&!sr.has(n)}var lr=new Set(["table","td","th"]);function pr(e){return lr.has(ie(e))}var cr=[":popover-open",":modal"];function Ae(e){return cr.some(t=>{try{return e.matches(t)}catch{return!1}})}var dr=["transform","translate","scale","rotate","perspective"],ur=["transform","translate","scale","rotate","perspective","filter"],hr=["paint","layout","strict","content"];function ot(e){let t=at(),i=$(e)?I(e):e;return dr.some(r=>i[r]?i[r]!=="none":!1)||(i.containerType?i.containerType!=="normal":!1)||!t&&(i.backdropFilter?i.backdropFilter!=="none":!1)||!t&&(i.filter?i.filter!=="none":!1)||ur.some(r=>(i.willChange||"").includes(r))||hr.some(r=>(i.contain||"").includes(r))}function fr(e){let t=q(e);for(;P(t)&&!te(t);){if(ot(t))return t;if(Ae(t))return null;t=q(t)}return null}function at(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var mr=new Set(["html","body","#document"]);function te(e){return mr.has(ie(e))}function I(e){return A(e).getComputedStyle(e)}function He(e){return $(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function q(e){if(ie(e)==="html")return e;let t=e.assignedSlot||e.parentNode||Tt(e)&&e.host||B(e);return Tt(t)?t.host:t}function Jt(e){let t=q(e);return te(t)?e.ownerDocument?e.ownerDocument.body:e.body:P(t)&&ue(t)?t:Jt(t)}function je(e,t,i){var r;t===void 0&&(t=[]),i===void 0&&(i=!0);let n=Jt(e),o=n===((r=e.ownerDocument)==null?void 0:r.body),a=A(n);if(o){let s=Ne(a);return t.concat(a,a.visualViewport||[],ue(n)?n:[],s&&i?je(s):[])}return t.concat(n,je(n,[],i))}function Ne(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Qt(e){let t=I(e),i=parseFloat(t.width)||0,r=parseFloat(t.height)||0,n=P(e),o=n?e.offsetWidth:i,a=n?e.offsetHeight:r,s=xe(i)!==o||xe(r)!==a;return s&&(i=o,r=a),{width:i,height:r,$:s}}function Xt(e){return $(e)?e:e.contextElement}function Y(e){let t=Xt(e);if(!P(t))return M(1);let i=t.getBoundingClientRect(),{width:r,height:n,$:o}=Qt(t),a=(o?xe(i.width):i.width)/r,s=(o?xe(i.height):i.height)/n;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}var vr=M(0);function Yt(e){let t=A(e);return!at()||!t.visualViewport?vr:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function gr(e,t,i){return t===void 0&&(t=!1),!i||t&&i!==A(e)?!1:t}function pe(e,t,i,r){t===void 0&&(t=!1),i===void 0&&(i=!1);let n=e.getBoundingClientRect(),o=Xt(e),a=M(1);t&&(r?$(r)&&(a=Y(r)):a=Y(e));let s=gr(o,i,r)?Yt(o):M(0),p=(n.left+s.x)/a.x,l=(n.top+s.y)/a.y,c=n.width/a.x,d=n.height/a.y;if(o){let h=A(o),u=r&&$(r)?A(r):r,f=h,m=Ne(f);for(;m&&r&&u!==f;){let v=Y(m),y=m.getBoundingClientRect(),b=I(m),w=y.left+(m.clientLeft+parseFloat(b.paddingLeft))*v.x,k=y.top+(m.clientTop+parseFloat(b.paddingTop))*v.y;p*=v.x,l*=v.y,c*=v.x,d*=v.y,p+=w,l+=k,f=A(m),m=Ne(f)}}return Ee({width:c,height:d,x:p,y:l})}function $e(e,t){let i=He(e).scrollLeft;return t?t.left+i:pe(B(e)).left+i}function ei(e,t){let i=e.getBoundingClientRect(),r=i.left+t.scrollLeft-$e(e,i),n=i.top+t.scrollTop;return{x:r,y:n}}function yr(e){let{elements:t,rect:i,offsetParent:r,strategy:n}=e,o=n==="fixed",a=B(r),s=t?Ae(t.floating):!1;if(r===a||s&&o)return i;let p={scrollLeft:0,scrollTop:0},l=M(1),c=M(0),d=P(r);if((d||!d&&!o)&&((ie(r)!=="body"||ue(a))&&(p=He(r)),P(r))){let u=pe(r);l=Y(r),c.x=u.x+r.clientLeft,c.y=u.y+r.clientTop}let h=a&&!d&&!o?ei(a,p):M(0);return{width:i.width*l.x,height:i.height*l.y,x:i.x*l.x-p.scrollLeft*l.x+c.x+h.x,y:i.y*l.y-p.scrollTop*l.y+c.y+h.y}}function br(e){return Array.from(e.getClientRects())}function wr(e){let t=B(e),i=He(e),r=e.ownerDocument.body,n=X(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=X(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),a=-i.scrollLeft+$e(e),s=-i.scrollTop;return I(r).direction==="rtl"&&(a+=X(t.clientWidth,r.clientWidth)-n),{width:n,height:o,x:a,y:s}}var Ct=25;function xr(e,t){let i=A(e),r=B(e),n=i.visualViewport,o=r.clientWidth,a=r.clientHeight,s=0,p=0;if(n){o=n.width,a=n.height;let c=at();(!c||c&&t==="fixed")&&(s=n.offsetLeft,p=n.offsetTop)}let l=$e(r);if(l<=0){let c=r.ownerDocument,d=c.body,h=getComputedStyle(d),u=c.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,f=Math.abs(r.clientWidth-d.clientWidth-u);f<=Ct&&(o-=f)}else l<=Ct&&(o+=l);return{width:o,height:a,x:s,y:p}}var kr=new Set(["absolute","fixed"]);function Er(e,t){let i=pe(e,!0,t==="fixed"),r=i.top+e.clientTop,n=i.left+e.clientLeft,o=P(e)?Y(e):M(1),a=e.clientWidth*o.x,s=e.clientHeight*o.y,p=n*o.x,l=r*o.y;return{width:a,height:s,x:p,y:l}}function At(e,t,i){let r;if(t==="viewport")r=xr(e,i);else if(t==="document")r=wr(B(e));else if($(t))r=Er(t,i);else{let n=Yt(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Ee(r)}function ti(e,t){let i=q(e);return i===t||!$(i)||te(i)?!1:I(i).position==="fixed"||ti(i,t)}function Sr(e,t){let i=t.get(e);if(i)return i;let r=je(e,[],!1).filter(s=>$(s)&&ie(s)!=="body"),n=null,o=I(e).position==="fixed",a=o?q(e):e;for(;$(a)&&!te(a);){let s=I(a),p=ot(a);!p&&s.position==="fixed"&&(n=null),(o?!p&&!n:!p&&s.position==="static"&&n&&kr.has(n.position)||ue(a)&&!p&&ti(e,a))?r=r.filter(l=>l!==a):n=s,a=q(a)}return t.set(e,r),r}function Lr(e){let{element:t,boundary:i,rootBoundary:r,strategy:n}=e,o=[...i==="clippingAncestors"?Ae(t)?[]:Sr(t,this._c):[].concat(i),r],a=o[0],s=o.reduce((p,l)=>{let c=At(t,l,n);return p.top=X(c.top,p.top),p.right=Be(c.right,p.right),p.bottom=Be(c.bottom,p.bottom),p.left=X(c.left,p.left),p},At(t,a,n));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}}function Tr(e){let{width:t,height:i}=Qt(e);return{width:t,height:i}}function Cr(e,t,i){let r=P(t),n=B(t),o=i==="fixed",a=pe(e,!0,o,t),s={scrollLeft:0,scrollTop:0},p=M(0);function l(){p.x=$e(n)}if(r||!r&&!o)if((ie(t)!=="body"||ue(n))&&(s=He(t)),r){let u=pe(t,!0,o,t);p.x=u.x+t.clientLeft,p.y=u.y+t.clientTop}else n&&l();o&&!r&&n&&l();let c=n&&!r&&!o?ei(n,s):M(0),d=a.left+s.scrollLeft-p.x-c.x,h=a.top+s.scrollTop-p.y-c.y;return{x:d,y:h,width:a.width,height:a.height}}function De(e){return I(e).position==="static"}function Ht(e,t){if(!P(e)||I(e).position==="fixed")return null;if(t)return t(e);let i=e.offsetParent;return B(e)===i&&(i=i.ownerDocument.body),i}function ii(e,t){let i=A(e);if(Ae(e))return i;if(!P(e)){let n=q(e);for(;n&&!te(n);){if($(n)&&!De(n))return n;n=q(n)}return i}let r=Ht(e,t);for(;r&&pr(r)&&De(r);)r=Ht(r,t);return r&&te(r)&&De(r)&&!ot(r)?i:r||fr(e)||i}var Ar=async function(e){let t=this.getOffsetParent||ii,i=this.getDimensions,r=await i(e.floating);return{reference:Cr(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Hr(e){return I(e).direction==="rtl"}var $r={convertOffsetParentRelativeRectToViewportRelativeRect:yr,getDocumentElement:B,getClippingRect:Lr,getOffsetParent:ii,getElementRects:Ar,getClientRects:br,getDimensions:Tr,getScale:Y,isElement:$,isRTL:Hr},Ir=or,_r=ar,Mr=ir,Dr=(e,t,i)=>{let r=new Map,n={platform:$r,...i},o={...n.platform,_c:r};return tr(e,t,{...n,platform:o})},Pr=class{constructor(e){this.editor=e,this.tooltip=null,this.currentLink=null,this.hideTimeout=null,this.visibilityChangeHandler=null,this.isTooltipHovered=!1,this.linkCacheText=null,this.linkCache=[],this.init()}init(){this.createTooltip(),this.textareaListeners={selectionchange:()=>this.checkCursorPosition(),keyup:e=>{(e.key.includes("Arrow")||e.key==="Home"||e.key==="End")&&this.checkCursorPosition()},input:()=>this.hide(),scroll:()=>{this.currentLink&&this.positionTooltip(this.currentLink)},blur:()=>{this.isTooltipHovered||this.hide()}};for(let[e,t]of Object.entries(this.textareaListeners))this.editor.textarea.addEventListener(e,t);this.visibilityChangeHandler=()=>{document.hidden&&this.hide()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),this.tooltip.addEventListener("mouseenter",()=>{this.isTooltipHovered=!0,this.cancelHide()}),this.tooltip.addEventListener("mouseleave",()=>{this.isTooltipHovered=!1,this.scheduleHide()})}createTooltip(){this.tooltip=document.createElement("div"),this.tooltip.className="overtype-link-tooltip",this.editor._markChrome(this.tooltip),this.tooltip.innerHTML=`
|
|
913
|
+
<span style="display: flex; align-items: center; gap: 6px;">
|
|
914
|
+
<svg width="12" height="12" viewBox="0 0 20 20" fill="currentColor" style="flex-shrink: 0;">
|
|
915
|
+
<path d="M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z"></path>
|
|
916
|
+
<path d="M5 5a2 2 0 00-2 2v8a2 2 0 002 2h8a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z"></path>
|
|
917
|
+
</svg>
|
|
918
|
+
<span class="overtype-link-tooltip-url"></span>
|
|
919
|
+
</span>
|
|
920
|
+
`,this.tooltip.addEventListener("click",e=>{if(e.preventDefault(),e.stopPropagation(),this.currentLink){let t=T.sanitizeUrl(this.currentLink.url);t!=="#"&&window.open(t,"_blank"),this.hide()}}),this.editor.container.appendChild(this.tooltip)}checkCursorPosition(){let e=this.editor.textarea.selectionStart,t=this.editor.textarea.value,i=this.findLinkAtPosition(t,e);i?(!this.currentLink||this.currentLink.url!==i.url||this.currentLink.index!==i.index)&&this.show(i):this.scheduleHide()}findLinkAtPosition(e,t){if(this.editor.options.showActiveLineRaw)return null;this.linkCacheText!==e&&(this.linkCacheText=e,this.linkCache=T.findRenderableLinks(e));let i=this.linkCache;for(let[r,n]of i.entries()){let o=n.start,a=n.end;if(t>=o&&t<=a)return{text:n.text.raw,url:this.transformUrl(n.destination.value),index:r,start:o,end:a}}return null}transformUrl(e){let t=this.editor.options.transformLinkUrl;if(typeof t!="function")return e;try{let i=t(e);return typeof i=="string"?i:e}catch(i){return console.warn("transformLinkUrl threw:",i),e}}async show(e){this.currentLink=e,this.cancelHide();let t=this.tooltip.querySelector(".overtype-link-tooltip-url");t.textContent=e.url,await this.positionTooltip(e),this.currentLink===e&&this.tooltip.classList.add("visible")}async positionTooltip(e){let t=this.findAnchorElement(e.index);if(!t)return;let i=t.getBoundingClientRect();if(!(i.width===0||i.height===0))try{let{x:r,y:n}=await Dr(t,this.tooltip,{strategy:"fixed",placement:"bottom",middleware:[Ir(8),_r({padding:8}),Mr()]});Object.assign(this.tooltip.style,{left:`${r}px`,top:`${n}px`,position:"fixed"})}catch(r){console.warn("Floating UI positioning failed:",r)}}findAnchorElement(e){return this.editor.preview.querySelector(`a[style*="--link-${e}"]`)}hide(){this.tooltip.classList.remove("visible"),this.currentLink=null,this.isTooltipHovered=!1}scheduleHide(){this.cancelHide(),this.hideTimeout=setTimeout(()=>this.hide(),300)}cancelHide(){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null)}destroy(){if(this.cancelHide(),this.textareaListeners){for(let[e,t]of Object.entries(this.textareaListeners))this.editor.textarea.removeEventListener(e,t);this.textareaListeners=null}this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null),this.tooltip&&this.tooltip.parentNode&&this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null,this.currentLink=null,this.isTooltipHovered=!1}},Fr=`<svg viewBox="0 0 18 18">
|
|
921
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z"></path>
|
|
922
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z"></path>
|
|
923
|
+
</svg>`,Rr=`<svg viewBox="0 0 18 18">
|
|
924
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="13" y1="4" y2="4"></line>
|
|
925
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="5" x2="11" y1="14" y2="14"></line>
|
|
926
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="10" y1="14" y2="4"></line>
|
|
927
|
+
</svg>`,Or=`<svg viewBox="0 0 18 18">
|
|
928
|
+
<path fill="currentColor" d="M10,4V14a1,1,0,0,1-2,0V10H3v4a1,1,0,0,1-2,0V4A1,1,0,0,1,3,4V8H8V4a1,1,0,0,1,2,0Zm6.06787,9.209H14.98975V7.59863a.54085.54085,0,0,0-.605-.60547h-.62744a1.01119,1.01119,0,0,0-.748.29688L11.645,8.56641a.5435.5435,0,0,0-.022.8584l.28613.30762a.53861.53861,0,0,0,.84717.0332l.09912-.08789a1.2137,1.2137,0,0,0,.2417-.35254h.02246s-.01123.30859-.01123.60547V13.209H12.041a.54085.54085,0,0,0-.605.60547v.43945a.54085.54085,0,0,0,.605.60547h4.02686a.54085.54085,0,0,0,.605-.60547v-.43945A.54085.54085,0,0,0,16.06787,13.209Z"></path>
|
|
929
|
+
</svg>`,Br=`<svg viewBox="0 0 18 18">
|
|
930
|
+
<path fill="currentColor" d="M16.73975,13.81445v.43945a.54085.54085,0,0,1-.605.60547H11.855a.58392.58392,0,0,1-.64893-.60547V14.0127c0-2.90527,3.39941-3.42187,3.39941-4.55469a.77675.77675,0,0,0-.84717-.78125,1.17684,1.17684,0,0,0-.83594.38477c-.2749.26367-.561.374-.85791.13184l-.4292-.34082c-.30811-.24219-.38525-.51758-.1543-.81445a2.97155,2.97155,0,0,1,2.45361-1.17676,2.45393,2.45393,0,0,1,2.68408,2.40918c0,2.45312-3.1792,2.92676-3.27832,3.93848h2.79443A.54085.54085,0,0,1,16.73975,13.81445ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z"></path>
|
|
931
|
+
</svg>`,zr=`<svg viewBox="0 0 18 18">
|
|
932
|
+
<path fill="currentColor" d="M16.65186,12.30664a2.6742,2.6742,0,0,1-2.915,2.68457,3.96592,3.96592,0,0,1-2.25537-.6709.56007.56007,0,0,1-.13232-.83594L11.64648,13c.209-.34082.48389-.36328.82471-.1543a2.32654,2.32654,0,0,0,1.12256.33008c.71484,0,1.12207-.35156,1.12207-.78125,0-.61523-.61621-.86816-1.46338-.86816H13.2085a.65159.65159,0,0,1-.68213-.41895l-.05518-.10937a.67114.67114,0,0,1,.14307-.78125l.71533-.86914a8.55289,8.55289,0,0,1,.68213-.7373V8.58887a3.93913,3.93913,0,0,1-.748.05469H11.9873a.54085.54085,0,0,1-.605-.60547V7.59863a.54085.54085,0,0,1,.605-.60547h3.75146a.53773.53773,0,0,1,.60547.59375v.17676a1.03723,1.03723,0,0,1-.27539.748L14.74854,10.0293A2.31132,2.31132,0,0,1,16.65186,12.30664ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z"></path>
|
|
933
|
+
</svg>`,jr=`<svg viewBox="0 0 18 18">
|
|
934
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="11" y1="7" y2="11"></line>
|
|
935
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z"></path>
|
|
936
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z"></path>
|
|
937
|
+
</svg>`,Nr=`<svg viewBox="0 0 18 18">
|
|
938
|
+
<polyline stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" points="5 7 3 9 5 11"></polyline>
|
|
939
|
+
<polyline stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" points="13 7 15 9 13 11"></polyline>
|
|
940
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="10" x2="8" y1="5" y2="13"></line>
|
|
941
|
+
</svg>`,Vr=`<svg viewBox="0 0 18 18">
|
|
942
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="6" x2="15" y1="4" y2="4"></line>
|
|
943
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="6" x2="15" y1="9" y2="9"></line>
|
|
944
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="6" x2="15" y1="14" y2="14"></line>
|
|
945
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="3" x2="3" y1="4" y2="4"></line>
|
|
946
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="3" x2="3" y1="9" y2="9"></line>
|
|
947
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="3" x2="3" y1="14" y2="14"></line>
|
|
948
|
+
</svg>`,Ur=`<svg viewBox="0 0 18 18">
|
|
949
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="15" y1="4" y2="4"></line>
|
|
950
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="15" y1="9" y2="9"></line>
|
|
951
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="15" y1="14" y2="14"></line>
|
|
952
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1" x1="2.5" x2="4.5" y1="5.5" y2="5.5"></line>
|
|
953
|
+
<path fill="currentColor" d="M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z"></path>
|
|
954
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156"></path>
|
|
955
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109"></path>
|
|
956
|
+
</svg>`,qr=`<svg viewBox="2 2 20 20">
|
|
957
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 10.8182L9 10.8182C8.80222 10.8182 8.60888 10.7649 8.44443 10.665C8.27998 10.5651 8.15181 10.4231 8.07612 10.257C8.00043 10.0909 7.98063 9.90808 8.01922 9.73174C8.0578 9.55539 8.15304 9.39341 8.29289 9.26627C8.43275 9.13913 8.61093 9.05255 8.80491 9.01747C8.99889 8.98239 9.19996 9.00039 9.38268 9.0692C9.56541 9.13801 9.72159 9.25453 9.83147 9.40403C9.94135 9.55353 10 9.72929 10 9.90909L10 12.1818C10 12.664 9.78929 13.1265 9.41421 13.4675C9.03914 13.8084 8.53043 14 8 14"></path>
|
|
958
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 10.8182L15 10.8182C14.8022 10.8182 14.6089 10.7649 14.4444 10.665C14.28 10.5651 14.1518 10.4231 14.0761 10.257C14.0004 10.0909 13.9806 9.90808 14.0192 9.73174C14.0578 9.55539 14.153 9.39341 14.2929 9.26627C14.4327 9.13913 14.6109 9.05255 14.8049 9.01747C14.9989 8.98239 15.2 9.00039 15.3827 9.0692C15.5654 9.13801 15.7216 9.25453 15.8315 9.40403C15.9414 9.55353 16 9.72929 16 9.90909L16 12.1818C16 12.664 15.7893 13.1265 15.4142 13.4675C15.0391 13.8084 14.5304 14 14 14"></path>
|
|
959
|
+
</svg>`,Wr=`<svg viewBox="0 0 18 18">
|
|
960
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="16" y1="4" y2="4"></line>
|
|
961
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="16" y1="9" y2="9"></line>
|
|
962
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="16" y1="14" y2="14"></line>
|
|
963
|
+
<rect stroke="currentColor" fill="none" stroke-width="1.5" x="2" y="3" width="3" height="3" rx="0.5"></rect>
|
|
964
|
+
<rect stroke="currentColor" fill="none" stroke-width="1.5" x="2" y="13" width="3" height="3" rx="0.5"></rect>
|
|
965
|
+
<polyline stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" points="2.65 9.5 3.5 10.5 5 8.5"></polyline>
|
|
966
|
+
</svg>`,Kr=`<svg viewBox="0 0 18 18">
|
|
967
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.25 12.375v1.688A1.688 1.688 0 0 0 3.938 15.75h10.124a1.688 1.688 0 0 0 1.688-1.688V12.375"></path>
|
|
968
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5.063 6.188L9 2.25l3.938 3.938"></path>
|
|
969
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 2.25v10.125"></path>
|
|
970
|
+
</svg>`,Zr=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
971
|
+
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" fill="none"></path>
|
|
972
|
+
<circle cx="12" cy="12" r="3" fill="none"></circle>
|
|
973
|
+
</svg>`,S={bold:{name:"bold",actionId:"toggleBold",icon:Fr,title:"Bold (Ctrl+B)",isActive:({activeFormats:e})=>e.includes("bold"),action:({editor:e})=>{Ze(e.textarea),e.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},italic:{name:"italic",actionId:"toggleItalic",icon:Rr,title:"Italic (Ctrl+I)",isActive:({activeFormats:e})=>e.includes("italic"),action:({editor:e})=>{Ge(e.textarea),e.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},code:{name:"code",actionId:"toggleCode",icon:Nr,title:"Inline Code",isActive:()=>!1,action:({editor:e})=>{Je(e.textarea),e.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},separator:{name:"separator"},link:{name:"link",actionId:"insertLink",icon:jr,title:"Insert Link",action:({editor:e})=>{Qe(e.textarea),e.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h1:{name:"h1",actionId:"toggleH1",icon:Or,title:"Heading 1",isActive:({activeFormats:e})=>e.includes("header"),action:({editor:e})=>{tt(e.textarea),e.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h2:{name:"h2",actionId:"toggleH2",icon:Br,title:"Heading 2",isActive:({activeFormats:e})=>e.includes("header-2"),action:({editor:e})=>{it(e.textarea),e.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h3:{name:"h3",actionId:"toggleH3",icon:zr,title:"Heading 3",isActive:({activeFormats:e})=>e.includes("header-3"),action:({editor:e})=>{rt(e.textarea),e.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},bulletList:{name:"bulletList",actionId:"toggleBulletList",icon:Vr,title:"Bullet List",isActive:({activeFormats:e})=>e.includes("bullet-list"),action:({editor:e})=>{Xe(e.textarea),e.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},orderedList:{name:"orderedList",actionId:"toggleNumberedList",icon:Ur,title:"Numbered List",isActive:({activeFormats:e})=>e.includes("numbered-list"),action:({editor:e})=>{Ye(e.textarea),e.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},taskList:{name:"taskList",actionId:"toggleTaskList",icon:Wr,title:"Task List",isActive:({activeFormats:e})=>e.includes("task-list"),action:({editor:e})=>{we&&(we(e.textarea),e.textarea.dispatchEvent(new Event("input",{bubbles:!0})))}},quote:{name:"quote",actionId:"toggleQuote",icon:qr,title:"Quote",isActive:({activeFormats:e})=>e.includes("quote"),action:({editor:e})=>{et(e.textarea),e.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},upload:{name:"upload",actionId:"uploadFile",icon:Kr,title:"Upload File",action:({editor:e})=>{var t,i;if(!((t=e.options.fileUpload)!=null&&t.enabled))return;let r=document.createElement("input");r.type="file",r.multiple=!0,((i=e.options.fileUpload.mimeTypes)==null?void 0:i.length)>0&&(r.accept=e.options.fileUpload.mimeTypes.join(",")),r.onchange=()=>{var n;if(!((n=r.files)!=null&&n.length))return;let o=new DataTransfer;for(let a of r.files)o.items.add(a);e._handleDataTransfer(o)},r.click()}},viewMode:{name:"viewMode",icon:Zr,title:"View mode"}},Ve=[S.bold,S.italic,S.code,S.separator,S.link,S.separator,S.h1,S.h2,S.h3,S.separator,S.bulletList,S.orderedList,S.taskList,S.separator,S.quote,S.separator,S.viewMode],ae;function Gr(){if(ae!==void 0)return ae;if(ae=!1,typeof navigator<"u"){let e=navigator.userAgent||"";ae=/^((?!chrome|android|crios|fxios|edg|opr).)*safari/i.test(e)||/iPad|iPhone|iPod/.test(e)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1&&/Safari/.test(e)}return ae}function Pe(e){let t={};return(e||[]).forEach(i=>{if(!i||i.name==="separator")return;let r=i.actionId||i.name;i.action&&(t[r]=i.action)}),t}function $t(e){let t=e||Ve;return Array.isArray(t)?t.map(i=>({name:i?.name||null,actionId:i?.actionId||i?.name||null,icon:i?.icon||null,title:i?.title||null})):null}function Jr(e,t){let i=$t(e),r=$t(t);if(i===null||r===null)return i!==r;if(i.length!==r.length)return!0;for(let n=0;n<i.length;n++){let o=i[n],a=r[n];if(o.name!==a.name||o.actionId!==a.actionId||o.icon!==a.icon||o.title!==a.title)return!0}return!1}var _=class g{constructor(t,i={}){let r=g._resolveTargets(t);if(typeof t=="string"&&r.length===0)throw new Error(`No elements found for selector: ${t}`);return r.map(n=>{if(n.overTypeInstance)return n.overTypeInstance.reinit(i),n.overTypeInstance;let o=Object.create(g.prototype);return o._init(n,i),n.overTypeInstance=o,g.instances.set(n,o),o})}_init(t,i={}){var r;this.element=t,this.instanceTheme=i.theme||null,this.options=this._mergeOptions(i),this.instanceId=++g.instanceCount,this.initialized=!1,this._isSafari=Gr(),this._safariReflowRaf=null,this.options.persist&&!g.stylesChrome&&(g.stylesChrome=!0,(r=document.querySelector("style.overtype-styles"))==null||r.setAttribute("clay","editor-ui")),g.injectStyles(),g.initGlobalListeners();let n=t.querySelector(".overtype-container"),o=t.querySelector(".overtype-wrapper");n||o?this._recoverFromDOM(n,o):this._buildFromScratch(),this.instanceTheme==="auto"&&this.setTheme("auto"),this.shortcuts=new Pt(this),this._rebuildActionsMap(),this.linkTooltip=new Pr(this),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.textarea.scrollTop=this.preview.scrollTop,this.textarea.scrollLeft=this.preview.scrollLeft})}),this.initialized=!0,this.options.onChange&&this._notifyChange()}_mergeOptions(t){let i={fontSize:"14px",lineHeight:1.6,fontFamily:'"SF Mono", SFMono-Regular, Menlo, Monaco, "Cascadia Code", Consolas, "Roboto Mono", "Noto Sans Mono", "Droid Sans Mono", "Ubuntu Mono", "DejaVu Sans Mono", "Liberation Mono", "Courier New", Courier, monospace',padding:"16px",mobile:{fontSize:"16px",padding:"12px",lineHeight:1.5},textareaProps:{},autofocus:!1,autoResize:!1,minHeight:"100px",maxHeight:null,placeholder:"Start typing...",value:"",onChange:null,onKeydown:null,onRender:null,onFocus:null,onBlur:null,showActiveLineRaw:!1,showStats:!1,toolbar:!1,toolbarButtons:null,statsFormatter:null,smartLists:!0,clickToToggleTasks:!1,codeHighlighter:null,spellcheck:!1,persist:!1,transformLinkUrl:null},{theme:r,colors:n,...o}=t;return{...i,...o}}_recoverFromDOM(t,i){let r=this._extractContent();if(t&&t.classList.contains("overtype-container"))this.container=t,this.wrapper=t.querySelector(".overtype-wrapper");else if(i){if(this.wrapper=i,this.container=document.createElement("div"),this.container.className="overtype-container",this.instanceTheme){let a=typeof this.instanceTheme=="string"?K(this.instanceTheme):this.instanceTheme;a&&a.colors&&(this.container.style.cssText+=se(a.colors))}i.parentNode.insertBefore(this.container,i),this.container.appendChild(i)}if(this.textarea=this.wrapper?this.wrapper.querySelector(".overtype-input"):null,!this.textarea){t&&t.remove(),i&&i.remove(),this._buildFromScratch(r);return}let n=this.instanceTheme||g.currentTheme||U,o=typeof n=="string"?n:n.name;o&&this.container.setAttribute("data-theme",o),this.container.querySelectorAll(".overtype-toolbar, .overtype-link-tooltip, .overtype-stats, .overtype-placeholder, .overtype-preview").forEach(a=>a.remove()),this.container.classList.remove("overtype-auto-resize"),[this.wrapper,this.textarea].forEach(a=>{a.style.removeProperty("height"),a.style.removeProperty("overflow-y")}),this._createOverlay(),this.options.showStats&&this._createStatsBar(),this.wrapper._instance=this,this._applyInstanceCSSVars(),this._configureTextarea(),this._ensureTextareaId(),this._syncPreviewInteractivity(),this._applyOptions()}_buildFromScratch(t=this._extractContent()){this.element.innerHTML="",this._createDOM(),(t||this.options.value)&&this.setValue(t||this.options.value),this._applyOptions()}_extractContent(){let t=this.element.querySelector(".overtype-input");return t?t.value:this.element.textContent||""}_createDOM(){this.container=document.createElement("div"),this.container.className="overtype-container";let t=this.instanceTheme||g.currentTheme||U,i=typeof t=="string"?t:t.name;if(i&&this.container.setAttribute("data-theme",i),this.instanceTheme){let r=typeof this.instanceTheme=="string"?K(this.instanceTheme):this.instanceTheme;if(r&&r.colors){let n=se(r.colors);this.container.style.cssText+=n}}this.wrapper=document.createElement("div"),this.wrapper.className="overtype-wrapper",this._applyInstanceCSSVars(),this.wrapper._instance=this,this.textarea=document.createElement("textarea"),this.textarea.className="overtype-input",this.textarea.placeholder=this.options.placeholder,this._configureTextarea(),this.options.textareaProps&&Object.entries(this.options.textareaProps).forEach(([r,n])=>{r==="className"||r==="class"?this.textarea.className+=" "+n:r==="style"&&typeof n=="object"?Object.assign(this.textarea.style,n):this.textarea.setAttribute(r,n)}),this._ensureTextareaId(),this.wrapper.appendChild(this.textarea),this._createOverlay(),this.container.appendChild(this.wrapper),this.options.showStats&&this._createStatsBar(),this.element.appendChild(this.container),this.options.autoResize?this._setupAutoResize():this.container.classList.remove("overtype-auto-resize"),this._syncPreviewInteractivity()}_createOverlay(){this.preview=document.createElement("div"),this.preview.className="overtype-preview",this.preview.setAttribute("aria-hidden","true"),this.placeholderEl=document.createElement("div"),this.placeholderEl.className="overtype-placeholder",this.placeholderEl.setAttribute("aria-hidden","true"),this.placeholderEl.textContent=this.options.placeholder,this.wrapper.appendChild(this.preview),this.wrapper.appendChild(this.placeholderEl),this._markChrome(this.preview),this._markChrome(this.placeholderEl)}_createStatsBar(){this.statsBar=document.createElement("div"),this.statsBar.className="overtype-stats",this._markChrome(this.statsBar),this.container.appendChild(this.statsBar),this._updateStats()}_markChrome(t){this.options.persist&&t&&t.setAttribute("clay","editor-ui")}_configureTextarea(){this.textarea.setAttribute("autocomplete","off"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck",String(this.options.spellcheck)),this.textarea.setAttribute("data-gramm","false"),this.textarea.setAttribute("data-gramm_editor","false"),this.textarea.setAttribute("data-enable-grammarly","false"),this.options.persist&&this.textarea.setAttribute("persist","")}_ensureTextareaId(){let t=this.textarea.id,i=/^overtype-\d+-input$/.test(t);if(t&&!(i&&document.querySelectorAll(`[id="${t}"]`).length>1))return;let r=this.instanceId;for(;document.getElementById(`overtype-${r}-input`);)r++;this.textarea.id=`overtype-${r}-input`}_syncPreviewInteractivity(){if(!this.preview||!this.container)return;let t=this.container.dataset.mode==="preview";if(this.preview.inert=!t,this.preview.toggleAttribute("inert",!t),t){this.preview.removeAttribute("aria-hidden");return}this.preview.setAttribute("aria-hidden","true")}_createToolbar(){var t;let i=this.options.toolbarButtons||Ve;if((t=this.options.fileUpload)!=null&&t.enabled&&!i.some(r=>r?.name==="upload")){let r=i.findIndex(n=>n?.name==="viewMode");r!==-1?(i=[...i],i.splice(r,0,S.separator,S.upload)):i=[...i,S.separator,S.upload]}this.toolbar=new Ni(this,{toolbarButtons:i}),this.toolbar.create(),this._toolbarSelectionListener=()=>{this.toolbar&&this.toolbar.updateButtonStates()},this._toolbarInputListener=()=>{this.toolbar&&this.toolbar.updateButtonStates()},this.textarea.addEventListener("selectionchange",this._toolbarSelectionListener),this.textarea.addEventListener("input",this._toolbarInputListener)}_cleanupToolbarListeners(){this._toolbarSelectionListener&&(this.textarea.removeEventListener("selectionchange",this._toolbarSelectionListener),this._toolbarSelectionListener=null),this._toolbarInputListener&&(this.textarea.removeEventListener("input",this._toolbarInputListener),this._toolbarInputListener=null)}_rebuildActionsMap(){var t;this.actionsById=Pe(Ve),this.options.toolbarButtons&&Object.assign(this.actionsById,Pe(this.options.toolbarButtons)),(t=this.options.fileUpload)!=null&&t.enabled&&Object.assign(this.actionsById,Pe([S.upload]))}_applyInstanceCSSVars(){if(!this.wrapper)return;let t=[["--instance-font-size",this.options.fontSize,N.fontSize],["--instance-line-height",this.options.lineHeight,N.lineHeight],["--instance-padding",this.options.padding,N.padding],["--instance-font-family",this.options.fontFamily,N.fontFamily]];for(let[i,r,n]of t)r&&String(r)!==String(n)?this.wrapper.style.setProperty(i,String(r)):this.wrapper.style.removeProperty(i)}_applyOptions(){this._applyInstanceCSSVars(),this.options.autofocus&&this.textarea.focus(),this.options.autoResize?this.container.classList.contains("overtype-auto-resize")?this._updateAutoHeight():this._setupAutoResize():this.container.classList.remove("overtype-auto-resize"),this.options.toolbar&&!this.toolbar?this._createToolbar():!this.options.toolbar&&this.toolbar&&(this._cleanupToolbarListeners(),this.toolbar.destroy(),this.toolbar=null),this.placeholderEl&&(this.placeholderEl.textContent=this.options.placeholder),this.options.fileUpload&&!this.fileUploadInitialized?this._initFileUpload():!this.options.fileUpload&&this.fileUploadInitialized&&this._destroyFileUpload(),this.updatePreview()}_initFileUpload(){let t=this.options.fileUpload;if(!(!t||!t.enabled)){if(t.maxSize=t.maxSize||10*1024*1024,t.mimeTypes=t.mimeTypes||[],t.batch=t.batch||!1,!t.onInsertFile||typeof t.onInsertFile!="function"){console.warn("OverType: fileUpload.onInsertFile callback is required for file uploads.");return}this._fileUploadCounter=0,this._uploadedFiles=new Map,this._boundHandleFilePaste=this._handleFilePaste.bind(this),this._boundHandleFileDrop=this._handleFileDrop.bind(this),this._boundHandleDragOver=this._handleDragOver.bind(this),this.textarea.addEventListener("paste",this._boundHandleFilePaste),this.textarea.addEventListener("drop",this._boundHandleFileDrop),this.textarea.addEventListener("dragover",this._boundHandleDragOver),this.fileUploadInitialized=!0}}_extractMarkdownUrls(t){return T.findLinks(t,{allowEmptyText:!0}).map(i=>i.destination.value)}_trackInsertedUrls(t,i){if(!this._uploadedFiles||!i||!t)return;let r=T.findLinks(t,{allowEmptyText:!0});for(let n of r)this._uploadedFiles.set(n.destination.value,{filename:i.name,file:i,markdownDestination:n.destination.raw})}_checkForRemovedUploads(){var t;if(!this._uploadedFiles||this._uploadedFiles.size===0)return;let i=(t=this.options.fileUpload)==null?void 0:t.onRemoveFile,r=this.textarea.value,n=new Set(this._extractMarkdownUrls(this.textarea.value)),o=[];for(let[a,s]of this._uploadedFiles){let p=s.markdownDestination||a;!n.has(a)&&!r.includes(p)&&o.push({url:a,info:s})}for(let{url:a,info:s}of o)this._uploadedFiles.delete(a),i&&i({url:a,filename:s.filename,file:s.file})}_handleFilePaste(t){var i,r;(r=(i=t?.clipboardData)==null?void 0:i.files)!=null&&r.length&&(t.preventDefault(),this._handleDataTransfer(t.clipboardData))}_handleFileDrop(t){var i,r;(r=(i=t?.dataTransfer)==null?void 0:i.files)!=null&&r.length&&(t.preventDefault(),this._handleDataTransfer(t.dataTransfer))}_handleDataTransfer(t){let i=[];for(let r of t.files){if(r.size>this.options.fileUpload.maxSize||this.options.fileUpload.mimeTypes.length>0&&!this.options.fileUpload.mimeTypes.includes(r.type))continue;let n=++this._fileUploadCounter,o=`${r.type.startsWith("image/")?"!":""}[Uploading ${r.name} (#${n})...]()`;if(this.insertAtCursor(`${o}
|
|
974
|
+
`),this.options.fileUpload.batch){i.push({file:r,placeholder:o});continue}this.options.fileUpload.onInsertFile(r).then(a=>{this.textarea.value=this.textarea.value.replace(o,a),this._trackInsertedUrls(a,r),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))},a=>{console.error("OverType: File upload failed",a),this.textarea.value=this.textarea.value.replace(o,"[Upload failed]()"),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))})}this.options.fileUpload.batch&&i.length>0&&this.options.fileUpload.onInsertFile(i.map(r=>r.file)).then(r=>{(Array.isArray(r)?r:[r]).forEach((n,o)=>{this.textarea.value=this.textarea.value.replace(i[o].placeholder,n),this._trackInsertedUrls(n,i[o].file)}),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))},r=>{console.error("OverType: File upload failed",r),i.forEach(({placeholder:n})=>{this.textarea.value=this.textarea.value.replace(n,"[Upload failed]()")}),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))})}_handleDragOver(t){t.preventDefault()}_destroyFileUpload(){this.textarea.removeEventListener("paste",this._boundHandleFilePaste),this.textarea.removeEventListener("drop",this._boundHandleFileDrop),this.textarea.removeEventListener("dragover",this._boundHandleDragOver),this._boundHandleFilePaste=null,this._boundHandleFileDrop=null,this._boundHandleDragOver=null,this._uploadedFiles=null,this.fileUploadInitialized=!1}_handleTaskClick(t){if(!this.options.clickToToggleTasks||t.button!==0||!this._canEditTextarea()||this.container.dataset.mode==="preview")return;let i=[...this.preview.querySelectorAll("li.task-list, div.raw-line")].filter(a=>a.matches("li.task-list")||/^ *-\s+\[[ xX]\](?:\s|$)/.test(a.textContent)),r=0,n=0,o=null;for(let a of this.textarea.value.split(`
|
|
975
|
+
`)){if(o){Ue(a,o)&&(o=null),n+=a.length+1;continue}if(o=le(a),o){n+=a.length+1;continue}let s=/^( *-\s+\[)([ xX])\](?:\s|$)/.exec(a);if(!s||!T.parseLine(a).includes('<li class="task-list">')){n+=a.length+1;continue}let p=i[r++],l=p?.matches("li.task-list")?p.querySelector(":scope > .syntax-marker"):p,c=l?.firstChild;if(c?.nodeType===3){let d=c.textContent.indexOf("[")+1;if(!/^\[[ xX]\]$/.test(c.textContent.slice(d-1,d+2))){n+=a.length+1;continue}let h=document.createRange();if(h.setStart(c,d-1),h.setEnd(c,d+2),[...h.getClientRects()].some(u=>t.clientX>=u.left&&t.clientX<u.right&&t.clientY>=u.top&&t.clientY<u.bottom)){let u=this.textarea,f=u.selectionStart,m=u.selectionEnd,v=u.selectionDirection,y=n+s[1].length;u.focus(),u.setSelectionRange(y,y+1);let b=s[2]===" "?"x":" ",w=!1,k=()=>{w=!0};u.addEventListener("input",k);let E=!1;try{E=document.execCommand("insertText",!1,b)}catch{}finally{u.removeEventListener("input",k)}E||u.setRangeText(b,y,y+1,"preserve"),w||u.dispatchEvent(new Event("input",{bubbles:!0})),u.setSelectionRange(f,m,v);return}}n+=a.length+1}}insertAtCursor(t){let i=this.textarea.selectionStart,r=this.textarea.selectionEnd,n=!1;try{n=document.execCommand("insertText",!1,t)}catch{}if(!n){let o=this.textarea.value.slice(0,i),a=this.textarea.value.slice(r);this.textarea.value=o+t+a,this.textarea.setSelectionRange(i+t.length,i+t.length)}this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}updatePreview(){let t=this.textarea.value,i=this.textarea.selectionStart,r=this._getCurrentLine(t,i),n=this.container.dataset.mode==="preview",o=T.parse(t,r,this.options.showActiveLineRaw,this.options.codeHighlighter,n);this.preview.innerHTML=o,this.placeholderEl&&(this.placeholderEl.style.display=t?"none":""),this._applyCodeBlockBackgrounds(),this.options.showStats&&this.statsBar&&this._updateStats(),this.options.onRender&&this.options.onRender(this.preview,n?"preview":"normal",this)}_notifyChange(){this.initialized&&(this._checkForRemovedUploads(),this.options.onChange&&this.options.onChange(this.textarea.value,this))}_applyCodeBlockBackgrounds(){let t=this.preview.querySelectorAll(".code-fence");for(let i=0;i<t.length-1;i+=2){let r=t[i],n=t[i+1],o=r.parentElement,a=n.parentElement;!o||!a||(r.style.display="block",n.style.display="block",o.classList.add("code-block-line"),a.classList.add("code-block-line"))}}_getCurrentLine(t,i){return t.substring(0,i).split(`
|
|
976
|
+
`).length-1}handleInput(t){this.updatePreview(),this._notifyChange(),this._scheduleSafariReflow()}_scheduleSafariReflow(){!this._isSafari||this._safariReflowRaf||(this._safariReflowRaf=requestAnimationFrame(()=>{this._safariReflowRaf=null;let t=this.textarea;t&&(t.style.setProperty("letter-spacing","-0.001px","important"),t.offsetHeight,t.style.removeProperty("letter-spacing"))}))}handleFocus(t){this.options.onFocus&&this.options.onFocus(t,this)}handleBlur(t){this.options.onBlur&&this.options.onBlur(t,this)}handleKeydown(t){if(t.key==="Tab"){let i=this.textarea.selectionStart,r=this.textarea.selectionEnd;if(i!==r&&this._canEditTextarea()){t.preventDefault(),t.shiftKey?this.outdentSelection():this.indentSelection();return}}if(t.key==="Enter"&&!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&this.options.smartLists&&this.handleSmartListContinuation()){t.preventDefault();return}!this.shortcuts.handleKeydown(t)&&this.options.onKeydown&&this.options.onKeydown(t,this)}handleSmartListContinuation(){let t=this.textarea,i=t.selectionStart,r=T.getListContext(t.value,i);return!r||!r.inList?!1:r.content.trim()===""&&i>=r.markerEndPos?(this.deleteListMarker(r),!0):(i>r.markerEndPos&&i<r.lineEnd?this.splitListItem(r,i):this.insertNewListItem(r),r.listType==="numbered"&&this.scheduleNumberedListUpdate(),!0)}deleteListMarker(t){this.textarea.setSelectionRange(t.lineStart,t.markerEndPos),document.execCommand("delete"),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}insertNewListItem(t){let i=T.createNewListItem(t);document.execCommand("insertText",!1,`
|
|
977
|
+
`+i),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}splitListItem(t,i){let r=t.content.substring(i-t.markerEndPos);this.textarea.setSelectionRange(i,t.lineEnd),document.execCommand("delete");let n=T.createNewListItem(t);document.execCommand("insertText",!1,`
|
|
978
|
+
`+n+r);let o=this.textarea.selectionStart-r.length;this.textarea.setSelectionRange(o,o),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}scheduleNumberedListUpdate(){this.numberUpdateTimeout&&clearTimeout(this.numberUpdateTimeout),this.numberUpdateTimeout=setTimeout(()=>{this.updateNumberedLists()},10)}updateNumberedLists(){let t=this.textarea.value,i=this.textarea.selectionStart,r=T.renumberLists(t);if(r!==t){let n=0,o=t.split(`
|
|
979
|
+
`),a=r.split(`
|
|
980
|
+
`),s=0;for(let l=0;l<o.length&&s<i;l++){if(o[l]!==a[l]){let c=a[l].length-o[l].length;s+o[l].length<i&&(n+=c)}s+=o[l].length+1}this.textarea.value=r;let p=i+n;this.textarea.setSelectionRange(p,p),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}}handleScroll(t){this.preview.scrollTop=this.textarea.scrollTop,this.preview.scrollLeft=this.textarea.scrollLeft}getValue(){return this.textarea.value}setValue(t){let i=this.textarea.value!==t;this.textarea.value=t,this.updatePreview(),this.options.autoResize&&this._updateAutoHeight(),i&&(this._notifyChange(),this._scheduleSafariReflow())}async performAction(t,i=null){var r;let n=this.textarea;if(!n)return!1;let o=(r=this.actionsById)==null?void 0:r[t];if(!o)return console.warn(`OverType: Unknown action "${t}"`),!1;n.focus();try{return await o({editor:this,getValue:()=>this.getValue(),setValue:a=>this.setValue(a),event:i}),!0}catch(a){return console.error(`OverType: Action "${t}" error:`,a),this.wrapper.dispatchEvent(new CustomEvent("button-error",{detail:{actionId:t,error:a}})),!1}}getRenderedHTML(t={}){let i=this.getValue(),r=T.parse(i,-1,!1,this.options.codeHighlighter);return t.cleanHTML&&(r=r.replace(/<span class="syntax-marker[^"]*">.*?<\/span>/g,""),r=r.replace(/\sclass="(bullet-list|ordered-list|code-fence|hr-marker|blockquote|url-part)"/g,""),r=r.replace(/\sclass=""/g,"")),r}getPreviewHTML(){return this.preview.innerHTML}indentSelection(){this._replaceSelectedLines(t=>` ${t}`)}outdentSelection(){this._replaceSelectedLines(t=>t.replace(/^( {1,2}|\t)/,""))}_replaceSelectedLines(t){if(!this._canEditTextarea())return!1;let i=this.textarea,{selectionStart:r,selectionEnd:n,value:o}=i,a=o.lastIndexOf(`
|
|
981
|
+
`,r-1)+1,s=this._effectiveSelectionEnd(o,r,n),p=o.indexOf(`
|
|
982
|
+
`,s),l=p===-1?o.length:p,c=o.slice(a,l),d=c.split(`
|
|
983
|
+
`).map(t).join(`
|
|
984
|
+
`);if(d===c)return!1;i.setSelectionRange(a,l);let h=!1;try{h=document.execCommand("insertText",!1,d)}catch{}return h||i.setRangeText(d,a,l,"preserve"),i.setSelectionRange(a,a+d.length),i.dispatchEvent(new Event("input",{bubbles:!0})),!0}_effectiveSelectionEnd(t,i,r){return r>i&&t[r-1]===`
|
|
985
|
+
`?r-1:r}_canEditTextarea(){return this.textarea&&!this.textarea.disabled&&!this.textarea.readOnly}getCleanHTML(){return this.getRenderedHTML({cleanHTML:!0})}focus(){this.textarea.focus()}blur(){this.textarea.blur()}isInitialized(){return this.initialized}reinit(t={}){var i;let r=(i=this.options)==null?void 0:i.toolbarButtons;this.options=this._mergeOptions({...this.options,...t});let n=this.toolbar&&this.options.toolbar&&Jr(r,this.options.toolbarButtons);this._rebuildActionsMap(),n&&(this._cleanupToolbarListeners(),this.toolbar.destroy(),this.toolbar=null,this._createToolbar()),this.fileUploadInitialized&&this._destroyFileUpload(),this.options.fileUpload&&this._initFileUpload(),this._applyOptions(),this.updatePreview()}showToolbar(){this.toolbar?this.toolbar.show():this._createToolbar()}hideToolbar(){this.toolbar&&this.toolbar.hide()}setTheme(t){if(g._autoInstances.delete(this),this.instanceTheme=t,t==="auto")g._autoInstances.add(this),g._startAutoListener(),this._applyResolvedTheme(vt("auto"));else{let i=typeof t=="string"?K(t):t,r=typeof i=="string"?i:i.name;if(r&&this.container.setAttribute("data-theme",r),i&&i.colors){let n=se(i.colors,i.previewColors);this.container.style.cssText+=n}this.updatePreview()}return g._stopAutoListener(),this}_applyResolvedTheme(t){let i=K(t);this.container.setAttribute("data-theme",t),i&&i.colors&&(this.container.style.cssText=se(i.colors,i.previewColors)),this.updatePreview()}setCodeHighlighter(t){this.options.codeHighlighter=t,this.updatePreview()}_updateStats(){if(!this.statsBar)return;let t=this.textarea.value,i=t.split(`
|
|
986
|
+
`),r=t.length,n=t.split(/\s+/).filter(l=>l.length>0).length,o=this.textarea.selectionStart,a=t.substring(0,o).split(`
|
|
987
|
+
`),s=a.length,p=a[a.length-1].length+1;this.options.statsFormatter?this.statsBar.innerHTML=this.options.statsFormatter({chars:r,words:n,lines:i.length,line:s,column:p}):this.statsBar.innerHTML=`
|
|
988
|
+
<div class="overtype-stat">
|
|
989
|
+
<span class="live-dot"></span>
|
|
990
|
+
<span>${r} chars, ${n} words, ${i.length} lines</span>
|
|
991
|
+
</div>
|
|
992
|
+
<div class="overtype-stat">Line ${s}, Col ${p}</div>
|
|
993
|
+
`}_setupAutoResize(){this.container.classList.add("overtype-auto-resize"),this.previousHeight=null,this._updateAutoHeight(),this._autoResizeHandler||(this._autoResizeHandler=()=>this._updateAutoHeight(),this.textarea.addEventListener("input",this._autoResizeHandler),window.addEventListener("resize",this._autoResizeHandler))}_updateAutoHeight(){if(!this.options.autoResize)return;let t=this.textarea,i=this.preview,r=this.wrapper;if(this.container.dataset.mode==="preview"){r.style.removeProperty("height"),i.style.removeProperty("height"),i.style.removeProperty("overflow-y"),t.style.removeProperty("height"),t.style.removeProperty("overflow-y");return}let n=t.scrollTop;r.style.setProperty("height","auto","important"),t.style.setProperty("height","auto","important");let o=t.scrollHeight;if(this.options.minHeight){let p=parseInt(this.options.minHeight);o=Math.max(o,p)}let a="hidden";if(this.options.maxHeight){let p=parseInt(this.options.maxHeight);o>p&&(o=p,a="auto")}let s=o+"px";t.style.setProperty("height",s,"important"),t.style.setProperty("overflow-y",a,"important"),i.style.setProperty("height",s,"important"),i.style.setProperty("overflow-y",a,"important"),r.style.setProperty("height",s,"important"),t.scrollTop=n,i.scrollTop=n,this.previousHeight!==o&&(this.previousHeight=o)}showStats(t){this.options.showStats=t,t&&!this.statsBar?this._createStatsBar():t&&this.statsBar?this._updateStats():!t&&this.statsBar&&(this.statsBar.remove(),this.statsBar=null)}showNormalEditMode(){return this.container.dataset.mode="normal",this._syncPreviewInteractivity(),this.updatePreview(),this._updateAutoHeight(),requestAnimationFrame(()=>{this.textarea.scrollTop=this.preview.scrollTop,this.textarea.scrollLeft=this.preview.scrollLeft}),this}showPlainTextarea(){if(this.container.dataset.mode="plain",this._syncPreviewInteractivity(),this._updateAutoHeight(),this.toolbar){let t=this.container.querySelector('[data-action="toggle-plain"]');t&&(t.classList.remove("active"),t.title="Show markdown preview")}return this}showPreviewMode(){return this.container.dataset.mode="preview",this._syncPreviewInteractivity(),this.updatePreview(),this._updateAutoHeight(),this}destroy(){if(g._autoInstances.delete(this),g._stopAutoListener(),this.fileUploadInitialized&&this._destroyFileUpload(),this.element.overTypeInstance=null,g.instances.delete(this.element),this.shortcuts&&this.shortcuts.destroy(),this._safariReflowRaf&&(cancelAnimationFrame(this._safariReflowRaf),this._safariReflowRaf=null),this.linkTooltip&&(this.linkTooltip.destroy(),this.linkTooltip=null),this.toolbar&&(this._cleanupToolbarListeners(),this.toolbar.destroy(),this.toolbar=null),this._autoResizeHandler&&(this.textarea.removeEventListener("input",this._autoResizeHandler),window.removeEventListener("resize",this._autoResizeHandler),this._autoResizeHandler=null),this.wrapper)if(this.options.persist)[this.preview,this.placeholderEl,this.statsBar].forEach(t=>t?.remove()),this.statsBar=null,this.wrapper._instance=null;else{let t=this.getValue();this.wrapper.remove(),this.element.textContent=t}this.initialized=!1}static init(t,i={}){return new g(t,i)}static initFromData(t,i={}){return g._resolveTargets(t).map(r=>{let n={...i};for(let o of r.attributes){if(!o.name.startsWith("data-ot-"))continue;let a=o.name.slice(8);if(a.startsWith("textarea-")&&a!=="textarea-props"){let p=a.slice(9).replace(/-([a-z])/g,(l,c)=>c.toUpperCase());n.textareaProps={...n.textareaProps||{},[p]:g._parseDataValue(o.value)};continue}let s=a.replace(/-([a-z])/g,(p,l)=>l.toUpperCase());n[s]=g._parseDataValue(o.value)}return new g(r,n)[0]})}static _resolveTargets(t){if(t==null)throw new Error("Invalid target: must be selector string, Element, NodeList, or Array");if(typeof t=="string")return Array.from(document.querySelectorAll(t));if(t instanceof Element)return[t];if(t instanceof NodeList)return Array.from(t);if(Array.isArray(t))return t;if(typeof t.length=="number")return Array.from(t);throw new Error("Invalid target: must be selector string, Element, NodeList, or Array")}static _parseDataValue(t){if(t==="true")return!0;if(t==="false")return!1;if(t==="null")return null;if(t!==""&&!isNaN(Number(t)))return Number(t);let i=t.trim();if(i[0]==="{"||i[0]==="[")try{return JSON.parse(i)}catch{return t}return t}static getInstance(t){let i;return t instanceof Element?i=t:i=g._resolveTargets(t)[0],i&&(i.overTypeInstance||g.instances.get(i))||null}static destroyAll(){document.querySelectorAll("[data-overtype-instance]").forEach(t=>{let i=g.getInstance(t);i&&i.destroy()})}static injectStyles(t=!1){if(g.stylesInjected&&!t)return;let i=document.querySelector("style.overtype-styles");i&&i.remove();let r=g.currentTheme||U,n=Ai({theme:r}),o=document.createElement("style");o.className="overtype-styles",g.stylesChrome&&o.setAttribute("clay","editor-ui"),o.textContent=n,document.head.appendChild(o),g.stylesInjected=!0}static setTheme(t,i=null){if(g._globalAutoTheme=!1,g._globalAutoCustomColors=null,t==="auto"){g._globalAutoTheme=!0,g._globalAutoCustomColors=i,g._startAutoListener(),g._applyGlobalTheme(vt("auto"),i);return}g._stopAutoListener(),g._applyGlobalTheme(t,i)}static _applyGlobalTheme(t,i=null){let r=typeof t=="string"?K(t):t;i&&(r=Ci(r,i)),g.currentTheme=r,g.injectStyles(!0);let n=typeof r=="string"?r:r.name;document.querySelectorAll(".overtype-container").forEach(o=>{let a=o.querySelector(".overtype-wrapper");n&&a&&a._instance&&o.setAttribute("data-theme",n)}),document.querySelectorAll(".overtype-wrapper").forEach(o=>{o.closest(".overtype-container")||n&&o.setAttribute("data-theme",n);let a=o._instance;a&&a.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(o=>{n&&typeof o.setAttribute=="function"&&o.setAttribute("theme",n),typeof o.refreshTheme=="function"&&o.refreshTheme()})}static _startAutoListener(){g._autoMediaQuery||window.matchMedia&&(g._autoMediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),g._autoMediaListener=t=>{let i=t.matches?"cave":"solar";g._globalAutoTheme&&g._applyGlobalTheme(i,g._globalAutoCustomColors),g._autoInstances.forEach(r=>r._applyResolvedTheme(i))},g._autoMediaQuery.addEventListener("change",g._autoMediaListener))}static _stopAutoListener(){g._autoInstances.size>0||g._globalAutoTheme||g._autoMediaQuery&&(g._autoMediaQuery.removeEventListener("change",g._autoMediaListener),g._autoMediaQuery=null,g._autoMediaListener=null)}static setCodeHighlighter(t){T.setCodeHighlighter(t),document.querySelectorAll(".overtype-wrapper").forEach(i=>{let r=i._instance;r&&r.updatePreview&&r.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(i=>{if(typeof i.getEditor=="function"){let r=i.getEditor();r&&r.updatePreview&&r.updatePreview()}})}static setCustomSyntax(t){T.setCustomSyntax(t),document.querySelectorAll(".overtype-wrapper").forEach(i=>{let r=i._instance;r&&r.updatePreview&&r.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(i=>{if(typeof i.getEditor=="function"){let r=i.getEditor();r&&r.updatePreview&&r.updatePreview()}})}static initGlobalListeners(){let t=typeof window<"u"?window:globalThis,i="__overtypeGlobalListenersInitialized";if(g.globalListenersInitialized||t[i]){g.globalListenersInitialized=!0;return}t[i]=!0,document.addEventListener("input",r=>{if(r.target&&r.target.classList&&r.target.classList.contains("overtype-input")){let n=r.target.closest(".overtype-wrapper"),o=n?._instance;o&&o.handleInput(r)}}),document.addEventListener("keydown",r=>{if(r.target&&r.target.classList&&r.target.classList.contains("overtype-input")){let n=r.target.closest(".overtype-wrapper"),o=n?._instance;o&&o.handleKeydown(r)}}),document.addEventListener("click",r=>{if(r.target&&r.target.classList&&r.target.classList.contains("overtype-input")){let n=r.target.closest(".overtype-wrapper"),o=n?._instance;o&&o._handleTaskClick(r)}}),document.addEventListener("focus",r=>{if(r.target&&r.target.classList&&r.target.classList.contains("overtype-input")){let n=r.target.closest(".overtype-wrapper"),o=n?._instance;o&&o.handleFocus(r)}},!0),document.addEventListener("blur",r=>{if(r.target&&r.target.classList&&r.target.classList.contains("overtype-input")){let n=r.target.closest(".overtype-wrapper"),o=n?._instance;o&&o.handleBlur(r)}},!0),document.addEventListener("scroll",r=>{if(r.target&&r.target.classList&&r.target.classList.contains("overtype-input")){let n=r.target.closest(".overtype-wrapper"),o=n?._instance;o&&o.handleScroll(r)}},!0),document.addEventListener("selectionchange",r=>{let n=document.activeElement;if(n&&n.classList.contains("overtype-input")){let o=n.closest(".overtype-wrapper"),a=o?._instance;a&&(a.options.showStats&&a.statsBar&&a._updateStats(),clearTimeout(a._selectionTimeout),a._selectionTimeout=setTimeout(()=>{a.updatePreview()},50))}}),g.globalListenersInitialized=!0}};C(_,"instances",new WeakMap);C(_,"stylesInjected",!1);C(_,"stylesChrome",!1);C(_,"globalListenersInitialized",!1);C(_,"instanceCount",0);C(_,"_autoMediaQuery",null);C(_,"_autoMediaListener",null);C(_,"_autoInstances",new Set);C(_,"_globalAutoTheme",!1);C(_,"_globalAutoCustomColors",null);var re=_;re.MarkdownParser=T;re.ShortcutsManager=Pt;re.themes={solar:U,cave:K("cave")};re.getTheme=K;re.currentTheme=U;var Qr=re;export{Qr as default,S as toolbarButtons};
|