Web Component: j-Paper
j-Paper (BETA)
- jComponent
v19|v20
- output is a simple
Object Array
structure:[{ id: String, widget: String, newbie: Boolean, changed: Boolean, config: Object }]
- widgets repository: https://github.com/totaljs/parts/tree/main/paper
Configuration:
readonly
{Number}
enables/disables readonly mode0=disabled
,1=partially enabled
,2=fully enabled
parent
{String}
optional, a parent element for min-height (default:null
)margin
{Number}
additional margin for min-height (default:0
)autosave
{Boolean}
changes are serialized according to the path automaticallywidgets
{String}
a link to the widgets (default: Componentator CDN)- it can contain multiple addresses divided by the comma
mywidget1.html,/mywidget2.html,etc..
- or you can keep CDN structure
- it can contain multiple addresses divided by the comma
icon
{String}
a link to thefunction(opt, callback)
opt.element
{jQuery element}
- IMPORTANT: call the
callback
argument if the icon has been changed in the element
link
{String}
a link to thefunction(opt)
opt.element
{jQuery element}
opt.href
{String}
opt.target
{String}
opt.widget
{Object}
a widget instance
command
{String}
a link to thefunction(cmd)
cmd.widget
{Object}
a temporary widget instancecmd.widgets {Array}
a list of registered widgetscmd.remove()
{Function}
removes widgetcmd.append(name)
replaces the current temporary widget with a new widget (name
name of widget)
format
{String}
a link to thefunction(toolbar)
toolbar
can benull
toolbar.element
{jQuery element}
a current elementtoolbar.node
{HTML element}
a current elementtoolbar.widget
{Object}
a widget instancetoolbar.style
{Object}
contains a current style e.g.bold: 1, link: 1
upload
{String}
a link to thefunction(opt, callback)
opt.accept
{String}
optionalopt.files
{FileList}
optionalopt.multiple
{Boolean}
optional, default:false
opt.width
{Number}
optionalopt.height
{Number}
optional- IMPORTANT:
callback
argument must be executed after upload with thefiles {Array}
argument
change
{String}
a link to thefunction(change)
change.id
{String}
identifierchange.block
{String}
a block identifierchange.blockprev
{String}
a previous block identifierchange.widget
{String}
a widget idchange.type
{String}
operation type (insert, update, remove)
contextmenu
{String}
a link to thefunction(widget)
when the user pressed the right mouse button on the widgetcheck
{String}
a link to thefunction(widget)
that decides whether to enable editing or notplaceholder
{String}
a placeholder for the default HTML widget (default:Press / for adding rich content
)
Methods:
component.save(function(data, ischange) {
for saving contentcomponent.import(url or url_array, [callback])
for importing additional widgetscomponent.notify(event, [a], [b], [c], [d])
emits event in every widget
Good to know:
The component creates a global variable called window.papercache
{Object}
used by all j-Paper
instances.
- the component compares the content when you change data, so you can change data in real-time
- the component assigns (in the form)
paper-yourwidgetname
class to every widget element - reserved HTML classes
readonly
,widget
,selected
- readonly usage:
.readonly .paper-yourwidgetname { ... }
- readonly usage:
htmlelement.$widget
{Object}
contains a widget instancewidget.remove()
method will remove the widget
Shortcuts in text edit:
CMD + m
highlights textCMD + l
creates a linkCMD + p
adds an iconCMD + b
boldCMD + i
italicCMD + u
underline
Good to know:
[data-prevent]
attribute can prevent click event in the widget
Author
- Peter Širka petersirka@gmail.com
- License
Created
06. october 2022
Updated
12. june 2024
jComponent library
19 | 20
Version
v1
License
https://www.totaljs.com/license/
Dark mode
Yes
Responsive
Yes
Author
Peter Širka
Email
petersirka@gmail.com