Open Janus-Xu opened 6 years ago
I want to use this plugin as gitbook-editor : all images in dir assets, just as below:
assets
open ImagePaste.py,change def get_filename(self) block
ImagePaste.py
def get_filename(self)
def get_filename(self): view = self.view filename = view.file_name() # create dir in current path with the name of current filename dirname, _ = os.path.splitext(filename) # create new image file under currentdir/filename_without_ext/filename_without_ext%d.png fn_without_ext = os.path.basename(dirname) gitbook_dir = os.path.split(dirname)[0]+'\\assets' if not os.path.lexists(gitbook_dir): os.mkdir(gitbook_dir) i = 0 while True: # relative file path rel_filename = os.path.join("%s/%s%d.png" % ("assets", fn_without_ext, i)) # absolute file path abs_filename = os.path.join(gitbook_dir, "%s%d.png" % ( fn_without_ext, i)) if not os.path.exists(abs_filename): break i += 1 print("save file: " + abs_filename + "\nrel " + rel_filename) return abs_filename, rel_filename
Thx
I want to use this plugin as gitbook-editor : all images in dir
assets
, just as below:open
ImagePaste.py
,changedef get_filename(self)
block