Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/vjeantet/hugo-theme-docport.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'static/admin/shortcode/alert.js')
-rw-r--r--static/admin/shortcode/alert.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/static/admin/shortcode/alert.js b/static/admin/shortcode/alert.js
new file mode 100644
index 0000000..2c3a471
--- /dev/null
+++ b/static/admin/shortcode/alert.js
@@ -0,0 +1,44 @@
+CMS.registerEditorComponent({
+ // Internal id of the component
+ id: "alert",
+ // Visible label
+ label: "Alert",
+ hint:"",
+ // Fields the user need to fill out when adding an instance of the component
+ fields: [
+ {
+ name: 'theme',
+ label: 'Theme',
+ widget: 'select',
+ default:'info',
+ options: [
+ { label: "info", value: "info" },
+ { label: "success ", value: "success" },
+ { label: "warning", value: "warning" },
+ { label: "danger", value: "danger" }
+ ]
+ },
+ { label: 'Text', name: 'text', widget: 'markdown' }
+ ],
+ // Pattern to identify a block as being an instance of this component
+ pattern: /{{% alert theme="(\w+)" %}}(.*?){{% \/alert %}}/s,
+
+ // Function to extract data elements from the regexp match
+ fromBlock: function(match) {
+ return {
+ theme: match[1],
+ text: match[2]
+ };
+ },
+ // Function to create a text block from an instance of this component
+ toBlock: function(obj) {
+ return '{{% alert theme="'+obj.theme+'" %}}'+obj.text+'{{% /alert %}}';
+ },
+ // Preview output for this component. Can either be a string or a React component
+ // (component gives better render performance)
+ toPreview: function(obj) {
+ return (
+ '<strong> alert '+obj.theme+' -- '+obj.text+'</strong>'
+ );
+ }
+}); \ No newline at end of file