|
172 | 172 |
|
173 | 173 | // Empty tags will be automatically deleted |
174 | 174 | // Use <!--. --> to placeholder |
175 | | - var html = '<span><!-- . --><span contenteditable="false" class="'+ icon +'"></span></span>' |
| 175 | + var html = ' <span class="mark-fapkw"><!-- . --><span contenteditable="false" class="mark-fapk '+ icon +'"></span></span> ' |
176 | 176 | editor.execCommand('mceInsertContent', false, html) |
177 | 177 | editor.windowManager.close() |
178 | 178 | } |
179 | 179 | } |
180 | 180 | } |
181 | 181 | } |
182 | 182 |
|
| 183 | + var SettingPanel = function(editor) { |
| 184 | + var target = utils.getRngNode(editor) |
183 | 185 |
|
| 186 | + editor.windowManager.open({ |
| 187 | + title: 'Icon setting', |
| 188 | + body: { |
| 189 | + type: 'panel', |
| 190 | + items: [ |
| 191 | + { |
| 192 | + type: 'input', |
| 193 | + name: 'icon-size', |
| 194 | + label: 'icon size' |
| 195 | + }, |
| 196 | + { |
| 197 | + type: 'colorinput', |
| 198 | + name: 'icon-color', |
| 199 | + label: 'icon color' |
| 200 | + } |
| 201 | + ] |
| 202 | + }, |
| 203 | + buttons: [ |
| 204 | + { |
| 205 | + type: 'cancel', |
| 206 | + name: 'closeButton', |
| 207 | + text: 'Cancel' |
| 208 | + }, |
| 209 | + { |
| 210 | + type: 'submit', |
| 211 | + name: 'submitButton', |
| 212 | + text: 'change', |
| 213 | + primary: true |
| 214 | + } |
| 215 | + ], |
| 216 | + initialData: { |
| 217 | + 'icon-size': editor.$(target).css('font-size'), |
| 218 | + 'icon-color': editor.$(target).css('color'), |
| 219 | + }, |
| 220 | + onSubmit: function (api) { |
| 221 | + var data = api.getData() |
| 222 | + |
| 223 | + editor.$(target).css({ |
| 224 | + 'font-size': data['icon-size'], |
| 225 | + 'color': data['icon-color'] |
| 226 | + }) |
| 227 | + // editor.execCommand('mceReplaceContent', false, '') |
| 228 | + api.close() |
| 229 | + } |
| 230 | + }) |
| 231 | + } |
184 | 232 |
|
185 | | - var buttonIcon = '<svg width="24" height="24" viewBox=\"0 0 512 512\"><path d=\"M116.65 219.35a15.68 15.68 0 0 0 22.65 0l96.75-99.83c28.15-29 26.5-77.1-4.91-103.88C203.75-7.7 163-3.5 137.86 22.44L128 32.58l-9.85-10.14C93.05-3.5 52.25-7.7 24.86 15.64c-31.41 26.78-33 74.85-5 103.88zm143.92 100.49h-48l-7.08-14.24a27.39 27.39 0 0 0-25.66-17.78h-71.71a27.39 27.39 0 0 0-25.66 17.78l-7 14.24h-48A27.45 27.45 0 0 0 0 347.3v137.25A27.44 27.44 0 0 0 27.43 512h233.14A27.45 27.45 0 0 0 288 484.55V347.3a27.45 27.45 0 0 0-27.43-27.46zM144 468a52 52 0 1 1 52-52 52 52 0 0 1-52 52zm355.4-115.9h-60.58l22.36-50.75c2.1-6.65-3.93-13.21-12.18-13.21h-75.59c-6.3 0-11.66 3.9-12.5 9.1l-16.8 106.93c-1 6.3 4.88 11.89 12.5 11.89h62.31l-24.2 83c-1.89 6.65 4.2 12.9 12.23 12.9a13.26 13.26 0 0 0 10.92-5.25l92.4-138.91c4.88-6.91-1.16-15.7-10.87-15.7zM478.08.33L329.51 23.17C314.87 25.42 304 38.92 304 54.83V161.6a83.25 83.25 0 0 0-16-1.7c-35.35 0-64 21.48-64 48s28.65 48 64 48c35.2 0 63.73-21.32 64-47.66V99.66l112-17.22v47.18a83.25 83.25 0 0 0-16-1.7c-35.35 0-64 21.48-64 48s28.65 48 64 48c35.2 0 63.73-21.32 64-47.66V32c0-19.48-16-34.42-33.92-31.67z\"/></svg>' |
| 233 | + var iconsButtonSvg = '<svg width="24" height="24" viewBox=\"0 0 512 512\"><path d=\"M116.65 219.35a15.68 15.68 0 0 0 22.65 0l96.75-99.83c28.15-29 26.5-77.1-4.91-103.88C203.75-7.7 163-3.5 137.86 22.44L128 32.58l-9.85-10.14C93.05-3.5 52.25-7.7 24.86 15.64c-31.41 26.78-33 74.85-5 103.88zm143.92 100.49h-48l-7.08-14.24a27.39 27.39 0 0 0-25.66-17.78h-71.71a27.39 27.39 0 0 0-25.66 17.78l-7 14.24h-48A27.45 27.45 0 0 0 0 347.3v137.25A27.44 27.44 0 0 0 27.43 512h233.14A27.45 27.45 0 0 0 288 484.55V347.3a27.45 27.45 0 0 0-27.43-27.46zM144 468a52 52 0 1 1 52-52 52 52 0 0 1-52 52zm355.4-115.9h-60.58l22.36-50.75c2.1-6.65-3.93-13.21-12.18-13.21h-75.59c-6.3 0-11.66 3.9-12.5 9.1l-16.8 106.93c-1 6.3 4.88 11.89 12.5 11.89h62.31l-24.2 83c-1.89 6.65 4.2 12.9 12.23 12.9a13.26 13.26 0 0 0 10.92-5.25l92.4-138.91c4.88-6.91-1.16-15.7-10.87-15.7zM478.08.33L329.51 23.17C314.87 25.42 304 38.92 304 54.83V161.6a83.25 83.25 0 0 0-16-1.7c-35.35 0-64 21.48-64 48s28.65 48 64 48c35.2 0 63.73-21.32 64-47.66V99.66l112-17.22v47.18a83.25 83.25 0 0 0-16-1.7c-35.35 0-64 21.48-64 48s28.65 48 64 48c35.2 0 63.73-21.32 64-47.66V32c0-19.48-16-34.42-33.92-31.67z\"/></svg>' |
186 | 234 | function registerUi(editor) { |
187 | | - editor.ui.registry.addIcon(PLUGIN_NAME, buttonIcon) |
| 235 | + editor.ui.registry.addIcon(PLUGIN_NAME, iconsButtonSvg) |
188 | 236 | editor.ui.registry.addButton(PLUGIN_NAME, { |
189 | 237 | icon: PLUGIN_NAME, |
190 | 238 | tooltip: PLUGIN_NAME, |
|
199 | 247 | editor.execCommand('mceOpenFontawesomepicker') |
200 | 248 | } |
201 | 249 | }) |
| 250 | + |
| 251 | + editor.ui.registry.addMenuItem('fontawesomesetting', { |
| 252 | + icon: 'preferences', |
| 253 | + text: 'Icon setting', |
| 254 | + onAction: function () { |
| 255 | + SettingPanel(editor) |
| 256 | + } |
| 257 | + }) |
| 258 | + editor.ui.registry.addContextMenu('fontawesomesetting', { |
| 259 | + update: function (element) { |
| 260 | + var classList = element.classList |
| 261 | + if ( classList.contains('mark-fapk') || classList.contains('mark-fapkw') ) return 'fontawesomesetting' |
| 262 | + return '' |
| 263 | + } |
| 264 | + }) |
| 265 | + |
| 266 | + |
202 | 267 | } |
203 | 268 |
|
204 | 269 | var Icons = IconsPanel() |
|
210 | 275 | // setting |
211 | 276 | editor.settings.extended_valid_elements = editor.settings.extended_valid_elements || '' |
212 | 277 | editor.settings.extended_valid_elements += ',span[*]' |
| 278 | + editor.settings.contextmenu = editor.settings.contextmenu || '' |
| 279 | + editor.settings.contextmenu += ' fontawesomesetting' |
213 | 280 |
|
214 | 281 | // register |
215 | 282 | editor.addCommand('mceOpenFontawesomepicker', function () { |
|
0 commit comments