Module:TextCopy

Revision as of 18:16, 18 December 2023 by Yeeshani (talk | contribs)

Documentation for this module may be created at Module:TextCopy/doc

--
-- This module implements {{TextCopy}}
-- =p.main{text='testtext'}
--
require('Module:No globals')

local p = {}
local getArgs = require('Module:Arguments').getArgs

function p.main(frame, args)
	if not args then
		args = getArgs(frame)
        mw.log('got args')
	end
	local root = mw.html.create('div')
    
	root
		:addClass('textcopyouter')
		:tag('div')
			:addClass('copyleft')

	local sdiv = root:tag('div')
			:addClass('textcopyright')
    if args.text then
	  sdiv:wikitext(args.text)
    else
      sdiv:wikitext('no text given')
    end
    sdiv:tag('span')
      :attr('onclick','textCopyStringToClipboard(this)')
      :attr('role','button')
      :wikitext('📋')
      :addClass('textcopybutton')
   return tostring(root)
end

return p