math.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. // 数学公式组件
  2. // 该组件用于展示数学公式,使用 MathJax 渲染公式内容
  3. import { commonSetProperty } from './common';
  4. export function getMathProperty() {
  5. return {
  6. ...commonSetProperty,
  7. };
  8. }
  9. // 按用途分类的数学公式宏列表
  10. export const mathMacrosListByCategory = {
  11. // 关系符号
  12. relation: [
  13. 'approxeq',
  14. 'backsimeq',
  15. 'bumpeq',
  16. 'Bumpeq',
  17. 'circeq',
  18. 'doteqdot',
  19. 'Doteq',
  20. 'eqcirc',
  21. 'eqsim',
  22. 'eqslantgtr',
  23. 'eqslantless',
  24. 'fallingdotseq',
  25. 'geqq',
  26. 'geqslant',
  27. 'ggg',
  28. 'gggtr',
  29. 'gnapprox',
  30. 'gnsim',
  31. 'gtrapprox',
  32. 'gtrdot',
  33. 'gtreqless',
  34. 'gtreqqless',
  35. 'gtrless',
  36. 'gtrsim',
  37. 'leqq',
  38. 'leqslant',
  39. 'lessapprox',
  40. 'lessdot',
  41. 'lesseqgtr',
  42. 'lesseqqgtr',
  43. 'lessgtr',
  44. 'lesssim',
  45. 'lll',
  46. 'llless',
  47. 'lnapprox',
  48. 'lneqq',
  49. 'lnsim',
  50. 'ncong',
  51. 'neq',
  52. 'ngtr',
  53. 'nless',
  54. 'nprec',
  55. 'npreceq',
  56. 'nsim',
  57. 'nsucc',
  58. 'nsucceq',
  59. 'ntriangleleft',
  60. 'ntrianglelefteq',
  61. 'ntriangleright',
  62. 'ntrianglerighteq',
  63. 'prec',
  64. 'precapprox',
  65. 'preccurlyeq',
  66. 'precnapprox',
  67. 'precneqq',
  68. 'precnsim',
  69. 'precsim',
  70. 'succ',
  71. 'succapprox',
  72. 'succcurlyeq',
  73. 'succnapprox',
  74. 'succneqq',
  75. 'succnsim',
  76. 'succsim',
  77. 'Subset',
  78. 'subseteqq',
  79. 'Supset',
  80. 'supseteqq',
  81. 'sim',
  82. 'simeq',
  83. 'thickapprox',
  84. 'thicksim',
  85. 'trianglelefteq',
  86. 'trianglerighteq',
  87. 'triangleq',
  88. 'vartriangle',
  89. 'vartriangleleft',
  90. 'vartriangleright',
  91. 'vdash',
  92. 'vDash',
  93. 'Vdash',
  94. 'Vvdash',
  95. 'models',
  96. 'nvdash',
  97. 'shortmid',
  98. 'shortparallel',
  99. 'mid',
  100. 'parallel',
  101. 'dashv',
  102. 'nvDash',
  103. 'nVdash',
  104. 'nVDash',
  105. 'between',
  106. 'because',
  107. 'therefore',
  108. 'Join',
  109. 'leadsto',
  110. 'pitchfork',
  111. 'propto',
  112. 'varpropto',
  113. 'restriction',
  114. 'smallfrown',
  115. 'smallsmile',
  116. 'smile',
  117. 'frown',
  118. 'asymp',
  119. 'approx',
  120. 'cong',
  121. 'equiv',
  122. 'ne',
  123. 'notag',
  124. 'preceq',
  125. 'succeq',
  126. ],
  127. // 箭头符号
  128. arrows: [
  129. 'backepsilon',
  130. 'curvearrowleft',
  131. 'curvearrowright',
  132. 'dashleftarrow',
  133. 'dashrightarrow',
  134. 'downdownarrows',
  135. 'downharpoonleft',
  136. 'downharpoonright',
  137. 'hookleftarrow',
  138. 'hookrightarrow',
  139. 'leftarrow',
  140. 'Leftarrow',
  141. 'leftarrowtail',
  142. 'leftleftarrows',
  143. 'leftrightarrow',
  144. 'Leftrightarrow',
  145. 'leftrightarrows',
  146. 'leftrightharpoons',
  147. 'leftrightsquigarrow',
  148. 'looparrowleft',
  149. 'looparrowright',
  150. 'Lsh',
  151. 'rightarrow',
  152. 'Rightarrow',
  153. 'rightarrowtail',
  154. 'rightleftarrows',
  155. 'rightleftharpoons',
  156. 'rightrightarrows',
  157. 'rightsquigarrow',
  158. 'Rrightarrow',
  159. 'Rsh',
  160. 'twoheadleftarrow',
  161. 'twoheadrightarrow',
  162. 'upharpoonleft',
  163. 'upharpoonright',
  164. 'upuparrows',
  165. 'implies',
  166. 'impliedby',
  167. 'leadsto',
  168. 'mapsto',
  169. 'nleftarrow',
  170. 'nLeftarrow',
  171. 'nleftrightarrow',
  172. 'nLeftrightarrow',
  173. 'nrightarrow',
  174. 'nRightarrow',
  175. 'xleftarrow{1}',
  176. 'xrightarrow{1}',
  177. ],
  178. // 运算符号
  179. operators: [
  180. 'barwedge',
  181. 'bigstar',
  182. 'binom{1}{2}',
  183. 'boxdot',
  184. 'boxminus',
  185. 'boxplus',
  186. 'boxtimes',
  187. 'Cap',
  188. 'centerdot',
  189. 'cfrac{1}{2}',
  190. 'checkmark',
  191. 'circledast',
  192. 'circledcirc',
  193. 'circleddash',
  194. 'complement',
  195. 'Cup',
  196. 'curlyvee',
  197. 'curlywedge',
  198. 'dbinom{1}{2}',
  199. 'ddddot{x}',
  200. 'dddot{x}',
  201. 'DeclareMathOperator{\\foo}{bar}',
  202. 'dfrac{a}{b}',
  203. 'Diamond',
  204. 'divideontimes',
  205. 'dotplus',
  206. 'doublebarwedge',
  207. 'doublecap',
  208. 'doublecup',
  209. 'frac{1}{2}',
  210. 'genfrac{}{}{}{}{1}{4}',
  211. 'idotsint',
  212. 'iiiint',
  213. 'int',
  214. 'iint',
  215. 'iiint',
  216. 'intercal',
  217. 'land',
  218. 'lor',
  219. 'maltese',
  220. 'measuredangle',
  221. 'mho',
  222. 'multimap',
  223. 'prod',
  224. 'projlim',
  225. 'rtimes',
  226. 'ltimes',
  227. 'sideset{^*}{_a}\\sum',
  228. 'smallsetminus',
  229. 'sqcap',
  230. 'sqcup',
  231. 'star',
  232. 'substack{a \\\\ b}',
  233. 'sum',
  234. 'tbinom{1}{2}',
  235. 'tfrac{1}{2}',
  236. 'varinjlim',
  237. 'varliminf',
  238. 'varlimsup',
  239. 'varprojlim',
  240. 'wedge',
  241. 'vee',
  242. 'veebar',
  243. 'wr',
  244. ],
  245. // 集合符号
  246. sets: [
  247. 'beth',
  248. 'daleth',
  249. 'Finv',
  250. 'Game',
  251. 'gimel',
  252. 'varnothing',
  253. 'emptyset',
  254. 'in',
  255. 'notin',
  256. 'ni',
  257. 'owns',
  258. 'subset',
  259. 'supset',
  260. 'subseteq',
  261. 'supseteq',
  262. 'sqsubset',
  263. 'sqsupset',
  264. 'sqsubseteq',
  265. 'sqsupseteq',
  266. ],
  267. // 物理符号
  268. physics: [
  269. 'abs{a}',
  270. 'acomm{A}{B}',
  271. 'acos(x)',
  272. 'acosine',
  273. 'acot(x)',
  274. 'acsc(x)',
  275. 'admat{1, 2, 3}',
  276. 'anticommutator{A}{B}',
  277. 'arccos(x)',
  278. 'arccot(x)',
  279. 'arccsc(x)',
  280. 'arcsec(x)',
  281. 'arcsin(x)',
  282. 'arctan(x)',
  283. 'asec(x)',
  284. 'asin(x)',
  285. 'atan(x)',
  286. 'bmqty{x}',
  287. 'bqty{x}',
  288. 'Bqty{x}',
  289. 'bra{\\phi}',
  290. 'braket{a}{b}',
  291. 'comm{A}{B}',
  292. 'cos{1}',
  293. 'cosecant{1}',
  294. 'cosh{1}',
  295. 'cot{1}',
  296. 'coth{1}',
  297. 'cross{1}',
  298. 'csc{1}',
  299. 'csch{1}',
  300. 'curl{1}',
  301. 'dd{1}',
  302. 'det{1}',
  303. 'diagonalmatrix{1}',
  304. 'diffd{1}',
  305. 'div{1}',
  306. 'dv{1}',
  307. 'dyad{1}',
  308. 'erf{1}',
  309. 'ev{1}',
  310. 'eval{1}',
  311. 'exp{1}',
  312. 'expval{1}',
  313. 'fdv{1}',
  314. 'flatfrac{1}{2}',
  315. 'grad{1}',
  316. 'hypcosecant{1}',
  317. 'hypcosine{1}',
  318. 'hypcotangent{1}',
  319. 'hypsecant{1}',
  320. 'hypsine{1}',
  321. 'hyptangent{1}',
  322. 'Im{1}',
  323. 'imat{1}',
  324. 'ip{1}',
  325. 'ket{1}',
  326. 'ketbra{1}',
  327. 'laplacian{1}',
  328. 'ln{1}',
  329. 'log{1}',
  330. 'mdet{a & b \\newline c & d}',
  331. 'mel{n}{A}{m}',
  332. 'mqty{a & b \\newline c & d}',
  333. 'naturallogarithm{1}',
  334. 'norm{a}',
  335. 'op{1}',
  336. 'order{1}',
  337. 'pb{A}{B}',
  338. 'pdv{f}{x}',
  339. 'pmat{n}',
  340. 'pmqty{1}',
  341. 'Pmqty{1}',
  342. 'pqty{1}',
  343. 'Pr(tall)',
  344. 'pv{\\int f(z) \\dd{z}}',
  345. 'PV{\\int f(z) \\dd{z}}',
  346. 'qty{3.0}{m/s}',
  347. 'Re{z}',
  348. 'Res[f(z)]',
  349. 'sbmqty{1}',
  350. 'sec{x}',
  351. 'sech{1}',
  352. 'sin{1}',
  353. 'sinh{1}',
  354. 'smdet{1}',
  355. 'smqty{a & b \\newline c & d}',
  356. 'spmqty{a & b \\newline c & d}',
  357. 'sPmqty{a & b \\newline c & d}',
  358. 'svmqty{a & b \\newline c & d}',
  359. 'tan{1}',
  360. 'tanh{1}',
  361. 'tr{1}',
  362. 'Tr{1}',
  363. 'va{1}',
  364. 'var{F[g(x)]}',
  365. 'vb{a}',
  366. 'vdot',
  367. 'vmqty{x}',
  368. 'vnabla',
  369. 'vqty{x}',
  370. 'vu{a}',
  371. 'xmat{1}{2}{3}',
  372. 'zmat{2}{2}',
  373. ],
  374. // 希腊字母/变体
  375. greek: [
  376. 'varDelta',
  377. 'varGamma',
  378. 'varLambda',
  379. 'varOmega',
  380. 'varPhi',
  381. 'varPi',
  382. 'varPsi',
  383. 'varSigma',
  384. 'varTheta',
  385. 'varUpsilon',
  386. 'varXi',
  387. ],
  388. // 括号/分隔符
  389. brackets: ['lvert', 'lVert', 'rvert', 'rVert', 'llcorner', 'lrcorner', 'ulcorner', 'urcorner'],
  390. // 其他(文本、空格、特殊符号等)
  391. others: [
  392. 'Bbbk',
  393. 'blacklozenge',
  394. 'blacksquare',
  395. 'blacktriangle',
  396. 'blacktriangledown',
  397. 'blacktriangleleft',
  398. 'blacktriangleright',
  399. 'Box',
  400. 'boxed{Cup}',
  401. 'diagdown',
  402. 'diagup',
  403. 'eqref{eq1}',
  404. 'eth',
  405. 'hslash',
  406. 'mathring{x}',
  407. 'negmedspace',
  408. 'negthickspace',
  409. 'nexists',
  410. 'nobreakspace',
  411. 'operatorname{foo}',
  412. 'shoveleft x + y = z \\newline a + b = c',
  413. 'shoveright x + y = z \\newline a + b = c',
  414. 'sphericalangle',
  415. 'tag{1}',
  416. 'yen',
  417. ],
  418. };
  419. export const onlyMultiMacros = ['shoveleft', 'shoveright'];
  420. export const onlyAlignMacros = ['admat', 'xmat', 'zmat'];
  421. export const categoryList = {
  422. operators: '运算符号',
  423. relation: '关系符号',
  424. arrows: '箭头符号',
  425. sets: '集合符号',
  426. physics: '物理符号',
  427. greek: '希腊字母',
  428. brackets: '分隔符',
  429. others: '其他',
  430. };
  431. export function getMathData() {
  432. return {
  433. type: 'math',
  434. title: '公式',
  435. property: getMathProperty(),
  436. math: '$\n$', // 公式内容
  437. mind_map: {
  438. node_list: [{ name: '公式组件' }],
  439. },
  440. };
  441. }