Skip to content

Commit

Permalink
[bugfix] fix when copy all as txt/markdown, tag node's output is unde…
Browse files Browse the repository at this point in the history
…fined
  • Loading branch information
GarinZ committed Apr 15, 2023
1 parent dd1da00 commit c275525
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "link-map",
"displayName": "Link Map",
"version": "1.0.10",
"version": "1.0.11",
"browserslist": "Chrome >= 96",
"description": "Vertical Tabs Sidebar, But In Tree Structure",
"author": "Garin",
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
"message": "Link Map感觉自己更强大了!"
},
"updateNoteContent": {
"message": "在v1.0.0版本中,增加了一些小的改进,可以更细粒度的控制Link Map的行为。如果你感兴趣,只需查看树中的第一个节点来获取细节"
"message": "在v1.0.10版本中,增加了一些小的改进,可以更细粒度的控制Link Map的行为。如果你感兴趣,只需查看树中的第一个节点来获取细节"
},
"updateTutorialNode": {
"message": "v1.0.10中的新功能"
Expand Down
7 changes: 3 additions & 4 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ try {
await setIsNewUser(true);
}
if (
details.reason === 'update'
// &&
// details.previousVersion !== '1.0.10' &&
// browser.runtime.getManifest().version === '1.0.10'
details.reason === 'update' &&
details.previousVersion !== '1.0.10' &&
browser.runtime.getManifest().version === '1.0.10'
) {
// chrome.runtime.getManifest().version
await setIsUpdate(true);
Expand Down
26 changes: 16 additions & 10 deletions src/tree/features/tab-master-tree/nodes/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,31 @@ export const NodeUtils = {
},
convertToText(node: FancytreeNode, level = 0) {
const indent = ' '.repeat(level);
const { nodeType, url, pendingUrl } = node.data;
const { nodeType, url, pendingUrl, alias } = node.data;
let text = '';
text +=
nodeType === 'tab'
? `${indent}${node.title} (${url ?? pendingUrl})`
: `${indent}${node.title}`;
if (nodeType === 'tab') {
text += `${indent}${node.title} (${url ?? pendingUrl})`;
} else if (nodeType === 'note') {
text += `${indent}${alias}`;
} else {
text += `${indent}${node.title}`;
}
const childrenText: string = node.children
? node.children.map((child) => NodeUtils.convertToText(child, level + 1)).join('')
: '';
return `${text}\n${childrenText}`;
},
convertToMarkdown(node: FancytreeNode, level = 0) {
const indent = ' '.repeat(level);
const { nodeType, url, pendingUrl } = node.data;
const { nodeType, url, pendingUrl, alias } = node.data;
let text = '';
text +=
nodeType === 'tab'
? `${indent}- [${node.title}](${url ?? pendingUrl})`
: `${indent}- ${node.title}`;
if (nodeType === 'tab') {
text += `${indent}- [${node.title}](${url ?? pendingUrl})`;
} else if (nodeType === 'note') {
text += `${indent}- ${alias}`;
} else {
text += `${indent}- ${node.title}`;
}
const childrenText: string = node.children
? node.children.map((child) => NodeUtils.convertToMarkdown(child, level + 1)).join('')
: '';
Expand Down
39 changes: 37 additions & 2 deletions src/typings/jquery.fancytree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ declare namespace JQueryUI {
}

interface JQuery {
fancytree(options?: Fancytree.FancytreeOptions): Fancytree.Fancytree;
fancytree(options?: Fancytree.FancytreeOptions): JQuery;
fancytree(option?: string, ...rest: any[]): any;
}

declare namespace Fancytree {
import Widget = JQueryUI.Widget;
type EditTriggerCancelKeys = 'esc' | 'tab' | 'click';
type EditTriggerStartKey = 'f2' | 'mac+enter' | 'shift+click';
type EditEvent = { type: 'beforeClose' | 'beforeEdit' | 'close' | 'edit' | 'save' };
Expand Down Expand Up @@ -53,12 +54,14 @@ declare namespace Fancytree {

interface Fancytree {
$div: JQuery;
widget: any; //JQueryUI.Widget;
widget: Widget; //JQueryUI.Widget;
rootNode: FancytreeNode;
$container: JQuery;
focusNode: FancytreeNode;
options: FancytreeOptions;

new (widget: Widget): Fancytree;

/** Activate node with a given key and fire focus and
* activate events. A previously activated node will be
* deactivated. If activeVisible option is set, all parents
Expand Down Expand Up @@ -318,6 +321,8 @@ declare namespace Fancytree {
unselectableIgnore?: boolean | undefined;
unselectableStatus?: boolean | undefined;

new (parent: FancytreeNode, data: NodeData): FancytreeNode;

//#endregion

//#region Methods
Expand Down Expand Up @@ -1244,5 +1249,35 @@ declare namespace Fancytree {
unescapeHtml(s: string): string;

warn(msg: string): void;
/** Expose class object as `$.ui.fancytree._FancytreeClass`.
* Useful to extend `$.ui.fancytree._FancytreeClass.prototype`.
* @type {Fancytree}
*/
_FancytreeClass: Fancytree;
/** Expose class object as $.ui.fancytree._FancytreeNodeClass
* Useful to extend `$.ui.fancytree._FancytreeNodeClass.prototype`.
* @type {FancytreeNode}
*/
_FancytreeNodeClass: FancytreeNode;
/** Create a new Fancytree instance on a target element.
*
* @param {Element | jQueryObject | string} el Target DOM element or selector
* @param {FancytreeOptions} [opts] Fancytree options
* @returns {Fancytree} new tree instance
* @example
* var tree = $.ui.fancytree.createTree("#tree", {
* source: {url: "my/webservice"}
* }); // Create tree for this matching element
*
* @since 2.25
*/
createTree(el: Element | JQuery, opts: FancytreeOptions): Fancytree;
/** Return a function that executes *fn* at most every *timeout* ms.
* @param {integer} timeout
* @param {function} fn
* @param {boolean} [invokeAsap=false]
* @param {any} [ctx]
*/
debounce(timeout: number, fn: Function, invokeAsap?: boolean, ctx?: any): Function;
}
}

0 comments on commit c275525

Please sign in to comment.