Skip to content

Commit

Permalink
placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
stulip committed Dec 18, 2020
1 parent fc0e28c commit 6365fdf
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

### Fix
- Keyboard listener on unmount
- placeholder does not restore [issues 121](https://github.com/wxik/react-native-rich-editor/issues/121)

## 1.5.1
#### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ The editor component. Simply place this component in your view hierarchy to rece
* `onMessage`
Callback outside postMessage internal type processing
```
<img src="" ontouchstart="_.sendEvent('ImgClick')"/>
<img src="" onclick="_.sendEvent('ImgClick')" contenteditable="false"/>
```
* `commandDOM`
Expand Down
7 changes: 3 additions & 4 deletions examples/src/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ const imageList = [
'https://img.lesmao.vip/k/h256/R/MeiTu/1292.jpg',
];
const initHTML = `<br/>
<center><b onclick="_.sendEvent('TitleClick')" id="title" >Rich Editor</b></center>
<center><b onclick="_.sendEvent('TitleClick')" id="title" contenteditable="false">Rich Editor</b></center>
<center>
<a href="https://github.com/wxik/react-native-rich-editor">React Native</a>
<span>And</span>
<a href="https://github.com/wxik/flutter-rich-editor">Flutter</a>
</center>
<br/>
<img src="${imageList[0]}" onclick="_.sendEvent('ImgClick')"/>
<br/><br/>
<img src="${imageList[0]}" onclick="_.sendEvent('ImgClick')" contenteditable="false"/>
<br/>Click the picture to switch<br/>
`;

const phizIcon = require('./assets/phiz.png');
Expand Down Expand Up @@ -165,7 +165,6 @@ class Example extends React.Component {
);
// insert base64
// this.richText.current?.insertImage(`data:${image.mime};base64,${image.data}`);
// this.richText.current?.blurContentEditor();
}

onInsertLink() {
Expand Down
9 changes: 9 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ declare module 'react-native-pell-rich-editor' {
*/
onHeightChange?: (height: number) => void;

onMessage?: (message: {type: string; id: string; data?: any}) => void;

/**
* Styling for container or for Rich Editor more dark or light settings
*/
Expand Down Expand Up @@ -161,6 +163,13 @@ declare module 'react-native-pell-rich-editor' {

insertHTML: (html: string) => void;

/**
* $ = document.querySelector
* this.richText.current?.commandDOM(`$('#title').style.color='${color}'`);
* @param command
*/
commandDOM: (command: string) => void;

/**
* Returns whether the keyboard is on
*/
Expand Down
6 changes: 4 additions & 2 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ function createHTML(options = {}) {
content.autocomplete = 'off';
content.className = "pell-content";
content.oninput = function (_ref) {
// var firstChild = _ref.target.firstChild;
// if (firstChild && firstChild.nodeType === 3) exec(formatBlock, '<' + defaultParagraphSeparator + '>');else if (content.innerHTML === '<br>') content.innerHTML = '';
//TODO placeholder https://github.com/wxik/react-native-rich-editor/issues/121
var firstChild = _ref.target.firstChild;
if (firstChild && firstChild.nodeType === 3) exec(formatBlock, '<' + defaultParagraphSeparator + '>');else if (content.innerHTML === '<br>') content.innerHTML = '';
settings.onChange(content.innerHTML);
saveSelection();
};
Expand Down

0 comments on commit 6365fdf

Please sign in to comment.