@dextinity/admin-rte 2.0.0-canary-20260729062014
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/LICENSE +24 -0
- package/lib/core/BlockElement.d.ts +29 -0
- package/lib/core/BlockElement.d.ts.map +1 -0
- package/lib/core/BlockElement.js +43 -0
- package/lib/core/Controls/BlockTypesControls.d.ts +16 -0
- package/lib/core/Controls/BlockTypesControls.d.ts.map +1 -0
- package/lib/core/Controls/BlockTypesControls.js +91 -0
- package/lib/core/Controls/ControlButton.d.ts +28 -0
- package/lib/core/Controls/ControlButton.d.ts.map +1 -0
- package/lib/core/Controls/ControlButton.js +62 -0
- package/lib/core/Controls/Controls.d.ts +3 -0
- package/lib/core/Controls/Controls.d.ts.map +1 -0
- package/lib/core/Controls/Controls.js +30 -0
- package/lib/core/Controls/CustomControls.d.ts +3 -0
- package/lib/core/Controls/CustomControls.d.ts.map +1 -0
- package/lib/core/Controls/CustomControls.js +20 -0
- package/lib/core/Controls/FeaturesButtonGroup.d.ts +30 -0
- package/lib/core/Controls/FeaturesButtonGroup.d.ts.map +1 -0
- package/lib/core/Controls/FeaturesButtonGroup.js +147 -0
- package/lib/core/Controls/HistoryContols.d.ts +3 -0
- package/lib/core/Controls/HistoryContols.d.ts.map +1 -0
- package/lib/core/Controls/HistoryContols.js +24 -0
- package/lib/core/Controls/InlineStyleTypeControls.d.ts +3 -0
- package/lib/core/Controls/InlineStyleTypeControls.d.ts.map +1 -0
- package/lib/core/Controls/InlineStyleTypeControls.js +29 -0
- package/lib/core/Controls/LinkControls.d.ts +26 -0
- package/lib/core/Controls/LinkControls.d.ts.map +1 -0
- package/lib/core/Controls/LinkControls.js +54 -0
- package/lib/core/Controls/ListsControls.d.ts +3 -0
- package/lib/core/Controls/ListsControls.d.ts.map +1 -0
- package/lib/core/Controls/ListsControls.js +30 -0
- package/lib/core/Controls/ListsIndentControls.d.ts +3 -0
- package/lib/core/Controls/ListsIndentControls.d.ts.map +1 -0
- package/lib/core/Controls/ListsIndentControls.js +27 -0
- package/lib/core/Controls/SpecialCharactersControls.d.ts +4 -0
- package/lib/core/Controls/SpecialCharactersControls.d.ts.map +1 -0
- package/lib/core/Controls/SpecialCharactersControls.js +20 -0
- package/lib/core/Controls/Toolbar/Toolbar.d.ts +28 -0
- package/lib/core/Controls/Toolbar/Toolbar.d.ts.map +1 -0
- package/lib/core/Controls/Toolbar/Toolbar.js +41 -0
- package/lib/core/Controls/Toolbar/Toolbar.styles.d.ts +14 -0
- package/lib/core/Controls/Toolbar/Toolbar.styles.d.ts.map +1 -0
- package/lib/core/Controls/Toolbar/Toolbar.styles.js +21 -0
- package/lib/core/Controls/TranslationControls.d.ts +4 -0
- package/lib/core/Controls/TranslationControls.d.ts.map +1 -0
- package/lib/core/Controls/TranslationControls.js +20 -0
- package/lib/core/Controls/useBlockTypes.d.ts +23 -0
- package/lib/core/Controls/useBlockTypes.d.ts.map +1 -0
- package/lib/core/Controls/useBlockTypes.js +116 -0
- package/lib/core/Controls/useHistory.d.ts +13 -0
- package/lib/core/Controls/useHistory.d.ts.map +1 -0
- package/lib/core/Controls/useHistory.js +63 -0
- package/lib/core/Controls/useInlineStyleType.d.ts +16 -0
- package/lib/core/Controls/useInlineStyleType.d.ts.map +1 -0
- package/lib/core/Controls/useInlineStyleType.js +148 -0
- package/lib/core/Controls/useListIndent.d.ts +14 -0
- package/lib/core/Controls/useListIndent.d.ts.map +1 -0
- package/lib/core/Controls/useListIndent.js +114 -0
- package/lib/core/Rte.d.ts +72 -0
- package/lib/core/Rte.d.ts.map +1 -0
- package/lib/core/Rte.js +256 -0
- package/lib/core/RteReadOnly.d.ts +19 -0
- package/lib/core/RteReadOnly.d.ts.map +1 -0
- package/lib/core/RteReadOnly.js +62 -0
- package/lib/core/defaultBlocktypeMap.d.ts +6 -0
- package/lib/core/defaultBlocktypeMap.d.ts.map +1 -0
- package/lib/core/defaultBlocktypeMap.js +235 -0
- package/lib/core/extension/Link/Decorator.d.ts +5 -0
- package/lib/core/extension/Link/Decorator.d.ts.map +1 -0
- package/lib/core/extension/Link/Decorator.js +13 -0
- package/lib/core/extension/Link/EditorComponent.d.ts +12 -0
- package/lib/core/extension/Link/EditorComponent.d.ts.map +1 -0
- package/lib/core/extension/Link/EditorComponent.js +14 -0
- package/lib/core/extension/Link/ToolbarButton.d.ts +3 -0
- package/lib/core/extension/Link/ToolbarButton.d.ts.map +1 -0
- package/lib/core/extension/Link/ToolbarButton.js +162 -0
- package/lib/core/extension/LinksRemove/ToolbarButton.d.ts +3 -0
- package/lib/core/extension/LinksRemove/ToolbarButton.d.ts.map +1 -0
- package/lib/core/extension/LinksRemove/ToolbarButton.js +20 -0
- package/lib/core/extension/NonBreakingSpace/Decorator.d.ts +4 -0
- package/lib/core/extension/NonBreakingSpace/Decorator.d.ts.map +1 -0
- package/lib/core/extension/NonBreakingSpace/Decorator.js +17 -0
- package/lib/core/extension/NonBreakingSpace/EditorComponent.d.ts +9 -0
- package/lib/core/extension/NonBreakingSpace/EditorComponent.d.ts.map +1 -0
- package/lib/core/extension/NonBreakingSpace/EditorComponent.js +37 -0
- package/lib/core/extension/NonBreakingSpace/ToolbarButton.d.ts +4 -0
- package/lib/core/extension/NonBreakingSpace/ToolbarButton.d.ts.map +1 -0
- package/lib/core/extension/NonBreakingSpace/ToolbarButton.js +42 -0
- package/lib/core/extension/SoftHyphen/Decorator.d.ts +4 -0
- package/lib/core/extension/SoftHyphen/Decorator.d.ts.map +1 -0
- package/lib/core/extension/SoftHyphen/Decorator.js +17 -0
- package/lib/core/extension/SoftHyphen/EditorComponent.d.ts +9 -0
- package/lib/core/extension/SoftHyphen/EditorComponent.d.ts.map +1 -0
- package/lib/core/extension/SoftHyphen/EditorComponent.js +24 -0
- package/lib/core/extension/SoftHyphen/ToolbarButton.d.ts +3 -0
- package/lib/core/extension/SoftHyphen/ToolbarButton.d.ts.map +1 -0
- package/lib/core/extension/SoftHyphen/ToolbarButton.js +35 -0
- package/lib/core/filterEditor/composeFilterEditorFns.d.ts +4 -0
- package/lib/core/filterEditor/composeFilterEditorFns.d.ts.map +1 -0
- package/lib/core/filterEditor/composeFilterEditorFns.js +8 -0
- package/lib/core/filterEditor/default.d.ts +4 -0
- package/lib/core/filterEditor/default.d.ts.map +1 -0
- package/lib/core/filterEditor/default.js +16 -0
- package/lib/core/filterEditor/manageStandardBlockType.d.ts +4 -0
- package/lib/core/filterEditor/manageStandardBlockType.d.ts.map +1 -0
- package/lib/core/filterEditor/manageStandardBlockType.js +16 -0
- package/lib/core/filterEditor/removeBlocksExceedingBlockLimit.d.ts +4 -0
- package/lib/core/filterEditor/removeBlocksExceedingBlockLimit.d.ts.map +1 -0
- package/lib/core/filterEditor/removeBlocksExceedingBlockLimit.js +22 -0
- package/lib/core/filterEditor/removeUnsupportedBlockTypes.d.ts +4 -0
- package/lib/core/filterEditor/removeUnsupportedBlockTypes.d.ts.map +1 -0
- package/lib/core/filterEditor/removeUnsupportedBlockTypes.js +35 -0
- package/lib/core/filterEditor/removeUnsupportedEntities.d.ts +4 -0
- package/lib/core/filterEditor/removeUnsupportedEntities.d.ts.map +1 -0
- package/lib/core/filterEditor/removeUnsupportedEntities.js +18 -0
- package/lib/core/filterEditor/removeUnsupportedInlineStyles.d.ts +4 -0
- package/lib/core/filterEditor/removeUnsupportedInlineStyles.d.ts.map +1 -0
- package/lib/core/filterEditor/removeUnsupportedInlineStyles.js +26 -0
- package/lib/core/filterEditor/removeUnsupportedListLevels.d.ts +4 -0
- package/lib/core/filterEditor/removeUnsupportedListLevels.d.ts.map +1 -0
- package/lib/core/filterEditor/removeUnsupportedListLevels.js +16 -0
- package/lib/core/filterEditor/utils/changeBlockType.d.ts +9 -0
- package/lib/core/filterEditor/utils/changeBlockType.d.ts.map +1 -0
- package/lib/core/filterEditor/utils/changeBlockType.js +37 -0
- package/lib/core/filterEditor/utils/manipulateEntityData.d.ts +6 -0
- package/lib/core/filterEditor/utils/manipulateEntityData.d.ts.map +1 -0
- package/lib/core/filterEditor/utils/manipulateEntityData.js +43 -0
- package/lib/core/filterEditor/utils/removeEntities.d.ts +6 -0
- package/lib/core/filterEditor/utils/removeEntities.d.ts.map +1 -0
- package/lib/core/filterEditor/utils/removeEntities.js +34 -0
- package/lib/core/filterEditor/utils/removeInlineStyles.d.ts +5 -0
- package/lib/core/filterEditor/utils/removeInlineStyles.d.ts.map +1 -0
- package/lib/core/filterEditor/utils/removeInlineStyles.js +28 -0
- package/lib/core/makeRteApi.d.ts +26 -0
- package/lib/core/makeRteApi.d.ts.map +1 -0
- package/lib/core/makeRteApi.js +86 -0
- package/lib/core/translation/EditorStateTranslationDialog.d.ts +11 -0
- package/lib/core/translation/EditorStateTranslationDialog.d.ts.map +1 -0
- package/lib/core/translation/EditorStateTranslationDialog.js +32 -0
- package/lib/core/translation/ToolbarButton.d.ts +4 -0
- package/lib/core/translation/ToolbarButton.d.ts.map +1 -0
- package/lib/core/translation/ToolbarButton.js +98 -0
- package/lib/core/translation/htmlToState.d.ts +9 -0
- package/lib/core/translation/htmlToState.d.ts.map +1 -0
- package/lib/core/translation/htmlToState.js +53 -0
- package/lib/core/translation/htmlToState.spec.d.ts +2 -0
- package/lib/core/translation/htmlToState.spec.d.ts.map +1 -0
- package/lib/core/translation/stateToHtml.d.ts +13 -0
- package/lib/core/translation/stateToHtml.d.ts.map +1 -0
- package/lib/core/translation/stateToHtml.js +60 -0
- package/lib/core/translation/stateToHtml.spec.d.ts +2 -0
- package/lib/core/translation/stateToHtml.spec.d.ts.map +1 -0
- package/lib/core/types.d.ts +64 -0
- package/lib/core/types.d.ts.map +1 -0
- package/lib/core/types.js +1 -0
- package/lib/core/utils/createBlockRenderMap.d.ts +6 -0
- package/lib/core/utils/createBlockRenderMap.d.ts.map +1 -0
- package/lib/core/utils/createBlockRenderMap.js +22 -0
- package/lib/core/utils/findEntityDataInCurrentSelection.d.ts +3 -0
- package/lib/core/utils/findEntityDataInCurrentSelection.d.ts.map +1 -0
- package/lib/core/utils/findEntityDataInCurrentSelection.js +12 -0
- package/lib/core/utils/findEntityInCurrentSelection.d.ts +8 -0
- package/lib/core/utils/findEntityInCurrentSelection.d.ts.map +1 -0
- package/lib/core/utils/findEntityInCurrentSelection.js +81 -0
- package/lib/core/utils/findTextInCurrentSelection.d.ts +3 -0
- package/lib/core/utils/findTextInCurrentSelection.d.ts.map +1 -0
- package/lib/core/utils/findTextInCurrentSelection.js +16 -0
- package/lib/core/utils/getCurrentBlock.d.ts +3 -0
- package/lib/core/utils/getCurrentBlock.d.ts.map +1 -0
- package/lib/core/utils/getCurrentBlock.js +7 -0
- package/lib/core/utils/getRteTheme.d.ts +19 -0
- package/lib/core/utils/getRteTheme.d.ts.map +1 -0
- package/lib/core/utils/getRteTheme.js +18 -0
- package/lib/core/utils/pasteAndFilterText.d.ts +5 -0
- package/lib/core/utils/pasteAndFilterText.d.ts.map +1 -0
- package/lib/core/utils/pasteAndFilterText.js +17 -0
- package/lib/core/utils/rangesIntersect.d.ts +6 -0
- package/lib/core/utils/rangesIntersect.d.ts.map +1 -0
- package/lib/core/utils/rangesIntersect.js +22 -0
- package/lib/core/utils/selectionIsInOneBlock.d.ts +3 -0
- package/lib/core/utils/selectionIsInOneBlock.d.ts.map +1 -0
- package/lib/core/utils/selectionIsInOneBlock.js +6 -0
- package/lib/field/createFinalFormRte.d.ts +22 -0
- package/lib/field/createFinalFormRte.d.ts.map +1 -0
- package/lib/field/createFinalFormRte.js +84 -0
- package/lib/field/createRteField.d.ts +13 -0
- package/lib/field/createRteField.d.ts.map +1 -0
- package/lib/field/createRteField.js +44 -0
- package/lib/index.d.ts +31 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +29 -0
- package/lib/useDebounce.d.ts +2 -0
- package/lib/useDebounce.d.ts.map +1 -0
- package/lib/useDebounce.js +32 -0
- package/lib/usePrevious.d.ts +4 -0
- package/lib/usePrevious.d.ts.map +1 -0
- package/lib/usePrevious.js +20 -0
- package/lib/utils/requiredValidator.d.ts +4 -0
- package/lib/utils/requiredValidator.d.ts.map +1 -0
- package/lib/utils/requiredValidator.js +16 -0
- package/package.json +93 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { SelectionState } from "draft-js";
|
|
2
|
+
import rangesIntersect from "./rangesIntersect";
|
|
3
|
+
import selectionIsInOneBlock from "./selectionIsInOneBlock";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
// Searches for entities in the current selection
|
|
7
|
+
// If entity found, we return the first entity found and a selection of this entity and the text of this entity
|
|
8
|
+
//
|
|
9
|
+
export default function findEntityInCurrentSelection(editorState, entityType) {
|
|
10
|
+
// we dont support selections over multiple content blocks
|
|
11
|
+
if (!selectionIsInOneBlock(editorState)) {
|
|
12
|
+
return {
|
|
13
|
+
entity: null,
|
|
14
|
+
entitySelection: null,
|
|
15
|
+
entityText: null,
|
|
16
|
+
entityKey: null
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
// get the contentBlock of the selection
|
|
20
|
+
var contentState = editorState.getCurrentContent();
|
|
21
|
+
var selection = editorState.getSelection();
|
|
22
|
+
var startKey = selection.getStartKey();
|
|
23
|
+
var blockAtBeginning = contentState.getBlockForKey(startKey);
|
|
24
|
+
|
|
25
|
+
// we try to find one link entity in the selection
|
|
26
|
+
var entityText = "";
|
|
27
|
+
var entityKey = null;
|
|
28
|
+
var entitySelection = null;
|
|
29
|
+
var firstFoundLinkEntity = null;
|
|
30
|
+
|
|
31
|
+
// iterating over all entity ranges in the block
|
|
32
|
+
blockAtBeginning.findEntityRanges(function (_char) {
|
|
33
|
+
// we are only interested in entities of type {entityType}
|
|
34
|
+
if (_char.getEntity()) {
|
|
35
|
+
var entity = contentState.getEntity(_char.getEntity());
|
|
36
|
+
if (entity.getType() === entityType) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}, function (start, end) {
|
|
42
|
+
if (!firstFoundLinkEntity) {
|
|
43
|
+
// if we 've found one already we're done
|
|
44
|
+
if (rangesIntersect([selection.getStartOffset(), selection.getEndOffset()], [start, end])) {
|
|
45
|
+
// we are only interested in entities within the current selection
|
|
46
|
+
var innerEntityKey = blockAtBeginning.getEntityAt(start);
|
|
47
|
+
var entity = contentState.getEntity(innerEntityKey);
|
|
48
|
+
|
|
49
|
+
// ok, the entity is in the current selection, this is our match: firstFoundLinkEntity
|
|
50
|
+
// we also build a selection which selects the text for the firstFoundLinkEntity
|
|
51
|
+
if (entity) {
|
|
52
|
+
firstFoundLinkEntity = entity;
|
|
53
|
+
entityText = blockAtBeginning.getText().slice(start, end);
|
|
54
|
+
entityKey = innerEntityKey;
|
|
55
|
+
entitySelection = new SelectionState({
|
|
56
|
+
anchorKey: startKey,
|
|
57
|
+
anchorOffset: start,
|
|
58
|
+
focusKey: startKey,
|
|
59
|
+
// must be same as anchor key
|
|
60
|
+
focusOffset: end
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
if (firstFoundLinkEntity) {
|
|
67
|
+
return {
|
|
68
|
+
entity: firstFoundLinkEntity,
|
|
69
|
+
entitySelection: entitySelection,
|
|
70
|
+
entityText: entityText,
|
|
71
|
+
entityKey: entityKey
|
|
72
|
+
};
|
|
73
|
+
} else {
|
|
74
|
+
return {
|
|
75
|
+
entity: null,
|
|
76
|
+
entitySelection: null,
|
|
77
|
+
entityText: null,
|
|
78
|
+
entityKey: null
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findTextInCurrentSelection.d.ts","sourceRoot":"","sources":["../../../src/core/utils/findTextInCurrentSelection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAK5C,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAanF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import selectionIsInOneBlock from "./selectionIsInOneBlock";
|
|
2
|
+
|
|
3
|
+
// returns the text of the current selection
|
|
4
|
+
export default function findTextInCurrentSelection(editorState) {
|
|
5
|
+
if (!selectionIsInOneBlock(editorState)) {
|
|
6
|
+
return "";
|
|
7
|
+
}
|
|
8
|
+
var selectionState = editorState.getSelection();
|
|
9
|
+
var anchorKey = selectionState.getAnchorKey();
|
|
10
|
+
var currentContent = editorState.getCurrentContent();
|
|
11
|
+
var currentContentBlock = currentContent.getBlockForKey(anchorKey);
|
|
12
|
+
var start = selectionState.getStartOffset();
|
|
13
|
+
var end = selectionState.getEndOffset();
|
|
14
|
+
var selectedText = currentContentBlock.getText().slice(start, end);
|
|
15
|
+
return selectedText;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCurrentBlock.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getCurrentBlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,WAAW,EAAE,WAAW,iDAM/D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import type { RteProps } from "../Rte";
|
|
3
|
+
export type RteThemeColors = {
|
|
4
|
+
border: CSSProperties["color"];
|
|
5
|
+
outerBorderOnHover: CSSProperties["color"];
|
|
6
|
+
outerBorderOnFocus: CSSProperties["color"];
|
|
7
|
+
toolbarBackground: CSSProperties["color"];
|
|
8
|
+
buttonIcon: CSSProperties["color"];
|
|
9
|
+
buttonIconDisabled: CSSProperties["color"];
|
|
10
|
+
buttonBackgroundHover: CSSProperties["color"];
|
|
11
|
+
buttonBorderHover: CSSProperties["color"];
|
|
12
|
+
buttonBorderDisabled: CSSProperties["color"];
|
|
13
|
+
};
|
|
14
|
+
interface RteTheme {
|
|
15
|
+
colors: RteThemeColors;
|
|
16
|
+
}
|
|
17
|
+
declare const _default: (themeProps: Partial<RteProps> | undefined) => RteTheme;
|
|
18
|
+
export default _default;
|
|
19
|
+
//# sourceMappingURL=getRteTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRteTheme.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getRteTheme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,MAAM,cAAc,GAAG;IACzB,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,kBAAkB,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC3C,kBAAkB,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC3C,iBAAiB,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC1C,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACnC,kBAAkB,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC3C,qBAAqB,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,iBAAiB,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC1C,oBAAoB,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CAChD,CAAC;AAEF,UAAU,QAAQ;IACd,MAAM,EAAE,cAAc,CAAC;CAC1B;yBAEe,YAAY,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,KAAG,QAAQ;AAApE,wBAcE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { greyPalette, primaryPalette } from "@dextinity/admin";
|
|
2
|
+
import { grey as muiGreyPalette } from "@mui/material/colors";
|
|
3
|
+
export default (function (themeProps) {
|
|
4
|
+
var _themeProps$colors, _themeProps$colors2, _themeProps$colors3, _themeProps$colors4, _themeProps$colors5, _themeProps$colors6, _themeProps$colors7, _themeProps$colors8, _themeProps$colors9;
|
|
5
|
+
return {
|
|
6
|
+
colors: {
|
|
7
|
+
border: themeProps !== null && themeProps !== void 0 && (_themeProps$colors = themeProps.colors) !== null && _themeProps$colors !== void 0 && _themeProps$colors.border ? themeProps.colors.border : greyPalette[100],
|
|
8
|
+
outerBorderOnHover: themeProps !== null && themeProps !== void 0 && (_themeProps$colors2 = themeProps.colors) !== null && _themeProps$colors2 !== void 0 && _themeProps$colors2.outerBorderOnHover ? themeProps.colors.outerBorderOnHover : greyPalette[200],
|
|
9
|
+
outerBorderOnFocus: themeProps !== null && themeProps !== void 0 && (_themeProps$colors3 = themeProps.colors) !== null && _themeProps$colors3 !== void 0 && _themeProps$colors3.outerBorderOnFocus ? themeProps.colors.outerBorderOnFocus : primaryPalette.main,
|
|
10
|
+
toolbarBackground: themeProps !== null && themeProps !== void 0 && (_themeProps$colors4 = themeProps.colors) !== null && _themeProps$colors4 !== void 0 && _themeProps$colors4.toolbarBackground ? themeProps.colors.toolbarBackground : muiGreyPalette[100],
|
|
11
|
+
buttonIcon: themeProps !== null && themeProps !== void 0 && (_themeProps$colors5 = themeProps.colors) !== null && _themeProps$colors5 !== void 0 && _themeProps$colors5.buttonIcon ? themeProps.colors.buttonIcon : muiGreyPalette[600],
|
|
12
|
+
buttonIconDisabled: themeProps !== null && themeProps !== void 0 && (_themeProps$colors6 = themeProps.colors) !== null && _themeProps$colors6 !== void 0 && _themeProps$colors6.buttonIconDisabled ? themeProps.colors.buttonIconDisabled : muiGreyPalette[300],
|
|
13
|
+
buttonBackgroundHover: themeProps !== null && themeProps !== void 0 && (_themeProps$colors7 = themeProps.colors) !== null && _themeProps$colors7 !== void 0 && _themeProps$colors7.buttonBackgroundHover ? themeProps.colors.buttonBackgroundHover : muiGreyPalette[200],
|
|
14
|
+
buttonBorderHover: themeProps !== null && themeProps !== void 0 && (_themeProps$colors8 = themeProps.colors) !== null && _themeProps$colors8 !== void 0 && _themeProps$colors8.buttonBorderHover ? themeProps.colors.buttonBorderHover : muiGreyPalette[400],
|
|
15
|
+
buttonBorderDisabled: themeProps !== null && themeProps !== void 0 && (_themeProps$colors9 = themeProps.colors) !== null && _themeProps$colors9 !== void 0 && _themeProps$colors9.buttonBorderDisabled ? themeProps.colors.buttonBorderDisabled : muiGreyPalette[100]
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { EditorState } from "draft-js";
|
|
2
|
+
import { type IOptions } from "../Rte";
|
|
3
|
+
declare function pasteAndFilterText(html: string | undefined, editorState: EditorState, options: Pick<IOptions, "supports" | "listLevelMax" | "maxBlocks" | "standardBlockType">): false | EditorState;
|
|
4
|
+
export { pasteAndFilterText };
|
|
5
|
+
//# sourceMappingURL=pasteAndFilterText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pasteAndFilterText.d.ts","sourceRoot":"","sources":["../../../src/core/utils/pasteAndFilterText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAI5C,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvD,iBAAS,kBAAkB,CACvB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,GAAG,cAAc,GAAG,WAAW,GAAG,mBAAmB,CAAC,GACzF,KAAK,GAAG,WAAW,CAQrB;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { handleDraftEditorPastedText } from "draftjs-conductor";
|
|
8
|
+
import defaultFilterEditorStateBeforeUpdate from "../filterEditor/default";
|
|
9
|
+
import { defaultOptions } from "../Rte";
|
|
10
|
+
function pasteAndFilterText(html, editorState, options) {
|
|
11
|
+
var nextEditorState = handleDraftEditorPastedText(html, editorState);
|
|
12
|
+
if (nextEditorState) {
|
|
13
|
+
return defaultFilterEditorStateBeforeUpdate(nextEditorState, _objectSpread(_objectSpread({}, defaultOptions), options));
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
export { pasteAndFilterText };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rangesIntersect.d.ts","sourceRoot":"","sources":["../../../src/core/utils/rangesIntersect.ts"],"names":[],"mappings":"AAAA,KAAK,KAAK,GAAG,MAAM,CAAC;AACpB,KAAK,MAAM,GAAG,MAAM,CAAC;AACrB,KAAK,KAAK,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAE7B,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,uBAAuB,UAAO,GAAG,OAAO,CAUnG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
export default function rangesIntersect(a, b) {
|
|
8
|
+
var positiveWhenRangesTouch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
9
|
+
var _a = _slicedToArray(a, 2),
|
|
10
|
+
aStart = _a[0],
|
|
11
|
+
aOffset = _a[1];
|
|
12
|
+
var _b = _slicedToArray(b, 2),
|
|
13
|
+
bStart = _b[0],
|
|
14
|
+
bOffset = _b[1];
|
|
15
|
+
|
|
16
|
+
// returns true when the 2 lines intersect
|
|
17
|
+
if (positiveWhenRangesTouch) {
|
|
18
|
+
return !(aStart >= bOffset || aOffset <= bStart);
|
|
19
|
+
} else {
|
|
20
|
+
return !(aStart > bOffset || aOffset < bStart);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectionIsInOneBlock.d.ts","sourceRoot":"","sources":["../../../src/core/utils/selectionIsInOneBlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAM/E"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type FunctionComponent } from "react";
|
|
2
|
+
import type { FieldRenderProps } from "react-final-form";
|
|
3
|
+
import { type IMakeRteApiProps } from "../core/makeRteApi";
|
|
4
|
+
import { type IOptions as RteOptions, type RteProps } from "../core/Rte";
|
|
5
|
+
export interface IConfig<T = any> {
|
|
6
|
+
rteApiOptions?: IMakeRteApiProps<T>;
|
|
7
|
+
rteOptions?: RteOptions;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Used to create a Final Form-compatible RTE component.
|
|
11
|
+
*
|
|
12
|
+
* @see {@link createRteField} – preferred for typical form use. Use this only if no Field wrapper is needed.
|
|
13
|
+
*/
|
|
14
|
+
declare function createFinalFormRte<T = any>(config?: IConfig<T>): {
|
|
15
|
+
RteField: FunctionComponent<FieldRenderProps<T, HTMLInputElement, T> & Pick<RteProps, "options">>;
|
|
16
|
+
RteReadOnly: FunctionComponent<{
|
|
17
|
+
content?: T;
|
|
18
|
+
plainTextOnly?: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
};
|
|
21
|
+
export default createFinalFormRte;
|
|
22
|
+
//# sourceMappingURL=createFinalFormRte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFinalFormRte.d.ts","sourceRoot":"","sources":["../../src/field/createFinalFormRte.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,iBAAiB,EAAU,MAAM,OAAO,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAmB,EAAE,KAAK,gBAAgB,EAAmC,MAAM,oBAAoB,CAAC;AACxG,OAAO,EAAE,KAAK,QAAQ,IAAI,UAAU,EAAO,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG9E,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,GAAG;IAC5B,aAAa,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IACpC,UAAU,CAAC,EAAE,UAAU,CAAC;CAC3B;AAID;;;;GAIG;AACH,iBAAS,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,GAAE,OAAO,CAAC,CAAC,CAAiB;;;kBAmClB,CAAC;wBAAkB,OAAO;;EAiB9E;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["value", "onChange"],
|
|
3
|
+
_excluded2 = ["input", "meta", "value"];
|
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
8
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
10
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
11
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
17
|
+
import { useRef } from "react";
|
|
18
|
+
import makeRteApi from "../core/makeRteApi";
|
|
19
|
+
import { Rte } from "../core/Rte";
|
|
20
|
+
import RteReadOnlyBase from "../core/RteReadOnly";
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
var defaultConfig = {};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Used to create a Final Form-compatible RTE component.
|
|
26
|
+
*
|
|
27
|
+
* @see {@link createRteField} – preferred for typical form use. Use this only if no Field wrapper is needed.
|
|
28
|
+
*/
|
|
29
|
+
function createFinalFormRte() {
|
|
30
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultConfig;
|
|
31
|
+
var rteApiOptions = config.rteApiOptions,
|
|
32
|
+
rteOptions = config.rteOptions;
|
|
33
|
+
var _makeRteApi = makeRteApi(rteApiOptions),
|
|
34
|
+
_makeRteApi2 = _slicedToArray(_makeRteApi, 2),
|
|
35
|
+
useRteApi = _makeRteApi2[0],
|
|
36
|
+
createStateFromRawContent = _makeRteApi2[1].createStateFromRawContent;
|
|
37
|
+
var RteField = function RteField(_ref) {
|
|
38
|
+
var _ref$input = _ref.input,
|
|
39
|
+
value = _ref$input.value,
|
|
40
|
+
onChange = _ref$input.onChange,
|
|
41
|
+
restInput = _objectWithoutProperties(_ref$input, _excluded),
|
|
42
|
+
meta = _ref.meta,
|
|
43
|
+
remove = _ref.value,
|
|
44
|
+
rest = _objectWithoutProperties(_ref, _excluded2);
|
|
45
|
+
var ref = useRef(undefined);
|
|
46
|
+
var onDebouncedContentChange = function onDebouncedContentChange(debouncedEditorState, convertStateToRawContent) {
|
|
47
|
+
onChange(convertStateToRawContent(debouncedEditorState));
|
|
48
|
+
};
|
|
49
|
+
var _useRteApi = useRteApi({
|
|
50
|
+
defaultValue: value,
|
|
51
|
+
onDebouncedContentChange: onDebouncedContentChange
|
|
52
|
+
}),
|
|
53
|
+
editorState = _useRteApi.editorState,
|
|
54
|
+
setEditorState = _useRteApi.setEditorState;
|
|
55
|
+
return /*#__PURE__*/_jsx(Rte, _objectSpread(_objectSpread({
|
|
56
|
+
ref: ref,
|
|
57
|
+
value: editorState,
|
|
58
|
+
onChange: function onChange(c) {
|
|
59
|
+
setEditorState(c);
|
|
60
|
+
},
|
|
61
|
+
options: rteOptions
|
|
62
|
+
}, rest), restInput));
|
|
63
|
+
};
|
|
64
|
+
var RteReadOnly = function RteReadOnly(_ref2) {
|
|
65
|
+
var content = _ref2.content,
|
|
66
|
+
plainTextOnly = _ref2.plainTextOnly;
|
|
67
|
+
if (!content) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return /*#__PURE__*/_jsx(RteReadOnlyBase, {
|
|
71
|
+
value: createStateFromRawContent(content),
|
|
72
|
+
plainTextOnly: plainTextOnly,
|
|
73
|
+
options: {
|
|
74
|
+
blocktypeMap: rteOptions ? rteOptions.blocktypeMap : undefined,
|
|
75
|
+
customBlockMap: rteOptions ? rteOptions.customBlockMap : undefined
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
RteField: RteField,
|
|
81
|
+
RteReadOnly: RteReadOnly
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export default createFinalFormRte;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type FieldProps } from "@dextinity/admin";
|
|
2
|
+
import type { FunctionComponent } from "react";
|
|
3
|
+
import type { RteProps } from "../core/Rte";
|
|
4
|
+
import { type IConfig } from "./createFinalFormRte";
|
|
5
|
+
export type RteFieldProps = FieldProps<string, HTMLInputElement> & Partial<RteProps>;
|
|
6
|
+
export declare const createRteField: (config?: IConfig) => {
|
|
7
|
+
RteField: FunctionComponent<RteFieldProps>;
|
|
8
|
+
RteReadOnly: FunctionComponent<{
|
|
9
|
+
content?: any;
|
|
10
|
+
plainTextOnly?: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=createRteField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRteField.d.ts","sourceRoot":"","sources":["../../src/field/createRteField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAA2B,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAExE,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAQrF,eAAO,MAAM,cAAc,GAAI,SAAS,OAAO;;;;;;CAQ9C,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["required", "validate"];
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
10
|
+
import { Field } from "@dextinity/admin";
|
|
11
|
+
import { requiredValidator } from "../utils/requiredValidator";
|
|
12
|
+
import createFinalFormRte from "./createFinalFormRte";
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
// Same as in `Field` from `@dextinity/admin`
|
|
15
|
+
var composeValidators = function composeValidators() {
|
|
16
|
+
for (var _len = arguments.length, validators = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
17
|
+
validators[_key] = arguments[_key];
|
|
18
|
+
}
|
|
19
|
+
return function (value, allValues) {
|
|
20
|
+
return validators.reduce(function (error, validator) {
|
|
21
|
+
return error || validator(value, allValues);
|
|
22
|
+
}, undefined);
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export var createRteField = function createRteField(config) {
|
|
26
|
+
var _createFinalFormRte = createFinalFormRte(config),
|
|
27
|
+
RteFieldComponent = _createFinalFormRte.RteField,
|
|
28
|
+
RteReadOnly = _createFinalFormRte.RteReadOnly;
|
|
29
|
+
var RteField = function RteField(_ref) {
|
|
30
|
+
var required = _ref.required,
|
|
31
|
+
validate = _ref.validate,
|
|
32
|
+
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
33
|
+
var validateError = required ? validate ? composeValidators(requiredValidator, validate) : requiredValidator : validate;
|
|
34
|
+
return /*#__PURE__*/_jsx(Field, _objectSpread({
|
|
35
|
+
component: RteFieldComponent,
|
|
36
|
+
required: required,
|
|
37
|
+
validate: validateError
|
|
38
|
+
}, restProps));
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
RteField: RteField,
|
|
42
|
+
RteReadOnly: RteReadOnly
|
|
43
|
+
};
|
|
44
|
+
};
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export { BlockElement, type RteBlockElementClassKey, type RteBlockElementProps } from "./core/BlockElement";
|
|
2
|
+
export { default as BlockTypesControls, type RteBlockTypeControlsClassKey } from "./core/Controls/BlockTypesControls";
|
|
3
|
+
export { ControlButton, type IProps as IControlButtonProps, type RteControlButtonClassKey } from "./core/Controls/ControlButton";
|
|
4
|
+
export { FeaturesButtonGroup, type RteFeaturesButtonGroupClassKey } from "./core/Controls/FeaturesButtonGroup";
|
|
5
|
+
export { default as LinkControls, type RteLinkControlsClassKey, type RteLinkControlsProps } from "./core/Controls/LinkControls";
|
|
6
|
+
export { Toolbar } from "./core/Controls/Toolbar/Toolbar";
|
|
7
|
+
export type { RteToolbarClassKey } from "./core/Controls/Toolbar/Toolbar.styles";
|
|
8
|
+
export { default as LinkDecorator } from "./core/extension/Link/Decorator";
|
|
9
|
+
export { default as NonBreakingSpaceDecorator } from "./core/extension/NonBreakingSpace/Decorator";
|
|
10
|
+
export { default as SoftHyphenDecorator } from "./core/extension/SoftHyphen/Decorator";
|
|
11
|
+
export { default as filterEditorStateDefault } from "./core/filterEditor/default";
|
|
12
|
+
export { default as filterEditorStateRemoveUnsupportedBlockTypes } from "./core/filterEditor/removeUnsupportedBlockTypes";
|
|
13
|
+
export { default as filterEditorStateRemoveUnsupportedEntities } from "./core/filterEditor/removeUnsupportedEntities";
|
|
14
|
+
export { default as filterEditorStateRemoveUnsupportedInlineStyles } from "./core/filterEditor/removeUnsupportedInlineStyles";
|
|
15
|
+
export { default as filterEditorUtilsUnstyleBlocks } from "./core/filterEditor/utils/changeBlockType";
|
|
16
|
+
export { default as filterEditorUtilsManipulateEntityData } from "./core/filterEditor/utils/manipulateEntityData";
|
|
17
|
+
export { default as filterEditorUtilsRemoveEntities } from "./core/filterEditor/utils/removeEntities";
|
|
18
|
+
export { default as filterEditorUtilsRemoveInlineStyles } from "./core/filterEditor/utils/removeInlineStyles";
|
|
19
|
+
export { type IMakeRteApiProps, type IRteApiProps, default as makeRteApi, type OnDebouncedContentChangeFn } from "./core/makeRteApi";
|
|
20
|
+
export { type FilterEditorStateBeforeUpdateFn, type IOptions as IRteOptions, type IRteRef, Rte, type RteClassKey, type RteProps } from "./core/Rte";
|
|
21
|
+
export { type IOptions as IRteReadOnlyOptions, type IProps as IRteReadOnlyProps, default as RteReadOnly } from "./core/RteReadOnly";
|
|
22
|
+
export { htmlToState } from "./core/translation/htmlToState";
|
|
23
|
+
export { stateToHtml } from "./core/translation/stateToHtml";
|
|
24
|
+
export { default as findEntityInCurrentSelection } from "./core/utils/findEntityInCurrentSelection";
|
|
25
|
+
export { default as findTextInCurrentSelection } from "./core/utils/findTextInCurrentSelection";
|
|
26
|
+
export { pasteAndFilterText } from "./core/utils/pasteAndFilterText";
|
|
27
|
+
export { default as selectionIsInOneBlock } from "./core/utils/selectionIsInOneBlock";
|
|
28
|
+
export { default as createFinalFormRte } from "./field/createFinalFormRte";
|
|
29
|
+
export { createRteField, type RteFieldProps } from "./field/createRteField";
|
|
30
|
+
export { requiredValidator } from "./utils/requiredValidator";
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,uBAAuB,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC5G,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,KAAK,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AACtH,OAAO,EAAE,aAAa,EAAE,KAAK,MAAM,IAAI,mBAAmB,EAAE,KAAK,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACjI,OAAO,EAAE,mBAAmB,EAAE,KAAK,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAC/G,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,KAAK,uBAAuB,EAAE,KAAK,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAChI,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,YAAY,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACnG,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,4CAA4C,EAAE,MAAM,iDAAiD,CAAC;AAC1H,OAAO,EAAE,OAAO,IAAI,0CAA0C,EAAE,MAAM,+CAA+C,CAAC;AACtH,OAAO,EAAE,OAAO,IAAI,8CAA8C,EAAE,MAAM,mDAAmD,CAAC;AAC9H,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;AACtG,OAAO,EAAE,OAAO,IAAI,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAClH,OAAO,EAAE,OAAO,IAAI,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AACtG,OAAO,EAAE,OAAO,IAAI,mCAAmC,EAAE,MAAM,8CAA8C,CAAC;AAC9G,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,OAAO,IAAI,UAAU,EAAE,KAAK,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AACrI,OAAO,EAAE,KAAK,+BAA+B,EAAE,KAAK,QAAQ,IAAI,WAAW,EAAE,KAAK,OAAO,EAAE,GAAG,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AACpJ,OAAO,EAAE,KAAK,QAAQ,IAAI,mBAAmB,EAAE,KAAK,MAAM,IAAI,iBAAiB,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpI,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AACpG,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { BlockElement } from "./core/BlockElement";
|
|
2
|
+
export { default as BlockTypesControls } from "./core/Controls/BlockTypesControls";
|
|
3
|
+
export { ControlButton } from "./core/Controls/ControlButton";
|
|
4
|
+
export { FeaturesButtonGroup } from "./core/Controls/FeaturesButtonGroup";
|
|
5
|
+
export { default as LinkControls } from "./core/Controls/LinkControls";
|
|
6
|
+
export { Toolbar } from "./core/Controls/Toolbar/Toolbar";
|
|
7
|
+
export { default as LinkDecorator } from "./core/extension/Link/Decorator";
|
|
8
|
+
export { default as NonBreakingSpaceDecorator } from "./core/extension/NonBreakingSpace/Decorator";
|
|
9
|
+
export { default as SoftHyphenDecorator } from "./core/extension/SoftHyphen/Decorator";
|
|
10
|
+
export { default as filterEditorStateDefault } from "./core/filterEditor/default";
|
|
11
|
+
export { default as filterEditorStateRemoveUnsupportedBlockTypes } from "./core/filterEditor/removeUnsupportedBlockTypes";
|
|
12
|
+
export { default as filterEditorStateRemoveUnsupportedEntities } from "./core/filterEditor/removeUnsupportedEntities";
|
|
13
|
+
export { default as filterEditorStateRemoveUnsupportedInlineStyles } from "./core/filterEditor/removeUnsupportedInlineStyles";
|
|
14
|
+
export { default as filterEditorUtilsUnstyleBlocks } from "./core/filterEditor/utils/changeBlockType";
|
|
15
|
+
export { default as filterEditorUtilsManipulateEntityData } from "./core/filterEditor/utils/manipulateEntityData";
|
|
16
|
+
export { default as filterEditorUtilsRemoveEntities } from "./core/filterEditor/utils/removeEntities";
|
|
17
|
+
export { default as filterEditorUtilsRemoveInlineStyles } from "./core/filterEditor/utils/removeInlineStyles";
|
|
18
|
+
export { default as makeRteApi } from "./core/makeRteApi";
|
|
19
|
+
export { Rte } from "./core/Rte";
|
|
20
|
+
export { default as RteReadOnly } from "./core/RteReadOnly";
|
|
21
|
+
export { htmlToState } from "./core/translation/htmlToState";
|
|
22
|
+
export { stateToHtml } from "./core/translation/stateToHtml";
|
|
23
|
+
export { default as findEntityInCurrentSelection } from "./core/utils/findEntityInCurrentSelection";
|
|
24
|
+
export { default as findTextInCurrentSelection } from "./core/utils/findTextInCurrentSelection";
|
|
25
|
+
export { pasteAndFilterText } from "./core/utils/pasteAndFilterText";
|
|
26
|
+
export { default as selectionIsInOneBlock } from "./core/utils/selectionIsInOneBlock";
|
|
27
|
+
export { default as createFinalFormRte } from "./field/createFinalFormRte";
|
|
28
|
+
export { createRteField } from "./field/createRteField";
|
|
29
|
+
export { requiredValidator } from "./utils/requiredValidator";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebounce.d.ts","sourceRoot":"","sources":["../src/useDebounce.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAmB7D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
|
+
|
|
9
|
+
// https://usehooks.com/useDebounce/
|
|
10
|
+
|
|
11
|
+
export default function useDebounce(value, delay) {
|
|
12
|
+
// State and setters for debounced value
|
|
13
|
+
var _useState = useState(value),
|
|
14
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
15
|
+
debouncedValue = _useState2[0],
|
|
16
|
+
setDebouncedValue = _useState2[1];
|
|
17
|
+
useEffect(function () {
|
|
18
|
+
// Update debounced value after delay
|
|
19
|
+
var handler = setTimeout(function () {
|
|
20
|
+
setDebouncedValue(value);
|
|
21
|
+
}, delay);
|
|
22
|
+
|
|
23
|
+
// Cancel the timeout if value changes (also on delay change or unmount)
|
|
24
|
+
// This is how we prevent debounced value from updating if value is changed ...
|
|
25
|
+
// .. within the delay period. Timeout gets cleared and restarted.
|
|
26
|
+
return function () {
|
|
27
|
+
clearTimeout(handler);
|
|
28
|
+
};
|
|
29
|
+
}, [value, delay]); // Only re-call effect if value or delay changes
|
|
30
|
+
|
|
31
|
+
return debouncedValue;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrevious.d.ts","sourceRoot":"","sources":["../src/usePrevious.ts"],"names":[],"mappings":"AAIA,KAAK,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;AAE3C,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAetE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
// https://usehooks.com/usePrevious/
|
|
4
|
+
|
|
5
|
+
export default function usePrevious(value) {
|
|
6
|
+
// The ref object is a generic container whose current property is mutable ...
|
|
7
|
+
// ... and can hold any value, similar to an instance property on a class
|
|
8
|
+
var ref = useRef(undefined);
|
|
9
|
+
|
|
10
|
+
// Store current value in ref
|
|
11
|
+
useEffect(function () {
|
|
12
|
+
ref.current = value;
|
|
13
|
+
}, [value]); // Only re-run if value changes
|
|
14
|
+
|
|
15
|
+
// Return previous value (happens before update in useEffect above)
|
|
16
|
+
if (ref.current === undefined) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
return ref.current;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requiredValidator.d.ts","sourceRoot":"","sources":["../../src/utils/requiredValidator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAKjD,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,MAAM,GAAG,oBAAoB,GAAG,SAAS,CASvF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { convertFromRaw } from "draft-js";
|
|
2
|
+
import { FormattedMessage } from "react-intl";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
var requiredMessage = /*#__PURE__*/_jsx(FormattedMessage, {
|
|
5
|
+
id: "comet.form.required",
|
|
6
|
+
defaultMessage: "Required"
|
|
7
|
+
});
|
|
8
|
+
export var requiredValidator = function requiredValidator(value) {
|
|
9
|
+
if (value === undefined) {
|
|
10
|
+
return requiredMessage;
|
|
11
|
+
}
|
|
12
|
+
var rawState = typeof value === "string" ? JSON.parse(value) : value;
|
|
13
|
+
var contentState = convertFromRaw(rawState);
|
|
14
|
+
var hasText = contentState.hasText();
|
|
15
|
+
return hasText ? undefined : requiredMessage;
|
|
16
|
+
};
|