@frontify/guideline-blocks-settings 0.28.6 → 0.29.1

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.
Files changed (102) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/components/BlockItemWrapper/BlockItemWrapper.es.js.map +1 -1
  3. package/dist/components/RichTextEditor/SerializedText.es.js +2 -2
  4. package/dist/components/RichTextEditor/SerializedText.es.js.map +1 -1
  5. package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEdit.es.js +5 -5
  6. package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButton.es.js +6 -6
  7. package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom1Plugin.es.js +15 -14
  8. package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom1Plugin.es.js.map +1 -1
  9. package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom2Plugin.es.js +15 -14
  10. package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom2Plugin.es.js.map +1 -1
  11. package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom3Plugin.es.js +15 -14
  12. package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom3Plugin.es.js.map +1 -1
  13. package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading1Plugin.es.js +10 -9
  14. package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading1Plugin.es.js.map +1 -1
  15. package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading2Plugin.es.js +15 -7
  16. package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading2Plugin.es.js.map +1 -1
  17. package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading3Plugin.es.js +15 -7
  18. package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading3Plugin.es.js.map +1 -1
  19. package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading4Plugin.es.js +15 -7
  20. package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading4Plugin.es.js.map +1 -1
  21. package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageCaptionPlugin.es.js +15 -14
  22. package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageCaptionPlugin.es.js.map +1 -1
  23. package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageTitlePlugin.es.js +18 -17
  24. package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageTitlePlugin.es.js.map +1 -1
  25. package/dist/components/RichTextEditor/plugins/TextStylePlugins/quotePlugin.es.js +13 -12
  26. package/dist/components/RichTextEditor/plugins/TextStylePlugins/quotePlugin.es.js.map +1 -1
  27. package/dist/components/RichTextEditor/plugins/styles.es.js +0 -1
  28. package/dist/components/RichTextEditor/plugins/styles.es.js.map +1 -1
  29. package/dist/index.cjs.js +3 -20
  30. package/dist/index.cjs.js.map +1 -1
  31. package/dist/index.d.ts +3 -3
  32. package/dist/index.umd.js +3 -20
  33. package/dist/index.umd.js.map +1 -1
  34. package/dist/styles.css +1 -1
  35. package/dist/utilities/color/getReadableColor.es.js +8 -8
  36. package/dist/utilities/color/getReadableColor.es.js.map +1 -1
  37. package/dist/utilities/color/isDark.es.js +2 -2
  38. package/dist/utilities/color/isDark.es.js.map +1 -1
  39. package/dist/utilities/color/setAlpha.es.js +2 -2
  40. package/dist/utilities/color/setAlpha.es.js.map +1 -1
  41. package/dist/utilities/color/toColorObject.es.js +5 -5
  42. package/dist/utilities/color/toColorObject.es.js.map +1 -1
  43. package/dist/utilities/color/toHex8String.es.js +3 -3
  44. package/dist/utilities/color/toHex8String.es.js.map +1 -1
  45. package/dist/utilities/color/toHexString.es.js +3 -3
  46. package/dist/utilities/color/toHexString.es.js.map +1 -1
  47. package/dist/utilities/color/toRgbaString.es.js +3 -3
  48. package/dist/utilities/color/toRgbaString.es.js.map +1 -1
  49. package/package.json +24 -26
  50. package/src/components/Attachments/Attachments.spec.ct.tsx +1 -1
  51. package/src/components/BlockItemWrapper/BlockItemWrapper.tsx +2 -2
  52. package/src/components/BlockItemWrapper/types.ts +2 -0
  53. package/src/components/Link/LinkSelector/LinkSelector.spec.ct.tsx +1 -1
  54. package/src/components/RichTextEditor/RichTextEditor.spec.ct.tsx +1 -1
  55. package/src/components/RichTextEditor/SerializedText.tsx +2 -2
  56. package/src/components/RichTextEditor/plugins/TextStylePlugins/custom1Plugin.tsx +3 -2
  57. package/src/components/RichTextEditor/plugins/TextStylePlugins/custom2Plugin.tsx +3 -2
  58. package/src/components/RichTextEditor/plugins/TextStylePlugins/custom3Plugin.tsx +3 -2
  59. package/src/components/RichTextEditor/plugins/TextStylePlugins/heading1Plugin.tsx +3 -2
  60. package/src/components/RichTextEditor/plugins/TextStylePlugins/heading2Plugin.tsx +6 -2
  61. package/src/components/RichTextEditor/plugins/TextStylePlugins/heading3Plugin.tsx +6 -2
  62. package/src/components/RichTextEditor/plugins/TextStylePlugins/heading4Plugin.tsx +6 -2
  63. package/src/components/RichTextEditor/plugins/TextStylePlugins/imageCaptionPlugin.tsx +3 -2
  64. package/src/components/RichTextEditor/plugins/TextStylePlugins/imageTitlePlugin.tsx +3 -2
  65. package/src/components/RichTextEditor/plugins/TextStylePlugins/quotePlugin.tsx +3 -2
  66. package/src/components/RichTextEditor/plugins/styles.ts +1 -2
  67. package/src/utilities/color/getReadableColor.ts +3 -3
  68. package/src/utilities/color/isDark.ts +2 -2
  69. package/src/utilities/color/setAlpha.ts +2 -2
  70. package/src/utilities/color/toColorObject.ts +2 -2
  71. package/src/utilities/color/toHex8String.ts +2 -2
  72. package/src/utilities/color/toHexString.ts +2 -2
  73. package/src/utilities/color/toRgbaString.ts +2 -2
  74. package/tsconfig.json +1 -1
  75. package/dist/components/RichTextEditor/serializer/nodes/button.es.js +0 -17
  76. package/dist/components/RichTextEditor/serializer/nodes/button.es.js.map +0 -1
  77. package/dist/components/RichTextEditor/serializer/nodes/checkItemNode.es.js +0 -19
  78. package/dist/components/RichTextEditor/serializer/nodes/checkItemNode.es.js.map +0 -1
  79. package/dist/components/RichTextEditor/serializer/nodes/default.es.js +0 -32
  80. package/dist/components/RichTextEditor/serializer/nodes/default.es.js.map +0 -1
  81. package/dist/components/RichTextEditor/serializer/nodes/link.es.js +0 -15
  82. package/dist/components/RichTextEditor/serializer/nodes/link.es.js.map +0 -1
  83. package/dist/components/RichTextEditor/serializer/nodes/mentionHtmlNode.es.js +0 -12
  84. package/dist/components/RichTextEditor/serializer/nodes/mentionHtmlNode.es.js.map +0 -1
  85. package/dist/components/RichTextEditor/serializer/serializeNodesToHtmlRecursive.es.js +0 -61
  86. package/dist/components/RichTextEditor/serializer/serializeNodesToHtmlRecursive.es.js.map +0 -1
  87. package/dist/components/RichTextEditor/serializer/serializeToHtml.es.js +0 -25
  88. package/dist/components/RichTextEditor/serializer/serializeToHtml.es.js.map +0 -1
  89. package/dist/components/RichTextEditor/serializer/utlis/reactCssPropsToCss.es.js +0 -8
  90. package/dist/components/RichTextEditor/serializer/utlis/reactCssPropsToCss.es.js.map +0 -1
  91. package/dist/components/RichTextEditor/serializer/utlis/serializeLeafToHtml.es.js +0 -13
  92. package/dist/components/RichTextEditor/serializer/utlis/serializeLeafToHtml.es.js.map +0 -1
  93. package/src/components/RichTextEditor/serializer/index.ts +0 -3
  94. package/src/components/RichTextEditor/serializer/nodes/button.ts +0 -27
  95. package/src/components/RichTextEditor/serializer/nodes/checkItemNode.ts +0 -30
  96. package/src/components/RichTextEditor/serializer/nodes/default.ts +0 -68
  97. package/src/components/RichTextEditor/serializer/nodes/link.ts +0 -26
  98. package/src/components/RichTextEditor/serializer/nodes/mentionHtmlNode.ts +0 -17
  99. package/src/components/RichTextEditor/serializer/serializeNodesToHtmlRecursive.ts +0 -134
  100. package/src/components/RichTextEditor/serializer/serializeToHtml.ts +0 -49
  101. package/src/components/RichTextEditor/serializer/utlis/reactCssPropsToCss.ts +0 -21
  102. package/src/components/RichTextEditor/serializer/utlis/serializeLeafToHtml.ts +0 -32
@@ -1,134 +0,0 @@
1
- /* (c) Copyright Frontify Ltd., all rights reserved. */
2
-
3
- import {
4
- ELEMENT_CHECK_ITEM,
5
- LI_CLASSNAMES,
6
- MappedMentionableItems,
7
- OL_STYLES,
8
- UL_CLASSES,
9
- alignmentClassnames,
10
- getLiStyles,
11
- getLicElementClassNames,
12
- getOrderedListClasses,
13
- merge,
14
- } from '@frontify/fondue';
15
- import {
16
- ELEMENT_LI,
17
- ELEMENT_LIC,
18
- ELEMENT_LINK,
19
- ELEMENT_MENTION,
20
- ELEMENT_OL,
21
- ELEMENT_UL,
22
- TDescendant,
23
- TElement,
24
- isText,
25
- } from '@udecode/plate';
26
- import { serializeLeafToHtml } from './utlis/serializeLeafToHtml';
27
- import { reactCssPropsToCss } from './utlis/reactCssPropsToCss';
28
- import type { CSSProperties } from 'react';
29
- import { ButtonStylesType, buttonNode } from './nodes/button';
30
- import { linkNode } from './nodes/link';
31
- import { defaultNode } from './nodes/default';
32
- import { checkItemNode } from './nodes/checkItemNode';
33
- import { mentionHtmlNode } from './nodes/mentionHtmlNode';
34
- import { ELEMENT_BUTTON } from '../plugins';
35
-
36
- const countNodesOfType = (nodes: TDescendant[], type: string): number => {
37
- return nodes.reduce((acc, node) => {
38
- if (node.type === type) {
39
- acc++;
40
- }
41
- if (node.children) {
42
- return acc + countNodesOfType(node.children as TDescendant[], type);
43
- }
44
- return acc;
45
- }, 0);
46
- };
47
-
48
- type NestingCount = {
49
- [type: string]: number;
50
- };
51
-
52
- type SerializeNodeToHtmlRecursiveOptions = {
53
- mappedMentionable?: MappedMentionableItems;
54
- nestingCount?: NestingCount;
55
- };
56
-
57
- export const serializeNodeToHtmlRecursive = (
58
- node: TDescendant,
59
- styles: Record<string, CSSProperties & { hover?: CSSProperties }> | ButtonStylesType,
60
- { mappedMentionable, nestingCount = {} }: SerializeNodeToHtmlRecursiveOptions,
61
- ): string => {
62
- if (isText(node)) {
63
- return serializeLeafToHtml(node);
64
- }
65
-
66
- const rootNestingCount = nestingCount[node.type] || countNodesOfType([node], node.type);
67
- let children = '';
68
- for (const element of node.children) {
69
- children += serializeNodeToHtmlRecursive(element, styles, {
70
- nestingCount: {
71
- ...nestingCount,
72
- [element.type as string]: rootNestingCount,
73
- },
74
- mappedMentionable,
75
- });
76
- }
77
-
78
- const htmlMapper = MapNodeTypesToHtml[node.type];
79
- if (typeof htmlMapper !== 'undefined') {
80
- return htmlMapper({
81
- classNames: getClassNames(node.breakAfterColumn as string | undefined, node.align as string | undefined),
82
- children,
83
- rootNestingCount,
84
- node,
85
- mappedMentionable,
86
- styles,
87
- });
88
- } else {
89
- return defaultNode(
90
- node,
91
- children,
92
- styles[node.type],
93
- getClassNames(node.breakAfterColumn as string | undefined, node.align as string | undefined),
94
- );
95
- }
96
- };
97
-
98
- type Arguments = {
99
- classNames: string;
100
- children: string;
101
- rootNestingCount: number;
102
- node: TElement;
103
- mappedMentionable?: MappedMentionableItems;
104
- styles: Record<string, CSSProperties & { hover?: CSSProperties }> | ButtonStylesType;
105
- };
106
-
107
- const MapNodeTypesToHtml: { [key: string]: ({ ...args }: Arguments) => string } = {
108
- [ELEMENT_UL]: (args) => `<ul dir="auto" class="${UL_CLASSES} ${args.classNames}">${args.children}</ul>`,
109
- [ELEMENT_OL]: ({ classNames, children, node, rootNestingCount }) => {
110
- const nestingLevel = Math.max(rootNestingCount - countNodesOfType([node], ELEMENT_OL), 0);
111
- return `<ol dir="auto" class="${getOrderedListClasses(nestingLevel)} ${classNames}" style="${reactCssPropsToCss(
112
- OL_STYLES,
113
- )}">${children}</ol>`;
114
- },
115
- [ELEMENT_LI]: ({ classNames, children, node, styles }) =>
116
- `<li dir="auto" class="${classNames} ${LI_CLASSNAMES}" style="${reactCssPropsToCss(
117
- getLiStyles(node, styles),
118
- )}">${children}</li>`,
119
- [ELEMENT_LIC]: ({ classNames, children, node }) =>
120
- `<p dir="auto" class="${classNames} ${getLicElementClassNames(node)}"><span>${children}</span></p>`,
121
- [ELEMENT_LINK]: ({ node, children, classNames, styles }) => linkNode(node, children, classNames, styles),
122
- [ELEMENT_BUTTON]: ({ node, children, classNames, styles }) =>
123
- buttonNode(node, children, classNames, styles as ButtonStylesType),
124
- [ELEMENT_CHECK_ITEM]: ({ node, children, classNames, styles }) => checkItemNode(node, children, classNames, styles),
125
- [ELEMENT_MENTION]: ({ node, mappedMentionable }) => mentionHtmlNode(node, { mentionable: mappedMentionable }),
126
- };
127
-
128
- const getClassNames = (breakAfterColumn?: string, align?: string) => {
129
- const breakWordsClass = 'tw-break-words';
130
- const columnBreakClasses =
131
- breakAfterColumn === 'active' ? 'tw-break-after-column tw-break-inside-avoid-column' : '';
132
- const alignClass = align ? alignmentClassnames[align] : '';
133
- return merge([alignClass, breakWordsClass, columnBreakClasses]);
134
- };
@@ -1,49 +0,0 @@
1
- /* (c) Copyright Frontify Ltd., all rights reserved. */
2
-
3
- import { TDescendant } from '@udecode/plate';
4
- import { PluginComposer, SerializeNodesToHtmlOptions, mapMentionable, parseRawValue } from '@frontify/fondue';
5
- import { BlockStyles } from '../plugins';
6
- import { serializeNodeToHtmlRecursive } from './serializeNodesToHtmlRecursive';
7
-
8
- export const serializeRawToHtmlAsync = async (
9
- raw: string,
10
- columns: SerializeNodesToHtmlOptions['columns'] = 1,
11
- columnGap: SerializeNodesToHtmlOptions['columnGap'] = 'normal',
12
- plugins: PluginComposer = new PluginComposer(),
13
- ): Promise<string> => {
14
- const nodes = parseRawValue({ raw, plugins });
15
- const styles = plugins.getStyles;
16
- return Promise.resolve(serializeNodesToHtml(nodes, { columns, columnGap, styles }));
17
- };
18
-
19
- export const serializeNodesToHtml = (
20
- nodes: TDescendant[],
21
- { mentionable, columns = 1, columnGap = 'normal', styles = BlockStyles }: SerializeNodesToHtmlOptions = {},
22
- ): string => {
23
- const mappedMentionable = mentionable ? mapMentionable(mentionable) : new Map();
24
-
25
- let html = '';
26
- for (let i = 0, len = nodes.length; i < len; i++) {
27
- const node = nodes[i];
28
- if (isEmptyNode(node)) {
29
- html += '<br />';
30
- } else {
31
- html += serializeNodeToHtmlRecursive(node, styles, {
32
- mappedMentionable,
33
- });
34
- }
35
- }
36
-
37
- if (columns > 1) {
38
- return `<div style="columns:${columns}; column-gap:${columnGap};">${html}</div>`;
39
- }
40
-
41
- return html;
42
- };
43
-
44
- const isEmptyNode = (node: TDescendant): boolean => {
45
- if (!Array.isArray(node?.children)) {
46
- return false;
47
- }
48
- return node?.children?.every((child) => child.text === '');
49
- };
@@ -1,21 +0,0 @@
1
- /* (c) Copyright Frontify Ltd., all rights reserved. */
2
-
3
- import type { CSSProperties } from 'react';
4
-
5
- export const reactCssPropsToCss = (props?: CSSProperties): string => {
6
- if (!props) {
7
- return '';
8
- }
9
-
10
- return Object.keys(props)
11
- .reduce<string>((acc, key) => {
12
- const value = props[key as keyof CSSProperties];
13
- return value ? `${acc}${convertCamelCaseToKebabCase(key)}: ${value}; ` : acc;
14
- }, '')
15
- .trim()
16
- .replaceAll('"', "'");
17
- };
18
-
19
- const convertCamelCaseToKebabCase = (str: string): string => {
20
- return str.replaceAll(/([A-Z])/g, '-$1').toLowerCase();
21
- };
@@ -1,32 +0,0 @@
1
- /* (c) Copyright Frontify Ltd., all rights reserved. */
2
-
3
- import { BOLD_CLASSES, CODE_CLASSES, ITALIC_CLASSES, STRIKETHROUGH_CLASSES, UNDERLINE_CLASSES } from '@frontify/fondue';
4
- import { TText } from '@udecode/plate';
5
- import escapeHtml from 'escape-html';
6
-
7
- export const serializeLeafToHtml = (node: TText): string => {
8
- let string = escapeHtml(node.text);
9
- string = string.replaceAll('\n', '<br />');
10
- const { bold, italic, underline, strikethrough, code, subscript, superscript } = node;
11
- if (bold) {
12
- string = `<span class="${BOLD_CLASSES}">${string}</span>`;
13
- }
14
- if (italic) {
15
- string = `<span class="${ITALIC_CLASSES}">${string}</span>`;
16
- }
17
- if (underline) {
18
- string = `<span class="${UNDERLINE_CLASSES}">${string}</span>`;
19
- }
20
- if (strikethrough) {
21
- string = `<span class="${STRIKETHROUGH_CLASSES}">${string}</span>`;
22
- }
23
- if (code) {
24
- string = `<span class="${CODE_CLASSES}">${string}</span>`;
25
- }
26
- if (subscript) {
27
- string = `<sub>${string}</sub>`;
28
- } else if (superscript) {
29
- string = `<sup>${string}</sup>`;
30
- }
31
- return string;
32
- };