{"action":"opened","issue":{"url":"https://api.github.com/repos/Microsoft/monaco-editor/issues/723","repository_url":"https://api.github.com/repos/Microsoft/monaco-editor","labels_url":"https://api.github.com/repos/Microsoft/monaco-editor/issues/723/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/monaco-editor/issues/723/comments","events_url":"https://api.github.com/repos/Microsoft/monaco-editor/issues/723/events","html_url":"https://github.com/Microsoft/monaco-editor/issues/723","id":296274898,"number":723,"title":"APIs to define formatting rules","user":{"login":"chengtie","id":774409,"avatar_url":"https://avatars3.githubusercontent.com/u/774409?v=4","gravatar_id":"","url":"https://api.github.com/users/chengtie","html_url":"https://github.com/chengtie","followers_url":"https://api.github.com/users/chengtie/followers","following_url":"https://api.github.com/users/chengtie/following{/other_user}","gists_url":"https://api.github.com/users/chengtie/gists{/gist_id}","starred_url":"https://api.github.com/users/chengtie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chengtie/subscriptions","organizations_url":"https://api.github.com/users/chengtie/orgs","repos_url":"https://api.github.com/users/chengtie/repos","events_url":"https://api.github.com/users/chengtie/events{/privacy}","received_events_url":"https://api.github.com/users/chengtie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-12T06:07:40Z","updated_at":"2018-02-12T06:07:40Z","closed_at":null,"author_association":"NONE","body":"I am trying to add a formatter to a custom language in Monaco Editor. I know we can use \r\n\r\n```\r\nmonaco.languages.registerDocumentFormattingEditProvider(...)\r\nmonaco.languages.registerDocumentRangeFormattingEditProvider(...)\r\nmonaco.languages.registerOnTypeFormattingEditProvider(...)\r\n```\r\n\r\nIn each of the above APIs, we need to define a provider, e.g., [provideDocumentFormattingEdits](https://microsoft.github.io/monaco-editor/api/interfaces/monaco.languages.documentformattingeditprovider.html#providedocumentformattingedits) that returns a [TextEdit](https://microsoft.github.io/monaco-editor/api/interfaces/monaco.languages.textedit.html). In the TextEdit, we need to return a text, which will replace the initial text.\r\n\r\nOne way to construct the text of TextEdit, is to manually transfer the initial text by e.g., [replace](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace). But, I am wondering whether there is any existing APIs to simplify this process, for example, is there any way to set indentation/newline rules based on tokens?\r\n\r\nDoes anyone know?\r\n"}}
{"actor":{"display_login":"chengtie"}}