name: editor
requiredPermissions:
  - fetch
config:
  schema.config.properties:
    shortcuts:
      type: array
      items:
        type: object
        properties:
          command:
            type: string
          key:
            type: string
            nullable: true
          mac:
            type: string
            nullable: true
          slashCommand:
            type: string
            nullable: true
          priority:
            type: number
            nullable: true
        required:
          - command
      nullable: true
    useSmartQuotes:
      type: boolean
      nullable: true
    pwaOpenLastPage:
      type: boolean
      nullable: true
    hideEditButton:
      type: boolean
      nullable: true
    hideSyncButton:
      type: boolean
      nullable: true
    actionButtons:
      type: array
      items:
        type: object
        properties:
          icon:
            type: string
          description:
            type: string
            nullable: true
          command:
            type: string
          args:
            type: array
            items:
              type: object
            nullable: true
          mobile:
            type: boolean
            nullable: true
        required:
          - icon
          - command
    defaultLinkStyle:
      type: string
      nullable: true
functions:
  setEditorMode:
    path: "./editor.ts:setEditorMode"
    events:
      - editor:init
  toggleDarkMode:
    path: "./editor.ts:toggleDarkMode"
    command:
      name: "Editor: Toggle Dark Mode"

  openCommandPalette:
    path: editor.ts:openCommandPalette
    command:
      name: "Open Command Palette"
      key: "Ctrl-/"
      mac: "Cmd-/"

  openPageNavigator:
    path: editor.ts:openPageNavigator
    command:
      name: "Navigate: Page Picker"
      key: "Ctrl-k"
      mac: "Cmd-k"

  openMetaNavigator:
    path: editor.ts:openMetaNavigator
    command:
      name: "Navigate: Meta Picker"
      key: "Ctrl-Shift-k"
      mac: "Cmd-Shift-k"

  openAllNavigator:
    path: editor.ts:openAllNavigator
    command:
      name: "Navigate: All Pages Picker"

  # Page operations
  deletePage:
    path: "./page.ts:deletePage"
    command:
      name: "Page: Delete"
      requireMode: rw
  copyPage:
    path: "./page.ts:copyPage"
    command:
      name: "Page: Copy"
      requireMode: rw

  # Completion
  pageComplete:
    path: "./complete.ts:pageComplete"
    events:
      - editor:complete
  commandComplete:
    path: "./command.ts:commandComplete"
    events:
      - editor:complete

  reloadSystem:
    path: editor.ts:reloadSystem
    command:
      name: "System: Reload"
      key: Ctrl-Alt-r

  # Navigation
  linkNavigate:
    path: "./navigate.ts:linkNavigate"
    command:
      name: "Navigate: To This Page"
      key: Ctrl-Enter
      mac: Cmd-Enter
  clickNavigate:
    path: "./navigate.ts:clickNavigate"
    events:
      - page:click
  navigateHome:
    path: "./navigate.ts:navigateCommand"
    command:
      name: "Navigate: Home"
      key: "Alt-h"
      page: ""
  navigateToSettings:
    path: "./navigate.ts:navigateCommand"
    command:
      name: "Navigate: Open SETTINGS"
      key: "Ctrl-,"
      mac: "Cmd-,"
      page: "SETTINGS"
  moveToPos:
    path: "./editor.ts:moveToPosCommand"
    command:
      name: "Navigate: To Position"
  moveToLine:
    path: "./editor.ts:moveToLineCommand"
    command:
      name: "Navigate: To Line"
  navigateToPage:
    path: "./navigate.ts:navigateToPage"
    command:
      name: "Navigate: To Page"
      hide: true
  navigateToURL:
    path: "./navigate.ts:navigateToURL"
    command:
      name: "Navigate: To URL"
      hide: true
  navigateBack:
    path: "./navigate.ts:navigateBack"
    command:
      name: "Navigate: Back in History"
  navigateForward:
    path: "./navigate.ts:navigateForward"
    command:
      name: "Navigate: Forward in History"

  # Text editing commands
  quoteSelectionCommand:
    path: ./text.ts:quoteSelection
    command:
      name: "Text: Quote Selection"
      key: "Ctrl-Shift-."
      mac: "Cmd-Shift-."
      requireMode: rw
  listifySelection:
    path: ./text.ts:listifySelection
    command:
      name: "Text: Listify Selection"
      key: "Ctrl-Shift-8"
      mac: "Cmd-Shift-8"
      requireMode: rw
  numberListifySelection:
    path: ./text.ts:numberListifySelection
    command:
      name: "Text: Number Listify Selection"
      requireMode: rw
  linkSelection:
    path: ./text.ts:linkSelection
    command:
      name: "Text: Link Selection"
      requireMode: rw
  bold:
    path: ./text.ts:wrapSelection
    command:
      name: "Text: Bold"
      key: "Ctrl-b"
      mac: "Cmd-b"
      wrapper: "**"
      requireMode: rw
  italic:
    path: ./text.ts:wrapSelection
    command:
      name: "Text: Italic"
      key: "Ctrl-i"
      mac: "Cmd-i"
      wrapper: "_"
      requireMode: rw
  strikethrough:
    path: ./text.ts:wrapSelection
    command:
      name: "Text: Strikethrough"
      key: "Ctrl-Shift-s"
      wrapper: "~~"
      requireMode: rw
  marker:
    path: ./text.ts:wrapSelection
    command:
      name: "Text: Marker"
      key: "Alt-m"
      wrapper: "=="
      requireMode: rw
  centerCursor:
    path: "./editor.ts:centerCursorCommand"
    command:
      name: "Navigate: Center Cursor"
      key: "Ctrl-Alt-l"
      requireMode: rw
  deleteLine:
    path: "./editor.ts:deleteLineCommand"
    command:
      name: "Delete Line"
      key: "Ctrl-d"
      requireMode: rw

  # Debug commands
  parseCommand:
    path: ./debug.ts:parsePageCommand
    command:
      name: "Debug: Parse Document"

  # Link unfurl infrastructure
  unfurlLink:
    path: ./link.ts:unfurlCommand
    command:
      name: "Link: Unfurl"
      key: "Ctrl-Shift-u"
      mac: "Cmd-Shift-u"
      requireMode: rw

  # Title-based link unfurl
  titleUnfurlOptions:
    path: ./link.ts:titleUnfurlOptions
    events:
      - unfurl:options

  titleUnfurl:
    path: ./link.ts:titleUnfurl
    events:
      - unfurl:title-unfurl

  # Title-based link unfurl
  youtubeUnfurlOptions:
    path: ./link.ts:youtubeUnfurlOptions
    events:
      - unfurl:options

  youtubeUnfurl:
    path: ./link.ts:youtubeUnfurl
    events:
      - unfurl:youtube-unfurl

  embedWidget:
    path: ./embed.ts:embedWidget
    codeWidget: embed

  # Vim
  toggleVimMode:
    path: "./vim.ts:toggleVimMode"
    command:
      name: "Editor: Toggle Vim Mode"
  loadVimRc:
    path: "./vim.ts:loadVimRc"
    command:
      name: "Editor: Vim: Load VIMRC"
    events:
      - editor:modeswitch

  # Random stuff
  statsCommand:
    path: ./stats.ts:statsCommand
    command:
      name: "Stats: Show"
  reloadUICommand:
    path: ./debug.ts:reloadUICommand
    command:
      name: "Debug: Reload UI"

  resetClientCommand:
    path: ./debug.ts:resetClientCommand
    command:
      name: "Debug: Reset Client"

  versionCommand:
    path: ./help.ts:versionCommand
    command:
      name: "Help: Version"
  gettingStartedCommand:
    path: ./help.ts:gettingStartedCommand
    command:
      name: "Help: Getting Started"

  accountLogoutCommand:
    path: clean.ts:cleanCommand
    command:
      name: "Clear Local Storage & Logout"

  uploadFileCommand:
    path: ./upload.ts:uploadFile
    command:
      name: "Upload: File"
      requireMode: rw

  # Outline commands
  outlineMoveUp:
    path: ./outline.ts:moveItemUp
    command:
      name: "Outline: Move Up"
      key: "Alt-ArrowUp"
      requireMode: rw

  outlineMoveDown:
    path: ./outline.ts:moveItemDown
    command:
      name: "Outline: Move Down"
      key: "Alt-ArrowDown"
      requireMode: rw

  outlineIndent:
    path: ./outline.ts:indentItem
    command:
      name: "Outline: Move Right"
      key: "Alt->"
      requireMode: rw

  outlineOutdent:
    path: ./outline.ts:outdentItem
    command:
      name: "Outline: Move Left"
      key: "Alt-<"
      requireMode: rw

  # Outline folding commands
  foldCommand:
    path: ./outline.ts:foldCommand
    command:
      name: "Outline: Fold"
      key: "Ctrl-Alt-["
  unfoldCommand:
    path: ./outline.ts:unfoldCommand
    command:
      name: "Outline: Unfold"
      key: "Ctrl-Alt-]"
  toggleFoldCommand:
    path: ./outline.ts:toggleFoldCommand
    command:
      name: "Outline: Toggle Fold"
      key: "Alt-Shift-f"
  foldAllCommand:
    path: ./outline.ts:foldAllCommand
    command:
      name: "Outline: Fold All"
      key: "Ctrl-Alt-Shift-["
  unfoldAllCommand:
    path: ./outline.ts:unfoldAllCommand
    command:
      name: "Outline: Unfold All"
      key: "Ctrl-Alt-Shift-]"
  findInPageCommand:
    path: editor.ts:findInPageCommand
    command:
      name: "Editor: Find in Page"
      key: "Ctrl-f"
      mac: "Cmd-f"

  # Outline helper functions
  determineItemBounds:
    path: ./outline.ts:determineItemBounds
  ensureNewLine:
    path: ./outline.ts:ensureNewLine

  # Undo/redo
  undoCommand:
    path: ./editor.ts:undoCommand
    command:
      name: "Editor: Undo"
      key: "Ctrl-z"
      mac: "Cmd-z"
      requireMode: rw
  redoCommand:
    path: ./editor.ts:redoCommand
    command:
      name: "Editor: Redo"
      key: "Ctrl-y"
      mac: "Cmd-Shift-z"
      requireMode: rw

  # Demo
  customFlashMessage:
    path: editor.ts:customFlashMessage
    command:
      name: "Flash: Custom Message"
      hide: true
      contexts:
        - internal