-
Notifications
You must be signed in to change notification settings - Fork 16
/
redactor.jquery.txt
206 lines (169 loc) · 8.52 KB
/
redactor.jquery.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
REDACTOR
ALTERNATIVES ==> #See CKEditor
VERSION ==> #10.0.6
TO FINISH ==> #Doc "Get started" and "Customization" parts. "Plugins" too.
MODULE.FUNC(...) #Actually means JQ.redactor("MODULE.FUNC", ...)
#When JQ is several elements, returns ARR when should return VAL.
on("EVENT", FUNC(...)) #Actually means OBJ.EVENTCallback(...)
#this is JQR inside FUNC
JQ.redactor([ROBJ]) #Make TEXTAREA a WYSIWYG editor.
#ROBJ:
# - lang "LANG": localization. Must first load language file from source.
on("start|init", FUNC()) #Before|after initialization
core.getObject()->JQR #
core.setCallback("EVENT", ...) #Create possible event handler on("EVENT", FUNC(...))
core.destroy() #
on("destroy", FUNC())
core.getElement|Textarea()
JQR.$element|$textarea #Supercontainer ELEM
core.getBox()
JQR.$box #Container ELEM
core.getEditor()
JQR.$editor #Editor ELEM
core.getToolbar()
JQR.$toolbar #
code.sync() #To do everytime there is programatic change
on("sync[Before]", FUNC("HTML")) #
observe.images|links() #To do when IMG or links have been added outside the API
observe.load() #Do observe.images() + observe.links()
code.set("HTML") #Sets content
code.get()->"HTML" #Gets content
code.toggle|showCode|showVisual() #Toggle between HTML mode and WYSIWYG mode
on("source|visual", FUNC("HTML")) #When switch between visual|HTML mode
on("change|codeKeydown|up",FUNC())#When anything changes in visual|HTML mode
on("keydown|keyup", FUNC(JQEVENT))#
on("enter", FUNC(JQEVENT)) #
on("focus|blur|drop|click",
FUNC(JQEVENT)) #
on("autosave[Error]",
FUNC("NAME", OBJ)) #
on("fileUpload",
FUNC(A_ELEM, OBJ)) #OBJ: filelink "PATH", filename "TITLE", id NUM
on("fileUploadError",
FUNC(ERROR_OBJ)) #
on("imageUpload",
FUNC(IMG_ELEM, OBJ)) #OBJ: filelink "PATH", id NUM
on("imageUploadError",
FUNC(ERROR_OBJ)) #
on("imageDelete",FUNC("URL",ELEM))#
on("uploadStart",
FUNC(JQEVENT, "FORMDATA")) #
selection.selectAll() #
utils.isSelectAll()->BOOL #
utils.enable|disableSelectAll()
->BOOL #
selection.remove() #Deselects
selection.getText|Html()->STR #
selection.replaceSelection("HTML")#
selection.get() #Populates JQR.sel SEL and JQR.range RANGE
RANGE.setStart|End(ELEM|JQ, NUM) #
selection.addRange() #When RANGE has been programatically updated
selection.getCurrent()
->ELEM|false #
selection.getNodes()
->ELEM_ARR|false #
selection.getParent()->ELEM|false #
selection.getBlock()->ELEM|false #
selection.getBlocks()
->ELEM_ARR|false #
selection.getInlines()
->ELEM_ARR|false #
selection.wrap("TAG") #
selection.selectElement(ELEM|JQ) #
selection.save|restore() #
on("paste[Before]", FUNC("HTML")) #
clean.getPlainText("HTML")->STR #
clean.stripTags
("HTML"[, "<TAG>..."])->"HTML" #Remove all <TAG> from "HTML", except ones specified.
clean.getOnly[LinksAnd]Images
("HTML")->"HTML" #Same except links and img
clean.encodeEntities("HTML")->STR #HTML encode
clean.replaceDivs|ParagraphsToBr
("HTML")->"HTML" #
insert.set("HTML") #Replace text at cursor selection
insert.text|html(STR|"HTML") #Inserts text at cursor
insert.htmlWithoutClean("HTML") #Same but no HTML cleaning
insert.node(ELEM|JQ) #Inserts ELEM|JQ at cursor
insert.
nodeToCaretPositionFromPoint
(ELEM|JQ) #Inserts ELEM|JQ at cursor previous position (for drag&drop)
insert.nodeToPoint(ELEM|JQ, X, Y) #Must use caret.getOffset() to get coordinates.
alignment.left|right|center|
justify() #Align text
indent.increase|decrease() #
line.insert() #Adds <hr>
list.insert|remove|toggle
("[un]orderedlist") #<ol>, <ul>
paragraphize.load("HTML") #Adds <p>
placeholder.toggle|remove() #
progress.show|hide() #Progress bar
on("insertedTable|Link",
FUNC(ELEM)) #
block.format("TAG"[, STR, VAL]) #Put in <TAG>. Also, according to STR and VAL:
# - class "CLASS"
# - attr { name STR, value STR }
# - data { name STR, value STR }
block.toggle|set|removeClass(STR) #
block.toggle|setData("data-*",STR)#
block.removeData("data-*") #
block.toggle|setAttr(STR2, STR) #
block.removeAttr(STR2) #
inline.format("TAG"[, STR, VAL]) #Similar but for inline elements. STR and VAL:
# - class "CLASS"
# - style "CSS"
inline.removeFormat() #
inline.removeStyle() #
inline.removeStyleRule("CSS_PROP")#
inline.toggleClass(STR) #
inline.toggleStyle("CSS") #
link.toggleClass(STR) #Only for selected links
caret.setStart|End|Before|After
(ELEM|JQ) #Sets cursor position according to an ELEM|JQ
caret.getOffsetOfElement(ELEM|JQ) #Gets cursor position relatively to ELEM|JQ
caret.getOffset()->NUM
caret.setOffset(NUM) #Gets/sets absolute cursor position
focus.setStart|End() #Sets focus (scrolling)
focus.isFocused()->BOOL #
buffer.set() #Adds actions so far to the undo/redo buffer.
buffer.add() #Same but does not remember cursor position.
"BUTTON" #Toolbar button name, e.g. "bold"
button.get("BUTTON")->ELEM #
button.set[In]active("BUTTON") #
button.setInactiveAll() #
button.setAwesome("BUTTON","fa-*")#Sets icon (Font awesome)
button.add[First]("BUTTON", STR)
->BUTTON
button.addAfter|Before("BUTTON2",
"BUTTON", STR)->BUTTON #Adds a button. STR is tooltip.
button.remove("BUTTON") #
button.addCallback(BUTTON, FUNC())#Triggered by click
BUTTON.on("click", FUNC()) #
button.addDropdown(BUTTON, OBJ) #Adds dropdown. OBJ.VAR.title STR and OBJ.VAR.func()
on("dropdownShow[n]",
FUNC(ELEM, "TITLE", ELEM2)) #
on("dropdownHide", FUNC(ELEM)) #
observe.addButton("TAG", "BUTTON")#Wrap in <TAG>, and make it fire BUTTON
modal.load("NAME", "TITLE", NUM) #Prepares popup. NUM is width
modal.setTitle("TITLE") #
modal.addTemplate("ANAME", "HTML")#Content
modal.show|close() #
modal.addCallback("ANAME", FUNC())#When content shows
modal.createCancelButton()->BUTTON#
modal.createDelete|ActionButton()
->BUTTON #
modal.getModal()->MODAL #
modal.createTabber(MODAL) #Make it possible to add tabs
modal.addTab(NUM, "TNAME"
[, "active"]) #
on("modalOpened",
FUNC("NAME", MODAL)) #
on("modalClosed",
FUNC("NAME")) #
lang.get("html")->"LANG" #
utils.isMobile|Desktop()->BOOL #
utils.isRedactorParent(ELEM|NODE) #Returns true if in TEXTAREA
RedactorPlugins.PLUGIN()->OBJ #To define, for plugins.
#Must use ROBJ.plugins "PLUGIN"_ARR
#It calls OBJ.init(), with this JQR