mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	remove debug helper with uniqueId
This commit is contained in:
		
							parent
							
								
									06e0f2418c
								
							
						
					
					
						commit
						92adcf82e4
					
				@ -1,33 +0,0 @@
 | 
				
			|||||||
/** Used to generate unique IDs. */
 | 
					 | 
				
			||||||
const idCounter = {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Generates a unique ID. If `prefix` is given, the ID is appended to it.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * @since 0.1.0
 | 
					 | 
				
			||||||
 * @category Util
 | 
					 | 
				
			||||||
 * @param {string} [prefix=''] The value to prefix the ID with.
 | 
					 | 
				
			||||||
 * @returns {string} Returns the unique ID.
 | 
					 | 
				
			||||||
 * @see random
 | 
					 | 
				
			||||||
 * @example
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * uniqueId('contact_')
 | 
					 | 
				
			||||||
 * // => 'contact_104'
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * uniqueId()
 | 
					 | 
				
			||||||
 * // => '105'
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
function uniqueId(prefix='$lodash$') {
 | 
					 | 
				
			||||||
  if (!idCounter[prefix]) {
 | 
					 | 
				
			||||||
    idCounter[prefix] = 0
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const id =++idCounter[prefix]
 | 
					 | 
				
			||||||
  if (prefix === '$lodash$') {
 | 
					 | 
				
			||||||
    return `${id}`
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  return `${prefix}${id}`
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export default uniqueId
 | 
					 | 
				
			||||||
@ -3,7 +3,6 @@ import TypeWidget from "./type_widget.js";
 | 
				
			|||||||
import utils from '../../services/utils.js';
 | 
					import utils from '../../services/utils.js';
 | 
				
			||||||
import froca from "../../services/froca.js";
 | 
					import froca from "../../services/froca.js";
 | 
				
			||||||
import debounce from "./canvas-note-utils/lodash.debounce.js";
 | 
					import debounce from "./canvas-note-utils/lodash.debounce.js";
 | 
				
			||||||
import uniqueId from "./canvas-note-utils/lodash.uniqueId.js";
 | 
					 | 
				
			||||||
import replaceExternalAssets from "./canvas-note-utils/replaceExternalAssets.js";
 | 
					import replaceExternalAssets from "./canvas-note-utils/replaceExternalAssets.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {sleep} = utils;
 | 
					const {sleep} = utils;
 | 
				
			||||||
@ -60,18 +59,18 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
 | 
				
			|||||||
    constructor() {
 | 
					    constructor() {
 | 
				
			||||||
        super();
 | 
					        super();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // CONSTANTS
 | 
					        // constants
 | 
				
			||||||
        this.SCENE_VERSION_INITIAL = -1;
 | 
					        this.SCENE_VERSION_INITIAL = -1;
 | 
				
			||||||
        this.SCENE_VERSION_ERROR = -2;
 | 
					        this.SCENE_VERSION_ERROR = -2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // config
 | 
					        // config
 | 
				
			||||||
        this.debounceTimeOnchangeHandler = 750; // ms
 | 
					        this.DEBOUNCE_TIME_ONCHANGEHANDLER = 750; // ms
 | 
				
			||||||
        // ensure that assets are loaded from trilium
 | 
					        // ensure that assets are loaded from trilium
 | 
				
			||||||
        window.EXCALIDRAW_ASSET_PATH = `${window.location.origin}/node_modules/@excalidraw/excalidraw/dist/`;
 | 
					        window.EXCALIDRAW_ASSET_PATH = `${window.location.origin}/node_modules/@excalidraw/excalidraw/dist/`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // temporary vars
 | 
					        // temporary vars
 | 
				
			||||||
        this.currentNoteId = "";
 | 
					        this.currentNoteId = "";
 | 
				
			||||||
        this.currentSceneVersion = SCENE_VERSION_INITIAL;
 | 
					        this.currentSceneVersion = this.SCENE_VERSION_INITIAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // will be overwritten
 | 
					        // will be overwritten
 | 
				
			||||||
        this.excalidrawRef;
 | 
					        this.excalidrawRef;
 | 
				
			||||||
@ -89,15 +88,6 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
 | 
				
			|||||||
        this.isNewSceneVersion = this.isNewSceneVersion.bind(this);
 | 
					        this.isNewSceneVersion = this.isNewSceneVersion.bind(this);
 | 
				
			||||||
        this.updateSceneVersion = this.updateSceneVersion.bind(this);
 | 
					        this.updateSceneVersion = this.updateSceneVersion.bind(this);
 | 
				
			||||||
        this.getSceneVersion = this.getSceneVersion.bind(this);
 | 
					        this.getSceneVersion = this.getSceneVersion.bind(this);
 | 
				
			||||||
 | 
					 | 
				
			||||||
        // debugging helper - delete this block or comment
 | 
					 | 
				
			||||||
        this.uniqueId = uniqueId();
 | 
					 | 
				
			||||||
        console.log("uniqueId", this.uniqueId);
 | 
					 | 
				
			||||||
        if (!window.triliumexcalidraw) {
 | 
					 | 
				
			||||||
            window.triliumexcalidraw = [];
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        window.triliumexcalidraw[this.uniqueId] = this;
 | 
					 | 
				
			||||||
        // end debug
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -401,7 +391,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
 | 
				
			|||||||
                    onPaste: (data, event) => {
 | 
					                    onPaste: (data, event) => {
 | 
				
			||||||
                        this.log("excalidraw internal paste", data, event);
 | 
					                        this.log("excalidraw internal paste", data, event);
 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                    onChange: debounce(this.onChangeHandler, this.debounceTimeOnchangeHandler),
 | 
					                    onChange: debounce(this.onChangeHandler, this.DEBOUNCE_TIME_ONCHANGEHANDLER),
 | 
				
			||||||
                    // onPointerUpdate: (payload) => console.log(payload),
 | 
					                    // onPointerUpdate: (payload) => console.log(payload),
 | 
				
			||||||
                    onCollabButtonClick: () => {
 | 
					                    onCollabButtonClick: () => {
 | 
				
			||||||
                        window.alert("You clicked on collab button")
 | 
					                        window.alert("You clicked on collab button")
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user