SD yho
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    #### Node 節點方塊 * 節點方塊物件資料須帶有uuid和x,y 位置(提供套件svg繪圖用) ``` const elements = ref([ { id: '1', position: { x: 50, y: 50 }, label: 'Node 1', } ]); ``` * 節點新增可使用套件提供的addNodes()方法產生,像是自動化劇本在拖拉和判斷才產生畫面上節點 ``` const { addNodes } = useVueFlow() function generateRandomNode() { return { id: Math.random().toString(), position: { x: Math.random() * 500, y: Math.random() * 500 }, label: 'Random Node', } } function onAddNode() { // add a single node to the graph addNodes(generateRandomNode()) } ``` * 節點移除可以直接對原始node資料進行pop()等方法移除,或者使用特套件提供的removeNodes方法,利用node uuid進行移除 ``` function onRemoveNodes() { removeNodes(['1', '2']) } ``` #### 節點更新和options設置 https://vueflow.dev/guide/node.html#updating-node-data 設定節點可不可以拖拉或固定,每一個節點都有設定options參數 ``` elements.value.forEach((node) => { node.selectable = false node.draggable = false }) ``` #### 連接節點類型 type有default、input和output 3種,可以限制上下連結點 ``` import { ref } from 'vue' import { Position } from '@vue-flow/core' const nodes = ref([ { id: '1', label: 'Default Node', type: 'default', // You can omit this as it's the fallback type targetPosition: Position.Top, // or Bottom, Left, Right, sourcePosition: Position.Bottom, // or Top, Left, Right, } ]) ``` #### User定義客製化custom node樣式(slot template) https://vueflow.dev/examples/nodes/ slot 插槽名稱會以#node-xxxx 對應到node物件資料中的type名稱。 ``` const nodes = ref([ { id: '1', type: 'color-selector', data: { color: presets.ayame }, position: { x: 0, y: 50 }, }, { id: '2', type: 'output', position: { x: 350, y: 114 }, targetPosition: Position.Left, }, ]) <template> <VueFlow v-model:nodes="nodes" :edges="edges" class="custom-node-flow" :class="[colorSelectorData?.isGradient ? 'animated-bg-gradient' : '']" :style="{ backgroundColor: colorSelectorData?.color }" :default-viewport="{ zoom: 1.5 }" fit-view-on-init > <template #node-color-selector="{ id }"> <ColorSelectorNode :id="id" /> </template> <template #node-output> <OutputNode /> </template> <MiniMap :node-stroke-color="nodeStroke" :node-color="nodeColor" /> </VueFlow> </template> ``` https://vueflow.dev/guide/node.html#user-defined-nodes https://vueflow.dev/examples/nodes/ 調色盤案例 自訂節點槽內容- ex自動化據本是icon+文字 * 在調色盤案例中,有許多顏色的小調色icon,使用者點擊時會更換背景色,關鍵點在於點擊後呼叫原始useFlow方法,能去更動整個node物件資料,帶動外層父元件背景色資料替換。 * 去觀察ColorSelectorNode.vue檔案,利用useFlow去連接VueFlow組件的資料更新 ``` const { updateNodeData } = useVueFlow() // flow update到全局物件 function onSelect(color) { updateNodeData(props.id, { color, isGradient: false }) } // 按到時呼叫 ``` #### Node 事件 https://vueflow.dev/guide/node.html#node-events 有時候需要針對使用者正在拖拉、放進去的動作進行節點判斷等邏輯,就需要用vue flow event事件去定義。 ``` import { ref } from 'vue' import { VueFlow, useVueFlow } from '@vue-flow/core' // useVueFlow provides access to the event handlers const { onNodeDragStart, onNodeDrag, onNodeDragStop, onNodeClick, onNodeDoubleClick, onNodeContextMenu, onNodeMouseEnter, onNodeMouseLeave, onNodeMouseMove } = useVueFlow() const elements = ref([ { id: '1', label: 'Node 1', position: { x: 50, y: 50 }, }, ]) // bind listeners to the event handlers onNodeDragStart((event) => { console.log('Node drag started', event) }) onNodeDrag((event) => { console.log('Node dragged', event) }) onNodeDragStop((event) => { console.log('Node drag stopped', event) }) ``` https://vueflow.dev/guide/composables.html #### controlled flow 節點驗證 https://vueflow.dev/guide/controlled-flow.html#onnodeschange-onedgeschange-events * 當節點或連接線資料有異動時,也有對應監聽事件onNodeChange、onEdgeChange,也可以將資料驗證邏輯寫在這 #### 連接線(Edge) 連接線又名邊緣,是連結節點進而形成flow chart圖表。 https://vueflow.dev/guide/edge.html#adding-edges-to-the-graph * 基礎添加連接線可以直接在原始節點node物件,增加source/target資料形成連結接線 * 使用 addEdges方法 進行新增 * 使用 reomveEdge方法 進行連接線刪除 * **連接線uuid建議使用 e1-2 以e為開頭和一般節點區分開** ``` const { addEdges } = useVueFlow() onMounted(() => { // add an edge after mount addEdges([ { source: '1', target: '2', // if a node has multiple handles of the same type, // you should specify which handle to use by id sourceHandle: null, targetHandle: null, } ]) }) ``` #### 連接線類型(直線、階梯線、平滑等) https://vueflow.dev/guide/edge.html#predefined-edge-types edges type資料形態中設定 ``` export const edges = ref([ { id: 'e1-2', source: '1', target: '2', // this will create the edge-type `custom` type: 'custom', }, { id: 'e1-3', source: '1', target: '3', // this will create the edge-type `special` type: 'special', } ]) ``` #### 將外部node樣板拖拉進入vue flow流程圖 https://vueflow.dev/examples/dnd.html * 需要自己製作一個拖拉功能 useDragAndDrop() ``` const state = { /** * The type of the node being dragged. */ draggedType: ref(null), // 辦別拖拉元件類別 isDragOver: ref(false), // 拖拉完成 isDragging: ref(false), // 正在拖拉 } // 引入useVueFlow拖拉事件 const { addNodes, screenToFlowCoordinate, onNodesInitialized, updateNode } = useVueFlow() // 監聽使用者是否再拖拉 會傳入拖拉元素本身的DOM watch(isDragging, (dragging) => { // 設定拖拉時BODY元素不能選取 document.body.style.userSelect = dragging ? 'none' : '' }) // 用原生JS將選取元素掛上drag Event function onDragStart(event, type) { if (event.dataTransfer) { event.dataTransfer.setData('application/vueflow', type) event.dataTransfer.effectAllowed = 'move' } draggedType.value = type isDragging.value = true document.addEventListener('drop', onDragEnd) } ``` *

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully