typescriptでテキストに出力された文字を取得するプログラムを書いているのですが、
実行できずに困っています。参考にしたのがjavascriptのプログラムなので、
どこか間違っている可能性があるのですが、教えて頂ければ幸いです。
宜しくお願い致します。
<参考にしたサイト>
・テキストが選択・ドラッグされたときに、選択された文章を取得する方法https://qiita.com/uuuno/items/5a215d9bfeabec8adbc3
・Visual Studio Codeの拡張機能をTypeScriptで作る方法
https://clickan.click/vsc-ext/
Typescript
1import * as $ from "jquery"; 2$('body').on('mouseup', function(e){ //mouseupでイベント発火 3 var selectedStr; 4 if(window.getSelection){ //selectionオブジェクト取得 5 selectedStr = window.getSelection().toString(); //文章取得 6 if(selectedStr !== '' && selectedStr !== '\n'){ //文章チェック 7 console.log(selectedStr); 8 } 9 } 10 });
原因としては、package.jsonでpublisherの名前がないからかなと思っているので、
一応、package.jsonのコードを載せておきます。
package.json
1 2{ 3 "name": "highlight", 4 "displayName": "highlight", 5 "description": "", 6 "version": "0.0.1", 7 "engines": { 8 "vscode": "^1.34.0" 9 }, 10 "categories": [ 11 "Other" 12 ], 13 "activationEvents": [ 14 "*" 15 ], 16 "main": "./out/sample", 17 "contributes": { 18 "commands": [ 19 { 20 "command": "extension.helloWorld", 21 "title": "Hello World" 22 } 23 ] 24 }, 25 "scripts": { 26 "vscode:prepublish": "npm run compile", 27 "compile": "tsc -p ./", 28 "watch": "tsc -watch -p ./", 29 "postinstall": "node ./node_modules/vscode/bin/install", 30 "test": "npm run compile && node ./node_modules/vscode/bin/test", 31 "tsc": "tsc" 32 }, 33 "devDependencies": { 34 "@types/mocha": "^2.2.42", 35 "@types/node": "^8.10.48", 36 "jquery": "^3.4.1", 37 "js-yaml": "^3.13.1", 38 "tar": "^4.4.8", 39 "tslint": "^5.8.0", 40 "typescript": "^2.9.2", 41 "vscode": "^1.1.34" 42 }, 43 "dependencies": { 44 "@types/jquery": "^3.3.29", 45 "missing": "0.0.1", 46 "module.js": "^2.2.4", 47 "requirejs": "^2.3.6", 48 "tsd": "^0.7.3", 49 "yarn": "^1.16.0" 50 } 51}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/08 15:41
2019/06/08 15:59
2019/06/09 11:35
2019/06/10 15:00
2019/06/13 05:11
2019/06/13 05:52
2019/06/14 08:22