handler.sjs 873 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. var inlineTags = {
  2. abbr: 1,
  3. b: 1,
  4. big: 1,
  5. code: 1,
  6. del: 1,
  7. em: 1,
  8. i: 1,
  9. ins: 1,
  10. label: 1,
  11. q: 1,
  12. small: 1,
  13. span: 1,
  14. strong: 1
  15. }
  16. export default {
  17. // 从 rich-text 顶层标签的样式中取出一些给 rich-text
  18. getStyle: function(style) {
  19. if (style) {
  20. var i, j, res = '';
  21. if ((i = style.indexOf('display')) != -1)
  22. res = style.substring(i, (j = style.indexOf(';', i)) == -1 ? style.length : j);
  23. if ((i = style.indexOf('float')) != -1)
  24. res += ';' + style.substring(i, (j = style.indexOf(';', i)) == -1 ? style.length : j);
  25. return res;
  26. }
  27. },
  28. getNode: function(item) {
  29. return [item];
  30. },
  31. // 是否通过 rich-text 显示
  32. useRichText: function(item) {
  33. // rich-text 不支持 inline
  34. if (item.c || inlineTags[item.name] || (item.attrs.style && item.attrs.style.indexOf('display:inline') != -1))
  35. return false;
  36. return true;
  37. }
  38. }