Skip to content

feat (template): Add an editor extension template #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions Extensions/Editor Extensions/Template/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"plugin_type": "widget",
"name": "Extension Template",
"edit_page_url": "www.optimizely.com",
"form_schema": [
{
"default_value": "append",
"field_type": "dropdown",
"name": "position",
"label": "Position",
"options": {
"choices": [
{
"value": "beforebegin",
"label": "Before"
},
{
"value": "afterend",
"label": "After"
},
{
"value": "afterbegin",
"label": "At Beginning"
},
{
"value": "beforeend",
"label": "At End Of"
}
]
}
},
{
"default_value": "",
"field_type": "selector",
"name": "selector",
"label": "Selector",
"options": null
},
{
"default_value": "Title Text",
"field_type": "text",
"name": "title",
"label": "title",
"options": null
},
{
"default_value": "Text",
"field_type": "text",
"name": "text",
"label": "text",
"options": null
}
],
"description": "",
"options": {
"html": "<div id=\"optimizely-extension-{{ widget.$instance }}\"> </div>\n",
"css": "",
"apply_js": "document.querySelector(extension.selector).insertAdjacentHTML(extension.position, extension.$html);\n",
"undo_js": "document.getElementById(\"optimizely-extension-\" + extension.$instance).remove();"
}
}
Empty file.
1 change: 1 addition & 0 deletions Extensions/Editor Extensions/Template/extension.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div id="optimizely-extension-{{ widget.$instance }}"> </div>
1 change: 1 addition & 0 deletions Extensions/Editor Extensions/Template/extension_apply.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
document.querySelector(extension.selector).insertAdjacentHTML(extension.position, extension.$html);
55 changes: 55 additions & 0 deletions Extensions/Editor Extensions/Template/extension_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"plugin_type": "widget",
"name": "Extension Template",
"edit_page_url": "www.optimizely.com",
"form_schema": [
{
"default_value": "append",
"field_type": "dropdown",
"name": "position",
"label": "Position",
"options": {
"choices": [
{
"value": "beforebegin",
"label": "Before"
},
{
"value": "afterend",
"label": "After"
},
{
"value": "afterbegin",
"label": "At Beginning"
},
{
"value": "beforeend",
"label": "At End Of"
}
]
}
},
{
"default_value": "",
"field_type": "selector",
"name": "selector",
"label": "Selector",
"options": null
},
{
"default_value": "Title Text",
"field_type": "text",
"name": "title",
"label": "title",
"options": null
},
{
"default_value": "Text",
"field_type": "text",
"name": "text",
"label": "text",
"options": null
}
],
"description": ""
}
1 change: 1 addition & 0 deletions Extensions/Editor Extensions/Template/extension_undo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
document.getElementById("optimizely-extension-" + extension.$instance).remove();