-
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{409:function(t,e,a){"use strict";a.r(e);var r=a(56),v=Object(r.a)({},(function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"api"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#api"}},[t._v("#")]),t._v(" API")]),t._v(" "),a("p"),a("div",{staticClass:"table-of-contents"},[a("ul",[a("li",[a("a",{attrs:{href:"#function-parse-message"}},[t._v("function parse(message)")]),a("ul",[a("li",[a("a",{attrs:{href:"#arguments"}},[t._v("Arguments")])]),a("li",[a("a",{attrs:{href:"#returns"}},[t._v("Returns")])])])]),a("li",[a("a",{attrs:{href:"#interface-node"}},[t._v("interface Node")]),a("ul",[a("li",[a("a",{attrs:{href:"#root-node"}},[t._v("Root node")])]),a("li",[a("a",{attrs:{href:"#text-node"}},[t._v("Text node")])]),a("li",[a("a",{attrs:{href:"#channellink-node"}},[t._v("ChannelLink node")])]),a("li",[a("a",{attrs:{href:"#userlink-node"}},[t._v("UserLink node")])]),a("li",[a("a",{attrs:{href:"#url-node"}},[t._v("URL node")])]),a("li",[a("a",{attrs:{href:"#command-node"}},[t._v("Command node")])]),a("li",[a("a",{attrs:{href:"#emoji-node"}},[t._v("Emoji node")])]),a("li",[a("a",{attrs:{href:"#pretext-node"}},[t._v("PreText node")])]),a("li",[a("a",{attrs:{href:"#code-node"}},[t._v("Code node")])]),a("li",[a("a",{attrs:{href:"#italic-bold-strike-quote-node"}},[t._v("Italic/Bold/Strike/Quote node")])])])])])]),a("p"),t._v(" "),a("h2",{attrs:{id:"function-parse-message"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#function-parse-message"}},[t._v("#")]),t._v(" "),a("code",[t._v("function parse(message)")])]),t._v(" "),a("p",[t._v("Parses Slack message and returns a tree ("),a("a",{attrs:{href:"#interface-node"}},[a("code",[t._v("Node")])]),t._v(").")]),t._v(" "),a("h3",{attrs:{id:"arguments"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#arguments"}},[t._v("#")]),t._v(" Arguments")]),t._v(" "),a("table",[a("thead",[a("tr",[a("th",[t._v("Name")]),t._v(" "),a("th",[t._v("Type")]),t._v(" "),a("th",[t._v("Description")])])]),t._v(" "),a("tbody",[a("tr",[a("td",[t._v("message")]),t._v(" "),a("td",[t._v("String")]),t._v(" "),a("td",[t._v("a Slack message to parse")])])])]),t._v(" "),a("h3",{attrs:{id:"returns"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#returns"}},[t._v("#")]),t._v(" Returns")]),t._v(" "),a("table",[a("thead",[a("tr",[a("th",[t._v("Type")]),t._v(" "),a("th",[t._v("Description")])])]),t._v(" "),a("tbody",[a("tr",[a("td",[t._v("Node")]),t._v(" "),a("td",[t._v("Message tree")])])])]),t._v(" "),a("h2",{attrs:{id:"interface-node"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#interface-node"}},[t._v("#")]),t._v(" "),a("code",[t._v("interface Node")])]),t._v(" "),a("p",[t._v("Represents each parts of the message, its type and properties.")]),t._v(" "),a("p",[t._v("Every node at least have one property, "),a("code",[t._v("type")]),t._v(".")]),t._v(" "),a("table",[a("thead",[a("tr",[a("th",[t._v("Name")]),t._v(" "),a("th",[t._v("Type")]),t._v(" "),a("th",[t._v("Description")])])]),t._v(" "),a("tbody",[a("tr",[a("td",[t._v("type")]),t._v(" "),a("td",[t._v("Number(NodeType)")]),t._v(" "),a("td",[t._v("Type of the node")])]),t._v(" "),a("tr",[a("td",[t._v("source")]),t._v(" "),a("td",[t._v("String")]),t._v(" "),a("td",[t._v("Raw string of the node")])])])]),t._v(" "),a("p",[t._v("You can test the type with "),a("code",[t._v("NodeType")]),t._v(" object (which is actually TypeScript enum).")]),t._v(" "),a("div",{staticClass:"language-js extra-class"},[a("pre",{pre:!0,attrs:{class:"language-js"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v(" NodeType "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("from")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("'slack-message-parser'")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("switch")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("node"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("type"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" NodeType"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("Text"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ...")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" NodeType"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("ChannelLink"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ...")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("p",[t._v("The names of Node and NodeType are one-to-one equivalent (e.g. "),a("code",[t._v("Text")]),t._v(" node have "),a("code",[t._v("type")]),t._v(" property that the value is "),a("code",[t._v("NodeType.Text")]),t._v(").")]),t._v(" "),a("h3",{attrs:{id:"root-node"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#root-node"}},[t._v("#")]),t._v(" "),a("code",[t._v("Root")]),t._v(" node")]),t._v(" "),a("p",[t._v("A node sits on top of the tree. Every parse result have this node as its root node.")]),t._v(" "),a("h4",{attrs:{id:"properties"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#properties"}},[t._v("#")]),t._v(" Properties")]),t._v(" "),a("table",[a("thead",[a("tr",[a("th",[t._v("Name")]),t._v(" "),a("th",[t._v("Type")]),t._v(" "),a("th",[t._v("Description")])])]),t._v(" "),a("tbody",[a("tr",[a("td",[t._v("children")]),t._v(" "),a("td",[t._v("Node[]")]),t._v(" "),a("td",[t._v("Child nodes")])])])]),t._v(" "),a("h3",{attrs:{id:"text-node"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#text-node"}},[t._v("#")]),t._v(" "),a("code",[t._v("Text")]),t._v(" node")]),t._v(" "),a("p",[t._v("Texts.")]),t._v(" "),a("h4",{attrs:{id:"properties-2"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#properties-2"}},[t._v("#")]),t._v(" Properties")]),t._v(" "),a("table",[a("thead",[a("tr",[a("th",[t._v("Name")]),t._v(" "),a("th",[t._v("Type")]),t._v(" "),a("th",[t._v("Description")])])]),t._v(" "),a("tbody",[a("tr",[a("td",[t._v("text")]),t._v(" "),a("td",[t._v("String")]),t._v(" "),a("td",[t._v("Text content")])])])]),t._v(" "),a("h3",{attrs:{id:"channellink-node"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#channellink-node"}},[t._v("#")]),t._v(" "),a("code",[t._v("ChannelLink")]),t._v(" node")]),t._v(" "),a("p",[t._v("Link to a channel.")]),t._v(" "),a("h4",{attrs:{id:"properties-3"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#properties-3"}},[t._v("#")]),t._v(" Properties")]),t._v(" "),a("table",[a("thead",[a("tr",[a("th",[t._v("Name")]),t._v(" "),a("th",[t._v("Type")]),t._v(" "),a("th",[t._v("Description")])])]),t._v(" "),a("tbody",[a("tr",[a("td",[t._v("channelID")]),t._v(" "),a("td",[t._v("String")]),t._v(" "),a("td",[t._v("An ID of the channel")])]),t._v(" "),a("tr",[a("td",[t._v("label")]),t._v(" "),a("td",[t._v("Node[] | undefined")]),t._v(" "),a("td",[t._v("Display texts for the link")])])])]),t._v(" "),a("h3",{attrs:{id:"userlink-node"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#userlink-node"}},[t._v("#")]),t._v(" "),a("code",[t._v("UserLink")]),t._v(" node")]),t._v(" "),a("p",[t._v("Link to a user.")]),t._v(" "),a("h4",{attrs:{id:"properties-4"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#properties-4"}},[t._v("#")]),t._v(" Properties")]),t._v(" "),a("table",[a("thead",[a("tr",[a("th",[t._v("Name")]),t._v(" "),a("th",[t._v("Type")]),t._v(" "),a("th",[t._v("Description")])])]),t._v(" "),a("tbody",[a("tr",[a("td",[t._v("userId")]),t._v(" "),a("td",[t._v("String")]),t._v(" "),a("td",[t._v("An ID of the user")])]),t._v(" "),a("tr",[a("td",[t._v("label")]),t._v(" "),a("td",[t._v("Node[] | undefined")]),t._v(" "),a("td",[t._v("Display texts for the user")])])])]),t._v(" "),a("h3",{attrs:{id:"url-node"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#url-node"}},[t._v("#")]),t._v(" "),a("code",[t._v("URL")]),t._v(" node")]),t._v(" "),a("p",[t._v("Link other than channels and users (e.g. "),a("code",[t._v("https://foo.bar")]),t._v(", "),a("code",[t._v("mailto:foo@bar")]),t._v(").")]),t._v(" "),a("h4",{attrs:{id:"properties-5"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#properties-5"}},[t._v("#")]),t._v(" Properties")]),t._v(" "),a("table",[a("thead",[a("tr",[a("th",[t._v("Name")]),t._v(" "),a("th",[t._v("Type")]),t._v(" "),a("th",[t._v("Description")])])]),t._v(" "),a("tbody",[a("tr",[a("td",[t._v("url")]),t._v(" "),a("td",[t._v("String")]),t._v(" "),a("td",[t._v("A link url")])]),t._v(" "),a("tr",[a("td",[t._v("label")]),t._v(" "),a("td",[t._v("Node[] | undefined")]),t._v(" "),a("td",[t._v("Display texts for the link")])])])]),t._v(" "),a("h3",{attrs:{id:"command-node"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#command-node"}},[t._v("#")]),t._v(" "),a("code",[t._v("Command")]),t._v(" node")]),t._v(" "),a("p",[t._v("Special commands like "),a("code",[t._v("<!date>")]),t._v(", "),a("code",[t._v("<!everyone>")]),t._v(", "),a("code",[t._v("<!subteam^id|@handle>")]),t._v(", and more.\nFor more details, please refer "),a("a",{attrs:{href:"https://api.slack.com/docs/message-formatting",target:"_blank",rel:"noopener noreferrer"}},[t._v("Formatting messages | Slack"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("h4",{attrs:{id:"properties-6"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#properties-6"}},[t._v("#")]),t._v(" Properties")]),t._v(" "),a("table",[a("thead",[a("tr",[a("th",[t._v("Name")]),t._v(" "),a("th",[t._v("Type")]),t._v(" "),a("th",[t._v("Description")])])]),t._v(" "),a("tbody",[a("tr",[a("td",[t._v("name")]),t._v(" "),a("td",[t._v("String")]),t._v(" "),a("td",[t._v("A name of the command")])]),t._v(" "),a("tr",[a("td",[t._v("arguments")]),t._v(" "),a("td",[t._v("String[]")]),t._v(" "),a("td",[t._v("Command arguments(prefixed by "),a("code",[t._v("^")]),t._v(", "),a("code",[t._v("ID")]),t._v(" is an argument of "),a("code",[t._v("<!subteam^ID>")]),t._v(")")])]),t._v(" "),a("tr",[a("td",[t._v("label")]),t._v(" "),a("td",[t._v("Node[] | undefined")]),t._v(" "),a("td",[t._v("Display texts for the link")])])])]),t._v(" "),a("h3",{attrs:{id:"emoji-node"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#emoji-node"}},[t._v("#")]),t._v(" "),a("code",[t._v("Emoji")]),t._v(" node")]),t._v(" "),a("p",[t._v("Emojis!")]),t._v(" "),a("h4",{attrs:{id:"properties-7"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#properties-7"}},[t._v("#")]),t._v(" Properties")]),t._v(" "),a("table",[a("thead",[a("tr",[a("th",[t._v("Name")]),t._v(" "),a("th",[t._v("Type")]),t._v(" "),a("th",[t._v("Description")])])]),t._v(" "),a("tbody",[a("tr",[a("td",[t._v("name")]),t._v(" "),a("td",[t._v("String")]),t._v(" "),a("td",[t._v("A name of the emoji (the text between both "),a("code",[t._v(":")]),t._v("s)")])]),t._v(" "),a("tr",[a("td",[t._v("variation")]),t._v(" "),a("td",[t._v("String | undefined")]),t._v(" "),a("td",[t._v("Emoji variation, currently "),a("code",[t._v("skin-tone-")]),t._v(" only")])])])]),t._v(" "),a("h3",{attrs:{id:"pretext-node"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#pretext-node"}},[t._v("#")]),t._v(" "),a("code",[t._v("PreText")]),t._v(" node")]),t._v(" "),a("p",[t._v("Code block. Multi-line codes.")]),t._v(" "),a("h4",{attrs:{id:"properties-8"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#properties-8"}},[t._v("#")]),t._v(" Properties")]),t._v(" "),a("table",[a("thead",[a("tr",[a("th",[t._v("Name")]),t._v(" "),a("th",[t._v("Type")]),t._v(" "),a("th",[t._v("Description")])])]),t._v(" "),a("tbody",[a("tr",[a("td",[t._v("text")]),t._v(" "),a("td",[t._v("String")]),t._v(" "),a("td",[t._v("Text content")])])])]),t._v(" "),a("h3",{attrs:{id:"code-node"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#code-node"}},[t._v("#")]),t._v(" "),a("code",[t._v("Code")]),t._v(" node")]),t._v(" "),a("p",[t._v("Inline code.")]),t._v(" "),a("h4",{attrs:{id:"properties-9"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#properties-9"}},[t._v("#")]),t._v(" Properties")]),t._v(" "),a("table",[a("thead",[a("tr",[a("th",[t._v("Name")]),t._v(" "),a("th",[t._v("Type")]),t._v(" "),a("th",[t._v("Description")])])]),t._v(" "),a("tbody",[a("tr",[a("td",[t._v("text")]),t._v(" "),a("td",[t._v("String")]),t._v(" "),a("td",[t._v("Text content")])])])]),t._v(" "),a("h3",{attrs:{id:"italic-bold-strike-quote-node"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#italic-bold-strike-quote-node"}},[t._v("#")]),t._v(" "),a("code",[t._v("Italic")]),t._v("/"),a("code",[t._v("Bold")]),t._v("/"),a("code",[t._v("Strike")]),t._v("/"),a("code",[t._v("Quote")]),t._v(" node")]),t._v(" "),a("p",[t._v("Represents text decorations. Each nodes just have decoration information, so it acts as container (does not hold texts directly).")]),t._v(" "),a("h4",{attrs:{id:"properties-10"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#properties-10"}},[t._v("#")]),t._v(" Properties")]),t._v(" "),a("table",[a("thead",[a("tr",[a("th",[t._v("Name")]),t._v(" "),a("th",[t._v("Type")]),t._v(" "),a("th",[t._v("Description")])])]),t._v(" "),a("tbody",[a("tr",[a("td",[t._v("children")]),t._v(" "),a("td",[t._v("Node[]")]),t._v(" "),a("td",[t._v("Child nodes")])])])])])}),[],!1,null,null,null);e.default=v.exports}}]);