Browse Source

New features!
* Containers now work correctly and can be parsed by Turndown (a patch for Turndown coming soon)
* Applicable to now also works and has "almost-the-same" styles
* Picture links are now modified from "/hc/" to full-type ones

Aleksandr Bashurov 11 months ago
parent
commit
cdc12a496a
5 changed files with 642 additions and 597 deletions
  1. 4 3
      package.json
  2. 28 3
      src/App.js
  3. 1 1
      src/components/Menubar.js
  4. 25 0
      src/index.css
  5. 584 590
      yarn.lock

+ 4 - 3
package.json

@@ -6,16 +6,17 @@
     "copy-to-clipboard": "^3.0.8",
     "localforage": "^1.5.6",
     "markdown-it": "^8.4.0",
+    "markdown-it-container": "^2.0.0",
     "noty": "3.2.0-beta",
     "prop-types": "^15.6.0",
     "react": "^16.1.1",
     "react-beforeunload": "^1.0.4",
     "react-dom": "^16.1.1",
     "react-helmet": "^5.2.0",
-    "react-scripts": "1.1.1",
+    "react-scripts": "1.1.4",
     "react-splitter-layout": "^3.0.0",
-    "semantic-ui-css": "2.1.8",
-    "semantic-ui-react": "0.78.3",
+    "semantic-ui-css": "2.3.1",
+    "semantic-ui-react": "0.81.1",
     "turndown": "^4.0.0-rc.2"
   },
   "scripts": {

+ 28 - 3
src/App.js

@@ -61,13 +61,14 @@ class App extends Component {
         kbHandle(true, false, 57, () => { this.insertSimple(this.snippetList[9]) }), // Ctrl + 9 -> snippet 9
         kbHandle(true, false, 66, () => { this.insertDecorate('**', '**') }), // Ctrl + B -> Bold font
         kbHandle(true, false, 68, () => { this.insertSimple('PLESK_WARN: ') }), // Ctrl + D -> PLESK_WARNING
-        kbHandle(true, false, 69, () => { this.insertPrepend('0. ') }), // Ctrl + E -> Ordered list
+        kbHandle(true, false, 69, () => { this.insertPrepend('1. ') }), // Ctrl + E -> Ordered list
+        kbHandle(true, false, 71, () => { this.insertDecorate('::: spoiler', '\n\n:::') }), // Ctrl + G -> Spoiler
         kbHandle(true, false, 72, () => { this.eventHandleDict["help"]() }), // Ctrl + H -> Help dialog
         kbHandle(true, false, 73, () => { this.insertDecorate('_', '_') }), // Ctrl + I -> Italic font
         kbHandle(true, false, 74, () => { this.insertSimple('CONFIG_TEXT: ') }), // Ctrl + J -> CONFIG_TEXT
         kbHandle(true, false, 75, () => { this.insertSimple('C:\\> ') }), // Ctrl + K -> CMD C:\>
         kbHandle(true, false, 76, () => { this.insertSimple('\\# ') }), // Ctrl + L -> bash \#
-        kbHandle(true, false, 77, () => { this.insertDecorate('`', '`') }), // Ctrl + M -> Monospace (code)
+        kbHandle(true, false, 78, () => { this.insertDecorate('`', '`') }), // Ctrl + M -> Monospace (code)
         kbHandle(true, false, 79, () => { this.insertSimple('PLESK_ERROR: ') }), // Ctrl + O -> PLESK_ERROR
         kbHandle(true, false, 80, () => { this.insertSimple('PS ') }), // Ctrl + P -> PowerShell PS
         kbHandle(true, false, 83, () => { this.exportHandler() }), // Ctrl + S -> Export
@@ -114,6 +115,19 @@ class App extends Component {
                     return '</div></div>\n';
                 }
             }
+        }).use(markdownitContainer, 'applicable', {
+            validate: function(params) {
+                return params.trim().match(/^applicable/);
+            },
+            render: function (tokens, idx) {
+                if (tokens[idx].nesting === 1) {
+                // opening tag
+                    return '<div class="applies_to">\n';
+                } else {
+                // closing tag
+                    return '</div>\n';
+                }
+            }
         })
         return Parser.render(this.state.text).replace(/<p>C:&gt;/g, '<p>C:\\&gt;')
     }
@@ -262,7 +276,18 @@ class App extends Component {
                 )
             }
         })
-        this.insertReplace(turndown.turndown(this.textArea.value))
+        turndown.addRule('applicable', {
+            filter: function (node, options) {
+                return (node.className === 'applies_to')
+            },
+            replacement: function (content, node, options) {
+                return (
+                    '::: applicable\n' + turndown.turndown(node) + '\n:::\n\n'
+                )
+            }
+        })
+        //This fixes 404 Not Found errors in preview window: Zendesk decided to spare some bytes by removing 'https://support.plesk.com' from links
+        this.insertReplace(turndown.turndown(this.textArea.value.replace(/"\/hc\/article_attachments/g, '"https://support.plesk.com/hc/article_attachments')))
     }
     helpHandler = (e) => { 
         this.setState({ helpIsOpen: !this.state.helpIsOpen })

+ 1 - 1
src/components/Menubar.js

@@ -43,7 +43,7 @@ class Menubar extends Component {
                 <Menu.Item fitted>
                     <DropdownLinks />
                 </Menu.Item>
-                <Menu.Item href='https://git.kcs.rocks/Plesk_Support/Editor' target='_blank' header>Editor v1.2 b342</Menu.Item>
+                <Menu.Item href='https://git.kcs.rocks/Plesk_Support/Editor' target='_blank' header>Editor v1.2 b378</Menu.Item>
             </Menu.Menu>
         </Menu>
         )

+ 25 - 0
src/index.css

@@ -1,4 +1,29 @@
+.applies_to {
+display: inline;
+margin: 0;
+font-size: 10pt;
+font-weight: bold;
+}
+.applies_to h2 {
+display: inline;
+}
+.applies_to ul {
+padding: 5px !important;
+margin: 5px !important;
+display: inline;
+}
+.applies_to li {
+display: inline-block;
+background-color: #52bce6;
+padding: 2px 10px 0px;
+border-radius: 3px;
+border: 0px;
+color: white;
+margin-left: 5px;
+margin-bottom: 5px;
+}
 .accordion {
+padding-left: 10px;
 text-transform: uppercase;
 border-bottom: solid 1px;
 margin-bottom: 1rem;

File diff suppressed because it is too large
+ 584 - 590
yarn.lock