@pie-lib/mask-markup 1.12.16-next.30 → 1.12.17

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/src/mask.jsx CHANGED
@@ -4,12 +4,12 @@ import get from 'lodash/get';
4
4
  import { withStyles } from '@material-ui/core/styles';
5
5
  import { MARK_TAGS } from './serialization';
6
6
 
7
- const Paragraph = withStyles(theme => ({
7
+ const Paragraph = withStyles((theme) => ({
8
8
  para: {
9
9
  paddingTop: 2 * theme.spacing.unit,
10
- paddingBottom: 2 * theme.spacing.unit
11
- }
12
- }))(props => <div className={props.classes.para}>{props.children}</div>);
10
+ paddingBottom: 2 * theme.spacing.unit,
11
+ },
12
+ }))((props) => <div className={props.classes.para}>{props.children}</div>);
13
13
 
14
14
  const restrictWhitespaceTypes = ['tbody', 'tr'];
15
15
 
@@ -24,8 +24,8 @@ const addText = (parentNode, text) => {
24
24
  }
25
25
  };
26
26
 
27
- const getMark = n => {
28
- const mark = n.leaves.find(leave => get(leave, 'marks', []).length);
27
+ const getMark = (n) => {
28
+ const mark = n.leaves.find((leave) => get(leave, 'marks', []).length);
29
29
 
30
30
  if (mark) {
31
31
  return mark.marks[0];
@@ -48,9 +48,9 @@ export const renderChildren = (layout, value, onChange, rootRenderChildren, pare
48
48
  children.push(
49
49
  <span
50
50
  dangerouslySetInnerHTML={{
51
- __html: `<math displaystyle="true">${n.nodes[0].innerHTML}</math>`
51
+ __html: `<math displaystyle="true">${n.nodes[0].innerHTML}</math>`,
52
52
  }}
53
- />
53
+ />,
54
54
  );
55
55
  return children;
56
56
  }
@@ -95,7 +95,7 @@ export const renderChildren = (layout, value, onChange, rootRenderChildren, pare
95
95
  children.push(
96
96
  <Tag key={key} {...n.data.attributes}>
97
97
  {subNodes}
98
- </Tag>
98
+ </Tag>,
99
99
  );
100
100
  } else {
101
101
  children.push(<Tag key={key} {...n.data.attributes} />);
@@ -108,9 +108,9 @@ export const renderChildren = (layout, value, onChange, rootRenderChildren, pare
108
108
 
109
109
  const MaskContainer = withStyles(() => ({
110
110
  main: {
111
- display: 'initial'
112
- }
113
- }))(props => <div className={props.classes.main}>{props.children}</div>);
111
+ display: 'initial',
112
+ },
113
+ }))((props) => <div className={props.classes.main}>{props.children}</div>);
114
114
 
115
115
  /**
116
116
  * Renders a layout that uses the slate.js Value model structure.
@@ -120,7 +120,7 @@ export default class Mask extends React.Component {
120
120
  renderChildren: PropTypes.func,
121
121
  layout: PropTypes.object,
122
122
  value: PropTypes.object,
123
- onChange: PropTypes.func
123
+ onChange: PropTypes.func,
124
124
  };
125
125
 
126
126
  handleChange = (id, value) => {
@@ -10,7 +10,7 @@ const MARK = ['em', 'strong', 'u'];
10
10
  const TEXT_NODE = 3;
11
11
  const COMMENT_NODE = 8;
12
12
 
13
- const attr = el => {
13
+ const attr = (el) => {
14
14
  if (!el.attributes || el.attributes.length <= 0) {
15
15
  return undefined;
16
16
  }
@@ -27,7 +27,7 @@ const attr = el => {
27
27
  return out;
28
28
  };
29
29
 
30
- const getObject = type => {
30
+ const getObject = (type) => {
31
31
  if (INLINE.includes(type)) {
32
32
  return 'inline';
33
33
  } else if (MARK.includes(type)) {
@@ -36,7 +36,7 @@ const getObject = type => {
36
36
  return 'block';
37
37
  };
38
38
 
39
- export const parseStyleString = s => {
39
+ export const parseStyleString = (s) => {
40
40
  const regex = /([\w-]*)\s*:\s*([^;]*)/g;
41
41
  let match;
42
42
  const result = {};
@@ -46,7 +46,7 @@ export const parseStyleString = s => {
46
46
  return result;
47
47
  };
48
48
 
49
- export const reactAttributes = o => toStyleObject(o, { camelize: true, addUnits: false });
49
+ export const reactAttributes = (o) => toStyleObject(o, { camelize: true, addUnits: false });
50
50
 
51
51
  const handleStyles = (el, attribute) => {
52
52
  const styleString = el.getAttribute(attribute);
@@ -62,7 +62,7 @@ const handleClass = (el, acc, attribute) => {
62
62
  return classNames;
63
63
  };
64
64
 
65
- const attributesToMap = el => (acc, attribute) => {
65
+ const attributesToMap = (el) => (acc, attribute) => {
66
66
  if (!el.getAttribute) {
67
67
  return acc;
68
68
  }
@@ -100,7 +100,7 @@ export const MARK_TAGS = {
100
100
  u: 'underline',
101
101
  s: 'strikethrough',
102
102
  code: 'code',
103
- strong: 'strong'
103
+ strong: 'strong',
104
104
  };
105
105
 
106
106
  const marks = {
@@ -111,9 +111,9 @@ const marks = {
111
111
  return {
112
112
  object: 'mark',
113
113
  type: mark,
114
- nodes: next(el.childNodes)
114
+ nodes: next(el.childNodes),
115
115
  };
116
- }
116
+ },
117
117
  };
118
118
 
119
119
  const rules = [
@@ -130,7 +130,7 @@ const rules = [
130
130
  if (el.nodeType === TEXT_NODE) {
131
131
  return {
132
132
  object: 'text',
133
- leaves: [{ text: el.textContent }]
133
+ leaves: [{ text: el.textContent }],
134
134
  };
135
135
  }
136
136
 
@@ -148,7 +148,7 @@ const rules = [
148
148
  if (el.tagName.toLowerCase() === 'math') {
149
149
  return {
150
150
  isMath: true,
151
- nodes: [el]
151
+ nodes: [el],
152
152
  };
153
153
  }
154
154
 
@@ -156,10 +156,10 @@ const rules = [
156
156
  object,
157
157
  type,
158
158
  data: { dataset: { ...el.dataset }, attributes: { ...allAttrs } },
159
- nodes: next(el.childNodes)
159
+ nodes: next(el.childNodes),
160
160
  };
161
- }
162
- }
161
+ },
162
+ },
163
163
  ];
164
164
 
165
165
  /**
@@ -168,4 +168,4 @@ const rules = [
168
168
  */
169
169
  const html = new Html({ rules, defaultBlock: 'span' });
170
170
 
171
- export const deserialize = s => html.deserialize(s, { toJSON: true });
171
+ export const deserialize = (s) => html.deserialize(s, { toJSON: true });
package/src/with-mask.jsx CHANGED
@@ -22,21 +22,14 @@ export const withMask = (type, renderChildren) => {
22
22
  */
23
23
  layout: PropTypes.object,
24
24
  value: PropTypes.object,
25
- onChange: PropTypes.func
25
+ onChange: PropTypes.func,
26
26
  };
27
27
 
28
28
  render() {
29
29
  const { markup, layout, value, onChange } = this.props;
30
30
 
31
31
  const maskLayout = layout ? layout : buildLayoutFromMarkup(markup, type);
32
- return (
33
- <Mask
34
- layout={maskLayout}
35
- value={value}
36
- onChange={onChange}
37
- renderChildren={renderChildren(this.props)}
38
- />
39
- );
32
+ return <Mask layout={maskLayout} value={value} onChange={onChange} renderChildren={renderChildren(this.props)} />;
40
33
  }
41
34
  };
42
35
  };