@@ -370,7 +370,8 @@ and follows the same targeting rules as the <code>--set</code> command.
370370<h3>Image Transfer Behavior</h3>
371371
372372<ul>
373- <li>Exactly <strong>one pin</strong> and <strong>one graphic</strong> must be selected.</li>
373+ <li>if transferring graphic image to pin Exactly <strong>one graphic</strong> and <strong>any number of pins</strong> must be selected.</li>
374+ <li>if transferring pin image to graphic Exactly <strong>one pin</strong> and <strong>any number of graphic</strong> must be selected.</li>
374375 <li>The direction of transfer is determined by the command argument.</li>
375376 <li>No filter options apply to image transfers.</li>
376377 <li>If the required objects are not selected, the command aborts with an error.</li>
@@ -1368,6 +1369,7 @@ ${splitButton("Change Keyword", "!pintool --library")}
13681369 "y" ,
13691370 "notes" ,
13701371 "gmNotes" ,
1372+ "iconText" ,
13711373 "y" ,
13721374 "y" ,
13731375 "_pageid"
@@ -1836,10 +1838,7 @@ if(key === "customizationType")
18361838 }
18371839
18381840 p . set ( updates ) ;
1839- p . set (
1840- {
1841- layer : p . get ( "layer" )
1842- } ) ;
1841+ //p.set({ layer: p.get("layer")});
18431842
18441843 } ) ;
18451844
@@ -1890,85 +1889,108 @@ function handleTransform(msg, argString)
18901889 const tokens = argString . split ( / \s + / ) ;
18911890 const transformType = tokens [ 0 ] . toLowerCase ( ) ;
18921891
1893- // ------------------------------------------------------------
1894- // Image Transfer (graphic <-> pin)
1895- // ------------------------------------------------------------
1892+ // ------------------------------------------------------------
1893+ // Image Transfer (graphic <-> pin)
1894+ // ------------------------------------------------------------
1895+
1896+ if ( transformType . startsWith ( "imageto|" ) )
1897+ {
1898+ const direction = transformType . split ( "|" ) [ 1 ] ;
1899+
1900+ if ( ! msg . selected || ! msg . selected . length )
1901+ {
1902+ return sendStyledMessage (
1903+ "Image Transfer" ,
1904+ "Usage: !pintool --transform imageto|pin OR imageto|graphic<br>" +
1905+ "Select one source object and one or more targets."
1906+ ) ;
1907+ }
1908+
1909+ let graphics = [ ] ;
1910+ let pins = [ ] ;
18961911
1897- if ( transformType . startsWith ( "imageto|" ) )
1912+ msg . selected . forEach ( s =>
18981913 {
1899- const direction = transformType . split ( "|" ) [ 1 ] ;
1914+ const obj = getObj ( s . _type , s . _id ) ;
1915+ if ( ! obj ) return ;
19001916
1901- if ( ! msg . selected || msg . selected . length !== 2 )
1917+ if ( s . _type === "graphic" ) graphics . push ( obj ) ;
1918+ if ( s . _type === "pin" ) pins . push ( obj ) ;
1919+ } ) ;
1920+
1921+ // ------------------------------------------------
1922+ // Graphic → Pins
1923+ // ------------------------------------------------
1924+ if ( direction === "pin" )
1925+ {
1926+ if ( graphics . length !== 1 || pins . length < 1 )
19021927 {
19031928 return sendStyledMessage (
19041929 "Image Transfer" ,
1905- "Usage: !pintool --transform imageto|pin OR imageto|graphic <br>" +
1906- "Select exactly <b>one pin </b> and <b>one graphic </b>."
1930+ "To transfer an image to pins: <br>" +
1931+ "Select <b>exactly one graphic </b> and <b>one or more pins </b>."
19071932 ) ;
19081933 }
19091934
1910- let graphic = null ;
1911- let pin = null ;
1912-
1913- msg . selected . forEach ( s =>
1914- {
1915- const obj = getObj ( s . _type , s . _id ) ;
1916- if ( ! obj ) return ;
1917-
1918- if ( s . _type === "graphic" ) graphic = obj ;
1919- if ( s . _type === "pin" ) pin = obj ;
1920- } ) ;
1935+ const img = graphics [ 0 ] . get ( "imgsrc" ) ;
19211936
1922- if ( ! graphic || ! pin )
1937+ if ( ! img )
19231938 {
19241939 return sendStyledMessage (
19251940 "Image Transfer" ,
1926- "Selection must contain exactly <b>one pin</b> and <b>one graphic</b> ."
1941+ "The selected graphic does not contain a usable image ."
19271942 ) ;
19281943 }
19291944
1930- if ( direction === "pin" )
1945+ pins . forEach ( p =>
19311946 {
1932- const img = graphic . get ( "imgsrc" ) ;
1933-
1934- if ( ! img )
1935- {
1936- return sendStyledMessage (
1937- "Image Transfer" ,
1938- "The selected graphic does not contain a usable image."
1939- ) ;
1940- }
1941-
1942- pin . set ( {
1947+ p . set ( {
19431948 pinImage : img ,
19441949 customizationType : "image"
19451950 } ) ;
1951+ } ) ;
19461952
1947- return ;
1948- }
1953+ return ;
1954+ }
19491955
1950- if ( direction === "graphic" )
1956+ // ------------------------------------------------
1957+ // Pin → Graphics
1958+ // ------------------------------------------------
1959+ if ( direction === "graphic" )
1960+ {
1961+ if ( pins . length !== 1 || graphics . length < 1 )
19511962 {
1952- const img = pin . get ( "pinImage" ) ;
1963+ return sendStyledMessage (
1964+ "Image Transfer" ,
1965+ "To transfer an image to graphics:<br>" +
1966+ "Select <b>exactly one pin</b> and <b>one or more graphics</b>."
1967+ ) ;
1968+ }
19531969
1954- if ( ! img )
1955- {
1956- return sendStyledMessage (
1957- "Image Transfer" ,
1958- "The selected pin does not contain a stored image."
1959- ) ;
1960- }
1970+ const img = pins [ 0 ] . get ( "pinImage" ) ;
19611971
1962- graphic . set ( "imgsrc" , img ) ;
1963- return ;
1972+ if ( ! img )
1973+ {
1974+ return sendStyledMessage (
1975+ "Image Transfer" ,
1976+ "The selected pin does not contain a stored image."
1977+ ) ;
19641978 }
19651979
1966- return sendStyledMessage (
1967- "Image Transfer" ,
1968- "Usage: !pintool --transform imageto|pin OR imageto|graphic"
1969- ) ;
1980+ graphics . forEach ( g =>
1981+ {
1982+ g . set ( "imgsrc" , img ) ;
1983+ } ) ;
1984+
1985+ return ;
19701986 }
19711987
1988+ return sendStyledMessage (
1989+ "Image Transfer" ,
1990+ "Usage: !pintool --transform imageto|pin OR imageto|graphic"
1991+ ) ;
1992+ }
1993+
19721994 // ------------------------------------------------------------
19731995 // Existing Transform Logic
19741996 // ------------------------------------------------------------
@@ -2060,7 +2082,7 @@ function handleTransform(msg, argString)
20602082 } ) ;
20612083
20622084 // force refresh
2063- p . set ( { layer : p . get ( "layer" ) } ) ;
2085+ // p.set({ layer: p.get("layer") });
20642086 } ) ;
20652087
20662088 if ( queue . length )
@@ -2770,4 +2792,4 @@ if(cmd === "--library")
27702792 {
27712793 API_Meta . PinTool . lineCount = ( parseInt ( e . stack . split ( / \n / ) [ 1 ] . replace ( / ^ .* : ( \d + ) : .* $ / , '$1' ) , 10 ) - API_Meta . PinTool . offset ) ;
27722794 }
2773- }
2795+ }
0 commit comments