@typix-editor/extension-auto-link 1.0.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -0,0 +1,48 @@
1
+ # @typix-editor/extension-auto-link
2
+
3
+ Automatically converts URLs and email addresses into clickable links as users type.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @typix-editor/extension-auto-link
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ import { AutoLinkExtension } from "@typix-editor/extension-auto-link";
15
+
16
+ <EditorRoot editorConfig={config}>
17
+ <EditorContent />
18
+ <AutoLinkExtension />
19
+ </EditorRoot>
20
+ ```
21
+
22
+ ### Custom Matchers
23
+
24
+ ```tsx
25
+ const EMAIL_MATCHER = /([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/;
26
+
27
+ <AutoLinkExtension
28
+ matchers={[
29
+ { pattern: EMAIL_MATCHER, type: "email" },
30
+ ]}
31
+ onChange={(url, prevUrl) => console.log("Link changed:", url)}
32
+ />
33
+ ```
34
+
35
+ ## Props
36
+
37
+ | Prop | Type | Default | Description |
38
+ |------|------|---------|-------------|
39
+ | `matchers` | `LinkMatcher[]` | URL + email matchers | Custom regex matchers for auto-linking |
40
+ | `onChange` | `(url: string \| null, prevUrl: string \| null) => void` | - | Callback when a link is created or removed |
41
+
42
+ ## Documentation
43
+
44
+ [typix.com/docs/extensions/auto-link](https://typix.com/docs/extensions/auto-link)
45
+
46
+ ## License
47
+
48
+ MIT
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  'use client'
2
- "use strict";var a=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var c=(t,n)=>{for(var e in n)a(t,e,{get:n[e],enumerable:!0})},u=(t,n,e,E)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of A(n))!L.call(t,o)&&o!==e&&a(t,o,{get:()=>n[o],enumerable:!(E=m(n,o))||E.enumerable});return t};var R=t=>u(a({},"__esModule",{value:!0}),t);var g={};c(g,{AutoLinkExtension:()=>i});module.exports=R(g);var r=require("@lexical/react/LexicalAutoLinkPlugin");var h=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)(?<![-.+():%])/,p=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;var s=require("react/jsx-runtime"),k=[(0,r.createLinkMatcherWithRegExp)(h,t=>t.startsWith("http")?t:`https://${t}`),(0,r.createLinkMatcherWithRegExp)(p,t=>`mailto:${t}`)];function i({matchers:t=k,onChange:n}){return(0,s.jsx)(r.AutoLinkPlugin,{matchers:t,onChange:n})}i.displayName="Typix.AutoLinkExtension";0&&(module.exports={AutoLinkExtension});
2
+ "use strict";var r=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var k=(t,o)=>{for(var e in o)r(t,e,{get:o[e],enumerable:!0})},f=(t,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of c(o))!d.call(t,n)&&n!==e&&r(t,n,{get:()=>o[n],enumerable:!(a=u(o,n))||a.enumerable});return t};var x=t=>f(r({},"__esModule",{value:!0}),t);var w={};k(w,{AutoLinkExtension:()=>s});module.exports=x(w);var h=require("@lexical/link"),i=require("@lexical/react/LexicalAutoLinkPlugin"),m=require("@lexical/react/LexicalComposerContext"),A=require("react");var p=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)(?<![-.+():%])/,E=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;var L=require("react/jsx-runtime"),l=[(0,i.createLinkMatcherWithRegExp)(p,t=>t.startsWith("http")?t:`https://${t}`),(0,i.createLinkMatcherWithRegExp)(E,t=>`mailto:${t}`)];function s({matchers:t=l,onChange:o}){let[e]=(0,m.useLexicalComposerContext)();return(0,A.useEffect)(()=>{if(!e.hasNodes([h.AutoLinkNode]))throw new Error("AutoLinkExtension: AutoLinkNode is not registered in the editor. Make sure to include AutoLinkNode in your extensionNodes array.")},[e]),(0,L.jsx)(i.AutoLinkPlugin,{matchers:t,onChange:o})}s.displayName="Typix.AutoLinkExtension";0&&(module.exports={AutoLinkExtension});
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { JSX } from 'react';
2
1
  import { LinkMatcher, ChangeHandler } from '@lexical/react/LexicalAutoLinkPlugin';
2
+ import { JSX } from 'react';
3
3
 
4
4
  declare function AutoLinkExtension({ matchers, onChange, }: {
5
5
  matchers?: LinkMatcher[];
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { JSX } from 'react';
2
1
  import { LinkMatcher, ChangeHandler } from '@lexical/react/LexicalAutoLinkPlugin';
2
+ import { JSX } from 'react';
3
3
 
4
4
  declare function AutoLinkExtension({ matchers, onChange, }: {
5
5
  matchers?: LinkMatcher[];
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  'use client'
2
- import{AutoLinkPlugin as i,createLinkMatcherWithRegExp as r}from"@lexical/react/LexicalAutoLinkPlugin";var n=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)(?<![-.+():%])/,o=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;import{jsx as h}from"react/jsx-runtime";var E=[r(n,t=>t.startsWith("http")?t:`https://${t}`),r(o,t=>`mailto:${t}`)];function e({matchers:t=E,onChange:a}){return h(i,{matchers:t,onChange:a})}e.displayName="Typix.AutoLinkExtension";export{e as AutoLinkExtension};
2
+ import{AutoLinkNode as a}from"@lexical/link";import{AutoLinkPlugin as p,createLinkMatcherWithRegExp as i}from"@lexical/react/LexicalAutoLinkPlugin";import{useLexicalComposerContext as E}from"@lexical/react/LexicalComposerContext";import{useEffect as h}from"react";var e=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)(?<![-.+():%])/,n=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;import{jsx as A}from"react/jsx-runtime";var m=[i(e,t=>t.startsWith("http")?t:`https://${t}`),i(n,t=>`mailto:${t}`)];function r({matchers:t=m,onChange:s}){let[o]=E();return h(()=>{if(!o.hasNodes([a]))throw new Error("AutoLinkExtension: AutoLinkNode is not registered in the editor. Make sure to include AutoLinkNode in your extensionNodes array.")},[o]),A(p,{matchers:t,onChange:s})}r.displayName="Typix.AutoLinkExtension";export{r as AutoLinkExtension};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typix-editor/extension-auto-link",
3
- "version": "1.0.1",
3
+ "version": "4.0.0",
4
4
  "description": "Auto link extension for Typix",
5
5
  "keywords": [],
6
6
  "author": "Diyorbek Juraev <mrdiyorbekjuraev@gmail.com>",
@@ -29,13 +29,14 @@
29
29
  "react-dom": "^18.2.0 || ^19.0.0-0"
30
30
  },
31
31
  "devDependencies": {
32
- "@lexical/react": "^0.39.0",
32
+ "@lexical/react": "^0.40.0",
33
+ "@lexical/link": "^0.40.0",
33
34
  "@types/react": "^19.2.7",
34
35
  "@types/react-dom": "^19.2.1",
35
- "lexical": "^0.39.0",
36
+ "lexical": "^0.40.0",
36
37
  "react": "^18.2.0 || ^19.0.0-0",
37
38
  "react-dom": "^18.2.0 || ^19.0.0-0",
38
- "@typix-editor/react": "2.0.1"
39
+ "@typix-editor/react": "4.0.0"
39
40
  },
40
41
  "scripts": {
41
42
  "build": "tsup",