Skip to content

Commit

Permalink
widgetbay, add forceLink
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio-Emmolo committed Aug 2, 2024
1 parent b3fcea7 commit b738790
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/shortcodeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ tinymce.PluginManager.add('shortcodeList', function (editor, url) {
},
{
title: 'Widgetbay',
code: '[widgetbay id="optional" link="optional"]',
code: '[widgetbay id="optional" link="optional" forceLink="optional"]',
description: 'Insert a widgetbay iframe. You can use the id or the link, but not both. You can use multiple links separated by a comma. - link="https://link1.com,https://link2.com'
},
{
Expand Down
12 changes: 9 additions & 3 deletions src/widgetbay.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ tinymce.PluginManager.add('widgetbay', function (editor, url) {
</div>
</label>
<label>
<span class="label-span">Custom title (optional)</span>
<input type="text" name="widget-title" style="border: 2px solid #eeeeee; padding: 7px 10px; border-radius: 5px;">
</label>
<label>
<span class="label-span">Force Link (optional)</span>
<input type="text" name="widget-force-link" style="border: 2px solid #eeeeee; padding: 7px 10px; border-radius: 5px;">
<p style="color: #9f9f9f; font-size: 0.8rem;">It only works on single product</p>
</label>
<button type="submit" style="padding: 10px; border-radius: .2rem; cursor: pointer; background-color: rgb(14,165,233); color: white;">
Create
</button>
Expand Down Expand Up @@ -133,8 +138,9 @@ function generateShortcode () {
const parsedTitle = formData.get('widget-title') ? 'title="' + formData.get('widget-title') + '" ' : ''
const parsedLink = link ? 'link="' + link + '" ' : ' '
const parsedId = formData.get('widget-id') ? 'id="' + formData.get('widget-id') + '"' : ' '
const parsedForceLink = formData.get('widget-force-link') ? 'forceLink="' + formData.get('widget-force-link') + '" ' : ' '

const content = '[widgetbay ' + parsedId + parsedLink + parsedTitle + ']'
const content = '[widgetbay ' + parsedId + parsedLink + parsedTitle + parsedForceLink + ']'

tinymce.activeEditor.insertContent(content)
tinymce.activeEditor.windowManager.close()
Expand Down

0 comments on commit b738790

Please sign in to comment.