rme 0.0.32 → 0.0.35
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/dist/index.d.ts +6 -1
- package/dist/index.mjs +67 -11
- package/dist/index.mjs.map +4 -4
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ type EditorRef = {
|
|
|
18
18
|
getType: () => EditorViewType;
|
|
19
19
|
};
|
|
20
20
|
declare const Editor: react.MemoExoticComponent<react.ForwardRefExoticComponent<EditorProps & react.RefAttributes<EditorRef>>>;
|
|
21
|
-
type EditorChangeHandler = (params: RemirrorEventListenerProps<Extension
|
|
21
|
+
type EditorChangeHandler = (params: RemirrorEventListenerProps<Extension>) => void;
|
|
22
22
|
interface EditorProps {
|
|
23
23
|
delegate?: EditorDelegate;
|
|
24
24
|
content: string;
|
|
@@ -239,6 +239,11 @@ type Props = {
|
|
|
239
239
|
*/
|
|
240
240
|
codemirrorTheme?: CreateThemeOptions;
|
|
241
241
|
};
|
|
242
|
+
i18n?: {
|
|
243
|
+
locales?: Record<string, Record<'translation', Record<string, any>>>;
|
|
244
|
+
language?: string;
|
|
245
|
+
};
|
|
246
|
+
locales?: Record<string, any>;
|
|
242
247
|
children?: React.ReactNode;
|
|
243
248
|
};
|
|
244
249
|
declare const ThemeProvider: React.FC<Props>;
|
package/dist/index.mjs
CHANGED
|
@@ -7626,6 +7626,10 @@ var SourceCodeThemeWrapper = styled3.div.attrs((p) => p)`
|
|
|
7626
7626
|
font-size: ${(props) => props.theme.fontBase};
|
|
7627
7627
|
font-family: ${(props) => props.theme.codemirrorFontFamily} !important;
|
|
7628
7628
|
|
|
7629
|
+
&.cm-focused {
|
|
7630
|
+
outline: none;
|
|
7631
|
+
}
|
|
7632
|
+
|
|
7629
7633
|
.cm-line {
|
|
7630
7634
|
padding: 2px 2px 2px 6px;
|
|
7631
7635
|
|
|
@@ -16120,6 +16124,7 @@ import {
|
|
|
16120
16124
|
} from "@mui/material";
|
|
16121
16125
|
import { useCommands } from "@remirror/react";
|
|
16122
16126
|
import styled6 from "styled-components";
|
|
16127
|
+
import { useTranslation } from "react-i18next";
|
|
16123
16128
|
import { jsx as jsx10, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
16124
16129
|
var Container2 = styled6.div`
|
|
16125
16130
|
position: absolute;
|
|
@@ -16134,29 +16139,36 @@ var ActiveCellMenu = (props) => {
|
|
|
16134
16139
|
const [open, setOpen] = useState4(false);
|
|
16135
16140
|
const anchorRef = useRef4(null);
|
|
16136
16141
|
const offset = useContext(OffsetContext);
|
|
16142
|
+
const { t: t3 } = useTranslation();
|
|
16137
16143
|
const options = [
|
|
16138
16144
|
{
|
|
16139
16145
|
label: "insert column after",
|
|
16146
|
+
i18nKey: "table.insertColumnAfter",
|
|
16140
16147
|
handler: commands.addTableColumnAfter
|
|
16141
16148
|
},
|
|
16142
16149
|
{
|
|
16143
16150
|
label: "insert column before",
|
|
16151
|
+
i18nKey: "table.insertColumnBefore",
|
|
16144
16152
|
handler: commands.addTableColumnBefore
|
|
16145
16153
|
},
|
|
16146
16154
|
{
|
|
16147
16155
|
label: "insert row after",
|
|
16156
|
+
i18nKey: "table.insertRowAfter",
|
|
16148
16157
|
handler: commands.addTableRowAfter
|
|
16149
16158
|
},
|
|
16150
16159
|
{
|
|
16151
16160
|
label: "insert row before",
|
|
16161
|
+
i18nKey: "table.insertRowBefore",
|
|
16152
16162
|
handler: commands.addTableRowBefore
|
|
16153
16163
|
},
|
|
16154
16164
|
{
|
|
16155
16165
|
label: "delete column",
|
|
16166
|
+
i18nKey: "table.deleteColumn",
|
|
16156
16167
|
handler: commands.deleteTableColumn
|
|
16157
16168
|
},
|
|
16158
16169
|
{
|
|
16159
16170
|
label: "delete row",
|
|
16171
|
+
i18nKey: "table.deleteRow",
|
|
16160
16172
|
handler: commands.deleteTableRow
|
|
16161
16173
|
}
|
|
16162
16174
|
];
|
|
@@ -16208,7 +16220,7 @@ var ActiveCellMenu = (props) => {
|
|
|
16208
16220
|
option.handler();
|
|
16209
16221
|
setOpen(false);
|
|
16210
16222
|
},
|
|
16211
|
-
children: /* @__PURE__ */ jsx10(ListItemText, { children: option.
|
|
16223
|
+
children: /* @__PURE__ */ jsx10(ListItemText, { children: t3(option.i18nKey) })
|
|
16212
16224
|
},
|
|
16213
16225
|
option.label
|
|
16214
16226
|
)) }) }) })
|
|
@@ -16820,8 +16832,7 @@ var WysiwygEditor = (props) => {
|
|
|
16820
16832
|
const handleChange = useCallback4(
|
|
16821
16833
|
(params) => {
|
|
16822
16834
|
try {
|
|
16823
|
-
|
|
16824
|
-
props.onChange?.(params, textContent);
|
|
16835
|
+
props.onChange?.(params);
|
|
16825
16836
|
} catch (error) {
|
|
16826
16837
|
console.error(error);
|
|
16827
16838
|
}
|
|
@@ -17584,8 +17595,7 @@ var SourceEditor = (props) => {
|
|
|
17584
17595
|
const handleChange = useCallback5(
|
|
17585
17596
|
(params) => {
|
|
17586
17597
|
try {
|
|
17587
|
-
|
|
17588
|
-
props.onChange?.(params, textContent);
|
|
17598
|
+
props.onChange?.(params);
|
|
17589
17599
|
} catch (error) {
|
|
17590
17600
|
console.error(error);
|
|
17591
17601
|
}
|
|
@@ -17608,10 +17618,6 @@ var SourceEditor_default = memo5(SourceEditor);
|
|
|
17608
17618
|
// src/editor/hooks/index.ts
|
|
17609
17619
|
import { useHelpers, useKeymap, useRemirrorContext as useRemirrorContext3, useCommands as useCommands4 } from "@remirror/react";
|
|
17610
17620
|
|
|
17611
|
-
// src/editor/components/index.tsx
|
|
17612
|
-
import { ThemeProvider as ScThemeProvider } from "styled-components";
|
|
17613
|
-
import { useEffect as useEffect7 } from "react";
|
|
17614
|
-
|
|
17615
17621
|
// src/editor/components/Editor.tsx
|
|
17616
17622
|
import { forwardRef as forwardRef2, memo as memo6, useImperativeHandle as useImperativeHandle2, useMemo as useMemo5, useState as useState8 } from "react";
|
|
17617
17623
|
|
|
@@ -17646,12 +17652,62 @@ var Editor = memo6(
|
|
|
17646
17652
|
})
|
|
17647
17653
|
);
|
|
17648
17654
|
|
|
17649
|
-
// src/editor/components/
|
|
17655
|
+
// src/editor/components/ThemeProvider.tsx
|
|
17656
|
+
import { ThemeProvider as ScThemeProvider } from "styled-components";
|
|
17657
|
+
import { useEffect as useEffect7 } from "react";
|
|
17658
|
+
|
|
17659
|
+
// src/editor/i18n/index.ts
|
|
17660
|
+
import i18next from "i18next";
|
|
17661
|
+
import { initReactI18next } from "react-i18next";
|
|
17662
|
+
|
|
17663
|
+
// src/editor/i18n/en.json
|
|
17664
|
+
var en_default = {
|
|
17665
|
+
table: {
|
|
17666
|
+
insertColumnAfter: "insert column after",
|
|
17667
|
+
insertColumnBefore: "insert column before",
|
|
17668
|
+
insertRowAfter: "insert row after",
|
|
17669
|
+
insertRowBefore: "insert row before",
|
|
17670
|
+
deleteColumn: "delete column",
|
|
17671
|
+
deleteRow: "delete row"
|
|
17672
|
+
}
|
|
17673
|
+
};
|
|
17674
|
+
|
|
17675
|
+
// src/editor/i18n/index.ts
|
|
17676
|
+
async function i18nInit(locales = {}, options) {
|
|
17677
|
+
await i18next.use(initReactI18next).init({
|
|
17678
|
+
resources: {
|
|
17679
|
+
en: {
|
|
17680
|
+
translation: en_default
|
|
17681
|
+
},
|
|
17682
|
+
...locales
|
|
17683
|
+
},
|
|
17684
|
+
interpolation: {
|
|
17685
|
+
escapeValue: false
|
|
17686
|
+
// react already safes from xss
|
|
17687
|
+
},
|
|
17688
|
+
fallbackLng: "en",
|
|
17689
|
+
...options
|
|
17690
|
+
});
|
|
17691
|
+
}
|
|
17692
|
+
function changeLng(lng) {
|
|
17693
|
+
return i18next.changeLanguage(lng);
|
|
17694
|
+
}
|
|
17695
|
+
|
|
17696
|
+
// src/editor/components/ThemeProvider.tsx
|
|
17650
17697
|
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
17651
|
-
var ThemeProvider = ({ theme, children }) => {
|
|
17698
|
+
var ThemeProvider = ({ theme, i18n, children }) => {
|
|
17652
17699
|
const mode = theme?.mode || "light";
|
|
17653
17700
|
const defaultThemeToken = mode === "dark" ? darkTheme.styledConstants : lightTheme.styledConstants;
|
|
17654
17701
|
const themeToken = theme?.token ? { ...defaultThemeToken, ...theme.token } : defaultThemeToken;
|
|
17702
|
+
useEffect7(() => {
|
|
17703
|
+
if (i18n?.locales) {
|
|
17704
|
+
i18nInit(i18n.locales).then(() => {
|
|
17705
|
+
if (i18n?.language) {
|
|
17706
|
+
changeLng(i18n?.language);
|
|
17707
|
+
}
|
|
17708
|
+
});
|
|
17709
|
+
}
|
|
17710
|
+
}, [i18n]);
|
|
17655
17711
|
useEffect7(() => {
|
|
17656
17712
|
const codemirrorTheme = theme?.codemirrorTheme || mode === "dark" ? darkTheme.codemirrorTheme : lightTheme.codemirrorTheme;
|
|
17657
17713
|
changeTheme(codemirrorTheme);
|