@cyberyozh/text-editor 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor.js +1333 -123
- package/dist/editor.js.map +1 -1
- package/dist/editor.mjs +1281 -71
- package/dist/editor.mjs.map +1 -1
- package/dist/render.js +1301 -92
- package/dist/render.js.map +1 -1
- package/dist/render.mjs +1256 -47
- package/dist/render.mjs.map +1 -1
- package/package.json +38 -38
- package/src/editor/controls/bubble-menu-content.tsx +1 -1
- package/src/editor/dialogs/add-link-dialog/add-link-dialog.tsx +2 -6
- package/src/editor/handlers/dialog-handlers.ts +1 -0
- package/src/extensions/base/figure.ts +37 -0
- package/src/extensions/base/link.ts +63 -6
- package/src/types/link.ts +1 -0
package/dist/editor.js
CHANGED
|
@@ -818,7 +818,7 @@ var BubbleMenuContent = ({ editor, onLinkClick }) => {
|
|
|
818
818
|
editor.state.selection.$to.pos
|
|
819
819
|
);
|
|
820
820
|
const linkAttrs = editor.getAttributes("link");
|
|
821
|
-
onLinkClick?.({ title: selectedText
|
|
821
|
+
onLinkClick?.({ ...linkAttrs, title: selectedText });
|
|
822
822
|
openDialogCommand("link");
|
|
823
823
|
};
|
|
824
824
|
return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
|
|
@@ -2310,8 +2310,8 @@ var AddLinkDialog = ({
|
|
|
2310
2310
|
linkDialogContext
|
|
2311
2311
|
}) => {
|
|
2312
2312
|
const translations2 = useTiptapTranslations();
|
|
2313
|
-
const initialLinkTarget = linkDialogContext
|
|
2314
|
-
const initialLinkRel = linkDialogContext
|
|
2313
|
+
const initialLinkTarget = linkDialogContext ? linkDialogContext.target === "_blank" : true;
|
|
2314
|
+
const initialLinkRel = linkDialogContext ? !!linkDialogContext.rel?.includes("noopener") : true;
|
|
2315
2315
|
const [title, setTitle] = (0, import_react15.useState)(linkDialogContext?.title);
|
|
2316
2316
|
const [url, setUrl] = (0, import_react15.useState)(linkDialogContext?.href);
|
|
2317
2317
|
const [openInNewTab, setOpenInNewTab] = (0, import_react15.useState)(initialLinkTarget);
|
|
@@ -2731,7 +2731,7 @@ function handleExitNode(editor, nodeName) {
|
|
|
2731
2731
|
if (!isInsideTargetNode || !isCurrentNodeEmptyParagraph) {
|
|
2732
2732
|
return false;
|
|
2733
2733
|
}
|
|
2734
|
-
const { tr } = state;
|
|
2734
|
+
const { tr: tr2 } = state;
|
|
2735
2735
|
const posAfterTargetNode = $pos.after(targetNodeDepth);
|
|
2736
2736
|
const targetNode = $pos.node(targetNodeDepth);
|
|
2737
2737
|
let newPosAfterTargetNode = posAfterTargetNode;
|
|
@@ -2739,14 +2739,14 @@ function handleExitNode(editor, nodeName) {
|
|
|
2739
2739
|
const emptyParagraphStart = $pos.before();
|
|
2740
2740
|
const emptyParagraphEnd = $pos.after();
|
|
2741
2741
|
const deletionLength = emptyParagraphEnd - emptyParagraphStart;
|
|
2742
|
-
|
|
2742
|
+
tr2.delete(emptyParagraphStart, emptyParagraphEnd);
|
|
2743
2743
|
newPosAfterTargetNode = posAfterTargetNode - deletionLength;
|
|
2744
2744
|
}
|
|
2745
2745
|
const paragraphNode = schema.nodes.paragraph.createAndFill();
|
|
2746
2746
|
if (!paragraphNode) return false;
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
view.dispatch(
|
|
2747
|
+
tr2.insert(newPosAfterTargetNode, paragraphNode);
|
|
2748
|
+
tr2.setSelection(import_state.TextSelection.create(tr2.doc, newPosAfterTargetNode + 1));
|
|
2749
|
+
view.dispatch(tr2);
|
|
2750
2750
|
return true;
|
|
2751
2751
|
}
|
|
2752
2752
|
|
|
@@ -2766,7 +2766,7 @@ function migrateLegacyCallouts(editor) {
|
|
|
2766
2766
|
}
|
|
2767
2767
|
});
|
|
2768
2768
|
if (calloutsToMigrate.length === 0) return;
|
|
2769
|
-
const
|
|
2769
|
+
const tr2 = editor.state.tr;
|
|
2770
2770
|
calloutsToMigrate.sort((a, b) => b.pos - a.pos);
|
|
2771
2771
|
for (const { node, pos } of calloutsToMigrate) {
|
|
2772
2772
|
const oldType = node.attrs.calloutType;
|
|
@@ -2775,7 +2775,7 @@ function migrateLegacyCallouts(editor) {
|
|
|
2775
2775
|
if (hasInlineContent) {
|
|
2776
2776
|
const paragraph = schema.nodes.paragraph?.create(null, node.content);
|
|
2777
2777
|
const newContent = paragraph ? [paragraph] : [];
|
|
2778
|
-
|
|
2778
|
+
tr2.replaceRangeWith(
|
|
2779
2779
|
pos,
|
|
2780
2780
|
pos + node.nodeSize,
|
|
2781
2781
|
schema.nodes.callout.create(
|
|
@@ -2788,7 +2788,7 @@ function migrateLegacyCallouts(editor) {
|
|
|
2788
2788
|
)
|
|
2789
2789
|
);
|
|
2790
2790
|
} else {
|
|
2791
|
-
|
|
2791
|
+
tr2.setNodeMarkup(pos, void 0, {
|
|
2792
2792
|
...node.attrs,
|
|
2793
2793
|
type: newType,
|
|
2794
2794
|
calloutType: null,
|
|
@@ -2796,7 +2796,7 @@ function migrateLegacyCallouts(editor) {
|
|
|
2796
2796
|
});
|
|
2797
2797
|
}
|
|
2798
2798
|
}
|
|
2799
|
-
editor.view.dispatch(
|
|
2799
|
+
editor.view.dispatch(tr2);
|
|
2800
2800
|
}
|
|
2801
2801
|
|
|
2802
2802
|
// src/extensions/base/callout.ts
|
|
@@ -3004,13 +3004,13 @@ var BaseCustomQuote = import_core3.Node.create({
|
|
|
3004
3004
|
if (!isInsideCustomQuote) {
|
|
3005
3005
|
return false;
|
|
3006
3006
|
}
|
|
3007
|
-
const { tr } = state;
|
|
3007
|
+
const { tr: tr2 } = state;
|
|
3008
3008
|
const posAfter = $pos.after(depth);
|
|
3009
3009
|
const paragraphNode = schema.nodes.paragraph.createAndFill();
|
|
3010
3010
|
if (!paragraphNode) return false;
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
view.dispatch(
|
|
3011
|
+
tr2.insert(posAfter, paragraphNode);
|
|
3012
|
+
tr2.setSelection(import_state2.TextSelection.create(tr2.doc, posAfter + 1));
|
|
3013
|
+
view.dispatch(tr2);
|
|
3014
3014
|
return true;
|
|
3015
3015
|
}
|
|
3016
3016
|
};
|
|
@@ -3043,7 +3043,7 @@ var BaseCustomQuoteText = import_core3.Node.create({
|
|
|
3043
3043
|
return {
|
|
3044
3044
|
Enter: () => {
|
|
3045
3045
|
const { view, state } = this.editor;
|
|
3046
|
-
const { tr, selection } = state;
|
|
3046
|
+
const { tr: tr2, selection } = state;
|
|
3047
3047
|
const { $from } = selection;
|
|
3048
3048
|
if ($from.parent.type.name !== "customQuoteText") {
|
|
3049
3049
|
return false;
|
|
@@ -3052,8 +3052,8 @@ var BaseCustomQuoteText = import_core3.Node.create({
|
|
|
3052
3052
|
const nextNode = state.doc.nodeAt(posAfter);
|
|
3053
3053
|
if (!nextNode || nextNode.type.name !== "customQuoteAuthor") return false;
|
|
3054
3054
|
const nextNodeEnd = posAfter + nextNode.nodeSize - 1;
|
|
3055
|
-
|
|
3056
|
-
view.dispatch(
|
|
3055
|
+
tr2.setSelection(import_state2.TextSelection.create(tr2.doc, nextNodeEnd));
|
|
3056
|
+
view.dispatch(tr2);
|
|
3057
3057
|
return true;
|
|
3058
3058
|
}
|
|
3059
3059
|
};
|
|
@@ -3078,7 +3078,7 @@ var BaseCustomQuoteAuthor = import_core3.Node.create({
|
|
|
3078
3078
|
return {
|
|
3079
3079
|
Enter: () => {
|
|
3080
3080
|
const { view, state } = this.editor;
|
|
3081
|
-
const { tr, selection } = state;
|
|
3081
|
+
const { tr: tr2, selection } = state;
|
|
3082
3082
|
const { $from } = selection;
|
|
3083
3083
|
if ($from.parent.type.name !== "customQuoteAuthor") {
|
|
3084
3084
|
return false;
|
|
@@ -3087,8 +3087,8 @@ var BaseCustomQuoteAuthor = import_core3.Node.create({
|
|
|
3087
3087
|
const nextNode = state.doc.nodeAt(posAfter);
|
|
3088
3088
|
if (!nextNode || nextNode.type.name !== "customQuoteSign") return false;
|
|
3089
3089
|
const nextNodeEnd = posAfter + nextNode.nodeSize - 1;
|
|
3090
|
-
|
|
3091
|
-
view.dispatch(
|
|
3090
|
+
tr2.setSelection(import_state2.TextSelection.create(tr2.doc, nextNodeEnd));
|
|
3091
|
+
view.dispatch(tr2);
|
|
3092
3092
|
return true;
|
|
3093
3093
|
}
|
|
3094
3094
|
};
|
|
@@ -3123,15 +3123,1187 @@ var BaseCustomQuoteSign = import_core3.Node.create({
|
|
|
3123
3123
|
|
|
3124
3124
|
// src/extensions/base/link.ts
|
|
3125
3125
|
var import_extension_link = __toESM(require("@tiptap/extension-link"));
|
|
3126
|
+
var import_core4 = require("@tiptap/core");
|
|
3127
|
+
|
|
3128
|
+
// node_modules/linkifyjs/dist/linkify.mjs
|
|
3129
|
+
var encodedTlds = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";
|
|
3130
|
+
var encodedUtlds = "\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2";
|
|
3131
|
+
var numeric = "numeric";
|
|
3132
|
+
var ascii = "ascii";
|
|
3133
|
+
var alpha = "alpha";
|
|
3134
|
+
var asciinumeric = "asciinumeric";
|
|
3135
|
+
var alphanumeric = "alphanumeric";
|
|
3136
|
+
var domain = "domain";
|
|
3137
|
+
var emoji = "emoji";
|
|
3138
|
+
var scheme = "scheme";
|
|
3139
|
+
var slashscheme = "slashscheme";
|
|
3140
|
+
var whitespace = "whitespace";
|
|
3141
|
+
function registerGroup(name, groups) {
|
|
3142
|
+
if (!(name in groups)) {
|
|
3143
|
+
groups[name] = [];
|
|
3144
|
+
}
|
|
3145
|
+
return groups[name];
|
|
3146
|
+
}
|
|
3147
|
+
function addToGroups(t, flags, groups) {
|
|
3148
|
+
if (flags[numeric]) {
|
|
3149
|
+
flags[asciinumeric] = true;
|
|
3150
|
+
flags[alphanumeric] = true;
|
|
3151
|
+
}
|
|
3152
|
+
if (flags[ascii]) {
|
|
3153
|
+
flags[asciinumeric] = true;
|
|
3154
|
+
flags[alpha] = true;
|
|
3155
|
+
}
|
|
3156
|
+
if (flags[asciinumeric]) {
|
|
3157
|
+
flags[alphanumeric] = true;
|
|
3158
|
+
}
|
|
3159
|
+
if (flags[alpha]) {
|
|
3160
|
+
flags[alphanumeric] = true;
|
|
3161
|
+
}
|
|
3162
|
+
if (flags[alphanumeric]) {
|
|
3163
|
+
flags[domain] = true;
|
|
3164
|
+
}
|
|
3165
|
+
if (flags[emoji]) {
|
|
3166
|
+
flags[domain] = true;
|
|
3167
|
+
}
|
|
3168
|
+
for (const k in flags) {
|
|
3169
|
+
const group = registerGroup(k, groups);
|
|
3170
|
+
if (group.indexOf(t) < 0) {
|
|
3171
|
+
group.push(t);
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
function flagsForToken(t, groups) {
|
|
3176
|
+
const result = {};
|
|
3177
|
+
for (const c in groups) {
|
|
3178
|
+
if (groups[c].indexOf(t) >= 0) {
|
|
3179
|
+
result[c] = true;
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
return result;
|
|
3183
|
+
}
|
|
3184
|
+
function State(token = null) {
|
|
3185
|
+
this.j = {};
|
|
3186
|
+
this.jr = [];
|
|
3187
|
+
this.jd = null;
|
|
3188
|
+
this.t = token;
|
|
3189
|
+
}
|
|
3190
|
+
State.groups = {};
|
|
3191
|
+
State.prototype = {
|
|
3192
|
+
accepts() {
|
|
3193
|
+
return !!this.t;
|
|
3194
|
+
},
|
|
3195
|
+
/**
|
|
3196
|
+
* Follow an existing transition from the given input to the next state.
|
|
3197
|
+
* Does not mutate.
|
|
3198
|
+
* @param {string} input character or token type to transition on
|
|
3199
|
+
* @returns {?State<T>} the next state, if any
|
|
3200
|
+
*/
|
|
3201
|
+
go(input) {
|
|
3202
|
+
const state = this;
|
|
3203
|
+
const nextState = state.j[input];
|
|
3204
|
+
if (nextState) {
|
|
3205
|
+
return nextState;
|
|
3206
|
+
}
|
|
3207
|
+
for (let i = 0; i < state.jr.length; i++) {
|
|
3208
|
+
const regex = state.jr[i][0];
|
|
3209
|
+
const nextState2 = state.jr[i][1];
|
|
3210
|
+
if (nextState2 && regex.test(input)) {
|
|
3211
|
+
return nextState2;
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
return state.jd;
|
|
3215
|
+
},
|
|
3216
|
+
/**
|
|
3217
|
+
* Whether the state has a transition for the given input. Set the second
|
|
3218
|
+
* argument to true to only look for an exact match (and not a default or
|
|
3219
|
+
* regular-expression-based transition)
|
|
3220
|
+
* @param {string} input
|
|
3221
|
+
* @param {boolean} exactOnly
|
|
3222
|
+
*/
|
|
3223
|
+
has(input, exactOnly = false) {
|
|
3224
|
+
return exactOnly ? input in this.j : !!this.go(input);
|
|
3225
|
+
},
|
|
3226
|
+
/**
|
|
3227
|
+
* Short for "transition all"; create a transition from the array of items
|
|
3228
|
+
* in the given list to the same final resulting state.
|
|
3229
|
+
* @param {string | string[]} inputs Group of inputs to transition on
|
|
3230
|
+
* @param {Transition<T> | State<T>} [next] Transition options
|
|
3231
|
+
* @param {Flags} [flags] Collections flags to add token to
|
|
3232
|
+
* @param {Collections<T>} [groups] Master list of token groups
|
|
3233
|
+
*/
|
|
3234
|
+
ta(inputs, next, flags, groups) {
|
|
3235
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
3236
|
+
this.tt(inputs[i], next, flags, groups);
|
|
3237
|
+
}
|
|
3238
|
+
},
|
|
3239
|
+
/**
|
|
3240
|
+
* Short for "take regexp transition"; defines a transition for this state
|
|
3241
|
+
* when it encounters a token which matches the given regular expression
|
|
3242
|
+
* @param {RegExp} regexp Regular expression transition (populate first)
|
|
3243
|
+
* @param {T | State<T>} [next] Transition options
|
|
3244
|
+
* @param {Flags} [flags] Collections flags to add token to
|
|
3245
|
+
* @param {Collections<T>} [groups] Master list of token groups
|
|
3246
|
+
* @returns {State<T>} taken after the given input
|
|
3247
|
+
*/
|
|
3248
|
+
tr(regexp, next, flags, groups) {
|
|
3249
|
+
groups = groups || State.groups;
|
|
3250
|
+
let nextState;
|
|
3251
|
+
if (next && next.j) {
|
|
3252
|
+
nextState = next;
|
|
3253
|
+
} else {
|
|
3254
|
+
nextState = new State(next);
|
|
3255
|
+
if (flags && groups) {
|
|
3256
|
+
addToGroups(next, flags, groups);
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
this.jr.push([regexp, nextState]);
|
|
3260
|
+
return nextState;
|
|
3261
|
+
},
|
|
3262
|
+
/**
|
|
3263
|
+
* Short for "take transitions", will take as many sequential transitions as
|
|
3264
|
+
* the length of the given input and returns the
|
|
3265
|
+
* resulting final state.
|
|
3266
|
+
* @param {string | string[]} input
|
|
3267
|
+
* @param {T | State<T>} [next] Transition options
|
|
3268
|
+
* @param {Flags} [flags] Collections flags to add token to
|
|
3269
|
+
* @param {Collections<T>} [groups] Master list of token groups
|
|
3270
|
+
* @returns {State<T>} taken after the given input
|
|
3271
|
+
*/
|
|
3272
|
+
ts(input, next, flags, groups) {
|
|
3273
|
+
let state = this;
|
|
3274
|
+
const len = input.length;
|
|
3275
|
+
if (!len) {
|
|
3276
|
+
return state;
|
|
3277
|
+
}
|
|
3278
|
+
for (let i = 0; i < len - 1; i++) {
|
|
3279
|
+
state = state.tt(input[i]);
|
|
3280
|
+
}
|
|
3281
|
+
return state.tt(input[len - 1], next, flags, groups);
|
|
3282
|
+
},
|
|
3283
|
+
/**
|
|
3284
|
+
* Short for "take transition", this is a method for building/working with
|
|
3285
|
+
* state machines.
|
|
3286
|
+
*
|
|
3287
|
+
* If a state already exists for the given input, returns it.
|
|
3288
|
+
*
|
|
3289
|
+
* If a token is specified, that state will emit that token when reached by
|
|
3290
|
+
* the linkify engine.
|
|
3291
|
+
*
|
|
3292
|
+
* If no state exists, it will be initialized with some default transitions
|
|
3293
|
+
* that resemble existing default transitions.
|
|
3294
|
+
*
|
|
3295
|
+
* If a state is given for the second argument, that state will be
|
|
3296
|
+
* transitioned to on the given input regardless of what that input
|
|
3297
|
+
* previously did.
|
|
3298
|
+
*
|
|
3299
|
+
* Specify a token group flags to define groups that this token belongs to.
|
|
3300
|
+
* The token will be added to corresponding entires in the given groups
|
|
3301
|
+
* object.
|
|
3302
|
+
*
|
|
3303
|
+
* @param {string} input character, token type to transition on
|
|
3304
|
+
* @param {T | State<T>} [next] Transition options
|
|
3305
|
+
* @param {Flags} [flags] Collections flags to add token to
|
|
3306
|
+
* @param {Collections<T>} [groups] Master list of groups
|
|
3307
|
+
* @returns {State<T>} taken after the given input
|
|
3308
|
+
*/
|
|
3309
|
+
tt(input, next, flags, groups) {
|
|
3310
|
+
groups = groups || State.groups;
|
|
3311
|
+
const state = this;
|
|
3312
|
+
if (next && next.j) {
|
|
3313
|
+
state.j[input] = next;
|
|
3314
|
+
return next;
|
|
3315
|
+
}
|
|
3316
|
+
const t = next;
|
|
3317
|
+
let nextState, templateState = state.go(input);
|
|
3318
|
+
if (templateState) {
|
|
3319
|
+
nextState = new State();
|
|
3320
|
+
Object.assign(nextState.j, templateState.j);
|
|
3321
|
+
nextState.jr.push.apply(nextState.jr, templateState.jr);
|
|
3322
|
+
nextState.jd = templateState.jd;
|
|
3323
|
+
nextState.t = templateState.t;
|
|
3324
|
+
} else {
|
|
3325
|
+
nextState = new State();
|
|
3326
|
+
}
|
|
3327
|
+
if (t) {
|
|
3328
|
+
if (groups) {
|
|
3329
|
+
if (nextState.t && typeof nextState.t === "string") {
|
|
3330
|
+
const allFlags = Object.assign(flagsForToken(nextState.t, groups), flags);
|
|
3331
|
+
addToGroups(t, allFlags, groups);
|
|
3332
|
+
} else if (flags) {
|
|
3333
|
+
addToGroups(t, flags, groups);
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
nextState.t = t;
|
|
3337
|
+
}
|
|
3338
|
+
state.j[input] = nextState;
|
|
3339
|
+
return nextState;
|
|
3340
|
+
}
|
|
3341
|
+
};
|
|
3342
|
+
var ta = (state, input, next, flags, groups) => state.ta(input, next, flags, groups);
|
|
3343
|
+
var tr = (state, regexp, next, flags, groups) => state.tr(regexp, next, flags, groups);
|
|
3344
|
+
var ts = (state, input, next, flags, groups) => state.ts(input, next, flags, groups);
|
|
3345
|
+
var tt = (state, input, next, flags, groups) => state.tt(input, next, flags, groups);
|
|
3346
|
+
var WORD = "WORD";
|
|
3347
|
+
var UWORD = "UWORD";
|
|
3348
|
+
var ASCIINUMERICAL = "ASCIINUMERICAL";
|
|
3349
|
+
var ALPHANUMERICAL = "ALPHANUMERICAL";
|
|
3350
|
+
var LOCALHOST = "LOCALHOST";
|
|
3351
|
+
var TLD = "TLD";
|
|
3352
|
+
var UTLD = "UTLD";
|
|
3353
|
+
var SCHEME = "SCHEME";
|
|
3354
|
+
var SLASH_SCHEME = "SLASH_SCHEME";
|
|
3355
|
+
var NUM = "NUM";
|
|
3356
|
+
var WS = "WS";
|
|
3357
|
+
var NL = "NL";
|
|
3358
|
+
var OPENBRACE = "OPENBRACE";
|
|
3359
|
+
var CLOSEBRACE = "CLOSEBRACE";
|
|
3360
|
+
var OPENBRACKET = "OPENBRACKET";
|
|
3361
|
+
var CLOSEBRACKET = "CLOSEBRACKET";
|
|
3362
|
+
var OPENPAREN = "OPENPAREN";
|
|
3363
|
+
var CLOSEPAREN = "CLOSEPAREN";
|
|
3364
|
+
var OPENANGLEBRACKET = "OPENANGLEBRACKET";
|
|
3365
|
+
var CLOSEANGLEBRACKET = "CLOSEANGLEBRACKET";
|
|
3366
|
+
var FULLWIDTHLEFTPAREN = "FULLWIDTHLEFTPAREN";
|
|
3367
|
+
var FULLWIDTHRIGHTPAREN = "FULLWIDTHRIGHTPAREN";
|
|
3368
|
+
var LEFTCORNERBRACKET = "LEFTCORNERBRACKET";
|
|
3369
|
+
var RIGHTCORNERBRACKET = "RIGHTCORNERBRACKET";
|
|
3370
|
+
var LEFTWHITECORNERBRACKET = "LEFTWHITECORNERBRACKET";
|
|
3371
|
+
var RIGHTWHITECORNERBRACKET = "RIGHTWHITECORNERBRACKET";
|
|
3372
|
+
var FULLWIDTHLESSTHAN = "FULLWIDTHLESSTHAN";
|
|
3373
|
+
var FULLWIDTHGREATERTHAN = "FULLWIDTHGREATERTHAN";
|
|
3374
|
+
var AMPERSAND = "AMPERSAND";
|
|
3375
|
+
var APOSTROPHE = "APOSTROPHE";
|
|
3376
|
+
var ASTERISK = "ASTERISK";
|
|
3377
|
+
var AT = "AT";
|
|
3378
|
+
var BACKSLASH = "BACKSLASH";
|
|
3379
|
+
var BACKTICK = "BACKTICK";
|
|
3380
|
+
var CARET = "CARET";
|
|
3381
|
+
var COLON = "COLON";
|
|
3382
|
+
var COMMA = "COMMA";
|
|
3383
|
+
var DOLLAR = "DOLLAR";
|
|
3384
|
+
var DOT = "DOT";
|
|
3385
|
+
var EQUALS = "EQUALS";
|
|
3386
|
+
var EXCLAMATION = "EXCLAMATION";
|
|
3387
|
+
var HYPHEN = "HYPHEN";
|
|
3388
|
+
var PERCENT = "PERCENT";
|
|
3389
|
+
var PIPE = "PIPE";
|
|
3390
|
+
var PLUS = "PLUS";
|
|
3391
|
+
var POUND = "POUND";
|
|
3392
|
+
var QUERY = "QUERY";
|
|
3393
|
+
var QUOTE = "QUOTE";
|
|
3394
|
+
var FULLWIDTHMIDDLEDOT = "FULLWIDTHMIDDLEDOT";
|
|
3395
|
+
var SEMI = "SEMI";
|
|
3396
|
+
var SLASH = "SLASH";
|
|
3397
|
+
var TILDE = "TILDE";
|
|
3398
|
+
var UNDERSCORE = "UNDERSCORE";
|
|
3399
|
+
var EMOJI$1 = "EMOJI";
|
|
3400
|
+
var SYM = "SYM";
|
|
3401
|
+
var tk = /* @__PURE__ */ Object.freeze({
|
|
3402
|
+
__proto__: null,
|
|
3403
|
+
ALPHANUMERICAL,
|
|
3404
|
+
AMPERSAND,
|
|
3405
|
+
APOSTROPHE,
|
|
3406
|
+
ASCIINUMERICAL,
|
|
3407
|
+
ASTERISK,
|
|
3408
|
+
AT,
|
|
3409
|
+
BACKSLASH,
|
|
3410
|
+
BACKTICK,
|
|
3411
|
+
CARET,
|
|
3412
|
+
CLOSEANGLEBRACKET,
|
|
3413
|
+
CLOSEBRACE,
|
|
3414
|
+
CLOSEBRACKET,
|
|
3415
|
+
CLOSEPAREN,
|
|
3416
|
+
COLON,
|
|
3417
|
+
COMMA,
|
|
3418
|
+
DOLLAR,
|
|
3419
|
+
DOT,
|
|
3420
|
+
EMOJI: EMOJI$1,
|
|
3421
|
+
EQUALS,
|
|
3422
|
+
EXCLAMATION,
|
|
3423
|
+
FULLWIDTHGREATERTHAN,
|
|
3424
|
+
FULLWIDTHLEFTPAREN,
|
|
3425
|
+
FULLWIDTHLESSTHAN,
|
|
3426
|
+
FULLWIDTHMIDDLEDOT,
|
|
3427
|
+
FULLWIDTHRIGHTPAREN,
|
|
3428
|
+
HYPHEN,
|
|
3429
|
+
LEFTCORNERBRACKET,
|
|
3430
|
+
LEFTWHITECORNERBRACKET,
|
|
3431
|
+
LOCALHOST,
|
|
3432
|
+
NL,
|
|
3433
|
+
NUM,
|
|
3434
|
+
OPENANGLEBRACKET,
|
|
3435
|
+
OPENBRACE,
|
|
3436
|
+
OPENBRACKET,
|
|
3437
|
+
OPENPAREN,
|
|
3438
|
+
PERCENT,
|
|
3439
|
+
PIPE,
|
|
3440
|
+
PLUS,
|
|
3441
|
+
POUND,
|
|
3442
|
+
QUERY,
|
|
3443
|
+
QUOTE,
|
|
3444
|
+
RIGHTCORNERBRACKET,
|
|
3445
|
+
RIGHTWHITECORNERBRACKET,
|
|
3446
|
+
SCHEME,
|
|
3447
|
+
SEMI,
|
|
3448
|
+
SLASH,
|
|
3449
|
+
SLASH_SCHEME,
|
|
3450
|
+
SYM,
|
|
3451
|
+
TILDE,
|
|
3452
|
+
TLD,
|
|
3453
|
+
UNDERSCORE,
|
|
3454
|
+
UTLD,
|
|
3455
|
+
UWORD,
|
|
3456
|
+
WORD,
|
|
3457
|
+
WS
|
|
3458
|
+
});
|
|
3459
|
+
var ASCII_LETTER = /[a-z]/;
|
|
3460
|
+
var LETTER = /\p{L}/u;
|
|
3461
|
+
var EMOJI = /\p{Emoji}/u;
|
|
3462
|
+
var DIGIT = /\d/;
|
|
3463
|
+
var SPACE = /\s/;
|
|
3464
|
+
var CR = "\r";
|
|
3465
|
+
var LF = "\n";
|
|
3466
|
+
var EMOJI_VARIATION = "\uFE0F";
|
|
3467
|
+
var EMOJI_JOINER = "\u200D";
|
|
3468
|
+
var OBJECT_REPLACEMENT = "\uFFFC";
|
|
3469
|
+
var tlds = null;
|
|
3470
|
+
var utlds = null;
|
|
3471
|
+
function init$2(customSchemes = []) {
|
|
3472
|
+
const groups = {};
|
|
3473
|
+
State.groups = groups;
|
|
3474
|
+
const Start = new State();
|
|
3475
|
+
if (tlds == null) {
|
|
3476
|
+
tlds = decodeTlds(encodedTlds);
|
|
3477
|
+
}
|
|
3478
|
+
if (utlds == null) {
|
|
3479
|
+
utlds = decodeTlds(encodedUtlds);
|
|
3480
|
+
}
|
|
3481
|
+
tt(Start, "'", APOSTROPHE);
|
|
3482
|
+
tt(Start, "{", OPENBRACE);
|
|
3483
|
+
tt(Start, "}", CLOSEBRACE);
|
|
3484
|
+
tt(Start, "[", OPENBRACKET);
|
|
3485
|
+
tt(Start, "]", CLOSEBRACKET);
|
|
3486
|
+
tt(Start, "(", OPENPAREN);
|
|
3487
|
+
tt(Start, ")", CLOSEPAREN);
|
|
3488
|
+
tt(Start, "<", OPENANGLEBRACKET);
|
|
3489
|
+
tt(Start, ">", CLOSEANGLEBRACKET);
|
|
3490
|
+
tt(Start, "\uFF08", FULLWIDTHLEFTPAREN);
|
|
3491
|
+
tt(Start, "\uFF09", FULLWIDTHRIGHTPAREN);
|
|
3492
|
+
tt(Start, "\u300C", LEFTCORNERBRACKET);
|
|
3493
|
+
tt(Start, "\u300D", RIGHTCORNERBRACKET);
|
|
3494
|
+
tt(Start, "\u300E", LEFTWHITECORNERBRACKET);
|
|
3495
|
+
tt(Start, "\u300F", RIGHTWHITECORNERBRACKET);
|
|
3496
|
+
tt(Start, "\uFF1C", FULLWIDTHLESSTHAN);
|
|
3497
|
+
tt(Start, "\uFF1E", FULLWIDTHGREATERTHAN);
|
|
3498
|
+
tt(Start, "&", AMPERSAND);
|
|
3499
|
+
tt(Start, "*", ASTERISK);
|
|
3500
|
+
tt(Start, "@", AT);
|
|
3501
|
+
tt(Start, "`", BACKTICK);
|
|
3502
|
+
tt(Start, "^", CARET);
|
|
3503
|
+
tt(Start, ":", COLON);
|
|
3504
|
+
tt(Start, ",", COMMA);
|
|
3505
|
+
tt(Start, "$", DOLLAR);
|
|
3506
|
+
tt(Start, ".", DOT);
|
|
3507
|
+
tt(Start, "=", EQUALS);
|
|
3508
|
+
tt(Start, "!", EXCLAMATION);
|
|
3509
|
+
tt(Start, "-", HYPHEN);
|
|
3510
|
+
tt(Start, "%", PERCENT);
|
|
3511
|
+
tt(Start, "|", PIPE);
|
|
3512
|
+
tt(Start, "+", PLUS);
|
|
3513
|
+
tt(Start, "#", POUND);
|
|
3514
|
+
tt(Start, "?", QUERY);
|
|
3515
|
+
tt(Start, '"', QUOTE);
|
|
3516
|
+
tt(Start, "/", SLASH);
|
|
3517
|
+
tt(Start, ";", SEMI);
|
|
3518
|
+
tt(Start, "~", TILDE);
|
|
3519
|
+
tt(Start, "_", UNDERSCORE);
|
|
3520
|
+
tt(Start, "\\", BACKSLASH);
|
|
3521
|
+
tt(Start, "\u30FB", FULLWIDTHMIDDLEDOT);
|
|
3522
|
+
const Num = tr(Start, DIGIT, NUM, {
|
|
3523
|
+
[numeric]: true
|
|
3524
|
+
});
|
|
3525
|
+
tr(Num, DIGIT, Num);
|
|
3526
|
+
const Asciinumeric = tr(Num, ASCII_LETTER, ASCIINUMERICAL, {
|
|
3527
|
+
[asciinumeric]: true
|
|
3528
|
+
});
|
|
3529
|
+
const Alphanumeric = tr(Num, LETTER, ALPHANUMERICAL, {
|
|
3530
|
+
[alphanumeric]: true
|
|
3531
|
+
});
|
|
3532
|
+
const Word = tr(Start, ASCII_LETTER, WORD, {
|
|
3533
|
+
[ascii]: true
|
|
3534
|
+
});
|
|
3535
|
+
tr(Word, DIGIT, Asciinumeric);
|
|
3536
|
+
tr(Word, ASCII_LETTER, Word);
|
|
3537
|
+
tr(Asciinumeric, DIGIT, Asciinumeric);
|
|
3538
|
+
tr(Asciinumeric, ASCII_LETTER, Asciinumeric);
|
|
3539
|
+
const UWord = tr(Start, LETTER, UWORD, {
|
|
3540
|
+
[alpha]: true
|
|
3541
|
+
});
|
|
3542
|
+
tr(UWord, ASCII_LETTER);
|
|
3543
|
+
tr(UWord, DIGIT, Alphanumeric);
|
|
3544
|
+
tr(UWord, LETTER, UWord);
|
|
3545
|
+
tr(Alphanumeric, DIGIT, Alphanumeric);
|
|
3546
|
+
tr(Alphanumeric, ASCII_LETTER);
|
|
3547
|
+
tr(Alphanumeric, LETTER, Alphanumeric);
|
|
3548
|
+
const Nl2 = tt(Start, LF, NL, {
|
|
3549
|
+
[whitespace]: true
|
|
3550
|
+
});
|
|
3551
|
+
const Cr = tt(Start, CR, WS, {
|
|
3552
|
+
[whitespace]: true
|
|
3553
|
+
});
|
|
3554
|
+
const Ws = tr(Start, SPACE, WS, {
|
|
3555
|
+
[whitespace]: true
|
|
3556
|
+
});
|
|
3557
|
+
tt(Start, OBJECT_REPLACEMENT, Ws);
|
|
3558
|
+
tt(Cr, LF, Nl2);
|
|
3559
|
+
tt(Cr, OBJECT_REPLACEMENT, Ws);
|
|
3560
|
+
tr(Cr, SPACE, Ws);
|
|
3561
|
+
tt(Ws, CR);
|
|
3562
|
+
tt(Ws, LF);
|
|
3563
|
+
tr(Ws, SPACE, Ws);
|
|
3564
|
+
tt(Ws, OBJECT_REPLACEMENT, Ws);
|
|
3565
|
+
const Emoji = tr(Start, EMOJI, EMOJI$1, {
|
|
3566
|
+
[emoji]: true
|
|
3567
|
+
});
|
|
3568
|
+
tt(Emoji, "#");
|
|
3569
|
+
tr(Emoji, EMOJI, Emoji);
|
|
3570
|
+
tt(Emoji, EMOJI_VARIATION, Emoji);
|
|
3571
|
+
const EmojiJoiner = tt(Emoji, EMOJI_JOINER);
|
|
3572
|
+
tt(EmojiJoiner, "#");
|
|
3573
|
+
tr(EmojiJoiner, EMOJI, Emoji);
|
|
3574
|
+
const wordjr = [[ASCII_LETTER, Word], [DIGIT, Asciinumeric]];
|
|
3575
|
+
const uwordjr = [[ASCII_LETTER, null], [LETTER, UWord], [DIGIT, Alphanumeric]];
|
|
3576
|
+
for (let i = 0; i < tlds.length; i++) {
|
|
3577
|
+
fastts(Start, tlds[i], TLD, WORD, wordjr);
|
|
3578
|
+
}
|
|
3579
|
+
for (let i = 0; i < utlds.length; i++) {
|
|
3580
|
+
fastts(Start, utlds[i], UTLD, UWORD, uwordjr);
|
|
3581
|
+
}
|
|
3582
|
+
addToGroups(TLD, {
|
|
3583
|
+
tld: true,
|
|
3584
|
+
ascii: true
|
|
3585
|
+
}, groups);
|
|
3586
|
+
addToGroups(UTLD, {
|
|
3587
|
+
utld: true,
|
|
3588
|
+
alpha: true
|
|
3589
|
+
}, groups);
|
|
3590
|
+
fastts(Start, "file", SCHEME, WORD, wordjr);
|
|
3591
|
+
fastts(Start, "mailto", SCHEME, WORD, wordjr);
|
|
3592
|
+
fastts(Start, "http", SLASH_SCHEME, WORD, wordjr);
|
|
3593
|
+
fastts(Start, "https", SLASH_SCHEME, WORD, wordjr);
|
|
3594
|
+
fastts(Start, "ftp", SLASH_SCHEME, WORD, wordjr);
|
|
3595
|
+
fastts(Start, "ftps", SLASH_SCHEME, WORD, wordjr);
|
|
3596
|
+
addToGroups(SCHEME, {
|
|
3597
|
+
scheme: true,
|
|
3598
|
+
ascii: true
|
|
3599
|
+
}, groups);
|
|
3600
|
+
addToGroups(SLASH_SCHEME, {
|
|
3601
|
+
slashscheme: true,
|
|
3602
|
+
ascii: true
|
|
3603
|
+
}, groups);
|
|
3604
|
+
customSchemes = customSchemes.sort((a, b) => a[0] > b[0] ? 1 : -1);
|
|
3605
|
+
for (let i = 0; i < customSchemes.length; i++) {
|
|
3606
|
+
const sch = customSchemes[i][0];
|
|
3607
|
+
const optionalSlashSlash = customSchemes[i][1];
|
|
3608
|
+
const flags = optionalSlashSlash ? {
|
|
3609
|
+
[scheme]: true
|
|
3610
|
+
} : {
|
|
3611
|
+
[slashscheme]: true
|
|
3612
|
+
};
|
|
3613
|
+
if (sch.indexOf("-") >= 0) {
|
|
3614
|
+
flags[domain] = true;
|
|
3615
|
+
} else if (!ASCII_LETTER.test(sch)) {
|
|
3616
|
+
flags[numeric] = true;
|
|
3617
|
+
} else if (DIGIT.test(sch)) {
|
|
3618
|
+
flags[asciinumeric] = true;
|
|
3619
|
+
} else {
|
|
3620
|
+
flags[ascii] = true;
|
|
3621
|
+
}
|
|
3622
|
+
ts(Start, sch, sch, flags);
|
|
3623
|
+
}
|
|
3624
|
+
ts(Start, "localhost", LOCALHOST, {
|
|
3625
|
+
ascii: true
|
|
3626
|
+
});
|
|
3627
|
+
Start.jd = new State(SYM);
|
|
3628
|
+
return {
|
|
3629
|
+
start: Start,
|
|
3630
|
+
tokens: Object.assign({
|
|
3631
|
+
groups
|
|
3632
|
+
}, tk)
|
|
3633
|
+
};
|
|
3634
|
+
}
|
|
3635
|
+
function run$1(start, str) {
|
|
3636
|
+
const iterable = stringToArray(str.replace(/[A-Z]/g, (c) => c.toLowerCase()));
|
|
3637
|
+
const charCount = iterable.length;
|
|
3638
|
+
const tokens = [];
|
|
3639
|
+
let cursor = 0;
|
|
3640
|
+
let charCursor = 0;
|
|
3641
|
+
while (charCursor < charCount) {
|
|
3642
|
+
let state = start;
|
|
3643
|
+
let nextState = null;
|
|
3644
|
+
let tokenLength = 0;
|
|
3645
|
+
let latestAccepting = null;
|
|
3646
|
+
let sinceAccepts = -1;
|
|
3647
|
+
let charsSinceAccepts = -1;
|
|
3648
|
+
while (charCursor < charCount && (nextState = state.go(iterable[charCursor]))) {
|
|
3649
|
+
state = nextState;
|
|
3650
|
+
if (state.accepts()) {
|
|
3651
|
+
sinceAccepts = 0;
|
|
3652
|
+
charsSinceAccepts = 0;
|
|
3653
|
+
latestAccepting = state;
|
|
3654
|
+
} else if (sinceAccepts >= 0) {
|
|
3655
|
+
sinceAccepts += iterable[charCursor].length;
|
|
3656
|
+
charsSinceAccepts++;
|
|
3657
|
+
}
|
|
3658
|
+
tokenLength += iterable[charCursor].length;
|
|
3659
|
+
cursor += iterable[charCursor].length;
|
|
3660
|
+
charCursor++;
|
|
3661
|
+
}
|
|
3662
|
+
cursor -= sinceAccepts;
|
|
3663
|
+
charCursor -= charsSinceAccepts;
|
|
3664
|
+
tokenLength -= sinceAccepts;
|
|
3665
|
+
tokens.push({
|
|
3666
|
+
t: latestAccepting.t,
|
|
3667
|
+
// token type/name
|
|
3668
|
+
v: str.slice(cursor - tokenLength, cursor),
|
|
3669
|
+
// string value
|
|
3670
|
+
s: cursor - tokenLength,
|
|
3671
|
+
// start index
|
|
3672
|
+
e: cursor
|
|
3673
|
+
// end index (excluding)
|
|
3674
|
+
});
|
|
3675
|
+
}
|
|
3676
|
+
return tokens;
|
|
3677
|
+
}
|
|
3678
|
+
function stringToArray(str) {
|
|
3679
|
+
const result = [];
|
|
3680
|
+
const len = str.length;
|
|
3681
|
+
let index = 0;
|
|
3682
|
+
while (index < len) {
|
|
3683
|
+
let first = str.charCodeAt(index);
|
|
3684
|
+
let second;
|
|
3685
|
+
let char = first < 55296 || first > 56319 || index + 1 === len || (second = str.charCodeAt(index + 1)) < 56320 || second > 57343 ? str[index] : str.slice(index, index + 2);
|
|
3686
|
+
result.push(char);
|
|
3687
|
+
index += char.length;
|
|
3688
|
+
}
|
|
3689
|
+
return result;
|
|
3690
|
+
}
|
|
3691
|
+
function fastts(state, input, t, defaultt, jr) {
|
|
3692
|
+
let next;
|
|
3693
|
+
const len = input.length;
|
|
3694
|
+
for (let i = 0; i < len - 1; i++) {
|
|
3695
|
+
const char = input[i];
|
|
3696
|
+
if (state.j[char]) {
|
|
3697
|
+
next = state.j[char];
|
|
3698
|
+
} else {
|
|
3699
|
+
next = new State(defaultt);
|
|
3700
|
+
next.jr = jr.slice();
|
|
3701
|
+
state.j[char] = next;
|
|
3702
|
+
}
|
|
3703
|
+
state = next;
|
|
3704
|
+
}
|
|
3705
|
+
next = new State(t);
|
|
3706
|
+
next.jr = jr.slice();
|
|
3707
|
+
state.j[input[len - 1]] = next;
|
|
3708
|
+
return next;
|
|
3709
|
+
}
|
|
3710
|
+
function decodeTlds(encoded) {
|
|
3711
|
+
const words = [];
|
|
3712
|
+
const stack = [];
|
|
3713
|
+
let i = 0;
|
|
3714
|
+
let digits = "0123456789";
|
|
3715
|
+
while (i < encoded.length) {
|
|
3716
|
+
let popDigitCount = 0;
|
|
3717
|
+
while (digits.indexOf(encoded[i + popDigitCount]) >= 0) {
|
|
3718
|
+
popDigitCount++;
|
|
3719
|
+
}
|
|
3720
|
+
if (popDigitCount > 0) {
|
|
3721
|
+
words.push(stack.join(""));
|
|
3722
|
+
for (let popCount = parseInt(encoded.substring(i, i + popDigitCount), 10); popCount > 0; popCount--) {
|
|
3723
|
+
stack.pop();
|
|
3724
|
+
}
|
|
3725
|
+
i += popDigitCount;
|
|
3726
|
+
} else {
|
|
3727
|
+
stack.push(encoded[i]);
|
|
3728
|
+
i++;
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
return words;
|
|
3732
|
+
}
|
|
3733
|
+
var defaults = {
|
|
3734
|
+
defaultProtocol: "http",
|
|
3735
|
+
events: null,
|
|
3736
|
+
format: noop,
|
|
3737
|
+
formatHref: noop,
|
|
3738
|
+
nl2br: false,
|
|
3739
|
+
tagName: "a",
|
|
3740
|
+
target: null,
|
|
3741
|
+
rel: null,
|
|
3742
|
+
validate: true,
|
|
3743
|
+
truncate: Infinity,
|
|
3744
|
+
className: null,
|
|
3745
|
+
attributes: null,
|
|
3746
|
+
ignoreTags: [],
|
|
3747
|
+
render: null
|
|
3748
|
+
};
|
|
3749
|
+
function Options(opts, defaultRender = null) {
|
|
3750
|
+
let o = Object.assign({}, defaults);
|
|
3751
|
+
if (opts) {
|
|
3752
|
+
o = Object.assign(o, opts instanceof Options ? opts.o : opts);
|
|
3753
|
+
}
|
|
3754
|
+
const ignoredTags = o.ignoreTags;
|
|
3755
|
+
const uppercaseIgnoredTags = [];
|
|
3756
|
+
for (let i = 0; i < ignoredTags.length; i++) {
|
|
3757
|
+
uppercaseIgnoredTags.push(ignoredTags[i].toUpperCase());
|
|
3758
|
+
}
|
|
3759
|
+
this.o = o;
|
|
3760
|
+
if (defaultRender) {
|
|
3761
|
+
this.defaultRender = defaultRender;
|
|
3762
|
+
}
|
|
3763
|
+
this.ignoreTags = uppercaseIgnoredTags;
|
|
3764
|
+
}
|
|
3765
|
+
Options.prototype = {
|
|
3766
|
+
o: defaults,
|
|
3767
|
+
/**
|
|
3768
|
+
* @type string[]
|
|
3769
|
+
*/
|
|
3770
|
+
ignoreTags: [],
|
|
3771
|
+
/**
|
|
3772
|
+
* @param {IntermediateRepresentation} ir
|
|
3773
|
+
* @returns {any}
|
|
3774
|
+
*/
|
|
3775
|
+
defaultRender(ir) {
|
|
3776
|
+
return ir;
|
|
3777
|
+
},
|
|
3778
|
+
/**
|
|
3779
|
+
* Returns true or false based on whether a token should be displayed as a
|
|
3780
|
+
* link based on the user options.
|
|
3781
|
+
* @param {MultiToken} token
|
|
3782
|
+
* @returns {boolean}
|
|
3783
|
+
*/
|
|
3784
|
+
check(token) {
|
|
3785
|
+
return this.get("validate", token.toString(), token);
|
|
3786
|
+
},
|
|
3787
|
+
// Private methods
|
|
3788
|
+
/**
|
|
3789
|
+
* Resolve an option's value based on the value of the option and the given
|
|
3790
|
+
* params. If operator and token are specified and the target option is
|
|
3791
|
+
* callable, automatically calls the function with the given argument.
|
|
3792
|
+
* @template {keyof Opts} K
|
|
3793
|
+
* @param {K} key Name of option to use
|
|
3794
|
+
* @param {string} [operator] will be passed to the target option if it's a
|
|
3795
|
+
* function. If not specified, RAW function value gets returned
|
|
3796
|
+
* @param {MultiToken} [token] The token from linkify.tokenize
|
|
3797
|
+
* @returns {Opts[K] | any}
|
|
3798
|
+
*/
|
|
3799
|
+
get(key, operator, token) {
|
|
3800
|
+
const isCallable = operator != null;
|
|
3801
|
+
let option = this.o[key];
|
|
3802
|
+
if (!option) {
|
|
3803
|
+
return option;
|
|
3804
|
+
}
|
|
3805
|
+
if (typeof option === "object") {
|
|
3806
|
+
option = token.t in option ? option[token.t] : defaults[key];
|
|
3807
|
+
if (typeof option === "function" && isCallable) {
|
|
3808
|
+
option = option(operator, token);
|
|
3809
|
+
}
|
|
3810
|
+
} else if (typeof option === "function" && isCallable) {
|
|
3811
|
+
option = option(operator, token.t, token);
|
|
3812
|
+
}
|
|
3813
|
+
return option;
|
|
3814
|
+
},
|
|
3815
|
+
/**
|
|
3816
|
+
* @template {keyof Opts} L
|
|
3817
|
+
* @param {L} key Name of options object to use
|
|
3818
|
+
* @param {string} [operator]
|
|
3819
|
+
* @param {MultiToken} [token]
|
|
3820
|
+
* @returns {Opts[L] | any}
|
|
3821
|
+
*/
|
|
3822
|
+
getObj(key, operator, token) {
|
|
3823
|
+
let obj = this.o[key];
|
|
3824
|
+
if (typeof obj === "function" && operator != null) {
|
|
3825
|
+
obj = obj(operator, token.t, token);
|
|
3826
|
+
}
|
|
3827
|
+
return obj;
|
|
3828
|
+
},
|
|
3829
|
+
/**
|
|
3830
|
+
* Convert the given token to a rendered element that may be added to the
|
|
3831
|
+
* calling-interface's DOM
|
|
3832
|
+
* @param {MultiToken} token Token to render to an HTML element
|
|
3833
|
+
* @returns {any} Render result; e.g., HTML string, DOM element, React
|
|
3834
|
+
* Component, etc.
|
|
3835
|
+
*/
|
|
3836
|
+
render(token) {
|
|
3837
|
+
const ir = token.render(this);
|
|
3838
|
+
const renderFn = this.get("render", null, token) || this.defaultRender;
|
|
3839
|
+
return renderFn(ir, token.t, token);
|
|
3840
|
+
}
|
|
3841
|
+
};
|
|
3842
|
+
function noop(val) {
|
|
3843
|
+
return val;
|
|
3844
|
+
}
|
|
3845
|
+
function MultiToken(value, tokens) {
|
|
3846
|
+
this.t = "token";
|
|
3847
|
+
this.v = value;
|
|
3848
|
+
this.tk = tokens;
|
|
3849
|
+
}
|
|
3850
|
+
MultiToken.prototype = {
|
|
3851
|
+
isLink: false,
|
|
3852
|
+
/**
|
|
3853
|
+
* Return the string this token represents.
|
|
3854
|
+
* @return {string}
|
|
3855
|
+
*/
|
|
3856
|
+
toString() {
|
|
3857
|
+
return this.v;
|
|
3858
|
+
},
|
|
3859
|
+
/**
|
|
3860
|
+
* What should the value for this token be in the `href` HTML attribute?
|
|
3861
|
+
* Returns the `.toString` value by default.
|
|
3862
|
+
* @param {string} [scheme]
|
|
3863
|
+
* @return {string}
|
|
3864
|
+
*/
|
|
3865
|
+
toHref(scheme2) {
|
|
3866
|
+
return this.toString();
|
|
3867
|
+
},
|
|
3868
|
+
/**
|
|
3869
|
+
* @param {Options} options Formatting options
|
|
3870
|
+
* @returns {string}
|
|
3871
|
+
*/
|
|
3872
|
+
toFormattedString(options) {
|
|
3873
|
+
const val = this.toString();
|
|
3874
|
+
const truncate = options.get("truncate", val, this);
|
|
3875
|
+
const formatted = options.get("format", val, this);
|
|
3876
|
+
return truncate && formatted.length > truncate ? formatted.substring(0, truncate) + "\u2026" : formatted;
|
|
3877
|
+
},
|
|
3878
|
+
/**
|
|
3879
|
+
*
|
|
3880
|
+
* @param {Options} options
|
|
3881
|
+
* @returns {string}
|
|
3882
|
+
*/
|
|
3883
|
+
toFormattedHref(options) {
|
|
3884
|
+
return options.get("formatHref", this.toHref(options.get("defaultProtocol")), this);
|
|
3885
|
+
},
|
|
3886
|
+
/**
|
|
3887
|
+
* The start index of this token in the original input string
|
|
3888
|
+
* @returns {number}
|
|
3889
|
+
*/
|
|
3890
|
+
startIndex() {
|
|
3891
|
+
return this.tk[0].s;
|
|
3892
|
+
},
|
|
3893
|
+
/**
|
|
3894
|
+
* The end index of this token in the original input string (up to this
|
|
3895
|
+
* index but not including it)
|
|
3896
|
+
* @returns {number}
|
|
3897
|
+
*/
|
|
3898
|
+
endIndex() {
|
|
3899
|
+
return this.tk[this.tk.length - 1].e;
|
|
3900
|
+
},
|
|
3901
|
+
/**
|
|
3902
|
+
Returns an object of relevant values for this token, which includes keys
|
|
3903
|
+
* type - Kind of token ('url', 'email', etc.)
|
|
3904
|
+
* value - Original text
|
|
3905
|
+
* href - The value that should be added to the anchor tag's href
|
|
3906
|
+
attribute
|
|
3907
|
+
@method toObject
|
|
3908
|
+
@param {string} [protocol] `'http'` by default
|
|
3909
|
+
*/
|
|
3910
|
+
toObject(protocol = defaults.defaultProtocol) {
|
|
3911
|
+
return {
|
|
3912
|
+
type: this.t,
|
|
3913
|
+
value: this.toString(),
|
|
3914
|
+
isLink: this.isLink,
|
|
3915
|
+
href: this.toHref(protocol),
|
|
3916
|
+
start: this.startIndex(),
|
|
3917
|
+
end: this.endIndex()
|
|
3918
|
+
};
|
|
3919
|
+
},
|
|
3920
|
+
/**
|
|
3921
|
+
*
|
|
3922
|
+
* @param {Options} options Formatting option
|
|
3923
|
+
*/
|
|
3924
|
+
toFormattedObject(options) {
|
|
3925
|
+
return {
|
|
3926
|
+
type: this.t,
|
|
3927
|
+
value: this.toFormattedString(options),
|
|
3928
|
+
isLink: this.isLink,
|
|
3929
|
+
href: this.toFormattedHref(options),
|
|
3930
|
+
start: this.startIndex(),
|
|
3931
|
+
end: this.endIndex()
|
|
3932
|
+
};
|
|
3933
|
+
},
|
|
3934
|
+
/**
|
|
3935
|
+
* Whether this token should be rendered as a link according to the given options
|
|
3936
|
+
* @param {Options} options
|
|
3937
|
+
* @returns {boolean}
|
|
3938
|
+
*/
|
|
3939
|
+
validate(options) {
|
|
3940
|
+
return options.get("validate", this.toString(), this);
|
|
3941
|
+
},
|
|
3942
|
+
/**
|
|
3943
|
+
* Return an object that represents how this link should be rendered.
|
|
3944
|
+
* @param {Options} options Formattinng options
|
|
3945
|
+
*/
|
|
3946
|
+
render(options) {
|
|
3947
|
+
const token = this;
|
|
3948
|
+
const href = this.toHref(options.get("defaultProtocol"));
|
|
3949
|
+
const formattedHref = options.get("formatHref", href, this);
|
|
3950
|
+
const tagName = options.get("tagName", href, token);
|
|
3951
|
+
const content = this.toFormattedString(options);
|
|
3952
|
+
const attributes = {};
|
|
3953
|
+
const className = options.get("className", href, token);
|
|
3954
|
+
const target = options.get("target", href, token);
|
|
3955
|
+
const rel = options.get("rel", href, token);
|
|
3956
|
+
const attrs = options.getObj("attributes", href, token);
|
|
3957
|
+
const eventListeners = options.getObj("events", href, token);
|
|
3958
|
+
attributes.href = formattedHref;
|
|
3959
|
+
if (className) {
|
|
3960
|
+
attributes.class = className;
|
|
3961
|
+
}
|
|
3962
|
+
if (target) {
|
|
3963
|
+
attributes.target = target;
|
|
3964
|
+
}
|
|
3965
|
+
if (rel) {
|
|
3966
|
+
attributes.rel = rel;
|
|
3967
|
+
}
|
|
3968
|
+
if (attrs) {
|
|
3969
|
+
Object.assign(attributes, attrs);
|
|
3970
|
+
}
|
|
3971
|
+
return {
|
|
3972
|
+
tagName,
|
|
3973
|
+
attributes,
|
|
3974
|
+
content,
|
|
3975
|
+
eventListeners
|
|
3976
|
+
};
|
|
3977
|
+
}
|
|
3978
|
+
};
|
|
3979
|
+
function createTokenClass(type, props) {
|
|
3980
|
+
class Token extends MultiToken {
|
|
3981
|
+
constructor(value, tokens) {
|
|
3982
|
+
super(value, tokens);
|
|
3983
|
+
this.t = type;
|
|
3984
|
+
}
|
|
3985
|
+
}
|
|
3986
|
+
for (const p in props) {
|
|
3987
|
+
Token.prototype[p] = props[p];
|
|
3988
|
+
}
|
|
3989
|
+
Token.t = type;
|
|
3990
|
+
return Token;
|
|
3991
|
+
}
|
|
3992
|
+
var Email = createTokenClass("email", {
|
|
3993
|
+
isLink: true,
|
|
3994
|
+
toHref() {
|
|
3995
|
+
return "mailto:" + this.toString();
|
|
3996
|
+
}
|
|
3997
|
+
});
|
|
3998
|
+
var Text = createTokenClass("text");
|
|
3999
|
+
var Nl = createTokenClass("nl");
|
|
4000
|
+
var Url = createTokenClass("url", {
|
|
4001
|
+
isLink: true,
|
|
4002
|
+
/**
|
|
4003
|
+
Lowercases relevant parts of the domain and adds the protocol if
|
|
4004
|
+
required. Note that this will not escape unsafe HTML characters in the
|
|
4005
|
+
URL.
|
|
4006
|
+
@param {string} [scheme] default scheme (e.g., 'https')
|
|
4007
|
+
@return {string} the full href
|
|
4008
|
+
*/
|
|
4009
|
+
toHref(scheme2 = defaults.defaultProtocol) {
|
|
4010
|
+
return this.hasProtocol() ? this.v : `${scheme2}://${this.v}`;
|
|
4011
|
+
},
|
|
4012
|
+
/**
|
|
4013
|
+
* Check whether this URL token has a protocol
|
|
4014
|
+
* @return {boolean}
|
|
4015
|
+
*/
|
|
4016
|
+
hasProtocol() {
|
|
4017
|
+
const tokens = this.tk;
|
|
4018
|
+
return tokens.length >= 2 && tokens[0].t !== LOCALHOST && tokens[1].t === COLON;
|
|
4019
|
+
}
|
|
4020
|
+
});
|
|
4021
|
+
var makeState = (arg) => new State(arg);
|
|
4022
|
+
function init$1({
|
|
4023
|
+
groups
|
|
4024
|
+
}) {
|
|
4025
|
+
const qsAccepting = groups.domain.concat([AMPERSAND, ASTERISK, AT, BACKSLASH, BACKTICK, CARET, DOLLAR, EQUALS, HYPHEN, NUM, PERCENT, PIPE, PLUS, POUND, SLASH, SYM, TILDE, UNDERSCORE]);
|
|
4026
|
+
const qsNonAccepting = [APOSTROPHE, COLON, COMMA, DOT, EXCLAMATION, PERCENT, QUERY, QUOTE, SEMI, OPENANGLEBRACKET, CLOSEANGLEBRACKET, OPENBRACE, CLOSEBRACE, CLOSEBRACKET, OPENBRACKET, OPENPAREN, CLOSEPAREN, FULLWIDTHLEFTPAREN, FULLWIDTHRIGHTPAREN, LEFTCORNERBRACKET, RIGHTCORNERBRACKET, LEFTWHITECORNERBRACKET, RIGHTWHITECORNERBRACKET, FULLWIDTHLESSTHAN, FULLWIDTHGREATERTHAN];
|
|
4027
|
+
const localpartAccepting = [AMPERSAND, APOSTROPHE, ASTERISK, BACKSLASH, BACKTICK, CARET, DOLLAR, EQUALS, HYPHEN, OPENBRACE, CLOSEBRACE, PERCENT, PIPE, PLUS, POUND, QUERY, SLASH, SYM, TILDE, UNDERSCORE];
|
|
4028
|
+
const Start = makeState();
|
|
4029
|
+
const Localpart = tt(Start, TILDE);
|
|
4030
|
+
ta(Localpart, localpartAccepting, Localpart);
|
|
4031
|
+
ta(Localpart, groups.domain, Localpart);
|
|
4032
|
+
const Domain = makeState(), Scheme = makeState(), SlashScheme = makeState();
|
|
4033
|
+
ta(Start, groups.domain, Domain);
|
|
4034
|
+
ta(Start, groups.scheme, Scheme);
|
|
4035
|
+
ta(Start, groups.slashscheme, SlashScheme);
|
|
4036
|
+
ta(Domain, localpartAccepting, Localpart);
|
|
4037
|
+
ta(Domain, groups.domain, Domain);
|
|
4038
|
+
const LocalpartAt = tt(Domain, AT);
|
|
4039
|
+
tt(Localpart, AT, LocalpartAt);
|
|
4040
|
+
tt(Scheme, AT, LocalpartAt);
|
|
4041
|
+
tt(SlashScheme, AT, LocalpartAt);
|
|
4042
|
+
const LocalpartDot = tt(Localpart, DOT);
|
|
4043
|
+
ta(LocalpartDot, localpartAccepting, Localpart);
|
|
4044
|
+
ta(LocalpartDot, groups.domain, Localpart);
|
|
4045
|
+
const EmailDomain = makeState();
|
|
4046
|
+
ta(LocalpartAt, groups.domain, EmailDomain);
|
|
4047
|
+
ta(EmailDomain, groups.domain, EmailDomain);
|
|
4048
|
+
const EmailDomainDot = tt(EmailDomain, DOT);
|
|
4049
|
+
ta(EmailDomainDot, groups.domain, EmailDomain);
|
|
4050
|
+
const Email$1 = makeState(Email);
|
|
4051
|
+
ta(EmailDomainDot, groups.tld, Email$1);
|
|
4052
|
+
ta(EmailDomainDot, groups.utld, Email$1);
|
|
4053
|
+
tt(LocalpartAt, LOCALHOST, Email$1);
|
|
4054
|
+
const EmailDomainHyphen = tt(EmailDomain, HYPHEN);
|
|
4055
|
+
tt(EmailDomainHyphen, HYPHEN, EmailDomainHyphen);
|
|
4056
|
+
ta(EmailDomainHyphen, groups.domain, EmailDomain);
|
|
4057
|
+
ta(Email$1, groups.domain, EmailDomain);
|
|
4058
|
+
tt(Email$1, DOT, EmailDomainDot);
|
|
4059
|
+
tt(Email$1, HYPHEN, EmailDomainHyphen);
|
|
4060
|
+
const EmailColon = tt(Email$1, COLON);
|
|
4061
|
+
ta(EmailColon, groups.numeric, Email);
|
|
4062
|
+
const DomainHyphen = tt(Domain, HYPHEN);
|
|
4063
|
+
const DomainDot = tt(Domain, DOT);
|
|
4064
|
+
tt(DomainHyphen, HYPHEN, DomainHyphen);
|
|
4065
|
+
ta(DomainHyphen, groups.domain, Domain);
|
|
4066
|
+
ta(DomainDot, localpartAccepting, Localpart);
|
|
4067
|
+
ta(DomainDot, groups.domain, Domain);
|
|
4068
|
+
const DomainDotTld = makeState(Url);
|
|
4069
|
+
ta(DomainDot, groups.tld, DomainDotTld);
|
|
4070
|
+
ta(DomainDot, groups.utld, DomainDotTld);
|
|
4071
|
+
ta(DomainDotTld, groups.domain, Domain);
|
|
4072
|
+
ta(DomainDotTld, localpartAccepting, Localpart);
|
|
4073
|
+
tt(DomainDotTld, DOT, DomainDot);
|
|
4074
|
+
tt(DomainDotTld, HYPHEN, DomainHyphen);
|
|
4075
|
+
tt(DomainDotTld, AT, LocalpartAt);
|
|
4076
|
+
const DomainDotTldColon = tt(DomainDotTld, COLON);
|
|
4077
|
+
const DomainDotTldColonPort = makeState(Url);
|
|
4078
|
+
ta(DomainDotTldColon, groups.numeric, DomainDotTldColonPort);
|
|
4079
|
+
const Url$1 = makeState(Url);
|
|
4080
|
+
const UrlNonaccept = makeState();
|
|
4081
|
+
ta(Url$1, qsAccepting, Url$1);
|
|
4082
|
+
ta(Url$1, qsNonAccepting, UrlNonaccept);
|
|
4083
|
+
ta(UrlNonaccept, qsAccepting, Url$1);
|
|
4084
|
+
ta(UrlNonaccept, qsNonAccepting, UrlNonaccept);
|
|
4085
|
+
tt(DomainDotTld, SLASH, Url$1);
|
|
4086
|
+
tt(DomainDotTldColonPort, SLASH, Url$1);
|
|
4087
|
+
const SchemeColon = tt(Scheme, COLON);
|
|
4088
|
+
const SlashSchemeColon = tt(SlashScheme, COLON);
|
|
4089
|
+
const SlashSchemeColonSlash = tt(SlashSchemeColon, SLASH);
|
|
4090
|
+
const UriPrefix = tt(SlashSchemeColonSlash, SLASH);
|
|
4091
|
+
ta(Scheme, groups.domain, Domain);
|
|
4092
|
+
tt(Scheme, DOT, DomainDot);
|
|
4093
|
+
tt(Scheme, HYPHEN, DomainHyphen);
|
|
4094
|
+
ta(SlashScheme, groups.domain, Domain);
|
|
4095
|
+
tt(SlashScheme, DOT, DomainDot);
|
|
4096
|
+
tt(SlashScheme, HYPHEN, DomainHyphen);
|
|
4097
|
+
ta(SchemeColon, groups.domain, Url$1);
|
|
4098
|
+
tt(SchemeColon, SLASH, Url$1);
|
|
4099
|
+
tt(SchemeColon, QUERY, Url$1);
|
|
4100
|
+
ta(UriPrefix, groups.domain, Url$1);
|
|
4101
|
+
ta(UriPrefix, qsAccepting, Url$1);
|
|
4102
|
+
tt(UriPrefix, SLASH, Url$1);
|
|
4103
|
+
const bracketPairs = [
|
|
4104
|
+
[OPENBRACE, CLOSEBRACE],
|
|
4105
|
+
// {}
|
|
4106
|
+
[OPENBRACKET, CLOSEBRACKET],
|
|
4107
|
+
// []
|
|
4108
|
+
[OPENPAREN, CLOSEPAREN],
|
|
4109
|
+
// ()
|
|
4110
|
+
[OPENANGLEBRACKET, CLOSEANGLEBRACKET],
|
|
4111
|
+
// <>
|
|
4112
|
+
[FULLWIDTHLEFTPAREN, FULLWIDTHRIGHTPAREN],
|
|
4113
|
+
// ()
|
|
4114
|
+
[LEFTCORNERBRACKET, RIGHTCORNERBRACKET],
|
|
4115
|
+
// 「」
|
|
4116
|
+
[LEFTWHITECORNERBRACKET, RIGHTWHITECORNERBRACKET],
|
|
4117
|
+
// 『』
|
|
4118
|
+
[FULLWIDTHLESSTHAN, FULLWIDTHGREATERTHAN]
|
|
4119
|
+
// <>
|
|
4120
|
+
];
|
|
4121
|
+
for (let i = 0; i < bracketPairs.length; i++) {
|
|
4122
|
+
const [OPEN, CLOSE] = bracketPairs[i];
|
|
4123
|
+
const UrlOpen = tt(Url$1, OPEN);
|
|
4124
|
+
tt(UrlNonaccept, OPEN, UrlOpen);
|
|
4125
|
+
tt(UrlOpen, CLOSE, Url$1);
|
|
4126
|
+
const UrlOpenQ = makeState(Url);
|
|
4127
|
+
ta(UrlOpen, qsAccepting, UrlOpenQ);
|
|
4128
|
+
const UrlOpenSyms = makeState();
|
|
4129
|
+
ta(UrlOpen, qsNonAccepting);
|
|
4130
|
+
ta(UrlOpenQ, qsAccepting, UrlOpenQ);
|
|
4131
|
+
ta(UrlOpenQ, qsNonAccepting, UrlOpenSyms);
|
|
4132
|
+
ta(UrlOpenSyms, qsAccepting, UrlOpenQ);
|
|
4133
|
+
ta(UrlOpenSyms, qsNonAccepting, UrlOpenSyms);
|
|
4134
|
+
tt(UrlOpenQ, CLOSE, Url$1);
|
|
4135
|
+
tt(UrlOpenSyms, CLOSE, Url$1);
|
|
4136
|
+
}
|
|
4137
|
+
tt(Start, LOCALHOST, DomainDotTld);
|
|
4138
|
+
tt(Start, NL, Nl);
|
|
4139
|
+
return {
|
|
4140
|
+
start: Start,
|
|
4141
|
+
tokens: tk
|
|
4142
|
+
};
|
|
4143
|
+
}
|
|
4144
|
+
function run(start, input, tokens) {
|
|
4145
|
+
let len = tokens.length;
|
|
4146
|
+
let cursor = 0;
|
|
4147
|
+
let multis = [];
|
|
4148
|
+
let textTokens = [];
|
|
4149
|
+
while (cursor < len) {
|
|
4150
|
+
let state = start;
|
|
4151
|
+
let secondState = null;
|
|
4152
|
+
let nextState = null;
|
|
4153
|
+
let multiLength = 0;
|
|
4154
|
+
let latestAccepting = null;
|
|
4155
|
+
let sinceAccepts = -1;
|
|
4156
|
+
while (cursor < len && !(secondState = state.go(tokens[cursor].t))) {
|
|
4157
|
+
textTokens.push(tokens[cursor++]);
|
|
4158
|
+
}
|
|
4159
|
+
while (cursor < len && (nextState = secondState || state.go(tokens[cursor].t))) {
|
|
4160
|
+
secondState = null;
|
|
4161
|
+
state = nextState;
|
|
4162
|
+
if (state.accepts()) {
|
|
4163
|
+
sinceAccepts = 0;
|
|
4164
|
+
latestAccepting = state;
|
|
4165
|
+
} else if (sinceAccepts >= 0) {
|
|
4166
|
+
sinceAccepts++;
|
|
4167
|
+
}
|
|
4168
|
+
cursor++;
|
|
4169
|
+
multiLength++;
|
|
4170
|
+
}
|
|
4171
|
+
if (sinceAccepts < 0) {
|
|
4172
|
+
cursor -= multiLength;
|
|
4173
|
+
if (cursor < len) {
|
|
4174
|
+
textTokens.push(tokens[cursor]);
|
|
4175
|
+
cursor++;
|
|
4176
|
+
}
|
|
4177
|
+
} else {
|
|
4178
|
+
if (textTokens.length > 0) {
|
|
4179
|
+
multis.push(initMultiToken(Text, input, textTokens));
|
|
4180
|
+
textTokens = [];
|
|
4181
|
+
}
|
|
4182
|
+
cursor -= sinceAccepts;
|
|
4183
|
+
multiLength -= sinceAccepts;
|
|
4184
|
+
const Multi = latestAccepting.t;
|
|
4185
|
+
const subtokens = tokens.slice(cursor - multiLength, cursor);
|
|
4186
|
+
multis.push(initMultiToken(Multi, input, subtokens));
|
|
4187
|
+
}
|
|
4188
|
+
}
|
|
4189
|
+
if (textTokens.length > 0) {
|
|
4190
|
+
multis.push(initMultiToken(Text, input, textTokens));
|
|
4191
|
+
}
|
|
4192
|
+
return multis;
|
|
4193
|
+
}
|
|
4194
|
+
function initMultiToken(Multi, input, tokens) {
|
|
4195
|
+
const startIdx = tokens[0].s;
|
|
4196
|
+
const endIdx = tokens[tokens.length - 1].e;
|
|
4197
|
+
const value = input.slice(startIdx, endIdx);
|
|
4198
|
+
return new Multi(value, tokens);
|
|
4199
|
+
}
|
|
4200
|
+
var INIT = {
|
|
4201
|
+
scanner: null,
|
|
4202
|
+
parser: null,
|
|
4203
|
+
tokenQueue: [],
|
|
4204
|
+
pluginQueue: [],
|
|
4205
|
+
customSchemes: [],
|
|
4206
|
+
initialized: false
|
|
4207
|
+
};
|
|
4208
|
+
function init() {
|
|
4209
|
+
INIT.scanner = init$2(INIT.customSchemes);
|
|
4210
|
+
for (let i = 0; i < INIT.tokenQueue.length; i++) {
|
|
4211
|
+
INIT.tokenQueue[i][1]({
|
|
4212
|
+
scanner: INIT.scanner
|
|
4213
|
+
});
|
|
4214
|
+
}
|
|
4215
|
+
INIT.parser = init$1(INIT.scanner.tokens);
|
|
4216
|
+
for (let i = 0; i < INIT.pluginQueue.length; i++) {
|
|
4217
|
+
INIT.pluginQueue[i][1]({
|
|
4218
|
+
scanner: INIT.scanner,
|
|
4219
|
+
parser: INIT.parser
|
|
4220
|
+
});
|
|
4221
|
+
}
|
|
4222
|
+
INIT.initialized = true;
|
|
4223
|
+
return INIT;
|
|
4224
|
+
}
|
|
4225
|
+
function tokenize(str) {
|
|
4226
|
+
if (!INIT.initialized) {
|
|
4227
|
+
init();
|
|
4228
|
+
}
|
|
4229
|
+
return run(INIT.parser.start, str, run$1(INIT.scanner.start, str));
|
|
4230
|
+
}
|
|
4231
|
+
tokenize.scan = run$1;
|
|
4232
|
+
function find(str, type = null, opts = null) {
|
|
4233
|
+
if (type && typeof type === "object") {
|
|
4234
|
+
if (opts) {
|
|
4235
|
+
throw Error(`linkifyjs: Invalid link type ${type}; must be a string`);
|
|
4236
|
+
}
|
|
4237
|
+
opts = type;
|
|
4238
|
+
type = null;
|
|
4239
|
+
}
|
|
4240
|
+
const options = new Options(opts);
|
|
4241
|
+
const tokens = tokenize(str);
|
|
4242
|
+
const filtered = [];
|
|
4243
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
4244
|
+
const token = tokens[i];
|
|
4245
|
+
if (token.isLink && (!type || token.t === type) && options.check(token)) {
|
|
4246
|
+
filtered.push(token.toFormattedObject(options));
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
return filtered;
|
|
4250
|
+
}
|
|
4251
|
+
|
|
4252
|
+
// src/extensions/base/link.ts
|
|
4253
|
+
var isSameDomain = (url) => {
|
|
4254
|
+
if (typeof window === "undefined") return false;
|
|
4255
|
+
try {
|
|
4256
|
+
return new URL(url).hostname === window.location.hostname;
|
|
4257
|
+
} catch {
|
|
4258
|
+
return false;
|
|
4259
|
+
}
|
|
4260
|
+
};
|
|
3126
4261
|
var LinkExtension = import_extension_link.default.extend({
|
|
3127
|
-
|
|
4262
|
+
addAttributes() {
|
|
3128
4263
|
return {
|
|
3129
4264
|
...this.parent?.(),
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
4265
|
+
target: {
|
|
4266
|
+
default: "_blank",
|
|
4267
|
+
parseHTML: (element) => {
|
|
4268
|
+
const href = element.getAttribute("href") ?? "";
|
|
4269
|
+
return isSameDomain(href) ? "_self" : "_blank";
|
|
4270
|
+
}
|
|
4271
|
+
},
|
|
4272
|
+
rel: {
|
|
4273
|
+
default: null,
|
|
4274
|
+
parseHTML: (element) => {
|
|
4275
|
+
const href = element.getAttribute("href") ?? "";
|
|
4276
|
+
return isSameDomain(href) ? null : "noopener noreferrer nofollow";
|
|
4277
|
+
}
|
|
4278
|
+
}
|
|
3134
4279
|
};
|
|
4280
|
+
},
|
|
4281
|
+
addPasteRules() {
|
|
4282
|
+
if (!this.options.linkOnPaste) {
|
|
4283
|
+
return this.parent?.() ?? [];
|
|
4284
|
+
}
|
|
4285
|
+
const { protocols, defaultProtocol } = this.options;
|
|
4286
|
+
return [
|
|
4287
|
+
(0, import_core4.markPasteRule)({
|
|
4288
|
+
find: (text) => find(text).filter(
|
|
4289
|
+
(link) => link.isLink && this.options.isAllowedUri(link.value, {
|
|
4290
|
+
defaultValidate: (href) => !!(0, import_extension_link.isAllowedUri)(href, protocols),
|
|
4291
|
+
protocols,
|
|
4292
|
+
defaultProtocol
|
|
4293
|
+
})
|
|
4294
|
+
).filter((link) => this.options.shouldAutoLink?.(link.value) !== false).map((link) => ({ text: link.value, data: { href: link.href }, index: link.start })),
|
|
4295
|
+
type: this.type,
|
|
4296
|
+
getAttributes: (match) => {
|
|
4297
|
+
const href = match.data?.href ?? "";
|
|
4298
|
+
const sameDomain = isSameDomain(href);
|
|
4299
|
+
return {
|
|
4300
|
+
href,
|
|
4301
|
+
target: sameDomain ? "_self" : "_blank",
|
|
4302
|
+
rel: sameDomain ? null : "noopener noreferrer nofollow"
|
|
4303
|
+
};
|
|
4304
|
+
}
|
|
4305
|
+
})
|
|
4306
|
+
];
|
|
3135
4307
|
}
|
|
3136
4308
|
}).configure({
|
|
3137
4309
|
openOnClick: false,
|
|
@@ -3141,8 +4313,8 @@ var LinkExtension = import_extension_link.default.extend({
|
|
|
3141
4313
|
});
|
|
3142
4314
|
|
|
3143
4315
|
// src/extensions/base/myth-reality.ts
|
|
3144
|
-
var
|
|
3145
|
-
var BaseMythRealityBlock =
|
|
4316
|
+
var import_core5 = require("@tiptap/core");
|
|
4317
|
+
var BaseMythRealityBlock = import_core5.Node.create({
|
|
3146
4318
|
name: "mythRealityBlock",
|
|
3147
4319
|
group: "block",
|
|
3148
4320
|
content: "block+",
|
|
@@ -3152,12 +4324,12 @@ var BaseMythRealityBlock = import_core4.Node.create({
|
|
|
3152
4324
|
renderHTML({ HTMLAttributes }) {
|
|
3153
4325
|
return [
|
|
3154
4326
|
"div",
|
|
3155
|
-
(0,
|
|
4327
|
+
(0, import_core5.mergeAttributes)(HTMLAttributes, { "data-myth-reality-block": "" }),
|
|
3156
4328
|
["div", { class: "myth-reality-block-content" }, 0]
|
|
3157
4329
|
];
|
|
3158
4330
|
}
|
|
3159
4331
|
});
|
|
3160
|
-
var BaseMythReality =
|
|
4332
|
+
var BaseMythReality = import_core5.Node.create({
|
|
3161
4333
|
name: "mythReality",
|
|
3162
4334
|
group: "block",
|
|
3163
4335
|
content: "(mythRealityBlock) (mythRealityBlock)",
|
|
@@ -3167,7 +4339,7 @@ var BaseMythReality = import_core4.Node.create({
|
|
|
3167
4339
|
return [{ tag: "div[data-myth-reality]" }];
|
|
3168
4340
|
},
|
|
3169
4341
|
renderHTML({ HTMLAttributes }) {
|
|
3170
|
-
return ["div", (0,
|
|
4342
|
+
return ["div", (0, import_core5.mergeAttributes)(HTMLAttributes, { "data-myth-reality": "" }), 0];
|
|
3171
4343
|
},
|
|
3172
4344
|
addKeyboardShortcuts() {
|
|
3173
4345
|
return {
|
|
@@ -3177,9 +4349,9 @@ var BaseMythReality = import_core4.Node.create({
|
|
|
3177
4349
|
});
|
|
3178
4350
|
|
|
3179
4351
|
// src/extensions/base/prompt.ts
|
|
3180
|
-
var
|
|
4352
|
+
var import_core6 = require("@tiptap/core");
|
|
3181
4353
|
var import_state3 = require("@tiptap/pm/state");
|
|
3182
|
-
var BasePrompt =
|
|
4354
|
+
var BasePrompt = import_core6.Node.create({
|
|
3183
4355
|
name: "prompt",
|
|
3184
4356
|
group: "block",
|
|
3185
4357
|
content: "(promptHeader | promptV2Header) (promptContent | promptV2Content)",
|
|
@@ -3205,13 +4377,13 @@ var BasePrompt = import_core5.Node.create({
|
|
|
3205
4377
|
if (!isInsidePrompt) {
|
|
3206
4378
|
return false;
|
|
3207
4379
|
}
|
|
3208
|
-
const { tr } = state;
|
|
4380
|
+
const { tr: tr2 } = state;
|
|
3209
4381
|
const posAfter = $pos.after(depth);
|
|
3210
4382
|
const paragraphNode = schema.nodes.paragraph.createAndFill();
|
|
3211
4383
|
if (!paragraphNode) return false;
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
view.dispatch(
|
|
4384
|
+
tr2.insert(posAfter, paragraphNode);
|
|
4385
|
+
tr2.setSelection(import_state3.TextSelection.create(tr2.doc, posAfter + 1));
|
|
4386
|
+
view.dispatch(tr2);
|
|
3215
4387
|
return true;
|
|
3216
4388
|
}
|
|
3217
4389
|
};
|
|
@@ -3224,10 +4396,10 @@ var BasePrompt = import_core5.Node.create({
|
|
|
3224
4396
|
];
|
|
3225
4397
|
},
|
|
3226
4398
|
renderHTML({ HTMLAttributes }) {
|
|
3227
|
-
return ["div", (0,
|
|
4399
|
+
return ["div", (0, import_core6.mergeAttributes)(HTMLAttributes, { "data-prompt": "" }), 0];
|
|
3228
4400
|
}
|
|
3229
4401
|
});
|
|
3230
|
-
var BasePromptHeader =
|
|
4402
|
+
var BasePromptHeader = import_core6.Node.create({
|
|
3231
4403
|
name: "promptHeader",
|
|
3232
4404
|
group: "block",
|
|
3233
4405
|
content: "inline*",
|
|
@@ -3241,13 +4413,13 @@ var BasePromptHeader = import_core5.Node.create({
|
|
|
3241
4413
|
];
|
|
3242
4414
|
},
|
|
3243
4415
|
renderHTML({ HTMLAttributes }) {
|
|
3244
|
-
return ["div", (0,
|
|
4416
|
+
return ["div", (0, import_core6.mergeAttributes)(HTMLAttributes, { "data-prompt-header": "" }), 0];
|
|
3245
4417
|
}
|
|
3246
4418
|
// addNodeView() {
|
|
3247
4419
|
// return ReactNodeViewRenderer(PromptHeaderView);
|
|
3248
4420
|
// },
|
|
3249
4421
|
});
|
|
3250
|
-
var BasePromptContent =
|
|
4422
|
+
var BasePromptContent = import_core6.Node.create({
|
|
3251
4423
|
name: "promptContent",
|
|
3252
4424
|
group: "block",
|
|
3253
4425
|
content: "text*",
|
|
@@ -3261,7 +4433,7 @@ var BasePromptContent = import_core5.Node.create({
|
|
|
3261
4433
|
];
|
|
3262
4434
|
},
|
|
3263
4435
|
renderHTML({ HTMLAttributes }) {
|
|
3264
|
-
return ["div", (0,
|
|
4436
|
+
return ["div", (0, import_core6.mergeAttributes)(HTMLAttributes, { "data-prompt-content": "" }), 0];
|
|
3265
4437
|
}
|
|
3266
4438
|
// addNodeView() {
|
|
3267
4439
|
// return ReactNodeViewRenderer(PromptContentView);
|
|
@@ -3269,8 +4441,8 @@ var BasePromptContent = import_core5.Node.create({
|
|
|
3269
4441
|
});
|
|
3270
4442
|
|
|
3271
4443
|
// src/extensions/base/video.ts
|
|
3272
|
-
var
|
|
3273
|
-
var BaseVideo =
|
|
4444
|
+
var import_core7 = require("@tiptap/core");
|
|
4445
|
+
var BaseVideo = import_core7.Node.create({
|
|
3274
4446
|
name: "video",
|
|
3275
4447
|
group: "block",
|
|
3276
4448
|
selectable: true,
|
|
@@ -3296,7 +4468,7 @@ var BaseVideo = import_core6.Node.create({
|
|
|
3296
4468
|
});
|
|
3297
4469
|
|
|
3298
4470
|
// src/extensions/base/figure.ts
|
|
3299
|
-
var
|
|
4471
|
+
var import_core8 = require("@tiptap/core");
|
|
3300
4472
|
var import_extension_image = __toESM(require("@tiptap/extension-image"));
|
|
3301
4473
|
var BaseFigure = import_extension_image.default.extend({
|
|
3302
4474
|
name: "image",
|
|
@@ -3316,6 +4488,43 @@ var BaseFigure = import_extension_image.default.extend({
|
|
|
3316
4488
|
addAttributes() {
|
|
3317
4489
|
return {
|
|
3318
4490
|
...this.parent?.(),
|
|
4491
|
+
src: {
|
|
4492
|
+
default: null,
|
|
4493
|
+
parseHTML: (element) => {
|
|
4494
|
+
const img = element.tagName === "FIGURE" ? element.querySelector("img") : element;
|
|
4495
|
+
return img?.getAttribute("src") ?? null;
|
|
4496
|
+
}
|
|
4497
|
+
},
|
|
4498
|
+
alt: {
|
|
4499
|
+
default: null,
|
|
4500
|
+
parseHTML: (element) => {
|
|
4501
|
+
const img = element.tagName === "FIGURE" ? element.querySelector("img") : element;
|
|
4502
|
+
return img?.getAttribute("alt") ?? null;
|
|
4503
|
+
}
|
|
4504
|
+
},
|
|
4505
|
+
title: {
|
|
4506
|
+
default: null,
|
|
4507
|
+
parseHTML: (element) => {
|
|
4508
|
+
const img = element.tagName === "FIGURE" ? element.querySelector("img") : element;
|
|
4509
|
+
return img?.getAttribute("title") ?? null;
|
|
4510
|
+
}
|
|
4511
|
+
},
|
|
4512
|
+
width: {
|
|
4513
|
+
default: null,
|
|
4514
|
+
parseHTML: (element) => {
|
|
4515
|
+
const img = element.tagName === "FIGURE" ? element.querySelector("img") : element;
|
|
4516
|
+
const val = img?.getAttribute("width");
|
|
4517
|
+
return val ? parseInt(val) : null;
|
|
4518
|
+
}
|
|
4519
|
+
},
|
|
4520
|
+
height: {
|
|
4521
|
+
default: null,
|
|
4522
|
+
parseHTML: (element) => {
|
|
4523
|
+
const img = element.tagName === "FIGURE" ? element.querySelector("img") : element;
|
|
4524
|
+
const val = img?.getAttribute("height");
|
|
4525
|
+
return val ? parseInt(val) : null;
|
|
4526
|
+
}
|
|
4527
|
+
},
|
|
3319
4528
|
fileId: {
|
|
3320
4529
|
default: null,
|
|
3321
4530
|
parseHTML: (element) => {
|
|
@@ -3367,7 +4576,7 @@ var BaseFigure = import_extension_image.default.extend({
|
|
|
3367
4576
|
},
|
|
3368
4577
|
{ getImageById: this.options.getImageById }
|
|
3369
4578
|
);
|
|
3370
|
-
const figureAttrs = (0,
|
|
4579
|
+
const figureAttrs = (0, import_core8.mergeAttributes)(this.options.HTMLAttributes);
|
|
3371
4580
|
const imgAttrs = {
|
|
3372
4581
|
src: resolvedSrc
|
|
3373
4582
|
};
|
|
@@ -3401,7 +4610,7 @@ var BaseFigure = import_extension_image.default.extend({
|
|
|
3401
4610
|
},
|
|
3402
4611
|
addPasteRules() {
|
|
3403
4612
|
return [
|
|
3404
|
-
(0,
|
|
4613
|
+
(0, import_core8.nodePasteRule)({
|
|
3405
4614
|
find: /!\[(.*?)\]\((.*?)(?:\s+"(.*?)")?\)/g,
|
|
3406
4615
|
type: this.type,
|
|
3407
4616
|
getAttributes: (match) => {
|
|
@@ -3414,10 +4623,10 @@ var BaseFigure = import_extension_image.default.extend({
|
|
|
3414
4623
|
});
|
|
3415
4624
|
|
|
3416
4625
|
// src/extensions/base/compatibility.ts
|
|
3417
|
-
var
|
|
4626
|
+
var import_core9 = require("@tiptap/core");
|
|
3418
4627
|
var import_state4 = require("@tiptap/pm/state");
|
|
3419
4628
|
var import_extension_image2 = __toESM(require("@tiptap/extension-image"));
|
|
3420
|
-
var BaseLegacyBookAlert =
|
|
4629
|
+
var BaseLegacyBookAlert = import_core9.Node.create({
|
|
3421
4630
|
name: "calloutAlert",
|
|
3422
4631
|
group: "block",
|
|
3423
4632
|
content: "block+",
|
|
@@ -3469,10 +4678,10 @@ var BaseLegacyBookAlert = import_core8.Node.create({
|
|
|
3469
4678
|
};
|
|
3470
4679
|
},
|
|
3471
4680
|
renderHTML({ HTMLAttributes }) {
|
|
3472
|
-
return ["div", (0,
|
|
4681
|
+
return ["div", (0, import_core9.mergeAttributes)(HTMLAttributes, { "data-type": "callout-alert" }), 0];
|
|
3473
4682
|
}
|
|
3474
4683
|
});
|
|
3475
|
-
var BaseLegacyBookTip =
|
|
4684
|
+
var BaseLegacyBookTip = import_core9.Node.create({
|
|
3476
4685
|
name: "calloutTip",
|
|
3477
4686
|
group: "block",
|
|
3478
4687
|
content: "block+",
|
|
@@ -3519,7 +4728,7 @@ var BaseLegacyBookTip = import_core8.Node.create({
|
|
|
3519
4728
|
];
|
|
3520
4729
|
},
|
|
3521
4730
|
renderHTML({ HTMLAttributes }) {
|
|
3522
|
-
return ["div", (0,
|
|
4731
|
+
return ["div", (0, import_core9.mergeAttributes)(HTMLAttributes, { "data-type": "callout-tip" }), 0];
|
|
3523
4732
|
},
|
|
3524
4733
|
addKeyboardShortcuts() {
|
|
3525
4734
|
return {
|
|
@@ -3527,7 +4736,7 @@ var BaseLegacyBookTip = import_core8.Node.create({
|
|
|
3527
4736
|
};
|
|
3528
4737
|
}
|
|
3529
4738
|
});
|
|
3530
|
-
var BaseLegacySEQuote =
|
|
4739
|
+
var BaseLegacySEQuote = import_core9.Node.create({
|
|
3531
4740
|
name: "customQuoteV2",
|
|
3532
4741
|
group: "block",
|
|
3533
4742
|
content: "customQuoteText customQuoteAuthor customQuoteSign",
|
|
@@ -3554,13 +4763,13 @@ var BaseLegacySEQuote = import_core8.Node.create({
|
|
|
3554
4763
|
if (!isInsideCustomQuoteV2) {
|
|
3555
4764
|
return false;
|
|
3556
4765
|
}
|
|
3557
|
-
const { tr } = state;
|
|
4766
|
+
const { tr: tr2 } = state;
|
|
3558
4767
|
const posAfter = $pos.after(depth);
|
|
3559
4768
|
const paragraphNode = schema.nodes.paragraph.createAndFill();
|
|
3560
4769
|
if (!paragraphNode) return false;
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
view.dispatch(
|
|
4770
|
+
tr2.insert(posAfter, paragraphNode);
|
|
4771
|
+
tr2.setSelection(import_state4.TextSelection.create(tr2.doc, posAfter + 1));
|
|
4772
|
+
view.dispatch(tr2);
|
|
3564
4773
|
return true;
|
|
3565
4774
|
}
|
|
3566
4775
|
};
|
|
@@ -3573,10 +4782,10 @@ var BaseLegacySEQuote = import_core8.Node.create({
|
|
|
3573
4782
|
];
|
|
3574
4783
|
},
|
|
3575
4784
|
renderHTML({ HTMLAttributes }) {
|
|
3576
|
-
return ["div", (0,
|
|
4785
|
+
return ["div", (0, import_core9.mergeAttributes)(HTMLAttributes, { "data-custom-quote-v2": "" }), 0];
|
|
3577
4786
|
}
|
|
3578
4787
|
});
|
|
3579
|
-
var BaseLegacyPromptSE =
|
|
4788
|
+
var BaseLegacyPromptSE = import_core9.Node.create({
|
|
3580
4789
|
name: "promptV2",
|
|
3581
4790
|
group: "block",
|
|
3582
4791
|
content: "(promptHeader | promptV2Header) (promptContent | promptV2Content)",
|
|
@@ -3602,13 +4811,13 @@ var BaseLegacyPromptSE = import_core8.Node.create({
|
|
|
3602
4811
|
if (!isInsidePromptV2) {
|
|
3603
4812
|
return false;
|
|
3604
4813
|
}
|
|
3605
|
-
const { tr } = state;
|
|
4814
|
+
const { tr: tr2 } = state;
|
|
3606
4815
|
const posAfter = $pos.after(depth);
|
|
3607
4816
|
const paragraphNode = schema.nodes.paragraph.createAndFill();
|
|
3608
4817
|
if (!paragraphNode) return false;
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
view.dispatch(
|
|
4818
|
+
tr2.insert(posAfter, paragraphNode);
|
|
4819
|
+
tr2.setSelection(import_state4.TextSelection.create(tr2.doc, posAfter + 1));
|
|
4820
|
+
view.dispatch(tr2);
|
|
3612
4821
|
return true;
|
|
3613
4822
|
}
|
|
3614
4823
|
};
|
|
@@ -3621,10 +4830,10 @@ var BaseLegacyPromptSE = import_core8.Node.create({
|
|
|
3621
4830
|
];
|
|
3622
4831
|
},
|
|
3623
4832
|
renderHTML({ HTMLAttributes }) {
|
|
3624
|
-
return ["div", (0,
|
|
4833
|
+
return ["div", (0, import_core9.mergeAttributes)(HTMLAttributes, { "data-prompt": "" }), 0];
|
|
3625
4834
|
}
|
|
3626
4835
|
});
|
|
3627
|
-
var BaseLegacyPromptSEHeader =
|
|
4836
|
+
var BaseLegacyPromptSEHeader = import_core9.Node.create({
|
|
3628
4837
|
name: "promptV2Header",
|
|
3629
4838
|
group: "block",
|
|
3630
4839
|
content: "inline*",
|
|
@@ -3638,13 +4847,13 @@ var BaseLegacyPromptSEHeader = import_core8.Node.create({
|
|
|
3638
4847
|
];
|
|
3639
4848
|
},
|
|
3640
4849
|
renderHTML({ HTMLAttributes }) {
|
|
3641
|
-
return ["div", (0,
|
|
4850
|
+
return ["div", (0, import_core9.mergeAttributes)(HTMLAttributes, { "data-prompt-header": "" }), 0];
|
|
3642
4851
|
}
|
|
3643
4852
|
// addNodeView() {
|
|
3644
4853
|
// return ReactNodeViewRenderer(PromptHeaderView);
|
|
3645
4854
|
// },
|
|
3646
4855
|
});
|
|
3647
|
-
var BaseLegacyPromptSEContent =
|
|
4856
|
+
var BaseLegacyPromptSEContent = import_core9.Node.create({
|
|
3648
4857
|
name: "promptV2Content",
|
|
3649
4858
|
group: "block",
|
|
3650
4859
|
content: "text*",
|
|
@@ -3658,10 +4867,10 @@ var BaseLegacyPromptSEContent = import_core8.Node.create({
|
|
|
3658
4867
|
];
|
|
3659
4868
|
},
|
|
3660
4869
|
renderHTML({ HTMLAttributes }) {
|
|
3661
|
-
return ["div", (0,
|
|
4870
|
+
return ["div", (0, import_core9.mergeAttributes)(HTMLAttributes, { "data-prompt-content": "" }), 0];
|
|
3662
4871
|
}
|
|
3663
4872
|
});
|
|
3664
|
-
var BaseLegacyCustomBlockquote =
|
|
4873
|
+
var BaseLegacyCustomBlockquote = import_core9.Node.create({
|
|
3665
4874
|
name: "customBlockquote",
|
|
3666
4875
|
group: "block",
|
|
3667
4876
|
content: "block+",
|
|
@@ -3677,7 +4886,7 @@ var BaseLegacyCustomBlockquote = import_core8.Node.create({
|
|
|
3677
4886
|
return ["blockquote", 0];
|
|
3678
4887
|
}
|
|
3679
4888
|
});
|
|
3680
|
-
var BaseLegacyYouTube =
|
|
4889
|
+
var BaseLegacyYouTube = import_core9.Node.create({
|
|
3681
4890
|
name: "youtube",
|
|
3682
4891
|
group: "block",
|
|
3683
4892
|
selectable: true,
|
|
@@ -3713,7 +4922,7 @@ var BaseLegacyYouTube = import_core8.Node.create({
|
|
|
3713
4922
|
return ["video-embed", { src: HTMLAttributes.src }];
|
|
3714
4923
|
}
|
|
3715
4924
|
});
|
|
3716
|
-
var LegacyInlineLatexSE =
|
|
4925
|
+
var LegacyInlineLatexSE = import_core9.Node.create({
|
|
3717
4926
|
name: "inlineLatex",
|
|
3718
4927
|
group: "inline",
|
|
3719
4928
|
inline: true,
|
|
@@ -3735,7 +4944,7 @@ var LegacyInlineLatexSE = import_core8.Node.create({
|
|
|
3735
4944
|
];
|
|
3736
4945
|
},
|
|
3737
4946
|
renderHTML({ HTMLAttributes }) {
|
|
3738
|
-
return ["code", (0,
|
|
4947
|
+
return ["code", (0, import_core9.mergeAttributes)(HTMLAttributes, { class: "inline-latex" }), 0];
|
|
3739
4948
|
}
|
|
3740
4949
|
});
|
|
3741
4950
|
var BaseLegacyFigure = import_extension_image2.default.extend({
|
|
@@ -3820,7 +5029,7 @@ var BaseLegacyFigure = import_extension_image2.default.extend({
|
|
|
3820
5029
|
},
|
|
3821
5030
|
{ getImageById: this.options.getImageById }
|
|
3822
5031
|
);
|
|
3823
|
-
const figureAttrs = (0,
|
|
5032
|
+
const figureAttrs = (0, import_core9.mergeAttributes)(this.options.HTMLAttributes);
|
|
3824
5033
|
const imgAttrs = {
|
|
3825
5034
|
src: resolvedSrc
|
|
3826
5035
|
};
|
|
@@ -4172,19 +5381,19 @@ var legacyTypeMap3 = {
|
|
|
4172
5381
|
info: "success",
|
|
4173
5382
|
error: "error"
|
|
4174
5383
|
};
|
|
4175
|
-
var Callout = ({ type, bgColor, emoji, children, iconWrapper, calloutType }) => {
|
|
5384
|
+
var Callout = ({ type, bgColor, emoji: emoji2, children, iconWrapper, calloutType }) => {
|
|
4176
5385
|
const isLegacySECallout = !!calloutType;
|
|
4177
5386
|
const finalType = isLegacySECallout ? legacyTypeMap3[calloutType] : type;
|
|
4178
5387
|
const hasCustomColor = !!bgColor;
|
|
4179
5388
|
const className = hasCustomColor ? "callout-node" : `callout-node callout-${finalType}`;
|
|
4180
5389
|
const style = hasCustomColor ? { backgroundColor: bgColor } : void 0;
|
|
4181
5390
|
let icon;
|
|
4182
|
-
if (
|
|
4183
|
-
if (
|
|
4184
|
-
const IconComponent = calloutIconComponents[
|
|
5391
|
+
if (emoji2) {
|
|
5392
|
+
if (emoji2 in calloutIconComponents) {
|
|
5393
|
+
const IconComponent = calloutIconComponents[emoji2];
|
|
4185
5394
|
icon = /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(IconComponent, {});
|
|
4186
5395
|
} else {
|
|
4187
|
-
icon =
|
|
5396
|
+
icon = emoji2;
|
|
4188
5397
|
}
|
|
4189
5398
|
} else {
|
|
4190
5399
|
icon = calloutIcons[finalType];
|
|
@@ -4196,7 +5405,7 @@ var Callout = ({ type, bgColor, emoji, children, iconWrapper, calloutType }) =>
|
|
|
4196
5405
|
className,
|
|
4197
5406
|
"data-callout-type": hasCustomColor ? void 0 : type,
|
|
4198
5407
|
"data-bg-color": bgColor || void 0,
|
|
4199
|
-
"data-emoji":
|
|
5408
|
+
"data-emoji": emoji2 || void 0,
|
|
4200
5409
|
style,
|
|
4201
5410
|
children: [
|
|
4202
5411
|
iconContent,
|
|
@@ -4518,7 +5727,7 @@ var import_jsx_runtime84 = require("react/jsx-runtime");
|
|
|
4518
5727
|
var CalloutView = (props) => {
|
|
4519
5728
|
const type = props.node.attrs.type || "info";
|
|
4520
5729
|
const bgColor = props.node.attrs.bgColor;
|
|
4521
|
-
const
|
|
5730
|
+
const emoji2 = props.node.attrs.emoji;
|
|
4522
5731
|
const [showEmojiPicker, setShowEmojiPicker] = (0, import_react20.useState)(false);
|
|
4523
5732
|
const handleIconClick = (e) => {
|
|
4524
5733
|
e.preventDefault();
|
|
@@ -4534,7 +5743,7 @@ var CalloutView = (props) => {
|
|
|
4534
5743
|
{
|
|
4535
5744
|
type,
|
|
4536
5745
|
bgColor,
|
|
4537
|
-
emoji,
|
|
5746
|
+
emoji: emoji2,
|
|
4538
5747
|
iconWrapper: (icon) => /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)("div", { className: "callout-icon-wrapper", children: [
|
|
4539
5748
|
/* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
|
|
4540
5749
|
"button",
|
|
@@ -4776,9 +5985,9 @@ var LegacyYouTube = BaseLegacyYouTube.extend({
|
|
|
4776
5985
|
});
|
|
4777
5986
|
|
|
4778
5987
|
// src/extensions/editor/commands.ts
|
|
4779
|
-
var
|
|
5988
|
+
var import_core10 = require("@tiptap/core");
|
|
4780
5989
|
var import_suggestion = __toESM(require("@tiptap/suggestion"));
|
|
4781
|
-
var Commands =
|
|
5990
|
+
var Commands = import_core10.Extension.create({
|
|
4782
5991
|
name: "slashCommands",
|
|
4783
5992
|
addOptions() {
|
|
4784
5993
|
return {
|
|
@@ -4811,13 +6020,13 @@ var import_extension_superscript = __toESM(require("@tiptap/extension-superscrip
|
|
|
4811
6020
|
var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"));
|
|
4812
6021
|
|
|
4813
6022
|
// node_modules/@tiptap/extension-text-style/dist/index.js
|
|
4814
|
-
var import_core10 = require("@tiptap/core");
|
|
4815
6023
|
var import_core11 = require("@tiptap/core");
|
|
4816
6024
|
var import_core12 = require("@tiptap/core");
|
|
4817
6025
|
var import_core13 = require("@tiptap/core");
|
|
4818
6026
|
var import_core14 = require("@tiptap/core");
|
|
4819
6027
|
var import_core15 = require("@tiptap/core");
|
|
4820
6028
|
var import_core16 = require("@tiptap/core");
|
|
6029
|
+
var import_core17 = require("@tiptap/core");
|
|
4821
6030
|
var MAX_FIND_CHILD_SPAN_DEPTH = 20;
|
|
4822
6031
|
var findChildSpans = (element, depth = 0) => {
|
|
4823
6032
|
const childSpans = [];
|
|
@@ -4848,7 +6057,7 @@ var mergeNestedSpanStyles = (element) => {
|
|
|
4848
6057
|
childSpan.setAttribute("style", `${closestParentSpanStyleOfChild};${childStyle}`);
|
|
4849
6058
|
});
|
|
4850
6059
|
};
|
|
4851
|
-
var TextStyle =
|
|
6060
|
+
var TextStyle = import_core11.Mark.create({
|
|
4852
6061
|
name: "textStyle",
|
|
4853
6062
|
priority: 101,
|
|
4854
6063
|
addOptions() {
|
|
@@ -4876,21 +6085,21 @@ var TextStyle = import_core10.Mark.create({
|
|
|
4876
6085
|
];
|
|
4877
6086
|
},
|
|
4878
6087
|
renderHTML({ HTMLAttributes }) {
|
|
4879
|
-
return ["span", (0,
|
|
6088
|
+
return ["span", (0, import_core11.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
4880
6089
|
},
|
|
4881
6090
|
addCommands() {
|
|
4882
6091
|
return {
|
|
4883
6092
|
toggleTextStyle: (attributes) => ({ commands }) => {
|
|
4884
6093
|
return commands.toggleMark(this.name, attributes);
|
|
4885
6094
|
},
|
|
4886
|
-
removeEmptyTextStyle: () => ({ tr }) => {
|
|
4887
|
-
const { selection } =
|
|
4888
|
-
|
|
6095
|
+
removeEmptyTextStyle: () => ({ tr: tr2 }) => {
|
|
6096
|
+
const { selection } = tr2;
|
|
6097
|
+
tr2.doc.nodesBetween(selection.from, selection.to, (node, pos) => {
|
|
4889
6098
|
if (node.isTextblock) {
|
|
4890
6099
|
return true;
|
|
4891
6100
|
}
|
|
4892
6101
|
if (!node.marks.filter((mark) => mark.type === this.type).some((mark) => Object.values(mark.attrs).some((value) => !!value))) {
|
|
4893
|
-
|
|
6102
|
+
tr2.removeMark(pos, pos + node.nodeSize, this.type);
|
|
4894
6103
|
}
|
|
4895
6104
|
});
|
|
4896
6105
|
return true;
|
|
@@ -4898,7 +6107,7 @@ var TextStyle = import_core10.Mark.create({
|
|
|
4898
6107
|
};
|
|
4899
6108
|
}
|
|
4900
6109
|
});
|
|
4901
|
-
var BackgroundColor =
|
|
6110
|
+
var BackgroundColor = import_core12.Extension.create({
|
|
4902
6111
|
name: "backgroundColor",
|
|
4903
6112
|
addOptions() {
|
|
4904
6113
|
return {
|
|
@@ -4954,7 +6163,7 @@ var BackgroundColor = import_core11.Extension.create({
|
|
|
4954
6163
|
};
|
|
4955
6164
|
}
|
|
4956
6165
|
});
|
|
4957
|
-
var Color =
|
|
6166
|
+
var Color = import_core13.Extension.create({
|
|
4958
6167
|
name: "color",
|
|
4959
6168
|
addOptions() {
|
|
4960
6169
|
return {
|
|
@@ -5010,7 +6219,7 @@ var Color = import_core12.Extension.create({
|
|
|
5010
6219
|
};
|
|
5011
6220
|
}
|
|
5012
6221
|
});
|
|
5013
|
-
var FontFamily =
|
|
6222
|
+
var FontFamily = import_core14.Extension.create({
|
|
5014
6223
|
name: "fontFamily",
|
|
5015
6224
|
addOptions() {
|
|
5016
6225
|
return {
|
|
@@ -5049,7 +6258,7 @@ var FontFamily = import_core13.Extension.create({
|
|
|
5049
6258
|
};
|
|
5050
6259
|
}
|
|
5051
6260
|
});
|
|
5052
|
-
var FontSize =
|
|
6261
|
+
var FontSize = import_core15.Extension.create({
|
|
5053
6262
|
name: "fontSize",
|
|
5054
6263
|
addOptions() {
|
|
5055
6264
|
return {
|
|
@@ -5088,7 +6297,7 @@ var FontSize = import_core14.Extension.create({
|
|
|
5088
6297
|
};
|
|
5089
6298
|
}
|
|
5090
6299
|
});
|
|
5091
|
-
var LineHeight =
|
|
6300
|
+
var LineHeight = import_core16.Extension.create({
|
|
5092
6301
|
name: "lineHeight",
|
|
5093
6302
|
addOptions() {
|
|
5094
6303
|
return {
|
|
@@ -5127,7 +6336,7 @@ var LineHeight = import_core15.Extension.create({
|
|
|
5127
6336
|
};
|
|
5128
6337
|
}
|
|
5129
6338
|
});
|
|
5130
|
-
var TextStyleKit =
|
|
6339
|
+
var TextStyleKit = import_core17.Extension.create({
|
|
5131
6340
|
name: "textStyleKit",
|
|
5132
6341
|
addExtensions() {
|
|
5133
6342
|
const extensions = [];
|
|
@@ -5219,7 +6428,7 @@ var LegacyPromptSEContent = BaseLegacyPromptSEContent.extend({
|
|
|
5219
6428
|
|
|
5220
6429
|
// src/extensions/editor/figure.ts
|
|
5221
6430
|
var import_react34 = require("@tiptap/react");
|
|
5222
|
-
var
|
|
6431
|
+
var import_core18 = require("@tiptap/core");
|
|
5223
6432
|
var Figure2 = BaseFigure.extend({
|
|
5224
6433
|
addNodeView() {
|
|
5225
6434
|
const resizeOptions = this.options.resize;
|
|
@@ -5310,7 +6519,7 @@ var Figure2 = BaseFigure.extend({
|
|
|
5310
6519
|
});
|
|
5311
6520
|
imageContainer.appendChild(editButton);
|
|
5312
6521
|
}
|
|
5313
|
-
const resizableView = new
|
|
6522
|
+
const resizableView = new import_core18.ResizableNodeView({
|
|
5314
6523
|
element: imageContainer,
|
|
5315
6524
|
editor,
|
|
5316
6525
|
node,
|
|
@@ -5479,15 +6688,15 @@ var createHandleImageAdd = (editor, closeDialogCommand, savedPos) => {
|
|
|
5479
6688
|
if (!editor) return;
|
|
5480
6689
|
const { state } = editor;
|
|
5481
6690
|
const insertPos = savedPos ?? state.selection.from;
|
|
5482
|
-
editor.chain().focus().command(({ tr, state: state2 }) => {
|
|
6691
|
+
editor.chain().focus().command(({ tr: tr2, state: state2 }) => {
|
|
5483
6692
|
const $pos = state2.doc.resolve(insertPos);
|
|
5484
6693
|
const imageNode = state2.schema.nodes.image.create({ ...attrs });
|
|
5485
6694
|
if ($pos.parent.type.name === "paragraph" && $pos.parent.textContent === "") {
|
|
5486
|
-
|
|
5487
|
-
|
|
6695
|
+
tr2.replaceWith($pos.before(), $pos.after(), imageNode);
|
|
6696
|
+
tr2.setSelection(import_state5.TextSelection.near(tr2.doc.resolve($pos.before())));
|
|
5488
6697
|
} else {
|
|
5489
|
-
|
|
5490
|
-
|
|
6698
|
+
tr2.insert(insertPos, imageNode);
|
|
6699
|
+
tr2.setSelection(import_state5.TextSelection.near(tr2.doc.resolve(insertPos)));
|
|
5491
6700
|
}
|
|
5492
6701
|
return true;
|
|
5493
6702
|
}).run();
|
|
@@ -5506,15 +6715,15 @@ var createHandleVideoAdd = (editor, closeDialogCommand, savedPos) => {
|
|
|
5506
6715
|
if (!editor) return;
|
|
5507
6716
|
const { state } = editor;
|
|
5508
6717
|
const insertPos = savedPos ?? state.selection.from;
|
|
5509
|
-
editor.chain().focus().command(({ tr, state: state2 }) => {
|
|
6718
|
+
editor.chain().focus().command(({ tr: tr2, state: state2 }) => {
|
|
5510
6719
|
const $pos = state2.doc.resolve(insertPos);
|
|
5511
6720
|
const videoNode = state2.schema.nodes.video.create({ src: url });
|
|
5512
6721
|
if ($pos.parent.type.name === "paragraph" && $pos.parent.textContent === "") {
|
|
5513
|
-
|
|
5514
|
-
|
|
6722
|
+
tr2.replaceWith($pos.before(), $pos.after(), videoNode);
|
|
6723
|
+
tr2.setSelection(import_state5.TextSelection.near(tr2.doc.resolve($pos.before())));
|
|
5515
6724
|
} else {
|
|
5516
|
-
|
|
5517
|
-
|
|
6725
|
+
tr2.insert(insertPos, videoNode);
|
|
6726
|
+
tr2.setSelection(import_state5.TextSelection.near(tr2.doc.resolve(insertPos)));
|
|
5518
6727
|
}
|
|
5519
6728
|
return true;
|
|
5520
6729
|
}).run();
|
|
@@ -5526,21 +6735,22 @@ var createHandleLinkAdd = (editor, closeDialogCommand, linkParams, savedPos) =>
|
|
|
5526
6735
|
const hasSelection = !editor.state.selection.empty;
|
|
5527
6736
|
const titleLength = linkParams.title?.length ?? 0;
|
|
5528
6737
|
if (hasSelection) {
|
|
5529
|
-
editor.chain().focus().command(({ tr, state }) => {
|
|
6738
|
+
editor.chain().focus().command(({ tr: tr2, state }) => {
|
|
5530
6739
|
const { from, to } = state.selection;
|
|
5531
|
-
|
|
5532
|
-
|
|
6740
|
+
tr2.insertText(linkParams.title ?? "", from, to);
|
|
6741
|
+
tr2.removeMark(from, from + titleLength);
|
|
6742
|
+
tr2.addMark(from, from + titleLength, editor.schema.marks.link.create({ ...linkParams }));
|
|
5533
6743
|
return true;
|
|
5534
6744
|
}).run();
|
|
5535
6745
|
} else {
|
|
5536
6746
|
const { state } = editor;
|
|
5537
6747
|
const insertPos = savedPos ?? state.selection.from;
|
|
5538
6748
|
const titleLength2 = linkParams.title?.length ?? 0;
|
|
5539
|
-
editor.chain().focus().command(({ tr }) => {
|
|
6749
|
+
editor.chain().focus().command(({ tr: tr2 }) => {
|
|
5540
6750
|
const linkMark = editor.schema.marks.link.create({ ...linkParams });
|
|
5541
6751
|
const textNode = editor.schema.text(linkParams.title ?? "", [linkMark]);
|
|
5542
|
-
|
|
5543
|
-
|
|
6752
|
+
tr2.insert(insertPos, textNode);
|
|
6753
|
+
tr2.setSelection(import_state5.TextSelection.create(tr2.doc, insertPos, insertPos + titleLength2));
|
|
5544
6754
|
return true;
|
|
5545
6755
|
}).run();
|
|
5546
6756
|
}
|
|
@@ -5554,10 +6764,10 @@ var createHandleKatexAdd = (editor, closeDialogCommand, savedPos) => {
|
|
|
5554
6764
|
} else {
|
|
5555
6765
|
const { state } = editor;
|
|
5556
6766
|
const insertPos = savedPos ?? state.selection.from;
|
|
5557
|
-
editor.chain().focus().command(({ tr, state: state2 }) => {
|
|
6767
|
+
editor.chain().focus().command(({ tr: tr2, state: state2 }) => {
|
|
5558
6768
|
const inlineMathNode = state2.schema.nodes.inlineMath.create({ latex });
|
|
5559
|
-
|
|
5560
|
-
|
|
6769
|
+
tr2.insert(insertPos, inlineMathNode);
|
|
6770
|
+
tr2.setSelection(import_state5.TextSelection.near(tr2.doc.resolve(insertPos)));
|
|
5561
6771
|
return true;
|
|
5562
6772
|
}).run();
|
|
5563
6773
|
}
|
|
@@ -5567,7 +6777,7 @@ var createHandleKatexAdd = (editor, closeDialogCommand, savedPos) => {
|
|
|
5567
6777
|
|
|
5568
6778
|
// src/editor/commands/suggestion.tsx
|
|
5569
6779
|
var import_dom = require("@floating-ui/dom");
|
|
5570
|
-
var
|
|
6780
|
+
var import_core19 = require("@tiptap/core");
|
|
5571
6781
|
var import_react35 = require("@tiptap/react");
|
|
5572
6782
|
|
|
5573
6783
|
// src/editor/commands/items.ts
|
|
@@ -5911,7 +7121,7 @@ var createSuggestions = (translations2, hasImageHandlers) => ({
|
|
|
5911
7121
|
component.element.style.position = "absolute";
|
|
5912
7122
|
document.body.appendChild(component.element);
|
|
5913
7123
|
const virtualElement = {
|
|
5914
|
-
getBoundingClientRect: () => (0,
|
|
7124
|
+
getBoundingClientRect: () => (0, import_core19.posToDOMRect)(
|
|
5915
7125
|
props.editor.view,
|
|
5916
7126
|
props.editor.state.selection.from,
|
|
5917
7127
|
props.editor.state.selection.to
|
|
@@ -5938,7 +7148,7 @@ var createSuggestions = (translations2, hasImageHandlers) => ({
|
|
|
5938
7148
|
return;
|
|
5939
7149
|
}
|
|
5940
7150
|
const virtualElement = {
|
|
5941
|
-
getBoundingClientRect: () => (0,
|
|
7151
|
+
getBoundingClientRect: () => (0, import_core19.posToDOMRect)(
|
|
5942
7152
|
props.editor.view,
|
|
5943
7153
|
props.editor.state.selection.from,
|
|
5944
7154
|
props.editor.state.selection.to
|
|
@@ -6505,7 +7715,7 @@ var Tiptap = (props) => {
|
|
|
6505
7715
|
};
|
|
6506
7716
|
|
|
6507
7717
|
// src/utils/html-to-tiptap-content.ts
|
|
6508
|
-
var
|
|
7718
|
+
var import_core20 = require("@tiptap/core");
|
|
6509
7719
|
var import_extension_table2 = require("@tiptap/extension-table");
|
|
6510
7720
|
function isJSONContent(value) {
|
|
6511
7721
|
return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
|
|
@@ -6529,7 +7739,7 @@ function htmlToTiptapContent(content) {
|
|
|
6529
7739
|
const sharedExtensions = getSharedExtensions();
|
|
6530
7740
|
const extensions = [...sharedExtensions, BaseFigure, import_extension_table2.TableKit, BaseCodeBlock];
|
|
6531
7741
|
try {
|
|
6532
|
-
return (0,
|
|
7742
|
+
return (0, import_core20.generateJSON)(content, extensions);
|
|
6533
7743
|
} catch (error) {
|
|
6534
7744
|
console.error("Failed to convert HTML to Tiptap content:", error);
|
|
6535
7745
|
return { type: "doc", content: [{ type: "paragraph" }] };
|