Skip to content

Commit

Permalink
Ability to configure readonly mode and accept all react-native-webvie…
Browse files Browse the repository at this point in the history
…w versions
  • Loading branch information
wtomaszewski-applause committed Nov 14, 2023
1 parent 116ca0a commit 9a4e3ea
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"peerDependencies": {
"react": "*",
"react-native": "*",
"react-native-webview": "^11.0.0"
"react-native-webview": ">=11.0.0"
},
"jest": {
"preset": "react-native",
Expand Down
5 changes: 4 additions & 1 deletion src/constants/editor/create_quill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const create_quill = ({
theme,
customFonts = [],
customJS,
readonly = false,
}: {
id: string;
toolbar: 'false' | string;
Expand All @@ -16,6 +17,7 @@ export const create_quill = ({
theme: 'snow' | 'bubble';
customFonts: Array<string>;
customJS: string;
readonly: boolean;
}) => {
let font = '';
if (customFonts.length > 0) {
Expand Down Expand Up @@ -46,7 +48,8 @@ export const create_quill = ({
var quill = new Quill('#${id}', {
modules: { ${modules} },
placeholder: '${placeholder}',
theme: '${theme}'
theme: '${theme}',
readonly: ${readonly},
});
</script>
`;
Expand Down
3 changes: 3 additions & 0 deletions src/editor/quill-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface EditorProps {
onBlur?: () => void;
onFocus?: () => void;
customJS?: string;
readonly?: boolean;
}

export default class QuillEditor extends React.Component<
Expand Down Expand Up @@ -135,6 +136,7 @@ export default class QuillEditor extends React.Component<
customStyles = [],
defaultFontFamily = undefined,
customJS = '',
readonly = false,
} = this.props;

return createHtml({
Expand All @@ -155,6 +157,7 @@ export default class QuillEditor extends React.Component<
placeholderColor: theme.placeholder,
customStyles,
customJS,
readonly,
});
};

Expand Down
3 changes: 3 additions & 0 deletions src/utils/editor-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface CreateHtmlArgs {
fonts: Array<CustomFont>;
defaultFontFamily?: string;
customJS?: string;
readonly?: boolean;
}

const Inital_Args = {
Expand All @@ -49,6 +50,7 @@ const Inital_Args = {
customStyles: [],
fonts: [],
customJS: '',
readonly: false,
} as CreateHtmlArgs;

export const createHtml = (args: CreateHtmlArgs = Inital_Args) => {
Expand Down Expand Up @@ -101,6 +103,7 @@ export const createHtml = (args: CreateHtmlArgs = Inital_Args) => {
theme: args.theme,
customFonts: args.fonts.map((f) => getFontName(f.name)),
customJS: args.customJS ? args.customJS : '',
readonly: args.readonly ? args.readonly : false,
})}
${editor_js}
</body>
Expand Down

0 comments on commit 9a4e3ea

Please sign in to comment.