bridgerte 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -6
- package/dist/bridge.d.ts +10 -3
- package/dist/core.d.ts +10 -3
- package/dist/dom.cjs +1 -1
- package/dist/dom.d.ts +20 -3
- package/dist/dom.js +2 -2
- package/dist/index-BaOlPu8L.cjs +4 -0
- package/dist/index-BaOlPu8L.cjs.map +1 -0
- package/dist/{index-BQAzp56J.js → index-BwZ0II4h.js} +1577 -1426
- package/dist/index-BwZ0II4h.js.map +1 -0
- package/dist/index-bN5Hs6-3.js +299 -0
- package/dist/index-bN5Hs6-3.js.map +1 -0
- package/dist/index-hd9Zi2DV.cjs +36 -0
- package/dist/index-hd9Zi2DV.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +20 -3
- package/dist/index.js +2 -2
- package/dist/native-spec.cjs +1 -1
- package/dist/native-spec.cjs.map +1 -1
- package/dist/native-spec.d.ts +10 -3
- package/dist/native-spec.js +50 -42
- package/dist/native-spec.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/webview.cjs +1 -1
- package/dist/webview.d.ts +10 -3
- package/dist/webview.js +1 -1
- package/package.json +2 -1
- package/dist/index-BQAzp56J.js.map +0 -1
- package/dist/index-Bui5UnkQ.cjs +0 -3
- package/dist/index-Bui5UnkQ.cjs.map +0 -1
- package/dist/index-CeYJbOQi.js +0 -137
- package/dist/index-CeYJbOQi.js.map +0 -1
- package/dist/index-DAlyGWXO.cjs +0 -2
- package/dist/index-DAlyGWXO.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { B as o, a as t, b as r } from "./index-CuNKUHed.js";
|
|
2
2
|
import { BRIDGE_CONTENT_CHANGE_DEBOUNCE_MS as m, BRIDGE_HEIGHT_CHANGE_THROTTLE_MS as T, defaultBridgeEventTiming as l, isBridgeMessage as n } from "./bridge.js";
|
|
3
3
|
import { codeBlockLanguagePanel as _, codeBlockLanguagePayloadPanel as s, createDisabledCommandStates as c, defaultMenuSchema as i, defaultToolbarConfig as R, getCommandStateMatchValue as B, isCommandStateForCommand as S, isMenuItemCommandState as g, resolveToolbarMenu as C, tableHeaderMenuItems as u } from "./native-spec.js";
|
|
4
|
-
import { c as f, a as M, b as N } from "./index-
|
|
5
|
-
import { c as x } from "./index-
|
|
4
|
+
import { c as f, a as M, b as N } from "./index-BwZ0II4h.js";
|
|
5
|
+
import { c as x } from "./index-bN5Hs6-3.js";
|
|
6
6
|
import { resolvePayloadPanelSchema as D } from "./core.js";
|
|
7
7
|
export {
|
|
8
8
|
o as BRIDGERTE_CONTENT_VERSION,
|
package/dist/native-spec.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./index-GaS65GL0.cjs"),g={id:"code-block-language",title:"代码语言",fields:[{type:"select",name:"language",label:"语言",defaultValue:"",options:[{label:"纯文本",value:""},{label:"
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./index-GaS65GL0.cjs"),g={id:"code-block-language",title:"代码语言",fields:[{type:"select",name:"language",label:"语言",defaultValue:"",options:[{label:"纯文本",value:""},{label:"Bash",value:"shellscript"},{label:"C",value:"c"},{label:"C++",value:"cpp"},{label:"C#",value:"csharp"},{label:"CSS",value:"css"},{label:"Dart",value:"dart"},{label:"Dockerfile",value:"docker"},{label:"Go",value:"go"},{label:"HTML",value:"html"},{label:"Java",value:"java"},{label:"JavaScript",value:"javascript"},{label:"JSON",value:"json"},{label:"Kotlin",value:"kotlin"},{label:"Markdown",value:"markdown"},{label:"PHP",value:"php"},{label:"Python",value:"python"},{label:"Rust",value:"rust"},{label:"SQL",value:"sql"},{label:"Swift",value:"swift"},{label:"TOML",value:"toml"},{label:"TSX",value:"tsx"},{label:"TypeScript",value:"typescript"},{label:"Vue",value:"vue"},{label:"XML",value:"xml"},{label:"YAML",value:"yaml"}]}]},k=g,x={id:"text-color",title:"文字颜色",fields:[{type:"color",name:"value",label:"颜色"}]},P={id:"background-color",title:"背景色",fields:[{type:"color",name:"value",label:"背景"}]},S={id:"font-size",title:"字号",fields:[{type:"select",name:"value",label:"字号",defaultValue:"16px",options:[{label:"小号 14px",value:"14px"},{label:"正文 16px",value:"16px"},{label:"强调 18px",value:"18px"},{label:"标题 20px",value:"20px"},{label:"大标题 24px",value:"24px"}]}]},M={id:"font-family",title:"字体",fields:[{type:"select",name:"value",label:"字体",defaultValue:"",options:[{label:"跟随页面",value:""},{label:"无衬线",value:"sans-serif"},{label:"衬线",value:"serif"},{label:"等宽",value:"monospace"}]}]},T={id:"line-height",title:"行高",fields:[{type:"select",name:"value",label:"行高",defaultValue:"1.7",options:[{label:"紧凑 1.4",value:"1.4"},{label:"常规 1.7",value:"1.7"},{label:"舒展 2",value:"2"}]}]},w={id:"table-insert",title:"插入表格",fields:[{type:"number",name:"rows",label:"行数",defaultValue:"3",min:1,max:b.BRIDGERTE_TABLE_INSERT_MAX_ROWS,step:1},{type:"number",name:"cols",label:"列数",defaultValue:"3",min:1,max:b.BRIDGERTE_TABLE_INSERT_MAX_COLS,step:1}]},y=[{id:"table-insert-row-after",command:{type:"table.insertRow",direction:"after"},label:"插入行",icon:"rows-plus",group:"table"},{id:"table-delete-row",command:{type:"table.deleteRow"},label:"删除行",icon:"rows-minus",group:"table"},{id:"table-insert-column-after",command:{type:"table.insertColumn",direction:"after"},label:"插入列",icon:"columns-plus",group:"table"},{id:"table-delete-column",command:{type:"table.deleteColumn"},label:"删除列",icon:"columns-minus",group:"table"},{id:"table-delete",command:{type:"table.delete"},label:"删除表格",icon:"table-delete",group:"table"}],c=[{id:"bold",command:{type:"format.bold"},label:"加粗",icon:"bold",group:"text"},{id:"italic",command:{type:"format.italic"},label:"斜体",icon:"italic",group:"text"},{id:"underline",command:{type:"format.underline"},label:"下划线",icon:"underline",group:"text"},{id:"strike",command:{type:"format.strike"},label:"删除线",icon:"strikethrough",group:"text"},{id:"inline-code",command:{type:"format.inlineCode"},label:"行内代码",icon:"code",group:"text"},{id:"superscript",command:{type:"format.superscript"},label:"上标",icon:"superscript",group:"text"},{id:"subscript",command:{type:"format.subscript"},label:"下标",icon:"subscript",group:"text"},{id:"clear-style",command:{type:"format.clear"},label:"清除样式",icon:"remove-formatting",group:"text"},{id:"color",command:{type:"format.color",value:""},label:"文字颜色",icon:"palette",group:"style",requiresPayload:!0,payloadPanel:x},{id:"background-color",command:{type:"format.backgroundColor",value:""},label:"背景色",icon:"paint-bucket",group:"style",requiresPayload:!0,payloadPanel:P},{id:"font-size",command:{type:"format.fontSize",value:""},label:"字号",icon:"case-sensitive",group:"style",requiresPayload:!0,payloadPanel:S},{id:"font-family",command:{type:"format.fontFamily",value:""},label:"字体",icon:"type",group:"style",requiresPayload:!0,payloadPanel:M},{id:"line-height",command:{type:"format.lineHeight",value:""},label:"行高",icon:"wrap-text",group:"style",requiresPayload:!0,payloadPanel:T},{id:"paragraph",command:{type:"block.paragraph"},label:"正文",icon:"pilcrow",group:"block"},{id:"heading-1",command:{type:"block.heading",level:1},label:"一级标题",icon:"heading-1",group:"block"},{id:"heading-2",command:{type:"block.heading",level:2},label:"二级标题",icon:"heading-2",group:"block"},{id:"heading-3",command:{type:"block.heading",level:3},label:"三级标题",icon:"heading-3",group:"block"},{id:"heading-4",command:{type:"block.heading",level:4},label:"四级标题",icon:"heading-4",group:"block"},{id:"heading-5",command:{type:"block.heading",level:5},label:"五级标题",icon:"heading-5",group:"block"},{id:"heading-6",command:{type:"block.heading",level:6},label:"六级标题",icon:"heading-6",group:"block"},{id:"quote",command:{type:"block.quote"},label:"引用",icon:"quote",group:"block"},{id:"divider",command:{type:"block.divider"},label:"分割线",icon:"minus",group:"block"},{id:"code-block",command:{type:"block.code"},label:"代码块",icon:"square-code",group:"block"},{id:"ordered-list",command:{type:"list.ordered"},label:"有序列表",icon:"list-ordered",group:"list"},{id:"unordered-list",command:{type:"list.unordered"},label:"无序列表",icon:"list",group:"list"},{id:"todo-list",command:{type:"list.todo"},label:"待办列表",icon:"list-todo",group:"list"},{id:"align-left",command:{type:"align",value:"left"},label:"左对齐",icon:"align-left",group:"align"},{id:"align-center",command:{type:"align",value:"center"},label:"居中",icon:"align-center",group:"align"},{id:"align-right",command:{type:"align",value:"right"},label:"右对齐",icon:"align-right",group:"align"},{id:"align-justify",command:{type:"align",value:"justify"},label:"两端对齐",icon:"align-justify",group:"align"},{id:"indent-increase",command:{type:"indent.increase"},label:"增加缩进",icon:"indent-increase",group:"align"},{id:"indent-decrease",command:{type:"indent.decrease"},label:"减少缩进",icon:"indent-decrease",group:"align"},{id:"mention",command:{type:"mention.insert",item:{id:"",label:"",value:""}},label:"@ 提及",icon:"at-sign",group:"insert",requiresPayload:!0},{id:"upload-image",command:{type:"media.pickImage"},label:"上传图片",icon:"upload-image",group:"media"},{id:"upload-video",command:{type:"media.pickVideo"},label:"上传视频",icon:"upload-video",group:"media"},{id:"table",command:{type:"table.insert",rows:3,cols:3},label:"表格",icon:"table",group:"table",requiresPayload:!0,payloadPanel:w},...y,{id:"slash-command",command:{type:"slash.open"},label:"/ 命令",icon:"list-plus",group:"insert"},{id:"undo",command:{type:"history.undo"},label:"撤销",icon:"undo",group:"history"},{id:"redo",command:{type:"history.redo"},label:"重做",icon:"redo",group:"history"},{id:"clear",command:{type:"content.clear"},label:"清空",icon:"trash-2",group:"history"},{id:"fullscreen",command:{type:"fullscreen.toggle"},label:"全屏",icon:"maximize",group:"view"}],r={align:e=>e.type==="align"?e.value:void 0,"block.heading":e=>e.type==="block.heading"?e.level:void 0,"block.setCodeLanguage":e=>e.type==="block.setCodeLanguage"?e.language:void 0},u=e=>{var l;return(l=r[e.type])==null?void 0:l.call(r,e)},v=(e,l)=>{const a=u(e);return l.command===e.type&&(a===void 0||l.value===a)},K=(e,l)=>v(e.command,l);function q(e=c){return e.map(l=>({command:l.command.type,active:!1,disabled:!0,value:u(l.command)}))}const d={toolbarKeys:["undo","redo","clear","|","paragraph","heading-1","heading-2","heading-3","heading-4","heading-5","heading-6","quote","divider","code-block","|","bold","italic","underline","strike","inline-code","superscript","subscript","clear-style","color","background-color","font-size","font-family","line-height","|","ordered-list","unordered-list","todo-list","|","upload-image","upload-video","|","table","|","align-left","align-center","align-right","align-justify","indent-increase","indent-decrease","|","fullscreen"]},I=e=>typeof e=="object"&&Array.isArray(e.menuKeys),C=e=>new Map(e.map(l=>[l.id,l])),L=(e,l)=>typeof e=="string"?e!=="|"&&l.has(e):l.has(e.key)||e.menuKeys.every(a=>l.has(a)),R=(e,l)=>{const a=new Set((l==null?void 0:l.excludeKeys)??[]),n=e.filter(o=>!L(o,a));if(!(l!=null&&l.insertKeys))return n;const t=Math.max(0,Math.min(l.insertKeys.index,n.length));return[...n.slice(0,t),...l.insertKeys.keys,...n.slice(t)]},E=(e,l,a,n)=>{if(e==="|")return[{type:"separator",key:`separator-${n}`}];if(typeof e=="string"){const t=l.get(e);return!t||t.requiresPayload&&!t.payloadPanel||a.has(t.id)?[]:[{type:"button",item:t}]}if(I(e)){const t=e.menuKeys.filter(o=>!a.has(o)).map(o=>l.get(o)).filter(o=>o!==void 0&&(!o.requiresPayload||o.payloadPanel!==void 0));return t.length>0?[{type:"group",key:e.key,title:e.title,icon:e.icon,items:t}]:[]}return[]},V=(e,l)=>{if(e.type!=="separator")return!0;const a=l[l.length-1];return a!==void 0&&a.type!=="separator"},j=e=>{var l;for(;((l=e.at(-1))==null?void 0:l.type)==="separator";)e.pop();return e},B=(e=d,l=c)=>{const a=C(l),n=e.toolbarKeys??d.toolbarKeys??[],t=R(n,e),o=new Set(e.excludeKeys??[]);let s=0;const h=t.reduce((i,p)=>{const f=E(p,a,o,s);return p==="|"&&(s+=1),f.forEach(m=>{V(m,i)&&i.push(m)}),i},[]);return j(h)};exports.codeBlockLanguagePanel=g;exports.codeBlockLanguagePayloadPanel=k;exports.createDisabledCommandStates=q;exports.defaultMenuSchema=c;exports.defaultToolbarConfig=d;exports.getCommandStateMatchValue=u;exports.isCommandStateForCommand=v;exports.isMenuItemCommandState=K;exports.resolveToolbarMenu=B;exports.tableHeaderMenuItems=y;
|
|
2
2
|
//# sourceMappingURL=native-spec.cjs.map
|
package/dist/native-spec.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-spec.cjs","sources":["../../native-spec/src/menuSchema/payloadPanels.ts","../../native-spec/src/menuSchema/tableHeaderMenuItems.ts","../../native-spec/src/menuSchema/defaultMenuSchema.ts","../../native-spec/src/commandState/index.ts","../../native-spec/src/toolbarConfig/index.ts"],"sourcesContent":["import {\n BRIDGERTE_TABLE_INSERT_MAX_COLS,\n BRIDGERTE_TABLE_INSERT_MAX_ROWS,\n type PayloadPanelSchema\n} from '@bridgerte/core';\n\n/**\n * 代码块语言列表给 DOM 代码块顶部控制栏和原生侧自绘使用。\n *\n * 空字符串表示纯文本;默认候选覆盖 Lexical Prism tokenizer 当前内置语言,并保留\n * JSON 这个高频实用项。业务如需裁剪语言、调整顺序或接入更多 Prism 语言,传入\n * 自己的 `codeBlockLanguagePanel` 即可,不需要改 DOM 内置语言菜单。\n */\nexport const codeBlockLanguagePanel: PayloadPanelSchema = {\n id: 'code-block-language',\n title: '代码语言',\n fields: [\n {\n type: 'select',\n name: 'language',\n label: '语言',\n defaultValue: '',\n options: [\n { label: '纯文本', value: '' },\n { label: 'C', value: 'c' },\n { label: 'C-like', value: 'clike' },\n { label: 'C++', value: 'cpp' },\n { label: 'CSS', value: 'css' },\n { label: 'HTML', value: 'html' },\n { label: 'Java', value: 'java' },\n { label: 'JavaScript', value: 'javascript' },\n { label: 'JSON', value: 'json' },\n { label: 'Markdown', value: 'markdown' },\n { label: 'Objective-C', value: 'objc' },\n { label: 'PowerShell', value: 'powershell' },\n { label: 'Python', value: 'python' },\n { label: 'Rust', value: 'rust' },\n { label: 'SQL', value: 'sql' },\n { label: 'Swift', value: 'swift' },\n { label: 'TypeScript', value: 'typescript' },\n { label: 'XML', value: 'xml' }\n ]\n }\n ]\n};\n\n/**\n * 兼容旧导出名。\n *\n * 代码块语言现在由代码块 header 触发,不再代表 toolbar 菜单 payload。\n */\nexport const codeBlockLanguagePayloadPanel = codeBlockLanguagePanel;\n\n/**\n * 颜色菜单使用 color 字段而不是预设色列表。\n *\n * DOM 默认面板可以渲染内置颜色控件,RN/Flutter/WebView 或业务自绘层仍读取同一份 schema。\n */\nexport const textColorPanel: PayloadPanelSchema = {\n id: 'text-color',\n title: '文字颜色',\n fields: [\n {\n type: 'color',\n name: 'value',\n label: '颜色'\n }\n ]\n};\n\nexport const backgroundColorPanel: PayloadPanelSchema = {\n id: 'background-color',\n title: '背景色',\n fields: [\n {\n type: 'color',\n name: 'value',\n label: '背景'\n }\n ]\n};\n\nexport const fontSizePanel: PayloadPanelSchema = {\n id: 'font-size',\n title: '字号',\n fields: [\n {\n type: 'select',\n name: 'value',\n label: '字号',\n defaultValue: '16px',\n options: [\n { label: '小号 14px', value: '14px' },\n { label: '正文 16px', value: '16px' },\n { label: '强调 18px', value: '18px' },\n { label: '标题 20px', value: '20px' },\n { label: '大标题 24px', value: '24px' }\n ]\n }\n ]\n};\n\nexport const fontFamilyPanel: PayloadPanelSchema = {\n id: 'font-family',\n title: '字体',\n fields: [\n {\n type: 'select',\n name: 'value',\n label: '字体',\n defaultValue: '',\n options: [\n { label: '跟随页面', value: '' },\n { label: '无衬线', value: 'sans-serif' },\n { label: '衬线', value: 'serif' },\n { label: '等宽', value: 'monospace' }\n ]\n }\n ]\n};\n\nexport const lineHeightPanel: PayloadPanelSchema = {\n id: 'line-height',\n title: '行高',\n fields: [\n {\n type: 'select',\n name: 'value',\n label: '行高',\n defaultValue: '1.7',\n options: [\n { label: '紧凑 1.4', value: '1.4' },\n { label: '常规 1.7', value: '1.7' },\n { label: '舒展 2', value: '2' }\n ]\n }\n ]\n};\n\n/**\n * 表格插入使用 number 字段收集行列。\n *\n * DOM 默认面板、H5 自绘和 RN/Flutter 原生表单都读取同一份 schema;真正的表格进阶操作\n * 仍放后续表格菜单阶段继续扩展。\n */\nexport const tableInsertPanel: PayloadPanelSchema = {\n id: 'table-insert',\n title: '插入表格',\n fields: [\n {\n type: 'number',\n name: 'rows',\n label: '行数',\n defaultValue: '3',\n min: 1,\n max: BRIDGERTE_TABLE_INSERT_MAX_ROWS,\n step: 1\n },\n {\n type: 'number',\n name: 'cols',\n label: '列数',\n defaultValue: '3',\n min: 1,\n max: BRIDGERTE_TABLE_INSERT_MAX_COLS,\n step: 1\n }\n ]\n};\n","import type { MenuItem } from './type';\n\n/*\n * 表格 header 和后续表格浮动菜单共用这组操作入口。\n * 这些菜单默认不进入 toolbar 排列,但仍放在 native-spec,保证 DOM/RN/Flutter 自绘读取同一份\n * command/label/icon 协议。\n */\nexport const tableHeaderMenuItems: MenuItem[] = [\n {\n id: 'table-insert-row-after',\n command: { type: 'table.insertRow', direction: 'after' },\n label: '插入行',\n icon: 'rows-plus',\n group: 'table'\n },\n {\n id: 'table-delete-row',\n command: { type: 'table.deleteRow' },\n label: '删除行',\n icon: 'rows-minus',\n group: 'table'\n },\n {\n id: 'table-insert-column-after',\n command: { type: 'table.insertColumn', direction: 'after' },\n label: '插入列',\n icon: 'columns-plus',\n group: 'table'\n },\n {\n id: 'table-delete-column',\n command: { type: 'table.deleteColumn' },\n label: '删除列',\n icon: 'columns-minus',\n group: 'table'\n },\n {\n id: 'table-delete',\n command: { type: 'table.delete' },\n label: '删除表格',\n icon: 'table-delete',\n group: 'table'\n }\n];\n","import type { MenuItem } from './type';\nimport {\n backgroundColorPanel,\n fontFamilyPanel,\n fontSizePanel,\n lineHeightPanel,\n tableInsertPanel,\n textColorPanel\n} from './payloadPanels';\nimport { tableHeaderMenuItems } from './tableHeaderMenuItems';\n\n/**\n * 默认菜单 schema 覆盖 wangEditor 常用入口。\n *\n * RN/Flutter 可以按 group 渲染分组,也可以基于 id 做业务侧排序或裁剪。\n */\nexport const defaultMenuSchema: MenuItem[] = [\n {\n id: 'bold',\n command: { type: 'format.bold' },\n label: '加粗',\n icon: 'bold',\n group: 'text'\n },\n {\n id: 'italic',\n command: { type: 'format.italic' },\n label: '斜体',\n icon: 'italic',\n group: 'text'\n },\n {\n id: 'underline',\n command: { type: 'format.underline' },\n label: '下划线',\n icon: 'underline',\n group: 'text'\n },\n {\n id: 'strike',\n command: { type: 'format.strike' },\n label: '删除线',\n icon: 'strikethrough',\n group: 'text'\n },\n {\n id: 'inline-code',\n command: { type: 'format.inlineCode' },\n label: '行内代码',\n icon: 'code',\n group: 'text'\n },\n {\n id: 'superscript',\n command: { type: 'format.superscript' },\n label: '上标',\n icon: 'superscript',\n group: 'text'\n },\n {\n id: 'subscript',\n command: { type: 'format.subscript' },\n label: '下标',\n icon: 'subscript',\n group: 'text'\n },\n {\n id: 'clear-style',\n command: { type: 'format.clear' },\n label: '清除样式',\n icon: 'remove-formatting',\n group: 'text'\n },\n {\n id: 'color',\n command: { type: 'format.color', value: '' },\n label: '文字颜色',\n icon: 'palette',\n group: 'style',\n requiresPayload: true,\n payloadPanel: textColorPanel\n },\n {\n id: 'background-color',\n command: { type: 'format.backgroundColor', value: '' },\n label: '背景色',\n icon: 'paint-bucket',\n group: 'style',\n requiresPayload: true,\n payloadPanel: backgroundColorPanel\n },\n {\n id: 'font-size',\n command: { type: 'format.fontSize', value: '' },\n label: '字号',\n icon: 'case-sensitive',\n group: 'style',\n requiresPayload: true,\n payloadPanel: fontSizePanel\n },\n {\n id: 'font-family',\n command: { type: 'format.fontFamily', value: '' },\n label: '字体',\n icon: 'type',\n group: 'style',\n requiresPayload: true,\n payloadPanel: fontFamilyPanel\n },\n {\n id: 'line-height',\n command: { type: 'format.lineHeight', value: '' },\n label: '行高',\n icon: 'wrap-text',\n group: 'style',\n requiresPayload: true,\n payloadPanel: lineHeightPanel\n },\n {\n id: 'paragraph',\n command: { type: 'block.paragraph' },\n label: '正文',\n icon: 'pilcrow',\n group: 'block'\n },\n {\n id: 'heading-1',\n command: { type: 'block.heading', level: 1 },\n label: '一级标题',\n icon: 'heading-1',\n group: 'block'\n },\n {\n id: 'heading-2',\n command: { type: 'block.heading', level: 2 },\n label: '二级标题',\n icon: 'heading-2',\n group: 'block'\n },\n {\n id: 'heading-3',\n command: { type: 'block.heading', level: 3 },\n label: '三级标题',\n icon: 'heading-3',\n group: 'block'\n },\n {\n id: 'heading-4',\n command: { type: 'block.heading', level: 4 },\n label: '四级标题',\n icon: 'heading-4',\n group: 'block'\n },\n {\n id: 'heading-5',\n command: { type: 'block.heading', level: 5 },\n label: '五级标题',\n icon: 'heading-5',\n group: 'block'\n },\n {\n id: 'heading-6',\n command: { type: 'block.heading', level: 6 },\n label: '六级标题',\n icon: 'heading-6',\n group: 'block'\n },\n {\n id: 'quote',\n command: { type: 'block.quote' },\n label: '引用',\n icon: 'quote',\n group: 'block'\n },\n {\n id: 'divider',\n command: { type: 'block.divider' },\n label: '分割线',\n icon: 'minus',\n group: 'block'\n },\n {\n id: 'code-block',\n command: { type: 'block.code' },\n label: '代码块',\n icon: 'square-code',\n group: 'block'\n },\n {\n id: 'ordered-list',\n command: { type: 'list.ordered' },\n label: '有序列表',\n icon: 'list-ordered',\n group: 'list'\n },\n {\n id: 'unordered-list',\n command: { type: 'list.unordered' },\n label: '无序列表',\n icon: 'list',\n group: 'list'\n },\n {\n id: 'todo-list',\n command: { type: 'list.todo' },\n label: '待办列表',\n icon: 'list-todo',\n group: 'list'\n },\n {\n id: 'align-left',\n command: { type: 'align', value: 'left' },\n label: '左对齐',\n icon: 'align-left',\n group: 'align'\n },\n {\n id: 'align-center',\n command: { type: 'align', value: 'center' },\n label: '居中',\n icon: 'align-center',\n group: 'align'\n },\n {\n id: 'align-right',\n command: { type: 'align', value: 'right' },\n label: '右对齐',\n icon: 'align-right',\n group: 'align'\n },\n {\n id: 'align-justify',\n command: { type: 'align', value: 'justify' },\n label: '两端对齐',\n icon: 'align-justify',\n group: 'align'\n },\n {\n id: 'indent-increase',\n command: { type: 'indent.increase' },\n label: '增加缩进',\n icon: 'indent-increase',\n group: 'align'\n },\n {\n id: 'indent-decrease',\n command: { type: 'indent.decrease' },\n label: '减少缩进',\n icon: 'indent-decrease',\n group: 'align'\n },\n {\n id: 'mention',\n command: { type: 'mention.insert', item: { id: '', label: '', value: '' } },\n label: '@ 提及',\n icon: 'at-sign',\n group: 'insert',\n requiresPayload: true\n },\n {\n id: 'upload-image',\n command: { type: 'media.pickImage' },\n label: '上传图片',\n icon: 'upload-image',\n group: 'media'\n },\n {\n id: 'upload-video',\n command: { type: 'media.pickVideo' },\n label: '上传视频',\n icon: 'upload-video',\n group: 'media'\n },\n {\n id: 'table',\n command: { type: 'table.insert', rows: 3, cols: 3 },\n label: '表格',\n icon: 'table',\n group: 'table',\n requiresPayload: true,\n payloadPanel: tableInsertPanel\n },\n ...tableHeaderMenuItems,\n {\n id: 'slash-command',\n command: { type: 'slash.open' },\n label: '/ 命令',\n icon: 'list-plus',\n group: 'insert'\n },\n {\n id: 'undo',\n command: { type: 'history.undo' },\n label: '撤销',\n icon: 'undo',\n group: 'history'\n },\n {\n id: 'redo',\n command: { type: 'history.redo' },\n label: '重做',\n icon: 'redo',\n group: 'history'\n },\n {\n id: 'clear',\n command: { type: 'content.clear' },\n label: '清空',\n icon: 'trash-2',\n group: 'history'\n },\n {\n id: 'fullscreen',\n command: { type: 'fullscreen.toggle' },\n label: '全屏',\n icon: 'maximize',\n group: 'view'\n }\n];\n","import type { CommandState, EditorCommand } from '@bridgerte/core';\nimport type { MenuItem } from '../menuSchema';\nimport { defaultMenuSchema } from '../menuSchema';\n\nconst commandStateValueByType: Partial<Record<EditorCommand['type'], (command: EditorCommand) => (\n CommandState['value'] | undefined\n)>> = {\n align: (command) => command.type === 'align' ? command.value : undefined,\n 'block.heading': (command) => command.type === 'block.heading' ? command.level : undefined,\n 'block.setCodeLanguage': (command) => (\n command.type === 'block.setCodeLanguage' ? command.language : undefined\n )\n};\n\n/**\n * 取出菜单命令用于匹配 `CommandState.value` 的稳定值。\n *\n * 同类命令存在多个菜单项时使用这个值区分,比如对齐方式和标题级别。\n */\nexport const getCommandStateMatchValue = (\n command: EditorCommand\n): CommandState['value'] | undefined => commandStateValueByType[command.type]?.(command);\n\n/**\n * 判断某条命令状态是否对应一个完整命令 payload。\n */\nexport const isCommandStateForCommand = (\n command: EditorCommand,\n state: CommandState\n): boolean => {\n const matchValue = getCommandStateMatchValue(command);\n\n return state.command === command.type\n && (matchValue === undefined || state.value === matchValue);\n};\n\n/**\n * 判断某条命令状态是否对应一个菜单项。\n *\n * 原生 toolbar 可以用它把 `CommandState[]` 映射回具体按钮 active/disabled 状态。\n */\nexport const isMenuItemCommandState = (item: MenuItem, state: CommandState): boolean => (\n isCommandStateForCommand(item.command, state)\n);\n\n/**\n * 为给定菜单生成默认禁用状态。\n *\n * 编辑器未 ready 或无选区时,原生 toolbar 可以先使用这组状态兜底。\n */\nexport function createDisabledCommandStates(menuSchema = defaultMenuSchema): CommandState[] {\n return menuSchema.map((item) => ({\n command: item.command.type,\n active: false,\n disabled: true,\n value: getCommandStateMatchValue(item.command)\n }));\n}\n","import type { ToolbarConfig, ToolbarGroupConfig, ToolbarKey } from '@bridgerte/core';\nimport type { MenuItem } from '../menuSchema';\nimport { defaultMenuSchema } from '../menuSchema';\nimport type { ResolvedToolbarItem } from './type';\n\nexport type * from './type';\n\n/**\n * 默认 DOM toolbar 配置。\n *\n * 这里只选择已实现或带参数面板的基础按钮;完整菜单全集仍由 `defaultMenuSchema` 维护。\n */\nexport const defaultToolbarConfig: ToolbarConfig = {\n toolbarKeys: [\n 'undo',\n 'redo',\n 'clear',\n '|',\n 'paragraph',\n 'heading-1',\n 'heading-2',\n 'heading-3',\n 'heading-4',\n 'heading-5',\n 'heading-6',\n 'quote',\n 'divider',\n 'code-block',\n '|',\n 'bold',\n 'italic',\n 'underline',\n 'strike',\n 'inline-code',\n 'superscript',\n 'subscript',\n 'clear-style',\n 'color',\n 'background-color',\n 'font-size',\n 'font-family',\n 'line-height',\n '|',\n 'ordered-list',\n 'unordered-list',\n 'todo-list',\n '|',\n 'upload-image',\n 'upload-video',\n '|',\n 'table',\n '|',\n 'align-left',\n 'align-center',\n 'align-right',\n 'align-justify',\n 'indent-increase',\n 'indent-decrease',\n '|',\n 'fullscreen'\n ]\n};\n\nconst isToolbarGroupConfig = (key: ToolbarKey): key is ToolbarGroupConfig => (\n typeof key === 'object' && Array.isArray(key.menuKeys)\n);\n\nconst createMenuMap = (menuSchema: MenuItem[]) => new Map(\n menuSchema.map((item) => [item.id, item])\n);\n\nconst shouldExcludeToolbarKey = (\n key: ToolbarKey,\n excludeKeys: Set<string>\n) => {\n if (typeof key === 'string') return key !== '|' && excludeKeys.has(key);\n\n return excludeKeys.has(key.key) || key.menuKeys.every((menuKey) => excludeKeys.has(menuKey));\n};\n\nconst applyToolbarConfigOverrides = (\n baseKeys: ToolbarKey[],\n toolbarConfig?: ToolbarConfig\n): ToolbarKey[] => {\n const excludeKeys = new Set(toolbarConfig?.excludeKeys ?? []);\n /*\n * 先排除再插入,等价于“在用户最终想保留的默认菜单里加东西”。\n * insert index 做夹取,避免业务传入负数或超长下标时破坏默认 toolbar。\n */\n const filteredKeys = baseKeys.filter((key) => !shouldExcludeToolbarKey(key, excludeKeys));\n\n if (!toolbarConfig?.insertKeys) return filteredKeys;\n\n const insertIndex = Math.max(0, Math.min(toolbarConfig.insertKeys.index, filteredKeys.length));\n\n return [\n ...filteredKeys.slice(0, insertIndex),\n ...toolbarConfig.insertKeys.keys,\n ...filteredKeys.slice(insertIndex)\n ];\n};\n\nconst resolveToolbarKey = (\n key: ToolbarKey,\n menuMap: Map<string, MenuItem>,\n excludeKeys: Set<string>,\n separatorIndex: number\n): ResolvedToolbarItem[] => {\n if (key === '|') {\n return [{ type: 'separator', key: `separator-${separatorIndex}` }];\n }\n\n if (typeof key === 'string') {\n const item = menuMap.get(key);\n\n // 未知 key 直接忽略;需要 payload 但没有 panel 的菜单暂不渲染,避免按钮点击后无法生成合法命令。\n if (!item || (item.requiresPayload && !item.payloadPanel) || excludeKeys.has(item.id)) {\n return [];\n }\n\n return [{ type: 'button', item }];\n }\n\n if (isToolbarGroupConfig(key)) {\n const items = key.menuKeys\n .filter((menuKey) => !excludeKeys.has(menuKey))\n .map((menuKey) => menuMap.get(menuKey))\n .filter((item): item is MenuItem => (\n item !== undefined && (!item.requiresPayload || item.payloadPanel !== undefined)\n ));\n\n return items.length > 0 ? [{\n type: 'group',\n key: key.key,\n title: key.title,\n icon: key.icon,\n items\n }] : [];\n }\n\n return [];\n};\n\nconst shouldKeepResolvedToolbarItem = (\n item: ResolvedToolbarItem,\n items: ResolvedToolbarItem[]\n) => {\n if (item.type !== 'separator') return true;\n\n const previousItem = items[items.length - 1];\n\n return previousItem !== undefined && previousItem.type !== 'separator';\n};\n\nconst trimTrailingToolbarSeparators = (items: ResolvedToolbarItem[]) => {\n while (items.at(-1)?.type === 'separator') {\n items.pop();\n }\n\n return items;\n};\n\n/**\n * 把 wangEditor 风格的 JSON 配置解析成 DOM/RN/Flutter 都能消费的菜单结构。\n *\n * 未知 key 和缺少 payloadPanel 的 requiresPayload 菜单会被忽略,避免默认 toolbar 渲染无法处理的按钮。\n * 分割线会自动去掉开头、结尾和连续项,避免被跳过的菜单留下空分隔。\n */\nexport const resolveToolbarMenu = (\n toolbarConfig: ToolbarConfig = defaultToolbarConfig,\n menuSchema: MenuItem[] = defaultMenuSchema\n): ResolvedToolbarItem[] => {\n const menuMap = createMenuMap(menuSchema);\n const baseKeys = toolbarConfig.toolbarKeys ?? defaultToolbarConfig.toolbarKeys ?? [];\n const toolbarKeys = applyToolbarConfigOverrides(baseKeys, toolbarConfig);\n const excludeKeys = new Set(toolbarConfig.excludeKeys ?? []);\n let separatorIndex = 0;\n\n const resolvedItems = toolbarKeys.reduce<ResolvedToolbarItem[]>((items, key) => {\n const nextItems = resolveToolbarKey(key, menuMap, excludeKeys, separatorIndex);\n\n if (key === '|') separatorIndex += 1;\n\n nextItems.forEach((item) => {\n if (shouldKeepResolvedToolbarItem(item, items)) {\n items.push(item);\n }\n });\n\n return items;\n }, []);\n\n return trimTrailingToolbarSeparators(resolvedItems);\n};\n"],"names":["codeBlockLanguagePanel","codeBlockLanguagePayloadPanel","textColorPanel","backgroundColorPanel","fontSizePanel","fontFamilyPanel","lineHeightPanel","tableInsertPanel","BRIDGERTE_TABLE_INSERT_MAX_ROWS","BRIDGERTE_TABLE_INSERT_MAX_COLS","tableHeaderMenuItems","defaultMenuSchema","commandStateValueByType","command","getCommandStateMatchValue","_a","isCommandStateForCommand","state","matchValue","isMenuItemCommandState","item","createDisabledCommandStates","menuSchema","defaultToolbarConfig","isToolbarGroupConfig","key","createMenuMap","shouldExcludeToolbarKey","excludeKeys","menuKey","applyToolbarConfigOverrides","baseKeys","toolbarConfig","filteredKeys","insertIndex","resolveToolbarKey","menuMap","separatorIndex","items","shouldKeepResolvedToolbarItem","previousItem","trimTrailingToolbarSeparators","resolveToolbarMenu","toolbarKeys","resolvedItems","nextItems"],"mappings":"wHAaaA,EAA6C,CACxD,GAAI,sBACJ,MAAO,OACP,OAAQ,CACN,CACE,KAAM,SACN,KAAM,WACN,MAAO,KACP,aAAc,GACd,QAAS,CACP,CAAE,MAAO,MAAO,MAAO,EAAA,EACvB,CAAE,MAAO,IAAK,MAAO,GAAA,EACrB,CAAE,MAAO,SAAU,MAAO,OAAA,EAC1B,CAAE,MAAO,MAAO,MAAO,KAAA,EACvB,CAAE,MAAO,MAAO,MAAO,KAAA,EACvB,CAAE,MAAO,OAAQ,MAAO,MAAA,EACxB,CAAE,MAAO,OAAQ,MAAO,MAAA,EACxB,CAAE,MAAO,aAAc,MAAO,YAAA,EAC9B,CAAE,MAAO,OAAQ,MAAO,MAAA,EACxB,CAAE,MAAO,WAAY,MAAO,UAAA,EAC5B,CAAE,MAAO,cAAe,MAAO,MAAA,EAC/B,CAAE,MAAO,aAAc,MAAO,YAAA,EAC9B,CAAE,MAAO,SAAU,MA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Aa,MAAO,GAEtC,MAAMoB,EAAeF,EAAMA,EAAM,OAAS,CAAC,EAE3C,OAAOE,IAAiB,QAAaA,EAAa,OAAS,WAC7D,EAEMC,EAAiCH,GAAiC,OACtE,OAAOvB,EAAAuB,EAAM,GAAG,EAAE,IAAX,YAAAvB,EAAc,QAAS,aAC5BuB,EAAM,IAAA,EAGR,OAAOA,CACT,EAQaI,EAAqB,CAChCV,EAA+BT,EAC/BD,EAAyBX,IACC,CAC1B,MAAMyB,EAAUV,EAAcJ,CAAU,EAClCS,EAAWC,EAAc,aAAeT,EAAqB,aAAe,CAAA,EAC5EoB,EAAcb,EAA4BC,EAAUC,CAAa,EACjEJ,EAAc,IAAI,IAAII,EAAc,aAAe,CAAA,CAAE,EAC3D,IAAIK,EAAiB,EAErB,MAAMO,EAAgBD,EAAY,OAA8B,CAACL,EAAOb,IAAQ,CAC9E,MAAMoB,EAAYV,EAAkBV,EAAKW,EAASR,EAAaS,CAAc,EAE7E,OAAIZ,IAAQ,MAAKY,GAAkB,GAEnCQ,EAAU,QAASzB,GAAS,CACtBmB,EAA8BnB,EAAMkB,CAAK,GAC3CA,EAAM,KAAKlB,CAAI,CAEnB,CAAC,EAEMkB,CACT,EAAG,CAAA,CAAE,EAEL,OAAOG,EAA8BG,CAAa,CACpD"}
|
|
1
|
+
{"version":3,"file":"native-spec.cjs","sources":["../../native-spec/src/menuSchema/payloadPanels.ts","../../native-spec/src/menuSchema/tableHeaderMenuItems.ts","../../native-spec/src/menuSchema/defaultMenuSchema.ts","../../native-spec/src/commandState/index.ts","../../native-spec/src/toolbarConfig/index.ts"],"sourcesContent":["import {\n BRIDGERTE_TABLE_INSERT_MAX_COLS,\n BRIDGERTE_TABLE_INSERT_MAX_ROWS,\n type PayloadPanelSchema\n} from '@bridgerte/core';\n\n/**\n * 代码块语言列表给 DOM 代码块顶部控制栏和原生侧自绘使用。\n *\n * 空字符串表示纯文本;默认候选按 Shiki 高频技术文档语言维护。业务如需裁剪语言、\n * 调整顺序或接入更多 Shiki 语言,传入自己的 `codeBlockLanguagePanel` 即可。\n */\nexport const codeBlockLanguagePanel: PayloadPanelSchema = {\n id: 'code-block-language',\n title: '代码语言',\n fields: [\n {\n type: 'select',\n name: 'language',\n label: '语言',\n defaultValue: '',\n options: [\n { label: '纯文本', value: '' },\n { label: 'Bash', value: 'shellscript' },\n { label: 'C', value: 'c' },\n { label: 'C++', value: 'cpp' },\n { label: 'C#', value: 'csharp' },\n { label: 'CSS', value: 'css' },\n { label: 'Dart', value: 'dart' },\n { label: 'Dockerfile', value: 'docker' },\n { label: 'Go', value: 'go' },\n { label: 'HTML', value: 'html' },\n { label: 'Java', value: 'java' },\n { label: 'JavaScript', value: 'javascript' },\n { label: 'JSON', value: 'json' },\n { label: 'Kotlin', value: 'kotlin' },\n { label: 'Markdown', value: 'markdown' },\n { label: 'PHP', value: 'php' },\n { label: 'Python', value: 'python' },\n { label: 'Rust', value: 'rust' },\n { label: 'SQL', value: 'sql' },\n { label: 'Swift', value: 'swift' },\n { label: 'TOML', value: 'toml' },\n { label: 'TSX', value: 'tsx' },\n { label: 'TypeScript', value: 'typescript' },\n { label: 'Vue', value: 'vue' },\n { label: 'XML', value: 'xml' },\n { label: 'YAML', value: 'yaml' }\n ]\n }\n ]\n};\n\n/**\n * 兼容旧导出名。\n *\n * 代码块语言现在由代码块 header 触发,不再代表 toolbar 菜单 payload。\n */\nexport const codeBlockLanguagePayloadPanel = codeBlockLanguagePanel;\n\n/**\n * 颜色菜单使用 color 字段而不是预设色列表。\n *\n * DOM 默认面板可以渲染内置颜色控件,RN/Flutter/WebView 或业务自绘层仍读取同一份 schema。\n */\nexport const textColorPanel: PayloadPanelSchema = {\n id: 'text-color',\n title: '文字颜色',\n fields: [\n {\n type: 'color',\n name: 'value',\n label: '颜色'\n }\n ]\n};\n\nexport const backgroundColorPanel: PayloadPanelSchema = {\n id: 'background-color',\n title: '背景色',\n fields: [\n {\n type: 'color',\n name: 'value',\n label: '背景'\n }\n ]\n};\n\nexport const fontSizePanel: PayloadPanelSchema = {\n id: 'font-size',\n title: '字号',\n fields: [\n {\n type: 'select',\n name: 'value',\n label: '字号',\n defaultValue: '16px',\n options: [\n { label: '小号 14px', value: '14px' },\n { label: '正文 16px', value: '16px' },\n { label: '强调 18px', value: '18px' },\n { label: '标题 20px', value: '20px' },\n { label: '大标题 24px', value: '24px' }\n ]\n }\n ]\n};\n\nexport const fontFamilyPanel: PayloadPanelSchema = {\n id: 'font-family',\n title: '字体',\n fields: [\n {\n type: 'select',\n name: 'value',\n label: '字体',\n defaultValue: '',\n options: [\n { label: '跟随页面', value: '' },\n { label: '无衬线', value: 'sans-serif' },\n { label: '衬线', value: 'serif' },\n { label: '等宽', value: 'monospace' }\n ]\n }\n ]\n};\n\nexport const lineHeightPanel: PayloadPanelSchema = {\n id: 'line-height',\n title: '行高',\n fields: [\n {\n type: 'select',\n name: 'value',\n label: '行高',\n defaultValue: '1.7',\n options: [\n { label: '紧凑 1.4', value: '1.4' },\n { label: '常规 1.7', value: '1.7' },\n { label: '舒展 2', value: '2' }\n ]\n }\n ]\n};\n\n/**\n * 表格插入使用 number 字段收集行列。\n *\n * DOM 默认面板、H5 自绘和 RN/Flutter 原生表单都读取同一份 schema;真正的表格进阶操作\n * 仍放后续表格菜单阶段继续扩展。\n */\nexport const tableInsertPanel: PayloadPanelSchema = {\n id: 'table-insert',\n title: '插入表格',\n fields: [\n {\n type: 'number',\n name: 'rows',\n label: '行数',\n defaultValue: '3',\n min: 1,\n max: BRIDGERTE_TABLE_INSERT_MAX_ROWS,\n step: 1\n },\n {\n type: 'number',\n name: 'cols',\n label: '列数',\n defaultValue: '3',\n min: 1,\n max: BRIDGERTE_TABLE_INSERT_MAX_COLS,\n step: 1\n }\n ]\n};\n","import type { MenuItem } from './type';\n\n/*\n * 表格 header 和后续表格浮动菜单共用这组操作入口。\n * 这些菜单默认不进入 toolbar 排列,但仍放在 native-spec,保证 DOM/RN/Flutter 自绘读取同一份\n * command/label/icon 协议。\n */\nexport const tableHeaderMenuItems: MenuItem[] = [\n {\n id: 'table-insert-row-after',\n command: { type: 'table.insertRow', direction: 'after' },\n label: '插入行',\n icon: 'rows-plus',\n group: 'table'\n },\n {\n id: 'table-delete-row',\n command: { type: 'table.deleteRow' },\n label: '删除行',\n icon: 'rows-minus',\n group: 'table'\n },\n {\n id: 'table-insert-column-after',\n command: { type: 'table.insertColumn', direction: 'after' },\n label: '插入列',\n icon: 'columns-plus',\n group: 'table'\n },\n {\n id: 'table-delete-column',\n command: { type: 'table.deleteColumn' },\n label: '删除列',\n icon: 'columns-minus',\n group: 'table'\n },\n {\n id: 'table-delete',\n command: { type: 'table.delete' },\n label: '删除表格',\n icon: 'table-delete',\n group: 'table'\n }\n];\n","import type { MenuItem } from './type';\nimport {\n backgroundColorPanel,\n fontFamilyPanel,\n fontSizePanel,\n lineHeightPanel,\n tableInsertPanel,\n textColorPanel\n} from './payloadPanels';\nimport { tableHeaderMenuItems } from './tableHeaderMenuItems';\n\n/**\n * 默认菜单 schema 覆盖 wangEditor 常用入口。\n *\n * RN/Flutter 可以按 group 渲染分组,也可以基于 id 做业务侧排序或裁剪。\n */\nexport const defaultMenuSchema: MenuItem[] = [\n {\n id: 'bold',\n command: { type: 'format.bold' },\n label: '加粗',\n icon: 'bold',\n group: 'text'\n },\n {\n id: 'italic',\n command: { type: 'format.italic' },\n label: '斜体',\n icon: 'italic',\n group: 'text'\n },\n {\n id: 'underline',\n command: { type: 'format.underline' },\n label: '下划线',\n icon: 'underline',\n group: 'text'\n },\n {\n id: 'strike',\n command: { type: 'format.strike' },\n label: '删除线',\n icon: 'strikethrough',\n group: 'text'\n },\n {\n id: 'inline-code',\n command: { type: 'format.inlineCode' },\n label: '行内代码',\n icon: 'code',\n group: 'text'\n },\n {\n id: 'superscript',\n command: { type: 'format.superscript' },\n label: '上标',\n icon: 'superscript',\n group: 'text'\n },\n {\n id: 'subscript',\n command: { type: 'format.subscript' },\n label: '下标',\n icon: 'subscript',\n group: 'text'\n },\n {\n id: 'clear-style',\n command: { type: 'format.clear' },\n label: '清除样式',\n icon: 'remove-formatting',\n group: 'text'\n },\n {\n id: 'color',\n command: { type: 'format.color', value: '' },\n label: '文字颜色',\n icon: 'palette',\n group: 'style',\n requiresPayload: true,\n payloadPanel: textColorPanel\n },\n {\n id: 'background-color',\n command: { type: 'format.backgroundColor', value: '' },\n label: '背景色',\n icon: 'paint-bucket',\n group: 'style',\n requiresPayload: true,\n payloadPanel: backgroundColorPanel\n },\n {\n id: 'font-size',\n command: { type: 'format.fontSize', value: '' },\n label: '字号',\n icon: 'case-sensitive',\n group: 'style',\n requiresPayload: true,\n payloadPanel: fontSizePanel\n },\n {\n id: 'font-family',\n command: { type: 'format.fontFamily', value: '' },\n label: '字体',\n icon: 'type',\n group: 'style',\n requiresPayload: true,\n payloadPanel: fontFamilyPanel\n },\n {\n id: 'line-height',\n command: { type: 'format.lineHeight', value: '' },\n label: '行高',\n icon: 'wrap-text',\n group: 'style',\n requiresPayload: true,\n payloadPanel: lineHeightPanel\n },\n {\n id: 'paragraph',\n command: { type: 'block.paragraph' },\n label: '正文',\n icon: 'pilcrow',\n group: 'block'\n },\n {\n id: 'heading-1',\n command: { type: 'block.heading', level: 1 },\n label: '一级标题',\n icon: 'heading-1',\n group: 'block'\n },\n {\n id: 'heading-2',\n command: { type: 'block.heading', level: 2 },\n label: '二级标题',\n icon: 'heading-2',\n group: 'block'\n },\n {\n id: 'heading-3',\n command: { type: 'block.heading', level: 3 },\n label: '三级标题',\n icon: 'heading-3',\n group: 'block'\n },\n {\n id: 'heading-4',\n command: { type: 'block.heading', level: 4 },\n label: '四级标题',\n icon: 'heading-4',\n group: 'block'\n },\n {\n id: 'heading-5',\n command: { type: 'block.heading', level: 5 },\n label: '五级标题',\n icon: 'heading-5',\n group: 'block'\n },\n {\n id: 'heading-6',\n command: { type: 'block.heading', level: 6 },\n label: '六级标题',\n icon: 'heading-6',\n group: 'block'\n },\n {\n id: 'quote',\n command: { type: 'block.quote' },\n label: '引用',\n icon: 'quote',\n group: 'block'\n },\n {\n id: 'divider',\n command: { type: 'block.divider' },\n label: '分割线',\n icon: 'minus',\n group: 'block'\n },\n {\n id: 'code-block',\n command: { type: 'block.code' },\n label: '代码块',\n icon: 'square-code',\n group: 'block'\n },\n {\n id: 'ordered-list',\n command: { type: 'list.ordered' },\n label: '有序列表',\n icon: 'list-ordered',\n group: 'list'\n },\n {\n id: 'unordered-list',\n command: { type: 'list.unordered' },\n label: '无序列表',\n icon: 'list',\n group: 'list'\n },\n {\n id: 'todo-list',\n command: { type: 'list.todo' },\n label: '待办列表',\n icon: 'list-todo',\n group: 'list'\n },\n {\n id: 'align-left',\n command: { type: 'align', value: 'left' },\n label: '左对齐',\n icon: 'align-left',\n group: 'align'\n },\n {\n id: 'align-center',\n command: { type: 'align', value: 'center' },\n label: '居中',\n icon: 'align-center',\n group: 'align'\n },\n {\n id: 'align-right',\n command: { type: 'align', value: 'right' },\n label: '右对齐',\n icon: 'align-right',\n group: 'align'\n },\n {\n id: 'align-justify',\n command: { type: 'align', value: 'justify' },\n label: '两端对齐',\n icon: 'align-justify',\n group: 'align'\n },\n {\n id: 'indent-increase',\n command: { type: 'indent.increase' },\n label: '增加缩进',\n icon: 'indent-increase',\n group: 'align'\n },\n {\n id: 'indent-decrease',\n command: { type: 'indent.decrease' },\n label: '减少缩进',\n icon: 'indent-decrease',\n group: 'align'\n },\n {\n id: 'mention',\n command: { type: 'mention.insert', item: { id: '', label: '', value: '' } },\n label: '@ 提及',\n icon: 'at-sign',\n group: 'insert',\n requiresPayload: true\n },\n {\n id: 'upload-image',\n command: { type: 'media.pickImage' },\n label: '上传图片',\n icon: 'upload-image',\n group: 'media'\n },\n {\n id: 'upload-video',\n command: { type: 'media.pickVideo' },\n label: '上传视频',\n icon: 'upload-video',\n group: 'media'\n },\n {\n id: 'table',\n command: { type: 'table.insert', rows: 3, cols: 3 },\n label: '表格',\n icon: 'table',\n group: 'table',\n requiresPayload: true,\n payloadPanel: tableInsertPanel\n },\n ...tableHeaderMenuItems,\n {\n id: 'slash-command',\n command: { type: 'slash.open' },\n label: '/ 命令',\n icon: 'list-plus',\n group: 'insert'\n },\n {\n id: 'undo',\n command: { type: 'history.undo' },\n label: '撤销',\n icon: 'undo',\n group: 'history'\n },\n {\n id: 'redo',\n command: { type: 'history.redo' },\n label: '重做',\n icon: 'redo',\n group: 'history'\n },\n {\n id: 'clear',\n command: { type: 'content.clear' },\n label: '清空',\n icon: 'trash-2',\n group: 'history'\n },\n {\n id: 'fullscreen',\n command: { type: 'fullscreen.toggle' },\n label: '全屏',\n icon: 'maximize',\n group: 'view'\n }\n];\n","import type { CommandState, EditorCommand } from '@bridgerte/core';\nimport type { MenuItem } from '../menuSchema';\nimport { defaultMenuSchema } from '../menuSchema';\n\nconst commandStateValueByType: Partial<Record<EditorCommand['type'], (command: EditorCommand) => (\n CommandState['value'] | undefined\n)>> = {\n align: (command) => command.type === 'align' ? command.value : undefined,\n 'block.heading': (command) => command.type === 'block.heading' ? command.level : undefined,\n 'block.setCodeLanguage': (command) => (\n command.type === 'block.setCodeLanguage' ? command.language : undefined\n )\n};\n\n/**\n * 取出菜单命令用于匹配 `CommandState.value` 的稳定值。\n *\n * 同类命令存在多个菜单项时使用这个值区分,比如对齐方式和标题级别。\n */\nexport const getCommandStateMatchValue = (\n command: EditorCommand\n): CommandState['value'] | undefined => commandStateValueByType[command.type]?.(command);\n\n/**\n * 判断某条命令状态是否对应一个完整命令 payload。\n */\nexport const isCommandStateForCommand = (\n command: EditorCommand,\n state: CommandState\n): boolean => {\n const matchValue = getCommandStateMatchValue(command);\n\n return state.command === command.type\n && (matchValue === undefined || state.value === matchValue);\n};\n\n/**\n * 判断某条命令状态是否对应一个菜单项。\n *\n * 原生 toolbar 可以用它把 `CommandState[]` 映射回具体按钮 active/disabled 状态。\n */\nexport const isMenuItemCommandState = (item: MenuItem, state: CommandState): boolean => (\n isCommandStateForCommand(item.command, state)\n);\n\n/**\n * 为给定菜单生成默认禁用状态。\n *\n * 编辑器未 ready 或无选区时,原生 toolbar 可以先使用这组状态兜底。\n */\nexport function createDisabledCommandStates(menuSchema = defaultMenuSchema): CommandState[] {\n return menuSchema.map((item) => ({\n command: item.command.type,\n active: false,\n disabled: true,\n value: getCommandStateMatchValue(item.command)\n }));\n}\n","import type { ToolbarConfig, ToolbarGroupConfig, ToolbarKey } from '@bridgerte/core';\nimport type { MenuItem } from '../menuSchema';\nimport { defaultMenuSchema } from '../menuSchema';\nimport type { ResolvedToolbarItem } from './type';\n\nexport type * from './type';\n\n/**\n * 默认 DOM toolbar 配置。\n *\n * 这里只选择已实现或带参数面板的基础按钮;完整菜单全集仍由 `defaultMenuSchema` 维护。\n */\nexport const defaultToolbarConfig: ToolbarConfig = {\n toolbarKeys: [\n 'undo',\n 'redo',\n 'clear',\n '|',\n 'paragraph',\n 'heading-1',\n 'heading-2',\n 'heading-3',\n 'heading-4',\n 'heading-5',\n 'heading-6',\n 'quote',\n 'divider',\n 'code-block',\n '|',\n 'bold',\n 'italic',\n 'underline',\n 'strike',\n 'inline-code',\n 'superscript',\n 'subscript',\n 'clear-style',\n 'color',\n 'background-color',\n 'font-size',\n 'font-family',\n 'line-height',\n '|',\n 'ordered-list',\n 'unordered-list',\n 'todo-list',\n '|',\n 'upload-image',\n 'upload-video',\n '|',\n 'table',\n '|',\n 'align-left',\n 'align-center',\n 'align-right',\n 'align-justify',\n 'indent-increase',\n 'indent-decrease',\n '|',\n 'fullscreen'\n ]\n};\n\nconst isToolbarGroupConfig = (key: ToolbarKey): key is ToolbarGroupConfig => (\n typeof key === 'object' && Array.isArray(key.menuKeys)\n);\n\nconst createMenuMap = (menuSchema: MenuItem[]) => new Map(\n menuSchema.map((item) => [item.id, item])\n);\n\nconst shouldExcludeToolbarKey = (\n key: ToolbarKey,\n excludeKeys: Set<string>\n) => {\n if (typeof key === 'string') return key !== '|' && excludeKeys.has(key);\n\n return excludeKeys.has(key.key) || key.menuKeys.every((menuKey) => excludeKeys.has(menuKey));\n};\n\nconst applyToolbarConfigOverrides = (\n baseKeys: ToolbarKey[],\n toolbarConfig?: ToolbarConfig\n): ToolbarKey[] => {\n const excludeKeys = new Set(toolbarConfig?.excludeKeys ?? []);\n /*\n * 先排除再插入,等价于“在用户最终想保留的默认菜单里加东西”。\n * insert index 做夹取,避免业务传入负数或超长下标时破坏默认 toolbar。\n */\n const filteredKeys = baseKeys.filter((key) => !shouldExcludeToolbarKey(key, excludeKeys));\n\n if (!toolbarConfig?.insertKeys) return filteredKeys;\n\n const insertIndex = Math.max(0, Math.min(toolbarConfig.insertKeys.index, filteredKeys.length));\n\n return [\n ...filteredKeys.slice(0, insertIndex),\n ...toolbarConfig.insertKeys.keys,\n ...filteredKeys.slice(insertIndex)\n ];\n};\n\nconst resolveToolbarKey = (\n key: ToolbarKey,\n menuMap: Map<string, MenuItem>,\n excludeKeys: Set<string>,\n separatorIndex: number\n): ResolvedToolbarItem[] => {\n if (key === '|') {\n return [{ type: 'separator', key: `separator-${separatorIndex}` }];\n }\n\n if (typeof key === 'string') {\n const item = menuMap.get(key);\n\n // 未知 key 直接忽略;需要 payload 但没有 panel 的菜单暂不渲染,避免按钮点击后无法生成合法命令。\n if (!item || (item.requiresPayload && !item.payloadPanel) || excludeKeys.has(item.id)) {\n return [];\n }\n\n return [{ type: 'button', item }];\n }\n\n if (isToolbarGroupConfig(key)) {\n const items = key.menuKeys\n .filter((menuKey) => !excludeKeys.has(menuKey))\n .map((menuKey) => menuMap.get(menuKey))\n .filter((item): item is MenuItem => (\n item !== undefined && (!item.requiresPayload || item.payloadPanel !== undefined)\n ));\n\n return items.length > 0 ? [{\n type: 'group',\n key: key.key,\n title: key.title,\n icon: key.icon,\n items\n }] : [];\n }\n\n return [];\n};\n\nconst shouldKeepResolvedToolbarItem = (\n item: ResolvedToolbarItem,\n items: ResolvedToolbarItem[]\n) => {\n if (item.type !== 'separator') return true;\n\n const previousItem = items[items.length - 1];\n\n return previousItem !== undefined && previousItem.type !== 'separator';\n};\n\nconst trimTrailingToolbarSeparators = (items: ResolvedToolbarItem[]) => {\n while (items.at(-1)?.type === 'separator') {\n items.pop();\n }\n\n return items;\n};\n\n/**\n * 把 wangEditor 风格的 JSON 配置解析成 DOM/RN/Flutter 都能消费的菜单结构。\n *\n * 未知 key 和缺少 payloadPanel 的 requiresPayload 菜单会被忽略,避免默认 toolbar 渲染无法处理的按钮。\n * 分割线会自动去掉开头、结尾和连续项,避免被跳过的菜单留下空分隔。\n */\nexport const resolveToolbarMenu = (\n toolbarConfig: ToolbarConfig = defaultToolbarConfig,\n menuSchema: MenuItem[] = defaultMenuSchema\n): ResolvedToolbarItem[] => {\n const menuMap = createMenuMap(menuSchema);\n const baseKeys = toolbarConfig.toolbarKeys ?? defaultToolbarConfig.toolbarKeys ?? [];\n const toolbarKeys = applyToolbarConfigOverrides(baseKeys, toolbarConfig);\n const excludeKeys = new Set(toolbarConfig.excludeKeys ?? []);\n let separatorIndex = 0;\n\n const resolvedItems = toolbarKeys.reduce<ResolvedToolbarItem[]>((items, key) => {\n const nextItems = resolveToolbarKey(key, menuMap, excludeKeys, separatorIndex);\n\n if (key === '|') separatorIndex += 1;\n\n nextItems.forEach((item) => {\n if (shouldKeepResolvedToolbarItem(item, items)) {\n items.push(item);\n }\n });\n\n return items;\n }, []);\n\n return trimTrailingToolbarSeparators(resolvedItems);\n};\n"],"names":["codeBlockLanguagePanel","codeBlockLanguagePayloadPanel","textColorPanel","backgroundColorPanel","fontSizePanel","fontFamilyPanel","lineHeightPanel","tableInsertPanel","BRIDGERTE_TABLE_INSERT_MAX_ROWS","BRIDGERTE_TABLE_INSERT_MAX_COLS","tableHeaderMenuItems","defaultMenuSchema","commandStateValueByType","command","getCommandStateMatchValue","_a","isCommandStateForCommand","state","matchValue","isMenuItemCommandState","item","createDisabledCommandStates","menuSchema","defaultToolbarConfig","isToolbarGroupConfig","key","createMenuMap","shouldExcludeToolbarKey","excludeKeys","menuKey","applyToolbarConfigOverrides","baseKeys","toolbarConfig","filteredKeys","insertIndex","resolveToolbarKey","menuMap","separatorIndex","items","shouldKeepResolvedToolbarItem","previousItem","trimTrailingToolbarSeparators","resolveToolbarMenu","toolbarKeys","resolvedItems","nextItems"],"mappings":"wHAYaA,EAA6C,CACxD,GAAI,sBACJ,MAAO,OACP,OAAQ,CACN,CACE,KAAM,SACN,KAAM,WACN,MAAO,KACP,aAAc,GACd,QAAS,CACP,CAAE,MAAO,MAAO,MAAO,EAAA,EACvB,CAAE,MAAO,OAAQ,MAAO,aAAA,EACxB,CAAE,MAAO,IAAK,MAAO,GAAA,EACrB,CAAE,MAAO,MAAO,MAAO,KAAA,EACvB,CAAE,MAAO,KAAM,MAAO,QAAA,EACtB,CAAE,MAAO,MAAO,MAAO,KAAA,EACvB,CAAE,MAAO,OAAQ,MAAO,MAAA,EACxB,CAAE,MAAO,aAAc,MAAO,QAAA,EAC9B,CAAE,MAAO,KAAM,MAAO,IAAA,EACtB,CAAE,MAAO,OAAQ,MAAO,MAAA,EACxB,CAAE,MAAO,OAAQ,MAAO,MAAA,EACxB,CAAE,MAAO,aAAc,MAAO,YAAA,EAC9B,CAAE,MAAO,OAAQ,MAAO,MAAA,EACxB,CAAE,MAAO,SAAU,MAAO,QAAA,EAC1B,CAAE,MAAO,WAAY,MAAO,UAAA,EAC5B,CAAE,MAAO,MAAO,MAAO,KAAA,EACvB,CAAE,MAAO,SAAU,MAAO,QAAA,EAC1B,CAAE,MAAO,OAAQ,MAAO,MAAA,EACxB,CAAE,MAAO,MAAO,MAAO,KAAA,EACvB,CAAE,MAAO,QAAS,MAAO,OAAA,EACzB,CAAE,MAAO,OAAQ,MAAO,MAAA,EACxB,CAAE,MAAO,MAAO,MAAO,KAAA,EACvB,CAAE,MAAO,aAAc,MAAO,YAAA,EAC9B,CAAE,MAAO,MAAO,MAAO,KAAA,EACvB,CAAE,MAAO,MAAO,MAAO,KAAA,EACvB,CAAE,MAAO,OAAQ,MAAO,MAAA,CAAO,CACjC,CACF,CAEJ,EAO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,OAAOA,CACT,EAQaI,EAAqB,CAChCV,EAA+BT,EAC/BD,EAAyBX,IACC,CAC1B,MAAMyB,EAAUV,EAAcJ,CAAU,EAClCS,EAAWC,EAAc,aAAeT,EAAqB,aAAe,CAAA,EAC5EoB,EAAcb,EAA4BC,EAAUC,CAAa,EACjEJ,EAAc,IAAI,IAAII,EAAc,aAAe,CAAA,CAAE,EAC3D,IAAIK,EAAiB,EAErB,MAAMO,EAAgBD,EAAY,OAA8B,CAACL,EAAOb,IAAQ,CAC9E,MAAMoB,EAAYV,EAAkBV,EAAKW,EAASR,EAAaS,CAAc,EAE7E,OAAIZ,IAAQ,MAAKY,GAAkB,GAEnCQ,EAAU,QAASzB,GAAS,CACtBmB,EAA8BnB,EAAMkB,CAAK,GAC3CA,EAAM,KAAKlB,CAAI,CAEnB,CAAC,EAEMkB,CACT,EAAG,CAAA,CAAE,EAEL,OAAOG,EAA8BG,CAAa,CACpD"}
|
package/dist/native-spec.d.ts
CHANGED
|
@@ -170,8 +170,8 @@ export type PasteHook = (request: PasteRequest) => PasteHookResult | Promise<Pas
|
|
|
170
170
|
/**
|
|
171
171
|
* toolbar JSON 配置里的菜单组。
|
|
172
172
|
*
|
|
173
|
-
* `menuKeys` 使用菜单 schema 的稳定 id,DOM
|
|
174
|
-
*
|
|
173
|
+
* `menuKeys` 使用菜单 schema 的稳定 id,DOM 渲染为一个分组入口,
|
|
174
|
+
* 点击后打开纵向收纳菜单;RN/Flutter/WebView 可按同一结构自绘平台菜单。
|
|
175
175
|
*/
|
|
176
176
|
export type ToolbarGroupConfig = {
|
|
177
177
|
key: string;
|
|
@@ -283,7 +283,7 @@ export type FormatClearScope = 'selection' | 'block';
|
|
|
283
283
|
/**
|
|
284
284
|
* 代码块语言标识。
|
|
285
285
|
*
|
|
286
|
-
* 保持 string 是为了兼容 highlight.js
|
|
286
|
+
* 保持 string 是为了兼容 Shiki、highlight.js 或业务自定义语言表。
|
|
287
287
|
*/
|
|
288
288
|
export type CodeBlockLanguage = string;
|
|
289
289
|
/**
|
|
@@ -527,7 +527,14 @@ export type SlashCommandMenuAnchorRect = {
|
|
|
527
527
|
width: number;
|
|
528
528
|
height: number;
|
|
529
529
|
};
|
|
530
|
+
/**
|
|
531
|
+
* slash command 菜单展示配置。
|
|
532
|
+
*
|
|
533
|
+
* `showIcon` 只决定默认候选菜单是否展示 icon;候选数据仍保留 icon key,方便 DOM、
|
|
534
|
+
* WebView 或业务自绘层按自己的 UI 策略渲染。
|
|
535
|
+
*/
|
|
530
536
|
export type SlashCommandMenuConfig = {
|
|
537
|
+
showIcon?: boolean;
|
|
531
538
|
loadingText?: string;
|
|
532
539
|
emptyText?: string;
|
|
533
540
|
errorText?: string;
|
package/dist/native-spec.js
CHANGED
|
@@ -10,27 +10,35 @@ const h = {
|
|
|
10
10
|
defaultValue: "",
|
|
11
11
|
options: [
|
|
12
12
|
{ label: "纯文本", value: "" },
|
|
13
|
+
{ label: "Bash", value: "shellscript" },
|
|
13
14
|
{ label: "C", value: "c" },
|
|
14
|
-
{ label: "C-like", value: "clike" },
|
|
15
15
|
{ label: "C++", value: "cpp" },
|
|
16
|
+
{ label: "C#", value: "csharp" },
|
|
16
17
|
{ label: "CSS", value: "css" },
|
|
18
|
+
{ label: "Dart", value: "dart" },
|
|
19
|
+
{ label: "Dockerfile", value: "docker" },
|
|
20
|
+
{ label: "Go", value: "go" },
|
|
17
21
|
{ label: "HTML", value: "html" },
|
|
18
22
|
{ label: "Java", value: "java" },
|
|
19
23
|
{ label: "JavaScript", value: "javascript" },
|
|
20
24
|
{ label: "JSON", value: "json" },
|
|
25
|
+
{ label: "Kotlin", value: "kotlin" },
|
|
21
26
|
{ label: "Markdown", value: "markdown" },
|
|
22
|
-
{ label: "
|
|
23
|
-
{ label: "PowerShell", value: "powershell" },
|
|
27
|
+
{ label: "PHP", value: "php" },
|
|
24
28
|
{ label: "Python", value: "python" },
|
|
25
29
|
{ label: "Rust", value: "rust" },
|
|
26
30
|
{ label: "SQL", value: "sql" },
|
|
27
31
|
{ label: "Swift", value: "swift" },
|
|
32
|
+
{ label: "TOML", value: "toml" },
|
|
33
|
+
{ label: "TSX", value: "tsx" },
|
|
28
34
|
{ label: "TypeScript", value: "typescript" },
|
|
29
|
-
{ label: "
|
|
35
|
+
{ label: "Vue", value: "vue" },
|
|
36
|
+
{ label: "XML", value: "xml" },
|
|
37
|
+
{ label: "YAML", value: "yaml" }
|
|
30
38
|
]
|
|
31
39
|
}
|
|
32
40
|
]
|
|
33
|
-
},
|
|
41
|
+
}, C = h, f = {
|
|
34
42
|
id: "text-color",
|
|
35
43
|
title: "文字颜色",
|
|
36
44
|
fields: [
|
|
@@ -85,7 +93,7 @@ const h = {
|
|
|
85
93
|
]
|
|
86
94
|
}
|
|
87
95
|
]
|
|
88
|
-
},
|
|
96
|
+
}, S = {
|
|
89
97
|
id: "line-height",
|
|
90
98
|
title: "行高",
|
|
91
99
|
fields: [
|
|
@@ -101,7 +109,7 @@ const h = {
|
|
|
101
109
|
]
|
|
102
110
|
}
|
|
103
111
|
]
|
|
104
|
-
},
|
|
112
|
+
}, w = {
|
|
105
113
|
id: "table-insert",
|
|
106
114
|
title: "插入表格",
|
|
107
115
|
fields: [
|
|
@@ -124,7 +132,7 @@ const h = {
|
|
|
124
132
|
step: 1
|
|
125
133
|
}
|
|
126
134
|
]
|
|
127
|
-
},
|
|
135
|
+
}, T = [
|
|
128
136
|
{
|
|
129
137
|
id: "table-insert-row-after",
|
|
130
138
|
command: { type: "table.insertRow", direction: "after" },
|
|
@@ -260,7 +268,7 @@ const h = {
|
|
|
260
268
|
icon: "wrap-text",
|
|
261
269
|
group: "style",
|
|
262
270
|
requiresPayload: !0,
|
|
263
|
-
payloadPanel:
|
|
271
|
+
payloadPanel: S
|
|
264
272
|
},
|
|
265
273
|
{
|
|
266
274
|
id: "paragraph",
|
|
@@ -424,9 +432,9 @@ const h = {
|
|
|
424
432
|
icon: "table",
|
|
425
433
|
group: "table",
|
|
426
434
|
requiresPayload: !0,
|
|
427
|
-
payloadPanel:
|
|
435
|
+
payloadPanel: w
|
|
428
436
|
},
|
|
429
|
-
...
|
|
437
|
+
...T,
|
|
430
438
|
{
|
|
431
439
|
id: "slash-command",
|
|
432
440
|
command: { type: "slash.open" },
|
|
@@ -469,11 +477,11 @@ const h = {
|
|
|
469
477
|
}, m = (e) => {
|
|
470
478
|
var l;
|
|
471
479
|
return (l = r[e.type]) == null ? void 0 : l.call(r, e);
|
|
472
|
-
},
|
|
480
|
+
}, K = (e, l) => {
|
|
473
481
|
const a = m(e);
|
|
474
482
|
return l.command === e.type && (a === void 0 || l.value === a);
|
|
475
|
-
}, _ = (e, l) =>
|
|
476
|
-
function
|
|
483
|
+
}, _ = (e, l) => K(e.command, l);
|
|
484
|
+
function A(e = p) {
|
|
477
485
|
return e.map((l) => ({
|
|
478
486
|
command: l.command.type,
|
|
479
487
|
active: !1,
|
|
@@ -481,7 +489,7 @@ function z(e = p) {
|
|
|
481
489
|
value: m(l.command)
|
|
482
490
|
}));
|
|
483
491
|
}
|
|
484
|
-
const
|
|
492
|
+
const s = {
|
|
485
493
|
toolbarKeys: [
|
|
486
494
|
"undo",
|
|
487
495
|
"redo",
|
|
@@ -530,32 +538,32 @@ const u = {
|
|
|
530
538
|
"|",
|
|
531
539
|
"fullscreen"
|
|
532
540
|
]
|
|
533
|
-
},
|
|
541
|
+
}, M = (e) => typeof e == "object" && Array.isArray(e.menuKeys), q = (e) => new Map(
|
|
534
542
|
e.map((l) => [l.id, l])
|
|
535
|
-
), I = (e, l) => typeof e == "string" ? e !== "|" && l.has(e) : l.has(e.key) || e.menuKeys.every((a) => l.has(a)),
|
|
536
|
-
const a = new Set((l == null ? void 0 : l.excludeKeys) ?? []), n = e.filter((
|
|
543
|
+
), I = (e, l) => typeof e == "string" ? e !== "|" && l.has(e) : l.has(e.key) || e.menuKeys.every((a) => l.has(a)), L = (e, l) => {
|
|
544
|
+
const a = new Set((l == null ? void 0 : l.excludeKeys) ?? []), n = e.filter((o) => !I(o, a));
|
|
537
545
|
if (!(l != null && l.insertKeys)) return n;
|
|
538
|
-
const
|
|
546
|
+
const t = Math.max(0, Math.min(l.insertKeys.index, n.length));
|
|
539
547
|
return [
|
|
540
|
-
...n.slice(0,
|
|
548
|
+
...n.slice(0, t),
|
|
541
549
|
...l.insertKeys.keys,
|
|
542
|
-
...n.slice(
|
|
550
|
+
...n.slice(t)
|
|
543
551
|
];
|
|
544
|
-
},
|
|
552
|
+
}, R = (e, l, a, n) => {
|
|
545
553
|
if (e === "|")
|
|
546
554
|
return [{ type: "separator", key: `separator-${n}` }];
|
|
547
555
|
if (typeof e == "string") {
|
|
548
|
-
const
|
|
549
|
-
return !
|
|
556
|
+
const t = l.get(e);
|
|
557
|
+
return !t || t.requiresPayload && !t.payloadPanel || a.has(t.id) ? [] : [{ type: "button", item: t }];
|
|
550
558
|
}
|
|
551
|
-
if (
|
|
552
|
-
const
|
|
553
|
-
return
|
|
559
|
+
if (M(e)) {
|
|
560
|
+
const t = e.menuKeys.filter((o) => !a.has(o)).map((o) => l.get(o)).filter((o) => o !== void 0 && (!o.requiresPayload || o.payloadPanel !== void 0));
|
|
561
|
+
return t.length > 0 ? [{
|
|
554
562
|
type: "group",
|
|
555
563
|
key: e.key,
|
|
556
564
|
title: e.title,
|
|
557
565
|
icon: e.icon,
|
|
558
|
-
items:
|
|
566
|
+
items: t
|
|
559
567
|
}] : [];
|
|
560
568
|
}
|
|
561
569
|
return [];
|
|
@@ -563,32 +571,32 @@ const u = {
|
|
|
563
571
|
if (e.type !== "separator") return !0;
|
|
564
572
|
const a = l[l.length - 1];
|
|
565
573
|
return a !== void 0 && a.type !== "separator";
|
|
566
|
-
},
|
|
574
|
+
}, V = (e) => {
|
|
567
575
|
var l;
|
|
568
576
|
for (; ((l = e.at(-1)) == null ? void 0 : l.type) === "separator"; )
|
|
569
577
|
e.pop();
|
|
570
578
|
return e;
|
|
571
|
-
},
|
|
572
|
-
const a =
|
|
579
|
+
}, z = (e = s, l = p) => {
|
|
580
|
+
const a = q(l), n = e.toolbarKeys ?? s.toolbarKeys ?? [], t = L(n, e), o = new Set(e.excludeKeys ?? []);
|
|
573
581
|
let d = 0;
|
|
574
|
-
const b =
|
|
575
|
-
const g =
|
|
576
|
-
return c === "|" && (d += 1), g.forEach((
|
|
577
|
-
E(
|
|
582
|
+
const b = t.reduce((i, c) => {
|
|
583
|
+
const g = R(c, a, o, d);
|
|
584
|
+
return c === "|" && (d += 1), g.forEach((u) => {
|
|
585
|
+
E(u, i) && i.push(u);
|
|
578
586
|
}), i;
|
|
579
587
|
}, []);
|
|
580
|
-
return
|
|
588
|
+
return V(b);
|
|
581
589
|
};
|
|
582
590
|
export {
|
|
583
591
|
h as codeBlockLanguagePanel,
|
|
584
|
-
|
|
585
|
-
|
|
592
|
+
C as codeBlockLanguagePayloadPanel,
|
|
593
|
+
A as createDisabledCommandStates,
|
|
586
594
|
p as defaultMenuSchema,
|
|
587
|
-
|
|
595
|
+
s as defaultToolbarConfig,
|
|
588
596
|
m as getCommandStateMatchValue,
|
|
589
|
-
|
|
597
|
+
K as isCommandStateForCommand,
|
|
590
598
|
_ as isMenuItemCommandState,
|
|
591
|
-
|
|
592
|
-
|
|
599
|
+
z as resolveToolbarMenu,
|
|
600
|
+
T as tableHeaderMenuItems
|
|
593
601
|
};
|
|
594
602
|
//# sourceMappingURL=native-spec.js.map
|