Browse Source

Copy html link context menu option

CrazyDoctor 4 months ago
parent
commit
05ee69a7a4
2 changed files with 14 additions and 0 deletions
  1. 4 0
      static/CDClientLib/CDClientLib.js
  2. 10 0
      static/page/class/script.js

+ 4 - 0
static/CDClientLib/CDClientLib.js

@@ -313,6 +313,10 @@ class Url {
 		location.reload();
 		location.reload();
 	}
 	}
 
 
+	static getPath() {
+		return new Url().getPath();
+	}
+
 	static getFullPath() {
 	static getFullPath() {
 		const url = new Url().url;
 		const url = new Url().url;
 		return `${url.origin}${url.pathname}`;
 		return `${url.origin}${url.pathname}`;

+ 10 - 0
static/page/class/script.js

@@ -1156,6 +1156,16 @@ class ClassPage {
 			this.createContextMenuItem('CopyLink', 'Copy link', () => {
 			this.createContextMenuItem('CopyLink', 'Copy link', () => {
 				DOM.copyToClipboard(`${Url.getFullPath()}#${propertyItemType === 'method' ? 'Methods' : 'Properties'}:${propertyItemName}`);
 				DOM.copyToClipboard(`${Url.getFullPath()}#${propertyItemType === 'method' ? 'Methods' : 'Properties'}:${propertyItemName}`);
 			});
 			});
+			this.createContextMenuDelimiter();
+			this.createContextMenuItem('CopyHtmlLink', 'Copy HTML link', () => {
+				let linkText = propertyItemName;
+				if(propertyItemName.startsWith(ClassPage.__static__))
+						linkText = `${Class[ClassPage.ClassProperties.ShortName] || Class[ClassPage.ClassProperties.Name]}.${propertyItemName.replace(ClassPage.__static__, '')}`;
+				if(propertyItemType === 'method')
+						linkText = `${linkText}()`;
+				console.log(propertyItemName, propertyItemName.startsWith(ClassPage.__static__), `${Class[ClassPage.ClassProperties.ShortName] || Class[ClassPage.ClassProperties.Name]}.${propertyItemName.replace(ClassPage.__static__, '')}`, linkText);
+				DOM.copyToClipboard(`<a href="${Url.getPath()}#${propertyItemType === 'method' ? 'Methods' : 'Properties'}:${propertyItemName}">${linkText}</a>`);
+			});
 			break;
 			break;
 		}
 		}