diff --git a/README.md b/README.md index e504196..79cfbe6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # Draw.io VS Code Integration -[![](https://img.shields.io/static/v1?style=social&label=Sponsor&message=%E2%9D%A4&logo=GitHub&color&link=%3Curl%3E)](https://github.com/sponsors/hediet) -[![](https://img.shields.io/static/v1?style=social&label=Donate&message=%E2%9D%A4&logo=Paypal&color&link=%3Curl%3E)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZP5F38L4C88UY&source=url) [![](https://img.shields.io/twitter/follow/hediet_dev.svg?style=social)](https://twitter.com/intent/follow?screen_name=hediet_dev) This unofficial extension integrates [Draw.io](https://app.diagrams.net/) (also known as [diagrams.net](diagrams.net)) into VS Code. @@ -23,13 +21,6 @@ Mentioned in the official diagrams.net [blog](https://www.diagrams.net/blog/embe ![](./docs/demo.gif) -
-
- -# Like it so far? You might also like my [open source](https://github.com/hediet/chrome-ext-github-monaco) [Chrome extension that enhances the Github markdown editor](https://chrome.google.com/webstore/detail/monaco-markdown-editor-fo/mmpbdjdnmhgkpligeniippcgfmkgkpnf)! - -
-
## Editing .drawio.svg/.drawio.png Files diff --git a/drawio-custom-plugins/src/donationDialog.ts b/drawio-custom-plugins/src/donationDialog.ts deleted file mode 100644 index 6bb0d8c..0000000 --- a/drawio-custom-plugins/src/donationDialog.ts +++ /dev/null @@ -1,110 +0,0 @@ -import "./styles.css"; -import * as m from "mithril"; -import { sendEvent } from "./vscode"; - -Draw.loadPlugin((ui) => { - function showDialog() { - var div = document.createElement("div"); - div.style.height = "100%"; - m.render( - div, - m( - "sponsor-dialog.div", - { - style: { - fontFamily: "Segoe WPC,Segoe UI,sans-serif", - display: "flex", - flexDirection: "column", - height: "100%", - }, - }, - [ - m("h1", ["Thank You for Your Support!"]), - m( - "p", - "This unofficial extension that brings Draw.io to VS Code was made possible by awesome sponsors and generous donations - thank you so much for that!" - ), - m( - "p", - "If you like this extension and want to see more open source projects like this, please consider donating too, if you haven't already!" - ), - - m("p", "By the way: Did you know that you can...", [ - m("ul", {}, [ - m( - "li", - "convert your diagram to SVG so that it is an SVG file and draw.io diagram at the same time?" - ), - m( - "li", - "use liveshare to present or edit diagrams collaboratively?" - ), - m("li", "paste screenshots into a diagram?"), - m( - "li", - 'link a screenshot of a react component "MyComponent" with its source by naming the node "#MyComponent"?' - ), - ]), - ]), - m("div", { style: { flex: 1 } }), - m("div", { style: { textAlign: "right" } }, [ - m( - "button.geBtn", - { - onclick: () => { - ui.hideDialog(); - }, - }, - ["Thanks, but I don't want to donate (yet)"] - ), - m( - "button.geBtn.gePrimaryBtn", - { - onclick: () => { - ui.hideDialog(); - sendEvent({ - event: "invokeCommand", - command: "openDonationPage", - }); - }, - }, - ["I'd like to donate ❤️"] - ), - ]), - ] - ) - ); - - ui.showDialog(div, 650, 380, true, false); - } - - let loadAction: (() => void) | undefined; - let loaded = false; - window.addEventListener("message", (evt) => { - if (evt.source !== window.opener) { - return; - } - - const data = JSON.parse(evt.data) as - | CustomDrawioAction - | { action: "load" }; - if (data.action === "load") { - loaded = true; - if (loadAction) { - loadAction(); - } - } - - if (data.action === "askForDonations") { - if (loaded) { - showDialog(); - } else { - // only show dialog after load happened - loadAction = () => { - loadAction = undefined; - showDialog(); - }; - } - } - }); -}); diff --git a/drawio-custom-plugins/src/index.ts b/drawio-custom-plugins/src/index.ts index 2ca931a..26b4ca3 100644 --- a/drawio-custom-plugins/src/index.ts +++ b/drawio-custom-plugins/src/index.ts @@ -2,7 +2,6 @@ import "./linkSelectedNodeWithData"; import "./liveshare"; import "./focus"; import "./menu-entries"; -import "./donationDialog"; Draw.loadPlugin((ui) => { (window as any).hediet_DbgUi = ui; diff --git a/drawio-custom-plugins/src/styles.css b/drawio-custom-plugins/src/styles.css index e04948e..4c9a93e 100644 --- a/drawio-custom-plugins/src/styles.css +++ b/drawio-custom-plugins/src/styles.css @@ -1,7 +1,3 @@ -.sponsor-dialog { - line-height: 1.3; -} - li { padding: 3px 0; -} +} \ No newline at end of file diff --git a/drawio-custom-plugins/src/types.d.ts b/drawio-custom-plugins/src/types.d.ts index 84eaa82..53178cb 100644 --- a/drawio-custom-plugins/src/types.d.ts +++ b/drawio-custom-plugins/src/types.d.ts @@ -1,12 +1,12 @@ declare type CustomDrawioAction = UpdateVerticesAction | AddVerticesAction | GetVerticesAction - | LinkSelectedNodeWithDataAction | NodeSelectionEnabledAction | UpdateLiveshareViewState | { action: "askForDonations" }; + | LinkSelectedNodeWithDataAction | NodeSelectionEnabledAction | UpdateLiveshareViewState; declare type CustomDrawioEvent = NodeSelectedEvent | GetVerticesResultEvent | UpdateLocalStorage | PluginLoaded | CursorChangedEvent | SelectionChangedEvent | FocusChangedEvent | InvokeCommandEvent | SelectionRectangleChangedEvent; declare interface InvokeCommandEvent { event: "invokeCommand"; - command: "export" | "save" | "convert" | "openDonationPage"; + command: "export" | "save" | "convert"; } declare interface FocusChangedEvent { diff --git a/src/DrawioClient/CustomizedDrawioClient.ts b/src/DrawioClient/CustomizedDrawioClient.ts index 0bdaa0e..6a8e4ab 100644 --- a/src/DrawioClient/CustomizedDrawioClient.ts +++ b/src/DrawioClient/CustomizedDrawioClient.ts @@ -98,12 +98,6 @@ export class CustomizedDrawioClient extends DrawioClient< }); } - public askForDonations(): void { - this.sendCustomAction({ - action: "askForDonations", - }); - } - protected async handleEvent(evt: CustomDrawioEvent): Promise { if (evt.event === "nodeSelected") { this.onNodeSelectedEmitter.emit({ diff --git a/src/Extension.ts b/src/Extension.ts index 0ee2002..188f0bb 100644 --- a/src/Extension.ts +++ b/src/Extension.ts @@ -7,7 +7,6 @@ import { DrawioEditorService } from "./DrawioEditorService"; import { LinkCodeWithSelectedNodeService } from "./features/CodeLinkFeature"; import { EditDiagramAsTextFeature } from "./features/EditDiagramAsTextFeature"; import { LiveshareFeature } from "./features/LiveshareFeature"; -import { ActivityTracking } from "./features/ActivtyTracking"; import { DrawioClientFactory } from "./DrawioClient"; import { registerFailableCommand } from "./utils/registerFailableCommand"; @@ -36,9 +35,6 @@ export class Extension { private readonly liveshareFeature = this.dispose.track( new LiveshareFeature(this.editorService, this.config) ); - private readonly insiderFeedbackFeature = this.dispose.track( - new ActivityTracking(this.editorService, this.config) - ); constructor(private readonly context: vscode.ExtensionContext) { this.dispose.track( diff --git a/src/features/ActivtyTracking.ts b/src/features/ActivtyTracking.ts deleted file mode 100644 index e79ba60..0000000 --- a/src/features/ActivtyTracking.ts +++ /dev/null @@ -1,96 +0,0 @@ -import { Disposable } from "@hediet/std/disposable"; -import { startTimeout, EventTimer } from "@hediet/std/timer"; -import { env, Uri, window } from "vscode"; -import { Config } from "../Config"; -import { DrawioEditorService } from "../DrawioEditorService"; - -export class ActivityTracking { - public readonly dispose = Disposable.fn(); - - constructor( - editorManager: DrawioEditorService, - private readonly config: Config - ) { - const timer = new EventTimer(1000 * 10, "stopped"); - timer.onTick.one(() => { - config.addUsageTime10Seconds(); - this.showFeedbackIfApplicable(); - }); - - let timeout: Disposable | undefined = undefined; - function onActivity() { - if (timeout) { - timeout.dispose(); - } else { - timer.start(); - } - const msIn1Minute = 1000 * 60 * 1; - timeout = startTimeout(msIn1Minute, () => { - timeout = undefined; - timer.stop(); - }); - } - - this.dispose.track( - editorManager.onEditorOpened.sub(({ editor }) => { - editor.drawioClient.onInit.sub(() => { - if (config.canAskForSponsorship) { - config.markAskedForSponsorship(); - editor.drawioClient.onInvokeCommand.sub( - ({ command }) => { - if (command === "openDonationPage") { - env.openExternal( - Uri.parse( - "https://github.com/sponsors/hediet" - ) - ); - } - } - ); - editor.drawioClient.askForDonations(); - } - }); - - onActivity(); - editor.drawioClient.onCursorChanged.sub(() => { - onActivity(); - }); - editor.drawioClient.onFocusChanged.sub(({ hasFocus }) => { - if (hasFocus) { - onActivity(); - } - }); - }) - ); - } - - private async showFeedbackIfApplicable(): Promise { - const { feedbackUrl, canAskForFeedback } = this.config; - if (!canAskForFeedback || !feedbackUrl) { - return; - } - this.config.markAskedToTest(); - - const result = await window.showInformationMessage( - `With your feedback on GitHub, the Draw.io extension version ${ - this.config.packageJson.versionName || - this.config.packageJson.version - } can be released as stable soon!`, - { modal: false }, - { - title: `Give Feedback ❤️`, - action: () => { - env.openExternal(feedbackUrl); - }, - }, - { - title: "Skip For This Build", - action: () => {}, - } - ); - - if (result) { - result.action(); - } - } -} diff --git a/yarn.lock b/yarn.lock index 2d7aec3..1ed0f0e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -397,10 +397,10 @@ resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-7.5.2.tgz#5e2f1d120f07b9cda07e5dedd4f3bf8888fccdb9" integrity sha512-T+m89VdXj/eidZyejvmoP9jivXgBDdkOSBVQjU9kF349NEx10QdPNGxHeZUaj1IlJ32/ewdyXJjnJxyxJroYwg== -"@types/vscode@1.46.0": - version "1.46.0" - resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.46.0.tgz#53f2075986e901ed25cd1ec5f3ffa5db84a111b3" - integrity sha512-8m9wPEB2mcRqTWNKs9A9Eqs8DrQZt0qNFO8GkxBOnyW6xR//3s77SoMgb/nY1ctzACsZXwZj3YRTDsn4bAoaUw== +"@types/vscode@1.70.0": + version "1.70.0" + resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.70.0.tgz#9cb14cdaac9f450a7005ae2db49ecee4a084c983" + integrity sha512-3/9Fz0F2eBgwciazc94Ien+9u1elnjFg9YAhvAb3qDy/WeFWD9VrOPU7CIytryOVUdbxus8uzL4VZYONA0gDtA== "@types/xml-formatter@^1.1.0": version "1.2.0"