leksy-editor 2.4.1 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -110,6 +110,7 @@ const app = createApp({
110
110
  | `showTabs` | Enables or disables the display of tabs. |
111
111
  | `enableFindAndReplace` | To enabled find and replace feature|
112
112
  | `customTooltip` | Customize tooltip according to your need, set using key-value pair|
113
+ | `customIcon` | Customize icon according to your need, set using key-value pair|
113
114
 
114
115
  ### CSS Customization
115
116
 
@@ -182,6 +183,7 @@ Similarly, Pexels and Tenor can be integrated using `pexels` and `tenor` plugins
182
183
  | `onChange(tabs)` | Triggered when content changes. |
183
184
  | `onBlur(tabs)` | Triggered when the editor loses focus. |
184
185
  | `onAttachment(files)` | Fires when files are attached. |
186
+ | `onLinkClick(href)` | To open custom link opener. |
185
187
  | `manipulateImage()` | Custom function for manipulating images. |
186
188
  | `handleFilePicker()` | Custom function for file upload, useful for Android and iOS file upload. |
187
189
  | `uploadVideo(file)` | Handles video uploads, returns a promise with video URL. |
package/index.js CHANGED
@@ -32,7 +32,9 @@ class LeksyEditor {
32
32
  * @property {Boolean} disabled
33
33
  * @property {Function} onFullScreen
34
34
  * @property {Boolean} showTabs
35
- * @property {Boolean} enableFindAndReplace
35
+ * @property {Boolean} enableFindAndReplace
36
+ * @property {Array<Object>} customTooltip
37
+ * @property {Array<Object>} customIcon
36
38
  */
37
39
  /**
38
40
  *
@@ -187,6 +189,9 @@ class LeksyEditor {
187
189
  onAttachment: (files) => {
188
190
  if (editorRef.onAttachment instanceof Function) editorRef.onAttachment(files)
189
191
  },
192
+ onLinkClick: (href) => {
193
+ if (editorRef.onLinkClick instanceof Function) editorRef.onLinkClick(href)
194
+ },
190
195
  manuplateImage: async (type, content) => {
191
196
  if (editorRef.manuplateImage instanceof Function) {
192
197
  core.changeStatus('Loading...')
@@ -299,6 +304,9 @@ class LeksyEditor {
299
304
  onSave: () => { },
300
305
  onBlur: () => { },
301
306
  onAttachment: () => { },
307
+ onLinkClick: (href) => {
308
+ window.open(href, '_blank', 'noopener noreferrer')
309
+ },
302
310
  manuplateImage: async () => { },
303
311
  handleFilePicker: async () => { },
304
312
  uploadVideo: async () => { },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leksy-editor",
3
- "version": "2.4.1",
3
+ "version": "2.6.0",
4
4
  "description": "Leksy Editor is an alternative to traditional WYSIWYG editors, designed primarily for creating mail templates, blogs, and documents without any content manipulation.",
5
5
  "main": "index.js",
6
6
  "directories": {
package/utilities.js CHANGED
@@ -204,6 +204,10 @@ const getTooltip = (plugin, options) => {
204
204
  return options?.customTooltip?.[plugin.pluginId] ?? plugin.title
205
205
  }
206
206
 
207
+ const getToolbarIcon = (plugin, options) => {
208
+ return options?.customIcon?.[plugin.pluginId] ?? plugin.icon
209
+ }
210
+
207
211
  const makeToolbarButton = (_plugin, options, core) => {
208
212
  const pluginButton = document.createElement('button');
209
213
  pluginButton.type = "button"
@@ -217,7 +221,7 @@ const makeToolbarButton = (_plugin, options, core) => {
217
221
  };
218
222
 
219
223
  const pluginIcon = document.createElement('div');
220
- pluginIcon.innerHTML = _plugin.icon;
224
+ pluginIcon.innerHTML = getToolbarIcon(_plugin, options);
221
225
  pluginButton.appendChild(pluginIcon)
222
226
  return pluginButton
223
227
  }
@@ -236,7 +240,7 @@ const makeToolbarButtonSelect = (_plugin, options, core) => {
236
240
  };
237
241
 
238
242
  const pluginIcon = document.createElement('div');
239
- pluginIcon.innerHTML = _plugin.icon;
243
+ pluginIcon.innerHTML = getToolbarIcon(_plugin, options);
240
244
  pluginButton.appendChild(pluginIcon)
241
245
  const pluginSelect = makeToolbarSelect({ ..._plugin, icon: '' }, options, core);
242
246
 
@@ -265,7 +269,7 @@ const makeToolbarColor = (_plugin, options, core) => {
265
269
  };
266
270
 
267
271
  const pluginIcon = document.createElement('div');
268
- pluginIcon.innerHTML = _plugin.icon;
272
+ pluginIcon.innerHTML = getToolbarIcon(_plugin, options);
269
273
  pluginIcon.onclick = () => pluginButton.click()
270
274
  pluginContainer.append(pluginButton, pluginIcon)
271
275
  return pluginContainer
@@ -348,7 +352,7 @@ const makeToolbarDropdown = (_plugin, options, core) => {
348
352
  dropdownButton.setAttribute('data-title', getTooltip(_plugin, options))
349
353
 
350
354
  const pluginIcon = document.createElement('div');
351
- pluginIcon.innerHTML = _plugin.icon;
355
+ pluginIcon.innerHTML = getToolbarIcon(_plugin, options);
352
356
  dropdownButton.appendChild(pluginIcon)
353
357
 
354
358
  const dropdownContent = document.createElement('div');
@@ -597,7 +601,7 @@ const makeToolbarSelect = (_plugin, options, core) => {
597
601
  pluginIcon.style.justifyContent = 'space-between'
598
602
 
599
603
  const iconName = document.createElement('span');
600
- iconName.innerHTML = _plugin.icon;
604
+ iconName.innerHTML = getToolbarIcon(_plugin, options);
601
605
 
602
606
  const arrow = document.createElement('span');
603
607
  if (_plugin.type == 'button-select') {
@@ -2352,19 +2356,19 @@ const showAnchorPopover = (element, x, y, options, core) => {
2352
2356
  popover.style.visibility = "hidden";
2353
2357
 
2354
2358
  // Create clickable link
2355
- let link = document.createElement("a");
2356
- link.href = href;
2357
- link.target = "_blank";
2358
- link.textContent = href;
2359
- link.style.textDecoration = "none";
2360
- link.style.color = "#007bff";
2361
- link.style.padding = "5px";
2362
- link.style.overflow = "hidden";
2363
- link.style.textOverflow = "ellipsis";
2364
- link.style.webkitBoxOrient = "vertical";
2365
- link.style.webkitLineClamp = "1";
2366
- link.style.maxWidth = "250px";
2367
- link.style.wordBreak = "break-word";
2359
+ let linkDiv = document.createElement("div");
2360
+ linkDiv.textContent = href;
2361
+ linkDiv.style.textDecoration = "none";
2362
+ linkDiv.style.color = "#007bff";
2363
+ linkDiv.style.padding = "5px";
2364
+ linkDiv.style.overflow = "hidden";
2365
+ linkDiv.style.textOverflow = "ellipsis";
2366
+ linkDiv.style.webkitBoxOrient = "vertical";
2367
+ linkDiv.style.webkitLineClamp = "1";
2368
+ linkDiv.style.maxWidth = "250px";
2369
+ linkDiv.style.wordBreak = "break-word";
2370
+ linkDiv.style.cursor = "pointer";
2371
+ linkDiv.onclick = () => core.onLinkClick(href);
2368
2372
 
2369
2373
  // Create Edit button
2370
2374
  let editButton = document.createElement("span");
@@ -2388,7 +2392,7 @@ const showAnchorPopover = (element, x, y, options, core) => {
2388
2392
  deleteButton.onclick = (event) => removeAnchorTag(event, element, core);
2389
2393
 
2390
2394
  // Append elements to popover
2391
- popover.append(link, copyButton, editButton, deleteButton);
2395
+ popover.append(linkDiv, copyButton, editButton, deleteButton);
2392
2396
 
2393
2397
  let parent = core.elements.iframeWindow.body;
2394
2398
  parent.appendChild(popover);