@@ -14,26 +14,6 @@ import { CharNode } from '../../plugin-char/src/CharNode';
1414import { Inline } from '../../plugin-inline/src/Inline' ;
1515import { Parser } from '../../plugin-parser/src/Parser' ;
1616
17- interface SelectedLinkInfo {
18- /**
19- * The selected text
20- */
21- text : string ;
22- /**
23- * The url of the link
24- */
25- url : string ;
26- /**
27- * The css class associated with the link
28- */
29- class : string ;
30- /**
31- * The target of an html anchor.
32- * Could be "_blank", "_self" ,"_parent", "_top" or the framename.
33- */
34- target : string ;
35- }
36-
3717export class DomHelpers < T extends JWPluginConfig = JWPluginConfig > extends JWPlugin < T > {
3818 commands = {
3919 'dom.addClass' : {
@@ -69,9 +49,6 @@ export class DomHelpers<T extends JWPluginConfig = JWPluginConfig> extends JWPlu
6949 'dom.moveAfter' : {
7050 handler : this . moveAfter . bind ( this ) ,
7151 } ,
72- 'dom.getLinkInfo' : {
73- handler : this . getLinkInfo . bind ( this ) ,
74- } ,
7552 } ;
7653
7754 //--------------------------------------------------------------------------
@@ -214,48 +191,6 @@ export class DomHelpers<T extends JWPluginConfig = JWPluginConfig> extends JWPlu
214191 fromNode . after ( toNode ) ;
215192 }
216193 }
217- async getSelectedText ( params : CommandParams ) : Promise < string > {
218- const selectedNode = params . context . range . selectedNodes ( ) . map ( node => node . clone ( ) ) ;
219- const container = new ContainerNode ( ) ;
220- container . append ( ...selectedNode ) ;
221- const renderer = this . editor . plugins . get ( Renderer ) ;
222- const renderedNode = await renderer . render < HTMLElement [ ] > (
223- HtmlDomRenderingEngine . id ,
224- container ,
225- ) ;
226- // todo: what if there is more rendered nodes?
227- return renderedNode ? renderedNode [ 0 ] . innerText : '' ;
228- }
229- async getSelectedLink ( params : CommandParams ) : Promise < string > {
230- const selectedNode = params . context . range . selectedNodes ( ) . map ( node => node . clone ( ) ) ;
231- const nodeWithFormat : InlineNode = selectedNode . find (
232- node =>
233- node . is ( InlineNode ) &&
234- node . modifiers . find ( modifier => modifier instanceof LinkFormat ) ,
235- ) as InlineNode ;
236- const linkFormat : LinkFormat =
237- nodeWithFormat &&
238- ( nodeWithFormat . modifiers . find (
239- modifier => modifier instanceof LinkFormat ,
240- ) as LinkFormat ) ;
241- return linkFormat ? linkFormat . url : '' ;
242- }
243- getLinkInfo ( params : CommandParams ) : SelectedLinkInfo {
244- const targettedNodes = params . context . range . targetedNodes ( CharNode ) ;
245- const text = targettedNodes . map ( x => x . char ) . join ( '' ) ;
246- //
247- const inline = this . editor . plugins . get ( Inline ) ;
248- const modifiers = inline . getCurrentModifiers ( params . context . range ) ;
249- return {
250- text : text ,
251- url : modifiers . get ( LinkFormat ) ?. url ,
252- class : modifiers . get ( Attributes ) ?. get ( 'class' ) ,
253- target : modifiers
254- . get ( LinkFormat )
255- ?. modifiers ?. get ( Attributes )
256- ?. get ( 'target' ) ,
257- } as SelectedLinkInfo ;
258- }
259194
260195 //--------------------------------------------------------------------------
261196 // Private
0 commit comments