PageSourceSearch

https://pika.page/assets/prosemirror-commands-534a48ce3c1a7fa1e36f…4d72832c8df8767724d512599b44db7f6e0aa3c5.js

js pika.page collected 2026-10-03 21:40:40 UTC 12,851 bytes, 5 lines download raw bytes

vendor: 4,328 bytes, lines 1-3
1// [email protected] downloaded from https://ga.jspm.io/npm:[email protected]/dist/index.js
2
3import{liftTarget as e,replaceStep as t,ReplaceStep as n,canJoin as r,joinPoint as i,canSplit as a,ReplaceAroundStep as o,findWrapping as s}from"prosemirror-transform";import{Slice as c,Fragment as l}from"prosemirror-model";import{NodeSelection as u,Selection as d,TextSelection as f,AllSelection as p,SelectionRange as m}from"prosemirror-state";const h=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function g(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}const _=(n,r,i)=>{let a=g(n,i);if(!a)return!1;let o=S(a);if(!o){let t=a.blockRange(),i=t&&e(t);return i==null?!1:(r&&r(n.tr.lift(t,i).scrollIntoView()),!0)}let s=o.nodeBefore;if(R(n,o,r,-1))return!0;if(a.parent.content.size==0&&(b(s,`end`)||u.isSelectable(s)))for(let e=a.depth;;e--){let i=t(n.doc,a.before(e),a.after(e),c.empty);if(i&&i.slice.size<i.to-i.from){if(r){let e=n.tr.step(i);e.setSelection(b(s,`end`)?d.findFrom(e.doc.resolve(e.mapping.map(o.pos,-1)),-1):u.create(e.doc,o.pos-s.nodeSize)),r(e.scrollIntoView())}return!0}if(e==1||a.node(e-1).childCount>1)break}return s.isAtom&&o.depth==a.depth-1?(r&&r(n.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0):!1},v=(e,t,n)=>{let r=g(e,n);if(!r)return!1;let i=S(r);return i?y(e,i,t):!1},ee=(e,t,n)=>{let r=C(e,n);if(!r)return!1;let i=E(r);return i?y(e,i,t):!1};function y(e,r,i){let a=r.nodeBefore,o=r.pos-1;for(;!a.isTextblock;o--){if(a.type.spec.isolating)return!1;let e=a.lastChild;if(!e)return!1;a=e}let s=r.nodeAfter,l=r.pos+1;for(;!s.isTextblock;l++){if(s.type.spec.isolating)return!1;let e=s.firstChild;if(!e)return!1;s=e}let u=t(e.doc,o,l,c.empty);if(!u||u.from!=o||u instanceof n&&u.slice.size>=l-o)return!1;if(i){let t=e.tr.step(u);t.setSelection(f.create(t.doc,o)),i(t.scrollIntoView())}return!0}function b(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const x=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=S(r)}let o=a&&a.nodeBefore;return!o||!u.isSelectable(o)?!1:(t&&t(e.tr.setSelection(u.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function S(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function C(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}const w=(e,n,r)=>{let i=C(e,r);if(!i)return!1;let a=E(i);if(!a)return!1;let o=a.nodeAfter;if(R(e,a,n,1))return!0;if(i.parent.content.size==0&&(b(o,`start`)||u.isSelectable(o))){let r=t(e.doc,i.before(),i.after(),c.empty);if(r&&r.slice.size<r.to-r.from){if(n){let t=e.tr.step(r);t.setSelection(b(o,`start`)?d.findFrom(t.doc.resolve(t.mapping.map(a.pos)),1):u.create(t.doc,t.mapping.map(a.pos))),n(t.scrollIntoView())}return!0}}return o.isAtom&&a.depth==i.depth-1?(n&&n(e.tr.delete(a.pos,a.pos+o.nodeSize).scrollIntoView()),!0):!1},T=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=E(r)}let o=a&&a.nodeAfter;return!o||!u.isSelectable(o)?!1:(t&&t(e.tr.setSelection(u.create(e.doc,a.pos)).scrollIntoView()),!0)};function E(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}const te=(e,t)=>{let n=e.selection,a=n instanceof u,o;if(a){if(n.node.isTextblock||!r(e.doc,n.from))return!1;o=n.from}else if(o=i(e.doc,n.from,-1),o==null)return!1;if(t){let n=e.tr.join(o);a&&n.setSelection(u.create(n.doc,o-e.doc.resolve(o).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},ne=(e,t)=>{let n=e.selection,a;if(n instanceof u){if(n.node.isTextblock||!r(e.doc,n.to))return!1;a=n.to}else if(a=i(e.doc,n.to,1),a==null)return!1;return t&&t(e.tr.join(a).scrollIntoView()),!0},D=(t,n)=>{let{$from:r,$to:i}=t.selection,a=r.blockRange(i),o=a&&e(a);return o==null?!1:(n&&n(t.tr.lift(a,o).scrollIntoView()),!0)}
3,O=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
4`).scrollIntoView()),!0)};function k(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const A=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=k(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(d.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},j=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof p||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=k(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(f.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},M=(t,n)=>{let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return!1;if(r.depth>1&&r.after()!=r.end(-1)){let e=r.before();if(a(t.doc,e))return n&&n(t.tr.split(e).scrollIntoView()),!0}let i=r.blockRange(),o=i&&e(i);return o==null?!1:(n&&n(t.tr.lift(i,o).scrollIntoView()),!0)};function N(e){return(t,n)=>{if(t.selection instanceof u&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!a(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof f||t.selection instanceof p)&&r.deleteSelection();let{$from:i}=r.selection,o=r.steps.length,s=[],c,l,d=!1,m=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){d=i.end(t)==i.pos+(i.depth-t),m=i.start(t)==i.pos-(i.depth-t),l=k(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,d,i);s.unshift(n||(d&&l?{type:l}:null)),c=t;break}else{if(t==1)return!1;s.unshift(null)}let h=i.pos,g=a(r.doc,h,s.length,s);if(g||(s[0]=l?{type:l}:null,g=a(r.doc,h,s.length,s)),!g)return!1;if(r.split(h,s.length,s),!d&&m&&i.node(c).type!=l){let e=r.mapping.slice(o),t=e.map(i.before(c)),n=r.doc.resolve(t);l&&i.node(c-1).canReplaceWith(n.index(),n.index()+1,l)&&r.setNodeMarkup(e.map(i.before(c)),l)}return n&&n(r.scrollIntoView()),!0}}const P=N(),F=(e,t)=>P(e,t&&(n=>{let r=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();r&&n.ensureMarks(r),t(n)})),I=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),t&&t(e.tr.setSelection(u.create(e.doc,i))),!0)},L=(e,t)=>(t&&t(e.tr.setSelection(new p(e.doc))),!0);function re(e,t,n){let i=t.nodeBefore,a=t.nodeAfter,o=t.index();return!i||!a||!i.type.compatibleContent(a.type)?!1:!i.content.size&&t.parent.canReplace(o-1,o)?(n&&n(e.tr.delete(t.pos-i.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(o,o+1)||!(a.isTextblock||r(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function R(t,n,i,a){let s=n.nodeBefore,u=n.nodeAfter,f,p,m=s.type.spec.isolating||u.type.spec.isolating;if(!m&&re(t,n,i))return!0;let h=!m&&n.parent.canReplace(n.index(),n.index()+1);if(h&&(f=(p=s.contentMatchAt(s.childCount)).findWrapping(u.type))&&p.matchType(f[0]||u.type).validEnd){if(i){let e=n.pos+u.nodeSize,a=l.empty;for(let e=f.length-1;e>=0;e--)a=l.from(f[e].create(null,a));a=l.from(s.copy(a));let d=t.tr.step(new o(n.pos-1,e,n.pos,e,new c(a,1,0),f.length,!0)),p=d.doc.resolve(e+2*f.length);p.nodeAfter&&p.nodeAfter.type==s.type&&r(d.doc,p.pos)&&d.join(p.pos),i(d.scrollIntoView())}return!0}let g=u.type.spec.isolating||a>0&&m?null:d.findFrom(n,1),_=g&&g.$from.blockRange(g.$to),v=_&&e(_);if(v!=null&&v>=n.depth)return i&&i(t.tr.lift(_,v).scrollIntoView()),!0;if(h&&b(u,`start`,!0)&&b(s,`end`)){let e=s,r=[];for(;r.push(e),!e.isTextblock;)e=e.lastChild;let a=u,d=1;for(;!a.isTextblock;a=a.firstChild)d++;if(e.canReplace(e.childCount,e.childCount,a.content)){if(i){let e=l.empty;for(let t=r.length-1;t>=0;t--)e=l.from(r[t].copy(e));i(t.tr.step(new o(n.pos-r.length,n.pos+u.nodeSize,n.pos+d,n.pos+u.nodeSize-d,new c(e,r.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function z(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(f.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}const B=z(-1),V=z(1);function H(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),c=o&&s(o,e,t);return c?(r&&r(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function U(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function W(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:a,$to:o}=t[i],s=a.depth==0?e.inlineContent&&e.type.allowsMarkType(n):!1;if(e.nodesBetween(a.pos,o.pos,(e,t)=>{if(s||!r&&e.isAtom&&e.isInline&&t>=a.pos&&t+e.nodeSize<=o.pos)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}function G(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new m(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new m(r,i))}return t}function K(e,t=null,n){let r=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,a=!(n&&n.includeWhitespace);return function(n,o){let{empty:s,$cursor:c,ranges:l}=n.selection;if(s&&!c||!W(n.doc,l,e,i))return!1;if(o)if(c)e.isInSet(n.storedMarks||c.marks())?o(n.tr.removeStoredMark(e)):o(n.tr.addStoredMark(e.create(t)));else{let s,c=n.tr;i||(l=G(l)),s=r?!l.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!l.every(t=>{let n=!1;return c.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,a)=>
vendor: 2,334 bytes, lines 4-5
4{if(n)return!1;n=!e.isInSet(r.marks)&&!!a&&a.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<l.length;n++){let{$from:r,$to:i}=l[n];if(!s)c.removeMark(r.pos,i.pos,e);else{let n=r.pos,o=i.pos,s=r.nodeAfter,l=i.nodeBefore,u=a&&s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=a&&l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+u<o&&(n+=u,o-=d),c.addMark(n,o,e.create(t))}}o(c.scrollIntoView())}return!0}}function q(e,t){return n=>{if(!n.isGeneric)return e(n);let i=[];for(let e=0;e<n.mapping.maps.length;e++){let t=n.mapping.maps[e];for(let e=0;e<i.length;e++)i[e]=t.map(i[e]);t.forEach((e,t,n,r)=>i.push(n,r))}let a=[];for(let e=0;e<i.length;e+=2){let r=i[e],o=i[e+1],s=n.doc.resolve(r),c=s.sharedDepth(o),l=s.node(c);for(let e=s.indexAfter(c),n=s.after(c+1);n<=o;++e){let r=l.maybeChild(e);if(!r)break;if(e&&a.indexOf(n)==-1){let i=l.child(e-1);i.type==r.type&&t(i,r)&&a.push(n)}n+=r.nodeSize}}a.sort((e,t)=>e-t);for(let e=a.length-1;e>=0;e--)r(n.doc,a[e])&&n.join(a[e]);e(n)}}function J(e,t){let n=Array.isArray(t)?e=>t.indexOf(e.type.name)>-1:t;return(t,r,i)=>e(t,r&&q(r,n),i)}function Y(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}let X=Y(h,_,x),Z=Y(h,w,T);const Q={Enter:Y(O,j,M,P),"Mod-Enter":A,Backspace:X,"Mod-Backspace":X,"Shift-Backspace":X,Delete:Z,"Mod-Delete":Z,"Mod-a":L},$={"Ctrl-h":Q.Backspace,"Alt-Backspace":Q[`Mod-Backspace`],"Ctrl-d":Q.Delete,"Ctrl-Alt-Backspace":Q[`Mod-Delete`],"Alt-Delete":Q[`Mod-Delete`],"Alt-d":Q[`Mod-Delete`],"Ctrl-a":B,"Ctrl-e":V};for(let e in Q)$[e]=Q[e];const ie=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?$:Q;export{J as autoJoin,ie as baseKeymap,Y as chainCommands,j as createParagraphNear,h as deleteSelection,A as exitCode,_ as joinBackward,ne as joinDown,w as joinForward,v as joinTextblockBackward,ee as joinTextblockForward,te as joinUp,D as lift,M as liftEmptyBlock,$ as macBaseKeymap,O as newlineInCode,Q as pcBaseKeymap,L as selectAll,x as selectNodeBackward,T as selectNodeForward,I as selectParentNode,V as selectTextblockEnd,B as selectTextblockStart,U as setBlockType,P as splitBlock,N as splitBlockAs,F as splitBlockKeepMarks,K as toggleMark,H as wrapIn};
5

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.