@dossier/d-quill
Advanced tools
Comparing version 0.2.0 to 0.2.1
/// <reference types="react" /> | ||
import Delta from "quill-delta"; | ||
import { InputStatus } from "@dossier/mithra-ui"; | ||
/** | ||
@@ -19,3 +20,3 @@ * Two themes: | ||
* The content of editor when it's updating | ||
* (TODO: this prop will cause performance issue when typing very fast, not use it at the moment) | ||
* (TODO: this prop will cause performance issue when typing very fast, not use it at the moment. May not need this prop at all.) | ||
*/ | ||
@@ -45,3 +46,7 @@ content?: Delta; | ||
id?: string; | ||
/** | ||
* Status of the editor. | ||
*/ | ||
status?: InputStatus; | ||
} | ||
export default function RichTextEditor(props: RichTextEditorProps): JSX.Element; |
@@ -1,4 +0,16 @@ | ||
import React, { useCallback, useContext, useEffect, useRef, useState, } from "react"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
import { useCallback, useContext, useEffect, useRef, useState, } from "react"; | ||
import Quill from "quill"; | ||
import { MithraContext, useOutsideClickListener } from "@dossier/mithra-ui"; | ||
import { MithraContext, useOutsideClickListener, } from "@dossier/mithra-ui"; | ||
import { deltaToHtmlConverter, isEqualDelta, usePrevious, } from "../utils/richTextEditorUtils"; | ||
@@ -15,3 +27,3 @@ /** | ||
export default function RichTextEditor(props) { | ||
var initialContent = props.initialContent, content = props.content, onChange = props.onChange, placeholder = props.placeholder, disabled = props.disabled, _a = props.theme, theme = _a === void 0 ? ToolBarTheme.FLOAT : _a, className = props.className, id = props.id; | ||
var initialContent = props.initialContent, content = props.content, onChange = props.onChange, placeholder = props.placeholder, disabled = props.disabled, _a = props.theme, theme = _a === void 0 ? ToolBarTheme.FLOAT : _a, className = props.className, id = props.id, status = props.status; | ||
var getMessage = useContext(MithraContext).getMessage; | ||
@@ -87,2 +99,17 @@ var editorRef = useRef(null); | ||
}, [editor, content, preContent]); | ||
var rePositionLinkEditor = function (linkEditor) { | ||
var linkEditorRect = linkEditor.getBoundingClientRect(); | ||
var leftPixel = linkEditor.style.left.split("px"); | ||
var leftPixelInt = parseInt(leftPixel[0]); | ||
var linkEditorContainer = document.querySelector(".ql-container"); | ||
var linkEditorContainerRect = linkEditorContainer.getBoundingClientRect(); | ||
if (leftPixelInt < 0) { | ||
linkEditor.style.left = "0px"; | ||
linkEditor.style.right = ""; | ||
} | ||
else if (linkEditorRect.right > linkEditorContainerRect.right) { | ||
linkEditor.style.left = ""; | ||
linkEditor.style.right = "0px"; | ||
} | ||
}; | ||
// Listen to link editor className changes and override texts | ||
@@ -95,2 +122,4 @@ useEffect(function () { | ||
mutations.forEach(function (mutation) { | ||
// Fixed wrong position of the link editor | ||
rePositionLinkEditor(linkEditor); | ||
if (mutation.target.classList.contains("ql-editing")) { | ||
@@ -115,2 +144,3 @@ saveLink.innerHTML = getMessage("gui.standard.save") || "Lagre"; | ||
disabled && "disabled", | ||
status, | ||
className, | ||
@@ -120,4 +150,3 @@ ] | ||
.join(" "); | ||
return (React.createElement("div", { id: id, className: computedClassName }, | ||
React.createElement("div", { ref: editorRef }))); | ||
return (_jsx("div", __assign({ id: id, className: computedClassName }, { children: _jsx("div", { ref: editorRef }, void 0) }), void 0)); | ||
} |
@@ -6,1 +6,2 @@ import Delta from "quill-delta"; | ||
export declare function deltaToHtmlConverter(content: Delta): string; | ||
export declare function isEmptyContent(content: Delta): boolean; |
@@ -25,1 +25,13 @@ import { useEffect, useRef } from "react"; | ||
} | ||
var emptyContent = { | ||
ops: [ | ||
{ | ||
insert: "\n", | ||
}, | ||
], | ||
}; | ||
export function isEmptyContent(content) { | ||
if (content) | ||
return isEqualDelta(content, emptyContent); | ||
return true; | ||
} |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "0.2.0"; | ||
export declare const VERSION = "0.2.1"; |
// THIS FILE IS GENERATED WHEN PUBLISHING TO NPM | ||
// DO NOT TOUCH | ||
export var VERSION = "0.2.0"; | ||
export var VERSION = "0.2.1"; |
{ | ||
"name": "@dossier/d-quill", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"private": false, | ||
@@ -29,2 +29,3 @@ "description": "A powerful React rich text editor", | ||
"dependencies": { | ||
"date-fns": "^2.25.0", | ||
"quill": "^1.3.6", | ||
@@ -31,0 +32,0 @@ "quill-delta": "^4.2.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
55361
1107
0
6
+ Addeddate-fns@^2.25.0
+ Added@babel/runtime@7.26.9(transitive)
+ Addeddate-fns@2.30.0(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)