universal_table/app/views/universal_tables/mind_map.html.erb

64 lines
2.0 KiB
Plaintext
Executable File

<%
data = action_data
OrbitHelper.render_css_in_head(["mind_map/mindmap"])
%>
<h2><%= data["title"] %></h2>
<div id="jsmind_container"></div>
<script type="module">
import '/assets/mind_map/utils/custom.overrides.js'
import '/assets/mind_map/jsmind/plugins/jsmind.draggable-node.js'
import { initJsmind, getJsmindData } from '/assets/mind_map/utils/custom.main.js'
import { INITIAL_MIND } from '/assets/mind_map/utils/custom.config.js'
// 操控心智圖是否可編輯
// Control whether the mind map is editable
let isEditable = false
// 心智圖實例
// Mind map instance
let jm
// 心智圖初始數據
// Initial mind map data
let mind = {
meta: {},
format: 'node_array',
data: <%= raw data["mind_map_data"].to_json %>
}
// 心智圖自訂選項(可參考 jsmind 官方文檔)
// Custom options for the mind map (refer to the jsmind official documentation)
const options = {
container: 'jsmind_container',
support_html: true,
editable: isEditable,
theme: 'primary',
mode: 'full',
tableUID: '',
text: {
addNode: "<%= t("universal_table.add_node") %>",
deleteNode: "<%= t("universal_table.delete_node") %>",
strokeColor: "<%= t("universal_table.stroke_color") %>",
bgColor: "<%= t("universal_table.bg_color") %>",
textColor: "<%= t("universal_table.text_color") %>"
},
view: {
engine: 'svg',
draggable: true,
node_overflow: 'wrap',
},
shortcut: {
mapping: {
// 避免與 Toolbar 按下 Enter 事件衝突
// Avoid conflicts with the Enter key event in the Toolbar
addbrother: 2048 + 13,
},
},
}
// 初始化心智圖並掛載實例
// Initialize the mind map and attach the instance
jm = initJsmind(mind, options, isEditable)
</script>