Is is Possible to have nested Context Menus in Sublime Text 2/3? - contextmenu

Sublime Text's Context menu has a few default items like Copy,Cut,paste, Select all etc... I know that we can add/remove items via configuration but can we have nested menus(menus within menus) like the one we have in chrome or notepad++.

I may not fully understand your question, we surely can customize our context menu with nested menus(menus within menus), all we need to do is creating a "Context.sublime-menu" file under "Packages\User" folder, make create customized menu items like this:
[
{
"caption": "-",
"id": "separator"
},
{
"caption": "First Level Menu",
// "mnemonic": "f",
"id": "firstlevelmenu",
"children":
[
{
"command": "Command1",
"caption": "command1"
},
{
"command": "Command2",
"caption": "command2"
},
{
"caption": "Second Level Menu",
"children":
[
{
"command": "Command3",
"caption": "command3"
},
{
"command": "Command4",
"caption": "command4"
}
]
},
]
},
{
"caption": "-",
"id": "separator"
}
]
Keyword "children" is the one to create sub-menus.
Hope it helps.

Related

How to create zoom like response in slack bot message using block kit?

I have used zoom integration with slack. When I send /zoom command the bot responds with a new meeting link in a box layout that looks really good.
Note the bordered box below "Call"
However I am not able to create similar box layout with border and section in my own slack bot. Which block kit syntax should I use to achieve the same design?
At max what I am able to achieve is like the below:
I did not find any relevant example in the documentation as well.
There are multiple ways suggested in slack's official documentation to format Messages in responses.
For instance:
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hello, Assistant to the Regional Manager Dwight! *Michael Scott* wants to know where you'd like to take the Paper Company investors to dinner tonight.\n\n *Please select a restaurant:*"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Farmhouse Thai Cuisine*\n:star::star::star::star: 1528 reviews\n They do have some vegan options, like the roti and curry, plus they have a ton of salad stuff and noodles can be ordered without meat!! They have something for everyone here"
},
"accessory": {
"type": "image",
"image_url": "https://s3-media3.fl.yelpcdn.com/bphoto/c7ed05m9lC2EmA3Aruue7A/o.jpg",
"alt_text": "alt text for image"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Kin Khao*\n:star::star::star::star: 1638 reviews\n The sticky rice also goes wonderfully with the caramelized pork belly, which is absolutely melt-in-your-mouth and so soft."
},
"accessory": {
"type": "image",
"image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/korel-1YjNtFtJlMTaC26A/o.jpg",
"alt_text": "alt text for image"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Ler Ros*\n:star::star::star::star: 2082 reviews\n I would really recommend the Yum Koh Moo Yang - Spicy lime dressing and roasted quick marinated pork shoulder, basil leaves, chili & rice powder."
},
"accessory": {
"type": "image",
"image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/DawwNigKJ2ckPeDeDM7jAg/o.jpg",
"alt_text": "alt text for image"
}
},
{
"type": "divider"
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Farmhouse",
"emoji": true
},
"value": "click_me_123"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Kin Khao",
"emoji": true
},
"value": "click_me_123",
"url": "https://google.com"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Ler Ros",
"emoji": true
},
"value": "click_me_123",
"url": "https://google.com"
}
]
}
]}
You can use these components to design your own experience in response.
Further reading: https://api.slack.com/messaging/composing
I think the elements you are referring to are produced by the Call API
It doesn't seem that it is an available block for use in message building.

Slack API invalid_block

I'm building a simple slack bot and I am playing with the checkboxes element.
When I return the following from my API in a JSON response to a slash-command I get an error failed with the error "invalid_blocks", however, when I put this in the block-kit-builder it works perfectly (including "sending to slack" button)
Any ideas why this is failing when I run my slash command - and is it possible to see more detailed error messages from slack?
{
"blocks": [
{
"elements": [
{
"style": "primary",
"text": {
"emoji": true,
"text": "Create new TODO list",
"type": "plain_text"
},
"type": "button",
"value": "value"
},
{
"style": "primary",
"text": {
"emoji": true,
"text": "Help",
"type": "plain_text"
},
"type": "button",
"value": "value"
}
],
"type": "actions"
},
{
"text": {
"text": "Today",
"type": "mrkdwn"
},
"type": "section"
},
{
"elements": [
{
"initial_options": [
{
"text": {
"text": "Get Into the garden",
"type": "mrkdwn"
},
"value": "foo"
}
],
"options": [
{
"text": {
"text": "Get Into the garden",
"type": "mrkdwn"
},
"value": "foo"
}
],
"type": "checkboxes"
},
{
"style": "primary",
"text": {
"emoji": true,
"text": "Add new Task",
"type": "plain_text"
},
"type": "button",
"value": "value"
}
],
"type": "actions"
}
],
"type": "home"
}
I am using the Slack Web API. I was getting the similar error. After a lot of looking around, here's how I solved it.
import json
blocks = [{...}]
payload = {
"blocks": json.dumps(blocks)
}
You will then send this payload.
in the api, the "blocks" parameter need to be string type. Did you convert it to string or you use it as a JSON ?
https://api.slack.com/methods/chat.postMessage
In the Block Kit Builder, the data is a JSON with a blocks key.
In the Slack API, the blocks param is only the list of JSON objects.
blocks = [
{
"text": {
"text": "Its the list of your blocks",
"type": "mrkdwn"
},
"type": "section"
}
]
text = 'Alternative data in text'
client.chat_postMessage(channel=channel_id, blocks=blocks, text=text)
Another cause of this problem seems to be too many blocks being returned. I can't find any documentation about this whatsoever, but personal experience seems to indicate about 20 blocks is the maximum.
An alternative is to return fewer blocks, with paging actions -- paging works well with the "replace" message so that the content being paged through does not result in many separate messages.
It appears that not all valid elements in block kit tool can be posted as a message, despite the fact that message preview works fine in the Block Tool.
In my case, the code failed when I included an input block and passed when i removed it. The input block was generated by the Block Kit tool.
{
"type": "input",
"element": {
"type": "plain_text_input",
"action_id": "plain_text_input-action"
},
"label": {
"type": "plain_text",
"text": "Feedback",
"emoji": true
}
}
The error was
{'ok': False, 'error': 'invalid_blocks'}
Also, although the documentation for python says you need to urlEncode the JSON-based array, there is no example, and it is incorrect. https://api.slack.com/methods/chat.postMessage
You can see on line 29 in the SDK test code below that blocks= takes a regular list of dicts not a string.
https://github.com/slackapi/python-slack-sdk/blob/c9dc6aa0907a72c16cf36aa15e7e80031a9fdce2/integration_tests/samples/basic_usage/sending_a_message.py

How to Select multiple work items programmatically in Azure devops?

I am writing a Task Creator extension for ADO where we can create multiple tasks for multiple WITs.
Currently, I have a working extension where it allows to create multiple tasks on a single PBI.
This is how my manifest file looks
{
"manifestVersion": 1,
"id": "taskcreatortest",
"version": "1.0.24",
"name": "TaskCreator",
"description": "Create bulk tasks for a Work Item",
"publisher": "ZankhanaRana",
"galleryFlags": [
"Preview"
],
"icons": {
"default": "static/images/logo.png"
},
"scopes": [
"vso.work_write",
"vso.work",
"vso.code"
],
"targets": [
{
"id": "Microsoft.VisualStudio.Services"
}
],
"screenshots": [
{
"path": "static/images/menu.png"
},
{
"path": "static/images/createtaskform.png"
}
],
"demands": [
"api-version/3.0"
],
"tags": [
"TFS/VSTS Task Creator","Task"
],
"content": {
"details": {
"path": "overview.md"
},
"license": {
"path": "license.md"
}
},
"links": {
"getstarted": {
"uri": "https://bit.ly"
},
"support": {
"uri": "https://bit.ly"
},
"issues": {
"uri": "https://bit.ly"
}
},
"repository": {
"type": "git",
"uri": "https://bit.ly"
},
"branding": {
"color": "rgb(220, 235, 252)",
"theme": "light"
},
"files": [ ... ],
"categories": [
"Azure Test Plans"
],
"contributions": [
{
"id": "createtasks-context-menu",
"type": "ms.vss-web.action",
"description": "Toolbar item to create tasks for a work item",
"targets":[
"ms.vss-work-web.work-item-context-menu",
"ms.vss-work-web.work-item-toolbar-menu"
],
"properties": {
"uri": "static/index.html",
"text": "Create Tasks",
"title": "Create multiple tasks for a work item",
"toolbarText": "Create Tasks",
"groupId":"core"
}
},
{
"id": "createTasks-Form",
"type": "ms.vss-web.control",
"description": "Select task to create",
"targets": [ ],
"properties": {
"uri": "static/createTaskForm.html"
}
}
]
}
I am unable to select multiple work items, right-click and Create tasks.
An alert message 'Select only one item' pops up.
There are other custom extensions I installed, for example, Work Item Visualization by Microsoft Devlabs which allows multiple item selection. I think it has something to do with my configuration/manifest file.
Can someone point at what am I doing wrong?
I found the solution to this problem. Initially, I thought it has something to do with the extension configuration file (vss-extension.json); but I had a code in my script which checked for the number of items selected and if the number of items is greater than 1, it returned the alert box.
I changed that condition and everything run fine.
VSS.ready(function () {
VSS.register(VSS.getContribution().id, function (context) {
return {
execute: function (actionContext) {
if (actionContext.workItemDirty)
showDialog("Please save your work item first");
else if (actionContext.workItemIds && actionContext.workItemIds.length > 1)
showDialog("Select only one work item");
else {
var workItemType = getWorkItemType(actionContext)
if ($.inArray(workItemType, allowedWorkItemTypes) >= 0)
showPropertiesInDialog(actionContext, "Create Tasks");
else
showDialog("Not available for " + workItemType);
}
}
};
});
VSS.notifyLoadSucceeded();
});

back button with jasonett/iOS

I am trying to create a back button that when the user clicks on it, it will take them to the previous page.
I found this code of a medium post by the author of Jasonett but it doesn't work for me. It creates the label but I can't click on it
"layers": [{
"type": "label",
"text": "👈",
"style": {
"top": "10",
"right": "10",
"width": "100",
"height": "100"
},
"action": {
"type": "$back"
}
}]
Source: The documentation
The element label is clickable or you can attach an action on a label only if it is at the item level.
So, for example, the following code will accept touch and the action set there would work fine.
{
"items": [{
"type": "label",
"text": "Submit",
"action": { SOME_ACTION }
}]
}
Where as the following won't accept a click.
{
"items": [{
"type": "vertical",
"components": [{
"type": "label",
"text": "touch me",
"action": { ... }
}]
}]
}
In your example, label is defined inside layers. Thus it is not accepting a click.
Basically you have two options here.
Implement a click handler in JasonLabelComponent.m so regardless of their position labels always respond to action if it is provided in JSON.
Take the label out and make it a button, which by default would have action enabled.

How do I use a Link Addition (hyperlink) in Apple News Format without using markdown?

I know that it is possible to include a hyperlink in an Apple News Format article using markdown by doing the following:
{
"version": "1.0",
"identifier": "sketchyTech_Demo",
"title": "My First Article",
"language": "en",
"layout": {},
"components": [
{
"role": "title",
"text": "My First Article",
"textStyle": "titleStyle"
},
{
"role": "body",
"format": "markdown",
"text": "Here's a [hyperlink](http://sketchytech.blogspot.co.uk).",
"textStyle": "bodyStyle"
}
],
"componentTextStyles": {
"titleStyle": {
"textAlignment": "center",
"fontName": "HelveticaNeue-Bold",
"fontSize": 64,
"lineHeight": 74,
"textColor": "#000"
},
"bodyStyle": {
"textAlignment": "left",
"fontName": "Georgia",
"fontSize": 18,
"lineHeight": 26,
"textColor": "#000"
}
}
}
but in Apple News Format there is also a Link Addition type, which I presume should work in a similar way to inline text styles, which are placed inside a component like this:
{
"role": "title",
"text": "My First Article",
"textStyle": "titleStyle",
"inlineTextStyles": [{
"rangeStart": 3,
"rangeLength": 5,
"textStyle": {
"textColor": "#FF00007F"
}
}
}
Apple provides sample code:
{
"type": "link",
"URL": "http://www.apple.com",
"rangeStart": 0,
"rangeLength": 20
}
But it doesn't give any instructions on where it should be placed like the other elements do. It is also rather mysterious that it has a "type" key, which is unlike other elements. Not only this but in the type description it is described as a LinkAddition in all uppercase. I have tried various combinations, the most obvious of which I would guess to be
"linkAdditions": [{
"type": "link",
"URL": "http://www.apple.com",
"rangeStart": 0,
"rangeLength": 20
}]
added to a component in the same way as inlineTextStyles (because a block of text could have multiple links, just as it can have multiple styles) but I can't get this or any variants that I've tried to work. Is it perhaps that News Preview isn't yet capable of rendering this?
Add it under the "additions" property instead of under "linkAdditions" inside of the component as you expected.
For example, this should work:
...
"role": "body",
"text": "Article text goes here and here",
"additions": [{
"type": "link",
"URL": "http://www.apple.com",
"rangeStart": 0,
"rangeLength": 20
}],
...
Note: if the format is markdown it will ignore the additions property.

Resources