Repository: marktext/marktext
File: src/renderer/components/editorWithTabs/editor.vue (Vue)

Code before:
        const iconClass = f.type === 'directory' ? 'icon-folder' : 'icon-image'
        return Object.assign(f, { iconClass, text: f.file + (f.type === 'directory' ? '/' : '') })
      })
    },

    async imageAction (image, id, alt = '') {
      const {
        imageInsertAction,
        imageFolderPath,
        imagePreferRelativeDirectory,
        imageRelativeDirectoryName,
        preferences
      } = this
      const { pathname } = this.currentFile

      // Figure out the current working directory.
      let cwd = pathname ? path.dirname(pathname) : null
      if (pathname && this.projectTree) {
        const { pathname: rootPath } = this.projectTree
        if (rootPath && isChildOfDirectory(rootPath, pathname)) {
          // Save assets relative to root directory.
          cwd = rootPath
        }
      }

      resolvedImageFolderPath = imageFolderPath.replace(/\${filename}/g, this.pathname)
      let result = ''
      switch (imageInsertAction) {
        case 'upload': {
          try {
            result = await uploadImage(pathname, image, preferences)
          } catch (err) {
            notice.notify({
              title: 'Upload Image',
              type: 'info',
              message: err
            })
            result = await moveImageToFolder(pathname, image, resolvedImageFolderPath)
          }
          break
        }
        case 'folder': {
          result = await moveImageToFolder(pathname, image, resolvedImageFolderPath)
          if (cwd && imagePreferRelativeDirectory) {
            result = await moveToRelativeFolder(cwd, result, imageRelativeDirectoryName)
          }
          break
        }
        case 'path': {
          if (typeof image === 'string') {
            result = image

Review comment (suggestion):
```suggestion
      const resolvedImageFolderPath = imageFolderPath.replace(/\${filename}/g, this.pathname)
```

Code after:
        const iconClass = f.type === 'directory' ? 'icon-folder' : 'icon-image'
        return Object.assign(f, { iconClass, text: f.file + (f.type === 'directory' ? '/' : '') })
      })
    },

    async imageAction (image, id, alt = '') {
      const {
        imageInsertAction,
        imageFolderPath,
        imagePreferRelativeDirectory,
        imageRelativeDirectoryName,
        preferences
      } = this
      const { pathname } = this.currentFile

      // Figure out the current working directory.
      let cwd = pathname ? path.dirname(pathname) : null
      if (pathname && this.projectTree) {
        const { pathname: rootPath } = this.projectTree
        if (rootPath && isChildOfDirectory(rootPath, pathname)) {
          // Save assets relative to root directory.
          cwd = rootPath
        }
      }

      const resolvedImageFolderPath = imageFolderPath.replace(/\${filename}/g, this.pathname)
      let result = ''
      switch (imageInsertAction) {
        case 'upload': {
          try {
            result = await uploadImage(pathname, image, preferences)
          } catch (err) {
            notice.notify({
              title: 'Upload Image',
              type: 'info',
              message: err
            })
            result = await moveImageToFolder(pathname, image, resolvedImageFolderPath)
          }
          break
        }
        case 'folder': {
          result = await moveImageToFolder(pathname, image, resolvedImageFolderPath)
          if (cwd && imagePreferRelativeDirectory) {
            result = await moveToRelativeFolder(cwd, result, imageRelativeDirectoryName)
          }
          break
        }
        case 'path': {
          if (typeof image === 'string') {
            result = image