1 /* 2 * PanmirrorUIContext.java 3 * 4 * Copyright (C) 2021 by RStudio, PBC 5 * 6 * Unless you have received this program directly from RStudio pursuant 7 * to the terms of a commercial license agreement with RStudio, then 8 * this program is licensed to you under the terms of version 3 of the 9 * GNU Affero General Public License. This program is distributed WITHOUT 10 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT, 11 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the 12 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details. 13 * 14 */ 15 16 package org.rstudio.studio.client.panmirror.ui; 17 18 19 import org.rstudio.core.client.jsinterop.JsVoidFunction; 20 21 import com.google.gwt.core.client.JsArrayString; 22 23 import elemental2.promise.Promise; 24 import jsinterop.annotations.JsFunction; 25 import jsinterop.annotations.JsType; 26 27 @JsType 28 public class PanmirrorUIContext 29 { 30 public BooleanGetter isActiveTab; 31 public StringGetter getDocumentPath; 32 public WithSavedDocument withSavedDocument; 33 public StringGetter getDefaultResourceDir; 34 public Mapper mapPathToResource; 35 public Mapper mapResourceToURL; 36 public WatchResource watchResource; 37 public Mapper translateText; 38 public StringArrayGetter droppedUris; 39 public ClipboardUris clipboardUris; 40 public ClipboardImage clipboardImage; 41 public ResolveImageUris resolveImageUris; 42 public BooleanGetter isWindowsDesktop; 43 44 @JsFunction 45 public interface StringGetter 46 { get()47 String get(); 48 } 49 50 @JsFunction 51 public interface BooleanGetter 52 { get()53 Boolean get(); 54 } 55 56 @JsFunction 57 public interface StringArrayGetter 58 { get()59 JsArrayString get(); 60 } 61 62 @JsFunction 63 public interface Mapper 64 { map(String path)65 String map(String path); 66 } 67 68 @JsFunction 69 public interface WatchResource 70 { watchResource(String path, JsVoidFunction notify)71 JsVoidFunction watchResource(String path, JsVoidFunction notify); 72 } 73 74 @JsFunction 75 public interface WithSavedDocument 76 { withSavedDocument()77 Promise<Boolean> withSavedDocument(); 78 } 79 80 @JsFunction 81 public interface ClipboardUris 82 { clipboardUris()83 Promise<JsArrayString> clipboardUris(); 84 } 85 86 @JsFunction 87 public interface ClipboardImage 88 { clipboardImage()89 Promise<String> clipboardImage(); 90 } 91 92 @JsFunction 93 public interface ResolveImageUris 94 { resolveImageUris(JsArrayString imageUris)95 Promise<JsArrayString> resolveImageUris(JsArrayString imageUris); 96 } 97 } 98 99 100