-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add copy to clipboard feature and editor configuration (#15)
* A editorconfig * A run lint at pre-commit * U change index_size to 4 * A copyMarkDownTitleFromFile/showMindMapFromFile * U lint copyMarkDownTitleFromFile/showMindMapFromFile * Revert 23ae53d: refuse adding husky. * lint: add new line to file * U mindMapPreviewWebview.ts 根据评审修改 * change command name & pre-release works: - Document: checked - Change Log: checked - Update version: checked Co-authored-by: Joseph Chris <baobao1270@gmail.com>
- Loading branch information
1 parent
196fd23
commit bb0e223
Showing
10 changed files
with
117 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
insert_final_newline = false | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# Change Log | ||
|
||
## [v1.3.0] | ||
- 【新增】提取 Markdown 标题生成思维导图 | ||
- 【新增】提取 Markdown 标题到剪贴板 | ||
|
||
## [v1.1.0] | ||
|
||
- 【新增】SVG 导出功能 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,30 @@ | ||
export function getFileNameWithoutExtension(filename: string) { | ||
function getFileNameWithoutExtension(filename: string) { | ||
var pattern = /\.[A-Za-z]+$/; | ||
let ansMatch = pattern.exec(filename); | ||
if (ansMatch !== null) { | ||
return (filename.slice(0, ansMatch.index)); | ||
return filename.slice(0, ansMatch.index); | ||
} else { | ||
return filename; | ||
} | ||
} | ||
|
||
function debounce(context: any, fn = () => {}, delay: number = 1000) { | ||
let timeout: any = null; | ||
return function () { | ||
clearTimeout(timeout); | ||
|
||
timeout = setTimeout(() => { | ||
fn.apply(context, []); | ||
}, delay); | ||
}; | ||
} | ||
|
||
function getMarkDownTitle(data: string = "") { | ||
const titleMatchReg = /#+\s[^#\n]+/g; | ||
let matchResult = data.match(titleMatchReg) || []; | ||
data = matchResult.join("\n"); | ||
|
||
return data; | ||
} | ||
|
||
export { getFileNameWithoutExtension, debounce, getMarkDownTitle }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as vscode from "vscode"; | ||
import * as utils from "./utils"; | ||
|
||
function writeToClipBoard() { | ||
let editingEditor = vscode.window.activeTextEditor; | ||
|
||
if (editingEditor && editingEditor.document) { | ||
let data = editingEditor.document.getText(); | ||
data = utils.getMarkDownTitle(data); | ||
vscode.env.clipboard.writeText(data).then( | ||
(res) => { | ||
vscode.window.setStatusBarMessage("copy success", 2000); | ||
}, | ||
(res) => { | ||
vscode.window.showErrorMessage("copy fail"); | ||
} | ||
); | ||
} | ||
} | ||
|
||
export { writeToClipBoard }; |