prosemirror-link-plugin 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,9 @@
1
- import { Decoration } from "prosemirror-view";
2
- import { Node } from "prosemirror-model";
3
- import { LinksKeyState, SpecObject } from "./types";
4
- declare const decorationsUpdateInRange: <T extends SpecObject>(from: number, to: number, doc: Node, pluginState: LinksKeyState<T>, createAliasDecoration: (decorationStart: number, decorationEnd: number, alias: string, matchPos: number, linkPluginState: LinksKeyState<T>, docNode: Node) => Decoration) => {
5
- decorationsToAdd: Decoration[];
6
- decorationsToRemove: Decoration[];
7
- };
8
- export default decorationsUpdateInRange;
1
+ import { Decoration } from "prosemirror-view";
2
+ import { Node } from "prosemirror-model";
3
+ import { LinksKeyState, SpecObject } from "./types";
4
+ declare const decorationsUpdateInRange: <T extends SpecObject>(from: number, to: number, doc: Node, pluginState: LinksKeyState<T>, createAliasDecoration: (decorationStart: number, decorationEnd: number, alias: string, matchPos: number, linkPluginState: LinksKeyState<T>, docNode: Node) => Decoration) => {
5
+ decorationsToAdd: Decoration[];
6
+ decorationsToRemove: Decoration[];
7
+ };
8
+ export default decorationsUpdateInRange;
9
+ //# sourceMappingURL=decorationsUpdateInRange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorationsUpdateInRange.d.ts","sourceRoot":"","sources":["../src/decorationsUpdateInRange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGpD,QAAA,MAAM,wBAAwB,GAAI,CAAC,SAAS,UAAU,EACpD,MAAM,MAAM,EACZ,IAAI,MAAM,EACV,KAAK,IAAI,EACT,aAAa,aAAa,CAAC,CAAC,CAAC,EAC7B,uBAAuB,CACrB,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,aAAa,CAAC,CAAC,CAAC,EACjC,OAAO,EAAE,IAAI,KACV,UAAU,KACd;IACD,gBAAgB,EAAE,UAAU,EAAE,CAAC;IAC/B,mBAAmB,EAAE,UAAU,EAAE,CAAC;CA8EnC,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
@@ -1,4 +1,5 @@
1
- import { Decoration } from "prosemirror-view";
2
- import { LinksKeyState } from "./types";
3
- declare const defaultAliasDecoration: <Spec extends Record<string, any>>(start: number, end: number, alias: string, matchPos: number, pluginState: LinksKeyState<Spec>) => Decoration;
4
- export default defaultAliasDecoration;
1
+ import { Decoration } from "prosemirror-view";
2
+ import { LinksKeyState } from "./types";
3
+ declare const defaultAliasDecoration: <Spec extends Record<string, any>>(start: number, end: number, alias: string, matchPos: number, pluginState: LinksKeyState<Spec>) => Decoration;
4
+ export default defaultAliasDecoration;
5
+ //# sourceMappingURL=defaultAliasDecoration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultAliasDecoration.d.ts","sourceRoot":"","sources":["../src/defaultAliasDecoration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,QAAA,MAAM,sBAAsB,GAAI,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC9D,OAAO,MAAM,EACb,KAAK,MAAM,EACX,OAAO,MAAM,EACb,UAAU,MAAM,EAChB,aAAa,aAAa,CAAC,IAAI,CAAC,eAWjC,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { autoLinkingPlugin, linksKey } from "./plugin";
2
- import defaultAliasDecoration from "./defaultAliasDecoration";
3
- import { SpecWithAlias, LinksKeyState, LinksMeta, LinksMetaType, LinksUpdateMeta } from "./types";
4
- export { SpecWithAlias, LinksKeyState, LinksMeta, LinksMetaType, LinksUpdateMeta, defaultAliasDecoration, autoLinkingPlugin, linksKey, };
1
+ export { autoLinkingPlugin, linksKey } from "./plugin";
2
+ export { LinksMetaType } from "./types";
3
+ export type { SpecWithAlias, LinksKeyState, LinksMeta, LinksUpdateMeta, } from "./types";
4
+ export { default as defaultAliasDecoration } from "./defaultAliasDecoration";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,YAAY,EACV,aAAa,EACb,aAAa,EACb,SAAS,EACT,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
package/dist/index.es.js CHANGED
@@ -1 +1 @@
1
- import{PluginKey as n,Plugin as e}from"prosemirror-state";import{DecorationSet as r,Decoration as o}from"prosemirror-view";var t,a=function(){return a=Object.assign||function(n){for(var e,r=1,o=arguments.length;r<o;r++)for(var t in e=arguments[r])Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t]);return n},a.apply(this,arguments)};function i(n,e,r){if(r||2===arguments.length)for(var o,t=0,a=e.length;t<a;t++)!o&&t in e||(o||(o=Array.prototype.slice.call(e,0,t)),o[t]=e[t]);return n.concat(o||Array.prototype.slice.call(e))}!function(n){n.linkUpdate="linkUpdate"}(t||(t={}));var c=function(n){var e=n.length?n.map((function(n){return"\\b".concat(n.trim(),"\\b")})).sort((function(n,e){return e.length-n.length})).join("|"):"a^";return new RegExp(e,"g")},d=function(n,e,r){if(!n)throw new Error('Invalid "node" parameter');if(!e)throw new Error('Invalid "predicate" parameter');return function(n,e){if(void 0===e&&(e=!0),!n)throw new Error('Invalid "node" parameter');var r=[];return n.descendants((function(n,o){if(r.push({node:n,pos:o}),!e)return!1})),r}(n,r).filter((function(n){return e(n.node)}))},u=function(n,e,r,o,t){var a=n,c=[],u=[],s=[],p=[],l=function(){var n,e=r.resolve(a),c=e.parent,s=a-e.parentOffset,l=s+c.nodeSize,f=o.decorations.find(s,l).filter((function(n){return n.from>=s&&n.to<=l}));p=i(i([],p,!0),f,!0),(void 0===n&&(n=!0),d(c,(function(n){return n.isText}),n)).map((function(n){var e,a;return Array.from((null===(a=null===(e=n.node)||void 0===e?void 0:e.text)||void 0===a?void 0:a.matchAll(o.regex))||[]).map((function(e){if(!e)throw new Error("wrong match");var a=e.index||0,c=e[0],d=n.pos+a+s,p=n.pos+a+c.length+s,l=n.pos+a,f=t(d,p,c,l,o,r);u=i(i([],u,!0),[f],!1)}))})),a+=c.nodeSize};do{l()}while(a<e);return p.map((function(n){var e=u.find((function(e){return e.from===n.from&&e.to===n.to&&(r=e.spec,o=n.spec,t=Object.keys(r),a=Object.keys(o),t.length===a.length&&t.reduce((function(n,e){return n&&o[e]===r[e]}),!0));var r,o,t,a}));return e?c.push(e):s.push(n),null})),{decorationsToAdd:u=u.filter((function(n){return!c.includes(n)})),decorationsToRemove:s}},s=new n("links"),p=function(n,o,d,p,l){void 0===l&&(l=c);var f=function(n){return n.map((function(n){return n.spec}))};return new e({key:s,state:{init:function(e,t){var i=l(n.map((function(n){return n.alias}))),c={decorations:r.empty,regex:i,aliasToSpec:n.reduce((function(n,e){var r;return a(a({},n),((r={})[e.alias]=e,r))}),{})},d=u(0,t.doc.nodeSize,t.doc,c,o),s=c.decorations.add(t.doc,d.decorationsToAdd);return a(a({},c),{decorations:s})},apply:function(n,e){var r=n.getMeta(s),c=e.regex,v=e.aliasToSpec;if((null==r?void 0:r.type)===t.linkUpdate){v=r.specs.reduce((function(n,e){var r;return a(a({},n),((r={})[e.alias]=e,r))}),{}),c=l(r.specs.map((function(n){return n.alias})));var m=u(0,n.doc.nodeSize,n.doc,a(a({},e),{regex:c,aliasToSpec:v}),o),g=m.decorationsToAdd,h=m.decorationsToRemove;return h.length&&p&&p(f(h)),g.length&&d&&d(f(g)),{decorations:e.decorations.remove(h).add(n.doc,g),regex:c,aliasToSpec:v}}if(!n.mapping.maps.length)return e;var w=[],y=e.decorations.map(n.mapping,n.doc,{onRemove:function(n){w.push(n)}}),T=function(n){for(var e=n.doc.nodeSize,r=0,o=0;o<n.mapping.maps.length;o+=1){var t=n.mapping.maps[o].ranges[0],a=t+n.mapping.maps[o].ranges[2];e=Math.min(e,t,a),r=Math.max(r,t,a)}return{start:e,end:r}}(n),x=T.start,S=T.end,k=u(x,S,n.doc,a(a({},e),{decorations:y}),o),A=k.decorationsToRemove,b=k.decorationsToAdd,O=i(i([],w,!0),f(A),!0);return O.length&&p&&p(O),b.length&&d&&d(f(b)),{decorations:y.remove(A).add(n.doc,b),regex:c,aliasToSpec:v}}},props:{decorations:function(n){var e;return r.create(n.doc,(null===(e=s.getState(n))||void 0===e?void 0:e.decorations.find())||[])}}})},l=function(n,e,r,t,a){var i=a.aliasToSpec[r];return o.inline(n,e,{class:"autoLink"},i)};export{t as LinksMetaType,p as autoLinkingPlugin,l as defaultAliasDecoration,s as linksKey};
1
+ import{PluginKey as e,Plugin as o}from"prosemirror-state";import{DecorationSet as t,Decoration as r}from"prosemirror-view";var n;!function(e){e.linkUpdate="linkUpdate"}(n||(n={}));const a=e=>{const o=e.length?e.map(e=>`\\b${e.trim()}\\b`).sort((e,o)=>o.length-e.length).join("|"):"a^";return new RegExp(o,"g")},s=(e,o,t)=>{if(!e)throw new Error('Invalid "node" parameter');if(!o)throw new Error('Invalid "predicate" parameter');return((e,o=!0)=>{if(!e)throw new Error('Invalid "node" parameter');const t=[];return e.descendants((e,r)=>{if(t.push({node:e,pos:r}),!o)return!1}),t})(e,t).filter(e=>o(e.node))},i=(e,o=!0)=>s(e,e=>e.isText,o),d=(e,o,t,r,n)=>{let a=e;const s=[];let d=[];const c=[];let p=[];do{const e=t.resolve(a),o=e.parent,s=a-e.parentOffset,c=s+o.nodeSize,l=r.decorations.find(s,c).filter(e=>e.from>=s&&e.to<=c);p=[...p,...l];i(o).map(e=>Array.from(e.node?.text?.matchAll(r.regex)||[]).map(o=>{if(!o)throw new Error("wrong match");const a=o.index||0,i=o[0],c=e.pos+a+s,p=e.pos+a+i.length+s,l=e.pos+a,m=n(c,p,i,l,r,t);d=[...d,m]})),a+=o.nodeSize}while(a<o);return p.map(e=>{const o=d.find(o=>o.from===e.from&&o.to===e.to&&((e,o)=>{const t=Object.keys(e),r=Object.keys(o);return t.length===r.length&&t.reduce((t,r)=>t&&o[r]===e[r],!0)})(o.spec,e.spec));return o?s.push(o):c.push(e),null}),d=d.filter(e=>!s.includes(e)),{decorationsToAdd:d,decorationsToRemove:c}},c=new e("links"),p=(e,r,s,i,p=a)=>{const l=e=>e.map(e=>e.spec);return new o({key:c,state:{init(o,n){const a=p(e.map(e=>e.alias)),s={decorations:t.empty,regex:a,aliasToSpec:e.reduce((e,o)=>({...e,[o.alias]:o}),{})},i=d(0,n.doc.nodeSize,n.doc,s,r),c=s.decorations.add(n.doc,i.decorationsToAdd);return{...s,decorations:c}},apply(e,o){const t=e.getMeta(c);let{regex:a,aliasToSpec:m}=o;if(t?.type===n.linkUpdate){m=t.specs.reduce((e,o)=>({...e,[o.alias]:o}),{}),a=p(t.specs.map(e=>e.alias));const{decorationsToAdd:n,decorationsToRemove:c}=d(0,e.doc.nodeSize,e.doc,{...o,regex:a,aliasToSpec:m},r);c.length&&i&&i(l(c)),n.length&&s&&s(l(n));return{decorations:o.decorations.remove(c).add(e.doc,n),regex:a,aliasToSpec:m}}if(!e.mapping.maps.length)return o;const g=[],h=o.decorations.map(e.mapping,e.doc,{onRemove:e=>{g.push(e)}}),{start:u,end:f}=(e=>{let o=e.doc.nodeSize,t=0;for(let r=0;r<e.mapping.maps.length;r+=1){const n=e.mapping.maps[r].ranges[0],a=n+e.mapping.maps[r].ranges[2];o=Math.min(o,n,a),t=Math.max(t,n,a)}return{start:o,end:t}})(e),{decorationsToRemove:w,decorationsToAdd:T}=d(u,f,e.doc,{...o,decorations:h},r),v=[...g,...l(w)];v.length&&i&&i(v),T.length&&s&&s(l(T));return{decorations:h.remove(w).add(e.doc,T),regex:a,aliasToSpec:m}}},props:{decorations:e=>t.create(e.doc,c.getState(e)?.decorations.find()||[])}})},l=(e,o,t,n,a)=>{const s=a.aliasToSpec[t];return r.inline(e,o,{class:"autoLink"},s)};export{n as LinksMetaType,p as autoLinkingPlugin,l as defaultAliasDecoration,c as linksKey};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("prosemirror-state"),n=require("prosemirror-view"),r=function(){return r=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},r.apply(this,arguments)};function t(e,n,r){if(r||2===arguments.length)for(var t,o=0,i=n.length;o<i;o++)!t&&o in n||(t||(t=Array.prototype.slice.call(n,0,o)),t[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}exports.LinksMetaType=void 0,(exports.LinksMetaType||(exports.LinksMetaType={})).linkUpdate="linkUpdate";var o=function(e){var n=e.length?e.map((function(e){return"\\b".concat(e.trim(),"\\b")})).sort((function(e,n){return n.length-e.length})).join("|"):"a^";return new RegExp(n,"g")},i=function(e,n,r){if(!e)throw new Error('Invalid "node" parameter');if(!n)throw new Error('Invalid "predicate" parameter');return function(e,n){if(void 0===n&&(n=!0),!e)throw new Error('Invalid "node" parameter');var r=[];return e.descendants((function(e,t){if(r.push({node:e,pos:t}),!n)return!1})),r}(e,r).filter((function(e){return n(e.node)}))},a=function(e,n,r,o,a){var c=e,s=[],u=[],d=[],p=[],l=function(){var e,n=r.resolve(c),s=n.parent,d=c-n.parentOffset,l=d+s.nodeSize,f=o.decorations.find(d,l).filter((function(e){return e.from>=d&&e.to<=l}));p=t(t([],p,!0),f,!0),(void 0===e&&(e=!0),i(s,(function(e){return e.isText}),e)).map((function(e){var n,i;return Array.from((null===(i=null===(n=e.node)||void 0===n?void 0:n.text)||void 0===i?void 0:i.matchAll(o.regex))||[]).map((function(n){if(!n)throw new Error("wrong match");var i=n.index||0,c=n[0],s=e.pos+i+d,p=e.pos+i+c.length+d,l=e.pos+i,f=a(s,p,c,l,o,r);u=t(t([],u,!0),[f],!1)}))})),c+=s.nodeSize};do{l()}while(c<n);return p.map((function(e){var n=u.find((function(n){return n.from===e.from&&n.to===e.to&&(r=n.spec,t=e.spec,o=Object.keys(r),i=Object.keys(t),o.length===i.length&&o.reduce((function(e,n){return e&&t[n]===r[n]}),!0));var r,t,o,i}));return n?s.push(n):d.push(e),null})),{decorationsToAdd:u=u.filter((function(e){return!s.includes(e)})),decorationsToRemove:d}},c=new e.PluginKey("links");exports.autoLinkingPlugin=function(i,s,u,d,p){void 0===p&&(p=o);var l=function(e){return e.map((function(e){return e.spec}))};return new e.Plugin({key:c,state:{init:function(e,t){var o=p(i.map((function(e){return e.alias}))),c={decorations:n.DecorationSet.empty,regex:o,aliasToSpec:i.reduce((function(e,n){var t;return r(r({},e),((t={})[n.alias]=n,t))}),{})},u=a(0,t.doc.nodeSize,t.doc,c,s),d=c.decorations.add(t.doc,u.decorationsToAdd);return r(r({},c),{decorations:d})},apply:function(e,n){var o=e.getMeta(c),i=n.regex,f=n.aliasToSpec;if((null==o?void 0:o.type)===exports.LinksMetaType.linkUpdate){f=o.specs.reduce((function(e,n){var t;return r(r({},e),((t={})[n.alias]=n,t))}),{}),i=p(o.specs.map((function(e){return e.alias})));var v=a(0,e.doc.nodeSize,e.doc,r(r({},n),{regex:i,aliasToSpec:f}),s),g=v.decorationsToAdd,m=v.decorationsToRemove;return m.length&&d&&d(l(m)),g.length&&u&&u(l(g)),{decorations:n.decorations.remove(m).add(e.doc,g),regex:i,aliasToSpec:f}}if(!e.mapping.maps.length)return n;var h=[],y=n.decorations.map(e.mapping,e.doc,{onRemove:function(e){h.push(e)}}),x=function(e){for(var n=e.doc.nodeSize,r=0,t=0;t<e.mapping.maps.length;t+=1){var o=e.mapping.maps[t].ranges[0],i=o+e.mapping.maps[t].ranges[2];n=Math.min(n,o,i),r=Math.max(r,o,i)}return{start:n,end:r}}(e),T=x.start,w=x.end,k=a(T,w,e.doc,r(r({},n),{decorations:y}),s),S=k.decorationsToRemove,A=k.decorationsToAdd,M=t(t([],h,!0),l(S),!0);return M.length&&d&&d(M),A.length&&u&&u(l(A)),{decorations:y.remove(S).add(e.doc,A),regex:i,aliasToSpec:f}}},props:{decorations:function(e){var r;return n.DecorationSet.create(e.doc,(null===(r=c.getState(e))||void 0===r?void 0:r.decorations.find())||[])}}})},exports.defaultAliasDecoration=function(e,r,t,o,i){var a=i.aliasToSpec[t];return n.Decoration.inline(e,r,{class:"autoLink"},a)},exports.linksKey=c;
1
+ "use strict";var e=require("prosemirror-state"),o=require("prosemirror-view");exports.LinksMetaType=void 0,(exports.LinksMetaType||(exports.LinksMetaType={})).linkUpdate="linkUpdate";const t=e=>{const o=e.length?e.map(e=>`\\b${e.trim()}\\b`).sort((e,o)=>o.length-e.length).join("|"):"a^";return new RegExp(o,"g")},r=(e,o,t)=>{if(!e)throw new Error('Invalid "node" parameter');if(!o)throw new Error('Invalid "predicate" parameter');return((e,o=!0)=>{if(!e)throw new Error('Invalid "node" parameter');const t=[];return e.descendants((e,r)=>{if(t.push({node:e,pos:r}),!o)return!1}),t})(e,t).filter(e=>o(e.node))},n=(e,o=!0)=>r(e,e=>e.isText,o),a=(e,o,t,r,a)=>{let s=e;const i=[];let d=[];const c=[];let p=[];do{const e=t.resolve(s),o=e.parent,i=s-e.parentOffset,c=i+o.nodeSize,l=r.decorations.find(i,c).filter(e=>e.from>=i&&e.to<=c);p=[...p,...l];n(o).map(e=>Array.from(e.node?.text?.matchAll(r.regex)||[]).map(o=>{if(!o)throw new Error("wrong match");const n=o.index||0,s=o[0],c=e.pos+n+i,p=e.pos+n+s.length+i,l=e.pos+n,m=a(c,p,s,l,r,t);d=[...d,m]})),s+=o.nodeSize}while(s<o);return p.map(e=>{const o=d.find(o=>o.from===e.from&&o.to===e.to&&((e,o)=>{const t=Object.keys(e),r=Object.keys(o);return t.length===r.length&&t.reduce((t,r)=>t&&o[r]===e[r],!0)})(o.spec,e.spec));return o?i.push(o):c.push(e),null}),d=d.filter(e=>!i.includes(e)),{decorationsToAdd:d,decorationsToRemove:c}},s=new e.PluginKey("links");exports.autoLinkingPlugin=(r,n,i,d,c=t)=>{const p=e=>e.map(e=>e.spec);return new e.Plugin({key:s,state:{init(e,t){const s=c(r.map(e=>e.alias)),i={decorations:o.DecorationSet.empty,regex:s,aliasToSpec:r.reduce((e,o)=>({...e,[o.alias]:o}),{})},d=a(0,t.doc.nodeSize,t.doc,i,n),p=i.decorations.add(t.doc,d.decorationsToAdd);return{...i,decorations:p}},apply(e,o){const t=e.getMeta(s);let{regex:r,aliasToSpec:l}=o;if(t?.type===exports.LinksMetaType.linkUpdate){l=t.specs.reduce((e,o)=>({...e,[o.alias]:o}),{}),r=c(t.specs.map(e=>e.alias));const{decorationsToAdd:s,decorationsToRemove:m}=a(0,e.doc.nodeSize,e.doc,{...o,regex:r,aliasToSpec:l},n);m.length&&d&&d(p(m)),s.length&&i&&i(p(s));return{decorations:o.decorations.remove(m).add(e.doc,s),regex:r,aliasToSpec:l}}if(!e.mapping.maps.length)return o;const m=[],g=o.decorations.map(e.mapping,e.doc,{onRemove:e=>{m.push(e)}}),{start:u,end:h}=(e=>{let o=e.doc.nodeSize,t=0;for(let r=0;r<e.mapping.maps.length;r+=1){const n=e.mapping.maps[r].ranges[0],a=n+e.mapping.maps[r].ranges[2];o=Math.min(o,n,a),t=Math.max(t,n,a)}return{start:o,end:t}})(e),{decorationsToRemove:f,decorationsToAdd:x}=a(u,h,e.doc,{...o,decorations:g},n),T=[...m,...p(f)];T.length&&d&&d(T),x.length&&i&&i(p(x));return{decorations:g.remove(f).add(e.doc,x),regex:r,aliasToSpec:l}}},props:{decorations:e=>o.DecorationSet.create(e.doc,s.getState(e)?.decorations.find()||[])}})},exports.defaultAliasDecoration=(e,t,r,n,a)=>{const s=a.aliasToSpec[r];return o.Decoration.inline(e,t,{class:"autoLink"},s)},exports.linksKey=s;
package/dist/plugin.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { Plugin, PluginKey } from "prosemirror-state";
2
- import { Decoration } from "prosemirror-view";
3
- import { Node } from "prosemirror-model";
4
- import { LinksKeyState, SpecObject, SpecWithAlias } from "./types";
5
- export declare const linksKey: PluginKey<LinksKeyState<any>>;
6
- export declare const autoLinkingPlugin: <T extends SpecObject>(aliasesWithSpec: SpecWithAlias<T>[], createAliasDecoration: (start: number, end: number, alias: string, matchPos: number, pluginState: LinksKeyState<T>, doc: Node) => Decoration, onLinkAdd?: ((addedLinks: SpecWithAlias<T>[]) => void) | undefined, onLinkRemove?: ((removedLinks: SpecWithAlias<T>[]) => void) | undefined, regexGenerator?: (aliases: string[]) => RegExp) => Plugin<LinksKeyState<T>>;
1
+ import { Plugin, PluginKey } from "prosemirror-state";
2
+ import { Decoration } from "prosemirror-view";
3
+ import { Node } from "prosemirror-model";
4
+ import { LinksKeyState, SpecObject, SpecWithAlias } from "./types";
5
+ export declare const linksKey: PluginKey<LinksKeyState<any>>;
6
+ export declare const autoLinkingPlugin: <T extends SpecObject>(aliasesWithSpec: Array<SpecWithAlias<T>>, createAliasDecoration: (start: number, end: number, alias: string, matchPos: number, pluginState: LinksKeyState<T>, doc: Node) => Decoration, onLinkAdd?: (addedLinks: Array<SpecWithAlias<T>>) => void, onLinkRemove?: (removedLinks: Array<SpecWithAlias<T>>) => void, regexGenerator?: (aliases: string[]) => RegExp) => Plugin<LinksKeyState<T>>;
7
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAe,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAiB,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EACL,aAAa,EAGb,UAAU,EACV,aAAa,EACd,MAAM,SAAS,CAAC;AAIjB,eAAO,MAAM,QAAQ,+BAA6C,CAAC;AAEnE,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,UAAU,EACpD,iBAAiB,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EACxC,uBAAuB,CACrB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,EAC7B,GAAG,EAAE,IAAI,KACN,UAAU,EACf,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EACzD,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAC9D,iBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,MAAsB,6BA2H9D,CAAC"}
@@ -1,8 +1,9 @@
1
- import { Node } from "prosemirror-model";
2
- export interface NodeWithPos {
3
- node: Node;
4
- pos: number;
5
- }
6
- export declare const flatten: (node: Node, descend?: boolean) => NodeWithPos[];
7
- export declare const findChildren: (node: Node, predicate: (child: Node) => boolean, descend: boolean) => NodeWithPos[];
8
- export declare const findTextNodes: (node: Node, descend?: boolean) => NodeWithPos[];
1
+ import { Node } from "prosemirror-model";
2
+ export interface NodeWithPos {
3
+ node: Node;
4
+ pos: number;
5
+ }
6
+ export declare const flatten: (node: Node, descend?: boolean) => NodeWithPos[];
7
+ export declare const findChildren: (node: Node, predicate: (child: Node) => boolean, descend: boolean) => NodeWithPos[];
8
+ export declare const findTextNodes: (node: Node, descend?: boolean) => NodeWithPos[];
9
+ //# sourceMappingURL=prosemirror-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prosemirror-utils.d.ts","sourceRoot":"","sources":["../src/prosemirror-utils.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AACD,eAAO,MAAM,OAAO,GAAI,MAAM,IAAI,EAAE,iBAAc,kBAajD,CAAC;AAQF,eAAO,MAAM,YAAY,GACvB,MAAM,IAAI,EACV,WAAW,CAAC,KAAK,EAAE,IAAI,KAAK,OAAO,EACnC,SAAS,OAAO,kBAQjB,CAAC;AAQF,eAAO,MAAM,aAAa,GAAI,MAAM,IAAI,EAAE,iBAAc,kBAEvD,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,20 +1,21 @@
1
- import { DecorationSet } from "prosemirror-view";
2
- export type SpecObject = Record<string, any>;
3
- export type SpecWithAlias<Spec extends SpecObject> = Spec & {
4
- alias: string;
5
- };
6
- export interface LinksKeyState<Spec extends SpecObject = {
7
- alias: string;
8
- }> {
9
- decorations: DecorationSet;
10
- regex: RegExp;
11
- aliasToSpec: Record<string, SpecWithAlias<Spec>>;
12
- }
13
- export declare enum LinksMetaType {
14
- linkUpdate = "linkUpdate"
15
- }
16
- export interface LinksUpdateMeta<Spec extends SpecObject> {
17
- type: LinksMetaType.linkUpdate;
18
- specs: Array<SpecWithAlias<Spec>>;
19
- }
20
- export type LinksMeta<Spec extends SpecObject> = LinksUpdateMeta<Spec>;
1
+ import { DecorationSet } from "prosemirror-view";
2
+ export type SpecObject = Record<string, any>;
3
+ export type SpecWithAlias<Spec extends SpecObject> = Spec & {
4
+ alias: string;
5
+ };
6
+ export interface LinksKeyState<Spec extends SpecObject = {
7
+ alias: string;
8
+ }> {
9
+ decorations: DecorationSet;
10
+ regex: RegExp;
11
+ aliasToSpec: Record<string, SpecWithAlias<Spec>>;
12
+ }
13
+ export declare enum LinksMetaType {
14
+ linkUpdate = "linkUpdate"
15
+ }
16
+ export interface LinksUpdateMeta<Spec extends SpecObject> {
17
+ type: LinksMetaType.linkUpdate;
18
+ specs: Array<SpecWithAlias<Spec>>;
19
+ }
20
+ export type LinksMeta<Spec extends SpecObject> = LinksUpdateMeta<Spec>;
21
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC7C,MAAM,MAAM,aAAa,CAAC,IAAI,SAAS,UAAU,IAAI,IAAI,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAC9E,MAAM,WAAW,aAAa,CAAC,IAAI,SAAS,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE;IAExE,WAAW,EAAE,aAAa,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;CAClD;AAED,oBAAY,aAAa;IACvB,UAAU,eAAe;CAC1B;AAED,MAAM,WAAW,eAAe,CAAC,IAAI,SAAS,UAAU;IACtD,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC;IAC/B,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;CACnC;AAED,MAAM,MAAM,SAAS,CAAC,IAAI,SAAS,UAAU,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC"}
package/dist/utils.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { Transaction } from "prosemirror-state";
2
- import { SpecObject } from "./types";
3
- export declare const generateRegex: (aliases: string[]) => RegExp;
4
- export declare const getTransactionRange: (tr: Transaction) => {
5
- start: number;
6
- end: number;
7
- };
8
- export declare const specEquals: (specA: SpecObject, specB: SpecObject) => boolean;
1
+ import { Transaction } from "prosemirror-state";
2
+ import { SpecObject } from "./types";
3
+ export declare const generateRegex: (aliases: string[]) => RegExp;
4
+ export declare const getTransactionRange: (tr: Transaction) => {
5
+ start: number;
6
+ end: number;
7
+ };
8
+ export declare const specEquals: (specA: SpecObject, specB: SpecObject) => boolean;
9
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,EAAE,KAAG,MASjD,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,IAAI,WAAW;;;CAclD,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO,UAAU,EAAE,OAAO,UAAU,YAO9D,CAAC"}
package/package.json CHANGED
@@ -1,27 +1,14 @@
1
1
  {
2
2
  "name": "prosemirror-link-plugin",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "ProseMirror plugin for automatic links",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
7
7
  "types": "dist/index.d.ts",
8
- "scripts": {
9
- "prebuild": "rimraf dist",
10
- "build": "rollup -c --bundleConfigAsCjs",
11
- "dev": "rollup -c -w --bundleConfigAsCjs",
12
- "format": "eslint src --ext .ts --fix",
13
- "prepublishOnly": "npm run build && npm test && npm run lint",
14
- "version": "npm run format && git add -A src",
15
- "postversion": "git push && git push --tags",
16
- "lint": "tsc --project tsconfig.json --noEmit && eslint src --ext .ts",
17
- "test": "jest",
18
- "upgrade-interactive": "npm-check --update",
19
- "install-peers": "npm-install-peers",
20
- "publish:np": "np"
21
- },
22
8
  "repository": {
23
9
  "type": "git",
24
- "url": "git+https://gitlab.com/emergence-engineering/prosemirror-link-plugin.git"
10
+ "url": "git+https://github.com/emergence-engineering/emergence-tools.git",
11
+ "directory": "packages/prosemirror-link-plugin"
25
12
  },
26
13
  "files": [
27
14
  "dist/**/*"
@@ -34,49 +21,49 @@
34
21
  ],
35
22
  "license": "ISC",
36
23
  "bugs": {
37
- "url": "https://gitlab.com/emergence-engineering/prosemirror-link-plugin/issues"
24
+ "url": "https://github.com/emergence-engineering/emergence-tools/issues"
25
+ },
26
+ "homepage": "https://github.com/emergence-engineering/emergence-tools/tree/main/packages/prosemirror-link-plugin#readme",
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "dependencies": {
31
+ "orderedmap": "^2.1.0"
38
32
  },
39
- "homepage": "https://gitlab.com/emergence-engineering/prosemirror-link-plugin#readme",
40
33
  "peerDependencies": {
41
34
  "prosemirror-commands": "^1.1.4",
42
35
  "prosemirror-model": "^1.11.0",
43
36
  "prosemirror-state": "^1.3.3",
37
+ "prosemirror-tables": "^1.3.0",
38
+ "prosemirror-transform": "^1.7.0",
44
39
  "prosemirror-view": "^1.15.5"
45
40
  },
46
41
  "devDependencies": {
47
42
  "@types/jest": "^29.2.4",
48
- "@typescript-eslint/eslint-plugin": "^5.46.1",
49
- "@typescript-eslint/parser": "^5.46.1",
50
- "eslint": "^8.29.0",
51
- "eslint-config-airbnb": "^19.0.4",
52
- "eslint-config-prettier": "^8.5.0",
53
- "eslint-plugin-import": "^2.26.0",
54
- "eslint-plugin-jest": "^27.1.6",
55
- "eslint-plugin-jsx-a11y": "^6.6.1",
56
- "eslint-plugin-prettier": "^4.2.1",
57
- "eslint-plugin-react": "^7.31.11",
58
43
  "jest": "^29.3.1",
59
- "np": "^7.6.2",
60
- "npm-check": "^6.0.1",
61
- "prettier": "^2.8.1",
44
+ "prosemirror-commands": "^1.1.4",
45
+ "prosemirror-model": "^1.11.0",
62
46
  "prosemirror-schema-basic": "^1.2.0",
63
47
  "prosemirror-schema-list": "^1.2.2",
48
+ "prosemirror-state": "^1.3.3",
49
+ "prosemirror-tables": "^1.3.0",
64
50
  "prosemirror-test-builder": "^1.1.0",
51
+ "prosemirror-transform": "^1.7.0",
52
+ "prosemirror-view": "^1.15.5",
53
+ "rimraf": "^5.0.0",
65
54
  "rollup": "^3.7.4",
66
55
  "rollup-plugin-minification": "^0.2.0",
67
56
  "rollup-plugin-typescript2": "^0.34.1",
68
57
  "ts-jest": "^29.0.3",
69
58
  "tslib": "^2.4.1",
70
- "typescript": "^4.9.4"
59
+ "typescript": "^5.2.2"
71
60
  },
72
- "dependencies": {
73
- "npm-install-peers": "^1.2.2",
74
- "orderedmap": "^2.1.0",
75
- "prosemirror-commands": "^1.1.4",
76
- "prosemirror-model": "^1.11.0",
77
- "prosemirror-state": "^1.3.3",
78
- "prosemirror-tables": "^1.3.0",
79
- "prosemirror-transform": "^1.7.0",
80
- "prosemirror-view": "^1.15.5"
61
+ "scripts": {
62
+ "prebuild": "rimraf dist",
63
+ "build": "rollup -c --bundleConfigAsCjs",
64
+ "dev": "rollup -c -w --bundleConfigAsCjs",
65
+ "format": "echo 'no formatter configured'",
66
+ "lint": "tsc --noEmit",
67
+ "test": "jest"
81
68
  }
82
- }
69
+ }