rme 0.0.60 → 0.0.62

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 CHANGED
@@ -261,17 +261,17 @@ interface WarpperProps$1 {
261
261
  codeEditor?: boolean;
262
262
  dark?: boolean;
263
263
  }
264
- declare const WysiwygThemeWrapper: styled_components.IStyledComponent<"web", styled_components_dist_types.FastOmit<styled_components_dist_types.Substitute<styled_components_dist_types.Substitute<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
264
+ declare const WysiwygThemeWrapper: styled_components_dist_types.IStyledComponentBase<"web", styled_components.FastOmit<styled_components_dist_types.Substitute<styled_components_dist_types.Substitute<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
265
265
  ref?: ((instance: HTMLDivElement | null) => void) | react.RefObject<HTMLDivElement> | null | undefined;
266
- }>, WarpperProps$1>, never>>;
266
+ }>, WarpperProps$1>, never>> & string;
267
267
 
268
268
  interface WarpperProps {
269
269
  codeEditor?: boolean;
270
270
  dark?: boolean;
271
271
  }
272
- declare const SourceCodeThemeWrapper: styled_components.IStyledComponent<"web", styled_components_dist_types.FastOmit<styled_components_dist_types.Substitute<styled_components_dist_types.Substitute<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
272
+ declare const SourceCodeThemeWrapper: styled_components_dist_types.IStyledComponentBase<"web", styled_components.FastOmit<styled_components_dist_types.Substitute<styled_components_dist_types.Substitute<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
273
273
  ref?: ((instance: HTMLDivElement | null) => void) | react.RefObject<HTMLDivElement> | null | undefined;
274
- }>, WarpperProps>, never>>;
274
+ }>, WarpperProps>, never>> & string;
275
275
 
276
276
  declare const tableSelectorSize = 15;
277
277
  declare const common: {
package/dist/index.mjs CHANGED
@@ -4471,11 +4471,12 @@ function buildHtmlStringFromAst(ast) {
4471
4471
 
4472
4472
  // src/editor/transform/markdown-it-html-inline.ts
4473
4473
  import Token2 from "markdown-it/lib/token.mjs";
4474
- var needSplitInlineHtmlTokenTags = ["img", "iframe"];
4475
- var excludeHtmlInlineNodes = ["html_image", "iframe_inline"];
4474
+ var needSplitInlineHtmlTokenTags = ["img", "iframe", "br"];
4475
+ var excludeHtmlInlineNodes = ["html_image", "iframe_inline", "html_br"];
4476
4476
  var typeMap = {
4477
4477
  img: "html_image",
4478
- iframe: "iframe_inline"
4478
+ iframe: "iframe_inline",
4479
+ br: "html_br"
4479
4480
  };
4480
4481
  function splitHtmlInlineTokens(t3) {
4481
4482
  if (!t3.children)
@@ -5141,7 +5142,16 @@ var LineTableExtension = class extends TableExtension {
5141
5142
  node.forEach((rowNode, _, rowIndex) => {
5142
5143
  const row = [];
5143
5144
  rowNode.forEach((cellNode, __, colIndex) => {
5144
- row.push(replaceNewLines(cellNode.textContent.trim()));
5145
+ let cellText = "";
5146
+ for (let i = 0; i < cellNode.childCount; i++) {
5147
+ let child = cellNode.child(i);
5148
+ if (child.textContent) {
5149
+ cellText += child.textContent;
5150
+ } else if (child.type.name === "html_br") {
5151
+ cellText += "<br/>";
5152
+ }
5153
+ }
5154
+ row.push(replaceNewLines(cellText.trim()));
5145
5155
  if (rowIndex === 0) {
5146
5156
  colAligns[colIndex] = 1 /* DEFAULT */;
5147
5157
  }
@@ -5801,7 +5811,7 @@ var fromMarkdownOptions = {
5801
5811
  };
5802
5812
  function parseInlineMarkdown(text) {
5803
5813
  try {
5804
- const root = fromMarkdown(text, "utf-8", fromMarkdownOptions);
5814
+ const root = fromMarkdown(text, fromMarkdownOptions);
5805
5815
  if (root.children.length === 0) {
5806
5816
  return [];
5807
5817
  }
@@ -5955,7 +5965,6 @@ function hasHtmlToken(mdastToken) {
5955
5965
  }
5956
5966
  function fromInlineMarkdown(text) {
5957
5967
  const phrasingContents = parseInlineMarkdown(text);
5958
- console.log("phrasingContents", phrasingContents);
5959
5968
  if (hasHtmlToken(phrasingContents)) {
5960
5969
  const nodes = flatHTMLInlineToken(phrasingContents);
5961
5970
  return nodes;
@@ -6477,7 +6486,11 @@ var ImgUri = class extends MarkExtension2 {
6477
6486
  default: ""
6478
6487
  }
6479
6488
  },
6480
- toDOM: (mark) => ["img", { src: globalImageHrefCache.get(mark.attrs.href) || mark.attrs.href }, 0]
6489
+ toDOM: (mark) => [
6490
+ "img",
6491
+ { src: mark.attrs.href },
6492
+ 0
6493
+ ]
6481
6494
  };
6482
6495
  }
6483
6496
  };
@@ -6880,7 +6893,7 @@ var LineHardBreakExtension = class extends HardBreakExtension {
6880
6893
  if (canReplace) {
6881
6894
  const schema = state.schema;
6882
6895
  if (needUseBrNodeNames.includes(nodeName)) {
6883
- dispatch?.(tr.replaceRangeWith(from, to, schema.text("<br/>\n")));
6896
+ dispatch?.(tr.replaceRangeWith(from, to, schema.nodes["html_br"].create()));
6884
6897
  } else {
6885
6898
  dispatch?.(tr.replaceRangeWith(from, to, schema.text("\n")));
6886
6899
  }
@@ -7558,43 +7571,44 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => p)`
7558
7571
  & h4,
7559
7572
  & h5,
7560
7573
  & h6 {
7574
+ position: relative;
7561
7575
  margin: 0;
7562
7576
  line-height: 1;
7563
7577
  }
7564
7578
 
7565
7579
  & h1 {
7566
7580
  font-weight: 600;
7567
- padding: 10px 0 20px 0;
7581
+ margin: 10px 0 20px 0;
7568
7582
  font-size: ${(props) => props.theme.fontH1};
7569
7583
  }
7570
7584
 
7571
7585
  & h2 {
7572
7586
  font-weight: 600;
7573
- padding: 10px 0 20px 0;
7587
+ margin: 10px 0 20px 0;
7574
7588
  font-size: ${(props) => props.theme.fontH2};
7575
7589
  }
7576
7590
 
7577
7591
  & h3 {
7578
7592
  font-weight: 600;
7579
- padding: 10px 0 20px 0;
7593
+ margin: 10px 0 20px 0;
7580
7594
  font-size: ${(props) => props.theme.fontH3};
7581
7595
  }
7582
7596
 
7583
7597
  & h4 {
7584
7598
  font-weight: 600;
7585
- padding: 10px 0 20px 0;
7599
+ margin: 10px 0 20px 0;
7586
7600
  font-size: ${(props) => props.theme.fontH4};
7587
7601
  }
7588
7602
 
7589
7603
  & h5 {
7590
7604
  font-weight: 600;
7591
- padding: 6px 0 16px 0;
7605
+ margin: 6px 0 16px 0;
7592
7606
  font-size: ${(props) => props.theme.fontH5};
7593
7607
  }
7594
7608
 
7595
7609
  & h6 {
7596
7610
  font-weight: 600;
7597
- padding: 6px 0 16px 0;
7611
+ margin: 6px 0 16px 0;
7598
7612
  font-size: ${(props) => props.theme.fontH6};
7599
7613
  }
7600
7614
 
@@ -8191,6 +8205,57 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => p)`
8191
8205
  ${(props) => props.dark && css`
8192
8206
  color-scheme: dark;
8193
8207
  `}
8208
+
8209
+ ${(props) => {
8210
+ const style = css`
8211
+ position: absolute;
8212
+ left: -20px;
8213
+ height: 100%;
8214
+ display: flex;
8215
+ align-items: center;
8216
+ font-size: 12px;
8217
+ font-weight: normal;
8218
+ color: ${props.theme.primaryFontColor};
8219
+ `;
8220
+ return css`
8221
+ & h1 {
8222
+ &:hover::before {
8223
+ content: 'h1';
8224
+ ${style}
8225
+ }
8226
+ }
8227
+ & h2 {
8228
+ &:hover::before {
8229
+ content: 'h2';
8230
+ ${style}
8231
+ }
8232
+ }
8233
+ & h3 {
8234
+ &:hover::before {
8235
+ content: 'h3';
8236
+ ${style}
8237
+ }
8238
+ }
8239
+ & h4 {
8240
+ &:hover::before {
8241
+ content: 'h4';
8242
+ ${style}
8243
+ }
8244
+ }
8245
+ & h5 {
8246
+ &:hover::before {
8247
+ content: 'h5';
8248
+ ${style}
8249
+ }
8250
+ }
8251
+ & h6 {
8252
+ &:hover::before {
8253
+ content: 'h6';
8254
+ ${style}
8255
+ }
8256
+ }
8257
+ `;
8258
+ }}
8194
8259
  `;
8195
8260
 
8196
8261
  // src/editor/theme/SourceCodeThemeWrapper.tsx
@@ -15378,7 +15443,7 @@ var ImageToolTips = (props) => {
15378
15443
  {
15379
15444
  placeholder: "Image URL [Enter]",
15380
15445
  value: srcVal,
15381
- style: { fontSize: "14px" },
15446
+ style: { fontSize: "14px", width: "300px" },
15382
15447
  onInput: handleSrcInput,
15383
15448
  onPressEnter: updateSrc
15384
15449
  }
@@ -16730,23 +16795,23 @@ import { memo as memo4, useMemo as useMemo3, useCallback as useCallback4 } from
16730
16795
  // src/editor/components/WysiwygEditor/delegate.ts
16731
16796
  import { createReactManager } from "@remirror/react";
16732
16797
  import { isExtension } from "@remirror/core";
16733
- function isMarkdownNodeExtension(extension9) {
16734
- return !!(isExtension(extension9) && extension9.fromMarkdown && extension9.toMarkdown);
16798
+ function isMarkdownNodeExtension(extension10) {
16799
+ return !!(isExtension(extension10) && extension10.fromMarkdown && extension10.toMarkdown);
16735
16800
  }
16736
16801
  function buildMarkdownParser(manager) {
16737
16802
  const parserRules = [];
16738
- for (const extension9 of manager.extensions) {
16739
- if (isMarkdownNodeExtension(extension9)) {
16740
- parserRules.push(...extension9.fromMarkdown());
16803
+ for (const extension10 of manager.extensions) {
16804
+ if (isMarkdownNodeExtension(extension10)) {
16805
+ parserRules.push(...extension10.fromMarkdown());
16741
16806
  }
16742
16807
  }
16743
16808
  return new MarkdownParser(manager.schema, parserRules);
16744
16809
  }
16745
16810
  function buildMarkdownSerializer(manager) {
16746
16811
  const specs = {};
16747
- for (const extension9 of manager.extensions) {
16748
- if (isMarkdownNodeExtension(extension9)) {
16749
- specs[extension9.name] = extension9.toMarkdown;
16812
+ for (const extension10 of manager.extensions) {
16813
+ if (isMarkdownNodeExtension(extension10)) {
16814
+ specs[extension10.name] = extension10.toMarkdown;
16750
16815
  }
16751
16816
  }
16752
16817
  return new MarkdownSerializer(specs);
@@ -16809,26 +16874,26 @@ var ActiveCellMenu = (props) => {
16809
16874
  const anchorRef = useRef4(null);
16810
16875
  const { t: t3 } = useTranslation();
16811
16876
  const options = [
16812
- {
16813
- label: "insert column after",
16814
- i18nKey: "table.insertColumnAfter",
16815
- handler: commands.addTableColumnAfter
16816
- },
16817
16877
  {
16818
16878
  label: "insert column before",
16819
16879
  i18nKey: "table.insertColumnBefore",
16820
16880
  handler: commands.addTableColumnBefore
16821
16881
  },
16822
16882
  {
16823
- label: "insert row after",
16824
- i18nKey: "table.insertRowAfter",
16825
- handler: commands.addTableRowAfter
16883
+ label: "insert column after",
16884
+ i18nKey: "table.insertColumnAfter",
16885
+ handler: commands.addTableColumnAfter
16826
16886
  },
16827
16887
  {
16828
16888
  label: "insert row before",
16829
16889
  i18nKey: "table.insertRowBefore",
16830
16890
  handler: commands.addTableRowBefore
16831
16891
  },
16892
+ {
16893
+ label: "insert row after",
16894
+ i18nKey: "table.insertRowAfter",
16895
+ handler: commands.addTableRowAfter
16896
+ },
16832
16897
  {
16833
16898
  label: "delete column",
16834
16899
  i18nKey: "table.deleteColumn",
@@ -17622,6 +17687,52 @@ var ClipboardExtension = class extends PlainExtension7 {
17622
17687
  }
17623
17688
  };
17624
17689
 
17690
+ // src/editor/extensions/HtmlBr/br-extension.ts
17691
+ import { extension as extension8, ExtensionTag as ExtensionTag3, NodeExtension as NodeExtension4 } from "@remirror/core";
17692
+ var HtmlBrExtension = class extends NodeExtension4 {
17693
+ get name() {
17694
+ return "html_br";
17695
+ }
17696
+ createTags() {
17697
+ return [ExtensionTag3.InlineNode];
17698
+ }
17699
+ createNodeSpec(extra, override) {
17700
+ return {
17701
+ inline: true,
17702
+ selectable: true,
17703
+ atom: true,
17704
+ ...override,
17705
+ attrs: {},
17706
+ parseDOM: [
17707
+ {
17708
+ tag: "br"
17709
+ }
17710
+ ],
17711
+ toDOM: () => {
17712
+ return ["br"];
17713
+ }
17714
+ };
17715
+ }
17716
+ fromMarkdown() {
17717
+ return [
17718
+ {
17719
+ type: 6 /* inline */,
17720
+ token: "html_br",
17721
+ node: this.name
17722
+ }
17723
+ ];
17724
+ }
17725
+ toMarkdown({ state, node }) {
17726
+ state.text("<br/>", false);
17727
+ }
17728
+ };
17729
+ HtmlBrExtension.disableExtraAttributes = true;
17730
+ HtmlBrExtension = __decorateClass([
17731
+ extension8({
17732
+ defaultOptions: {}
17733
+ })
17734
+ ], HtmlBrExtension);
17735
+
17625
17736
  // src/editor/extensions/index.ts
17626
17737
  function extensions({ handleViewImgSrcUrl }) {
17627
17738
  return [
@@ -17633,6 +17744,7 @@ function extensions({ handleViewImgSrcUrl }) {
17633
17744
  new HtmlImageExtension({
17634
17745
  handleViewImgSrcUrl
17635
17746
  }),
17747
+ new HtmlBrExtension(),
17636
17748
  new IframeExtension({
17637
17749
  enableResizing: true
17638
17750
  }),
@@ -18647,13 +18759,13 @@ var codemirror_lang_menu_default = createCodeMirrorMenuDecorations;
18647
18759
  // src/editor/extensions/CodeMirror/codemirror-extension.ts
18648
18760
  import {
18649
18761
  command as command4,
18650
- extension as extension8,
18762
+ extension as extension9,
18651
18763
  findParentNodeOfType as findParentNodeOfType5,
18652
18764
  isElementDomNode as isElementDomNode4,
18653
18765
  isEqual,
18654
18766
  isTextSelection as isTextSelection3,
18655
18767
  keyBinding as keyBinding2,
18656
- NodeExtension as NodeExtension4,
18768
+ NodeExtension as NodeExtension5,
18657
18769
  nodeInputRule as nodeInputRule4,
18658
18770
  setBlockType as setBlockType2
18659
18771
  } from "@remirror/core";
@@ -18711,7 +18823,7 @@ var CodeMirror6NodeView = class {
18711
18823
  // src/editor/extensions/CodeMirror/codemirror-extension.ts
18712
18824
  import { languages as languages3 } from "@codemirror/language-data";
18713
18825
  var fakeIndentedLanguage = "indent-code";
18714
- var LineCodeMirrorExtension = class extends NodeExtension4 {
18826
+ var LineCodeMirrorExtension = class extends NodeExtension5 {
18715
18827
  get name() {
18716
18828
  return "codeMirror";
18717
18829
  }
@@ -18903,7 +19015,7 @@ __decorateClass([
18903
19015
  command4()
18904
19016
  ], LineCodeMirrorExtension.prototype, "updateCodeMirror", 1);
18905
19017
  LineCodeMirrorExtension = __decorateClass([
18906
- extension8({
19018
+ extension9({
18907
19019
  defaultOptions: {
18908
19020
  hideDecoration: false,
18909
19021
  extensions: null,
@@ -19116,15 +19228,66 @@ var ThemeProvider = ({ theme, i18n, children }) => {
19116
19228
 
19117
19229
  // src/editor/components/Preview/preview.tsx
19118
19230
  import { prosemirrorNodeToHtml } from "remirror";
19231
+ import HTML2 from "html-parse-stringify";
19232
+ import { useEffect as useEffect8, useState as useState9 } from "react";
19233
+ import { nanoid as nanoid3 } from "nanoid";
19234
+ import { Loading3QuartersOutlined } from "zens/esm/Icons";
19119
19235
  import { jsx as jsx21 } from "react/jsx-runtime";
19120
19236
  var Preview = (props) => {
19121
19237
  const { doc, delegateOptions } = props;
19238
+ const [processedHtml, setProcessedHtml] = useState9("");
19122
19239
  let targetDoc = doc;
19123
19240
  if (typeof targetDoc === "string") {
19124
19241
  targetDoc = createWysiwygDelegate(delegateOptions).stringToDoc(targetDoc);
19125
19242
  }
19126
19243
  const html2 = prosemirrorNodeToHtml(targetDoc);
19127
- return /* @__PURE__ */ jsx21(WysiwygThemeWrapper, { dangerouslySetInnerHTML: { __html: html2 } });
19244
+ useEffect8(() => {
19245
+ const fullAst = HTML2.parse(html2);
19246
+ const imageLoadTasks = [];
19247
+ const handleHtmlText = async (ast) => {
19248
+ const handleNode = (node) => {
19249
+ if (!node) {
19250
+ return;
19251
+ }
19252
+ if (node.name === "img" && node.attrs?.src && delegateOptions?.handleViewImgSrcUrl) {
19253
+ imageLoadTasks.push(
19254
+ (async () => {
19255
+ node.attrs.src = await delegateOptions?.handleViewImgSrcUrl?.(node.attrs.src);
19256
+ node.attrs.key = nanoid3();
19257
+ })()
19258
+ );
19259
+ }
19260
+ if (node.children) {
19261
+ handleHtmlText(node.children);
19262
+ }
19263
+ };
19264
+ for (let i = 0; i < ast.length; i++) {
19265
+ handleNode(ast[i]);
19266
+ }
19267
+ };
19268
+ handleHtmlText(fullAst);
19269
+ Promise.all(imageLoadTasks).then((res) => {
19270
+ setProcessedHtml(HTML2.stringify(fullAst));
19271
+ }).catch(() => {
19272
+ setProcessedHtml(html2);
19273
+ });
19274
+ }, [html2]);
19275
+ if (!processedHtml) {
19276
+ return /* @__PURE__ */ jsx21(
19277
+ "div",
19278
+ {
19279
+ style: {
19280
+ width: "100%",
19281
+ minHeight: "60px",
19282
+ display: "flex",
19283
+ justifyContent: "center",
19284
+ alignItems: "center"
19285
+ },
19286
+ children: /* @__PURE__ */ jsx21(Loading3QuartersOutlined, { spin: true, size: 40 })
19287
+ }
19288
+ );
19289
+ }
19290
+ return /* @__PURE__ */ jsx21(WysiwygThemeWrapper, { dangerouslySetInnerHTML: { __html: processedHtml } });
19128
19291
  };
19129
19292
  export {
19130
19293
  Editor,