rme 0.0.73 → 0.0.75

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.mjs CHANGED
@@ -4372,15 +4372,17 @@ var require_querystringify = __commonJS({
4372
4372
  // src/editor/components/SourceEditor/index.tsx
4373
4373
  import { Remirror as Remirror2 } from "@remirror/react";
4374
4374
  import { createContextState } from "create-context-state";
4375
- import { memo as memo6, useCallback as useCallback5, useMemo as useMemo5 } from "react";
4375
+ import { memo as memo7, useCallback as useCallback5, useMemo as useMemo5 } from "react";
4376
4376
 
4377
4377
  // src/editor/components/Text/index.tsx
4378
4378
  import { useRemirrorContext } from "@remirror/react";
4379
+ import { memo } from "react";
4379
4380
  import { jsx } from "react/jsx-runtime";
4380
- var Text = ({ children, ...props }) => {
4381
+ var Text = memo(({ children, ...props }) => {
4381
4382
  const { getRootProps } = useRemirrorContext();
4382
- return /* @__PURE__ */ jsx("div", { ...props, ...getRootProps(), spellCheck: false, children });
4383
- };
4383
+ const { key, ...rootProps } = getRootProps();
4384
+ return /* @__PURE__ */ jsx("div", { ...props, ...rootProps, spellCheck: false, children });
4385
+ });
4384
4386
  var Text_default = Text;
4385
4387
 
4386
4388
  // src/editor/components/SourceEditor/index.tsx
@@ -4455,6 +4457,9 @@ function getTagName(str) {
4455
4457
  }
4456
4458
  return "";
4457
4459
  }
4460
+ function isImageElement(el) {
4461
+ return el && el.tagName?.toLocaleUpperCase() === "IMG";
4462
+ }
4458
4463
  function buildHtmlStringFromAst(ast) {
4459
4464
  let attrs = "";
4460
4465
  if (ast.attrs) {
@@ -4471,26 +4476,93 @@ function buildHtmlStringFromAst(ast) {
4471
4476
 
4472
4477
  // src/editor/transform/markdown-it-html-inline.ts
4473
4478
  import Token2 from "markdown-it/lib/token.mjs";
4479
+ import voidElements from "void-elements";
4474
4480
  var needSplitInlineHtmlTokenTags = ["img", "iframe", "br"];
4475
- var excludeHtmlInlineNodes = ["html_image", "iframe_inline", "html_br"];
4481
+ var excludeHtmlInlineNodes = ["html_inline_node", "html_image", "iframe_inline", "html_br"];
4476
4482
  var typeMap = {
4477
4483
  img: "html_image",
4478
4484
  iframe: "iframe_inline",
4479
4485
  br: "html_br"
4480
4486
  };
4481
- function splitHtmlInlineTokens(t3) {
4482
- if (!t3.children)
4483
- return [];
4484
- return t3.children.map((child) => {
4485
- if (isHtmlInlineToken(child) && needSplitInlineHtmlTokenTags.includes(child.tag) && !isClosingTag(child.content)) {
4486
- const newToken = new Token2(typeMap[child.tag], "", 0);
4487
- newToken.content = child.content;
4488
- newToken.attrs = getAttrsBySignalHtmlContent(child.content);
4489
- return newToken;
4490
- } else {
4491
- const token = new Token2("text", "", 0);
4492
- token.content = child.content;
4493
- return token;
4487
+ function getMergeArr(phrasingContents) {
4488
+ const unCloseedHtmlStack = [];
4489
+ const mergeArr = [];
4490
+ for (let i = 0; i < phrasingContents.length; i++) {
4491
+ const phrasingContent = phrasingContents[i];
4492
+ if (isHtmlInlineToken(phrasingContent)) {
4493
+ const tagName = getTagName(phrasingContent.content);
4494
+ const htmlNode = {
4495
+ tag: tagName,
4496
+ voidElement: !!voidElements[tagName],
4497
+ isClosingTag: isClosingTag(phrasingContent.content),
4498
+ index: i
4499
+ };
4500
+ if (!htmlNode.voidElement) {
4501
+ if (!htmlNode.isClosingTag) {
4502
+ unCloseedHtmlStack.push(htmlNode);
4503
+ } else if (unCloseedHtmlStack[unCloseedHtmlStack.length - 1]?.tag === htmlNode.tag) {
4504
+ if (unCloseedHtmlStack.length >= 1) {
4505
+ mergeArr.push([unCloseedHtmlStack.pop(), htmlNode]);
4506
+ phrasingContent.complete = true;
4507
+ }
4508
+ }
4509
+ } else {
4510
+ phrasingContent.complete = true;
4511
+ }
4512
+ }
4513
+ }
4514
+ for (let i = 0; i < mergeArr.length; i++) {
4515
+ const merge = mergeArr[i];
4516
+ const startIndex = merge[0].index;
4517
+ const endIndex = merge[1].index;
4518
+ const parentNode = mergeArr.findIndex(
4519
+ (item) => item[0].index < startIndex && item[1].index > endIndex
4520
+ );
4521
+ if (parentNode >= 0) {
4522
+ mergeArr.splice(i, 1);
4523
+ i--;
4524
+ }
4525
+ }
4526
+ return mergeArr;
4527
+ }
4528
+ function mergePhrasingContents(phrasingContents, startIndex, endIndex) {
4529
+ const merged = new Token2("html_inline_node", "", 0);
4530
+ for (let i = startIndex; i <= endIndex; i++) {
4531
+ merged.content += phrasingContents[i].content || "";
4532
+ merged.complete = true;
4533
+ }
4534
+ merged.attrs = {
4535
+ htmlText: merged.content
4536
+ };
4537
+ phrasingContents.splice(startIndex, endIndex - startIndex + 1, merged);
4538
+ return phrasingContents;
4539
+ }
4540
+ function mergeHtmlPhrasingContents(phrasingContents) {
4541
+ const mergeArr = getMergeArr(phrasingContents);
4542
+ let offset = 0;
4543
+ mergeArr.forEach((merge) => {
4544
+ const startIndex = merge[0].index + offset;
4545
+ const endIndex = merge[1].index + offset;
4546
+ mergePhrasingContents(phrasingContents, startIndex, endIndex);
4547
+ offset += startIndex - endIndex;
4548
+ });
4549
+ phrasingContents.forEach((phrasingContent, index) => {
4550
+ if (isHtmlInlineToken(phrasingContent)) {
4551
+ const tagName = getTagName(phrasingContent.content);
4552
+ if (typeMap[tagName]) {
4553
+ const newToken = new Token2(typeMap[tagName], "", 0);
4554
+ newToken.content = phrasingContent.content;
4555
+ newToken.attrs = getAttrsBySignalHtmlContent(phrasingContent.content);
4556
+ newToken.attrs.htmlText = newToken.content;
4557
+ phrasingContents.splice(index, 1, newToken);
4558
+ } else {
4559
+ const newToken = new Token2("html_inline_node", "", 0);
4560
+ newToken.content = phrasingContent.content;
4561
+ newToken.attrs = {
4562
+ htmlText: newToken.content
4563
+ };
4564
+ phrasingContents.splice(index, 1, newToken);
4565
+ }
4494
4566
  }
4495
4567
  });
4496
4568
  }
@@ -4503,29 +4575,40 @@ function isHtmlInlineToken(t3) {
4503
4575
  function isHtmlBlockToken(t3) {
4504
4576
  return t3.type === "html_block";
4505
4577
  }
4506
- function hasSplitInlineHtmlToken(t3) {
4507
- let res = false;
4508
- t3.children?.forEach((child) => {
4509
- if (isHtmlInlineToken(child)) {
4510
- const tag = getTagName(child.content);
4511
- child.tag = tag;
4512
- if (needSplitInlineHtmlTokenTags.includes(child.tag)) {
4513
- res = true;
4514
- }
4515
- }
4516
- });
4517
- return res;
4518
- }
4519
4578
  var rule2 = (state) => {
4520
4579
  const edited = false;
4521
4580
  const tokens = state.tokens;
4522
4581
  const tokensLength = tokens.length;
4523
- for (let i = tokensLength - 1; i >= 0; i--) {
4582
+ for (let i = 0; i <= tokensLength - 1; i++) {
4524
4583
  const curToken = tokens[i];
4525
4584
  if (isInlineToken2(curToken)) {
4526
- if (hasSplitInlineHtmlToken(curToken)) {
4527
- tokens.splice(i, 1, ...splitHtmlInlineTokens(curToken));
4528
- }
4585
+ const newChildren = curToken.children;
4586
+ if (newChildren) {
4587
+ mergeHtmlPhrasingContents(newChildren);
4588
+ }
4589
+ const newTokens = [];
4590
+ let childs = [];
4591
+ newChildren?.forEach((child, index) => {
4592
+ if (excludeHtmlInlineNodes.includes(child.type)) {
4593
+ if (childs.length > 0) {
4594
+ const newToken = new Token2("inline", "", 0);
4595
+ newToken.children = [...childs];
4596
+ newTokens.push(newToken);
4597
+ childs.length = 0;
4598
+ }
4599
+ newTokens.push(child);
4600
+ } else {
4601
+ childs.push(child);
4602
+ }
4603
+ });
4604
+ if (childs.length > 0) {
4605
+ const newToken = new Token2("inline", "", 0);
4606
+ newToken.children = childs;
4607
+ newToken.content = childs.map((child) => child.content).join("");
4608
+ newTokens.push(newToken);
4609
+ childs = [];
4610
+ }
4611
+ tokens.splice(i, 1, ...newTokens);
4529
4612
  } else if (isHtmlBlockToken(curToken)) {
4530
4613
  const tag = getTagName(curToken.content);
4531
4614
  if (isSingleNode(curToken.content) && needSplitInlineHtmlTokenTags.includes(tag)) {
@@ -4726,7 +4809,15 @@ function buildTokenHandlers(schema, parserRules) {
4726
4809
  var MarkdownParser = class {
4727
4810
  constructor(schema, parserRules) {
4728
4811
  this.schema = schema;
4729
- this.tokenizer = MarkdownIt("commonmark", { html: true }).disable(["emphasis", "autolink", "backticks", "entity", "reference"]).enable(["table"]).use(markdown_it_list_checkbox_default).use(markdown_it_html_inline_default);
4812
+ this.tokenizer = MarkdownIt("commonmark", { html: true }).disable([
4813
+ "emphasis",
4814
+ "autolink",
4815
+ "backticks",
4816
+ "entity",
4817
+ "reference",
4818
+ "image",
4819
+ "link"
4820
+ ]).enable(["table"]).use(markdown_it_html_inline_default).use(markdown_it_list_checkbox_default);
4730
4821
  this.tokenHandlers = buildTokenHandlers(schema, parserRules);
4731
4822
  }
4732
4823
  parse(text) {
@@ -5305,21 +5396,21 @@ import { isTextSelection as isTextSelection2, PlainExtension as PlainExtension2
5305
5396
  import { Decoration as Decoration2, DecorationSet as DecorationSet2 } from "@remirror/pm/view";
5306
5397
 
5307
5398
  // src/editor/extensions/Inline/inline-mark-extensions.ts
5308
- import { MarkExtension as MarkExtension2, extension as extension2, keyBinding } from "@remirror/core";
5399
+ import { MarkExtension, extension, keyBinding } from "@remirror/core";
5309
5400
 
5310
5401
  // src/editor/extensions/Inline/format-href.ts
5311
- function formatHref(location) {
5312
- if (isUnixFilePath(location) || isWindowsFilePath(location)) {
5313
- return formatFileUrl(location);
5402
+ function formatHref(location2) {
5403
+ if (isUnixFilePath(location2) || isWindowsFilePath(location2)) {
5404
+ return formatFileUrl(location2);
5314
5405
  } else {
5315
- return location;
5406
+ return location2;
5316
5407
  }
5317
5408
  }
5318
- function isUnixFilePath(location) {
5319
- return location.startsWith("/");
5409
+ function isUnixFilePath(location2) {
5410
+ return location2.startsWith("/");
5320
5411
  }
5321
- function isWindowsFilePath(location) {
5322
- return location.startsWith("\\") || /^[A-Z]{1,2}:/.test(location);
5412
+ function isWindowsFilePath(location2) {
5413
+ return location2.startsWith("\\") || /^[A-Z]{1,2}:/.test(location2);
5323
5414
  }
5324
5415
  function formatFileUrl(filePath) {
5325
5416
  let pathName = filePath;
@@ -5538,6 +5629,8 @@ import { gfmStrikethroughFromMarkdown } from "mdast-util-gfm-strikethrough";
5538
5629
  import { gfmAutolinkLiteral } from "micromark-extension-gfm-autolink-literal";
5539
5630
  import { gfmStrikethrough } from "micromark-extension-gfm-strikethrough";
5540
5631
  import { nanoid } from "nanoid";
5632
+ import voidElements2 from "void-elements";
5633
+ import { cloneDeep } from "lodash";
5541
5634
  gfmAutolinkLiteralFromMarkdown.transforms = [];
5542
5635
  function fixMarkNames(marks) {
5543
5636
  if (marks.length <= 1)
@@ -5799,6 +5892,7 @@ var fromMarkdownOptions = {
5799
5892
  "definition",
5800
5893
  "headingAtx",
5801
5894
  "htmlFlow",
5895
+ "htmlText",
5802
5896
  "list",
5803
5897
  "thematicBreak"
5804
5898
  ]
@@ -5850,150 +5944,25 @@ function parseMdInline(phrasingContents, depth = 1) {
5850
5944
  }
5851
5945
  return inlineTokens;
5852
5946
  }
5853
- var splitHtmlTokens = (tokens) => {
5854
- let splitArr = [];
5855
- for (let i = 0; i < tokens.length; i++) {
5856
- const cur = tokens[i];
5857
- if (cur.type === "html") {
5858
- const isClosing = isClosingTag(cur.value);
5859
- const curTagName = getTagName(cur.value);
5860
- if (needSplitInlineHtmlTokenTags.includes(curTagName)) {
5861
- continue;
5862
- }
5863
- if (!isClosing) {
5864
- const nextSelfCloseIndex = tokens.slice(i).findIndex((t3) => {
5865
- return getTagName(t3.value) === curTagName && isClosingTag(t3.value);
5866
- });
5867
- if (nextSelfCloseIndex >= 0) {
5868
- splitArr.push({
5869
- tagName: curTagName,
5870
- attrs: getAttrsBySignalHtmlContent(cur.value),
5871
- scope: [i, nextSelfCloseIndex + i]
5872
- });
5873
- i = nextSelfCloseIndex + i - 1;
5874
- }
5875
- }
5876
- }
5877
- }
5878
- return splitArr;
5879
- };
5880
- function flatHTMLInlineToken(mdastToken) {
5881
- const allTokens = [...mdastToken];
5882
- const markHtmlTokens = (tokens, depth) => {
5883
- const splitArr = splitHtmlTokens(tokens);
5884
- if (splitArr.length === 0) {
5885
- return;
5886
- }
5887
- splitArr.forEach((arr) => {
5888
- tokens[arr.scope[0]].start = true;
5889
- tokens[arr.scope[0]].complete = true;
5890
- tokens[arr.scope[1]].end = true;
5891
- tokens[arr.scope[1]].complete = true;
5892
- const start = arr.scope[0] + 1;
5893
- const end = arr.scope[1];
5894
- if (start === end) {
5895
- return;
5896
- }
5897
- const scopeTokens = tokens.slice(start, end);
5898
- scopeTokens.forEach((token) => {
5899
- token.depth = depth + 1;
5900
- if (token.htmlSpec) {
5901
- token.htmlSpec.push({
5902
- tagName: arr.tagName,
5903
- attrs: arr.attrs
5904
- });
5905
- } else {
5906
- token.htmlSpec = [
5907
- {
5908
- tagName: arr.tagName,
5909
- attrs: arr.attrs
5910
- }
5911
- ];
5912
- }
5913
- });
5914
- markHtmlTokens(scopeTokens, depth + 1);
5915
- });
5916
- };
5917
- markHtmlTokens(allTokens, 1);
5918
- const res = [];
5919
- allTokens.forEach((token) => {
5920
- if (token.type === "html") {
5921
- if (token.complete) {
5922
- res.push({
5923
- marks: ["mdMark"],
5924
- attrs: {
5925
- depth: token.depth || 1,
5926
- first: !!token.start,
5927
- last: !!token.end
5928
- },
5929
- start: token.position?.start?.offset,
5930
- end: token.position?.end?.offset
5931
- });
5932
- } else {
5933
- res.push({
5934
- marks: ["mdText"],
5935
- attrs: {
5936
- depth: token.depth || 1,
5937
- first: true,
5938
- last: true,
5939
- class: "html_tag"
5940
- },
5941
- start: token.position?.start?.offset,
5942
- end: token.position?.end?.offset
5943
- });
5944
- }
5945
- } else {
5946
- const nodes = flatPhrasingContent(token, token.depth || 1);
5947
- if (token.htmlSpec && nodes.length > 0) {
5948
- for (const node of nodes) {
5949
- node.marks.push("mdHtmlInline");
5950
- node.attrs.htmlSpec = token.htmlSpec;
5951
- }
5952
- }
5953
- res.push(...nodes);
5954
- }
5955
- });
5956
- return res;
5957
- }
5958
- function hasHtmlToken(mdastToken) {
5959
- for (const token of mdastToken) {
5960
- if (token.type === "html" && !needSplitInlineHtmlTokenTags.includes(getTagName(token.value))) {
5961
- return true;
5962
- }
5963
- }
5964
- return false;
5965
- }
5966
5947
  function fromInlineMarkdown(text) {
5967
5948
  const phrasingContents = parseInlineMarkdown(text);
5968
- if (hasHtmlToken(phrasingContents)) {
5969
- const nodes = flatHTMLInlineToken(phrasingContents);
5970
- return nodes;
5971
- }
5972
- const tokens = parseMdInline(phrasingContents);
5973
- return tokens;
5949
+ const res = parseMdInline(phrasingContents);
5950
+ return res;
5974
5951
  }
5975
- var canCreateDomTagName = (tagName) => {
5976
- try {
5977
- document.createElement(tagName);
5978
- return true;
5979
- } catch (error) {
5980
- return false;
5981
- }
5982
- };
5983
5952
 
5984
5953
  // src/editor/extensions/Inline/inline-mark-helpers.ts
5985
5954
  function parseTextBlock(schema, node, startPos, output) {
5986
5955
  if (!node.textContent) {
5987
5956
  return;
5988
5957
  }
5989
- const offsetPoss = [];
5958
+ let offsetPoss = [];
5990
5959
  let pos = 0;
5991
5960
  for (let i = 0; i < node.childCount; i++) {
5992
5961
  const child = node.child(i);
5962
+ pos += child.nodeSize;
5993
5963
  if (excludeHtmlInlineNodes.includes(child.type.name)) {
5994
5964
  offsetPoss.push(pos);
5995
5965
  }
5996
- pos += child.nodeSize;
5997
5966
  }
5998
5967
  const tokens = fromInlineMarkdown(node.textContent);
5999
5968
  let totalOffset = 0;
@@ -6001,12 +5970,20 @@ function parseTextBlock(schema, node, startPos, output) {
6001
5970
  const expectedMarks = token.marks.map((markName) => {
6002
5971
  return schema.marks[markName].create(token.attrs);
6003
5972
  });
6004
- let start = token.start;
6005
- let end = token.end;
6006
- const offset = offsetPoss.filter((pos2) => pos2 >= start && pos2 < end).length;
5973
+ let start = token.start + totalOffset;
5974
+ let end = token.end + totalOffset;
5975
+ const offsetPos = offsetPoss.filter((pos2) => pos2 >= start && pos2 < end);
5976
+ const offset = offsetPos.length;
6007
5977
  totalOffset += offset;
5978
+ if (output[output.length - 1]?.[1] - 1 === offsetPos[0] && offsetPos.length > 0) {
5979
+ output[output.length - 1] = [
5980
+ output[output.length - 1][0] + 1,
5981
+ output[output.length - 1][1] + 1,
5982
+ output[output.length - 1][2]
5983
+ ];
5984
+ }
6008
5985
  output.push([
6009
- startPos + token.start + totalOffset - offset,
5986
+ startPos + token.start + totalOffset,
6010
5987
  startPos + token.end + totalOffset,
6011
5988
  expectedMarks
6012
5989
  ]);
@@ -6202,58 +6179,6 @@ function deleteTextBlockChild(tr, textBlockNode, textBlockStart, childIndex) {
6202
6179
  return tr.delete(offset, offset + textBlockNode.child(childIndex).nodeSize);
6203
6180
  }
6204
6181
 
6205
- // src/editor/extensions/HtmlNode/html-inline-marks.ts
6206
- import { extension, MarkExtension } from "remirror";
6207
- var HtmlInlineMarks = class extends MarkExtension {
6208
- get name() {
6209
- return "mdHtmlInline";
6210
- }
6211
- createMarkSpec() {
6212
- return {
6213
- spanning: false,
6214
- attrs: {
6215
- depth: { default: 0 },
6216
- first: { default: false },
6217
- last: { default: false },
6218
- htmlSpec: { default: [] }
6219
- },
6220
- toDOM: (mark) => {
6221
- const htmlSpec = mark.attrs.htmlSpec.filter(
6222
- (spec) => canCreateDomTagName(spec.tagName)
6223
- );
6224
- if (htmlSpec.length >= 1) {
6225
- const getDomSpec = (spec) => {
6226
- const curSpec = spec[0];
6227
- const res = [curSpec.tagName];
6228
- if (curSpec.attrs) {
6229
- res.push(curSpec.attrs);
6230
- }
6231
- if (spec.length > 1) {
6232
- res.push(getDomSpec(spec.slice(1)));
6233
- } else {
6234
- res.push(0);
6235
- }
6236
- return res;
6237
- };
6238
- return getDomSpec(htmlSpec);
6239
- }
6240
- return ["span"];
6241
- }
6242
- };
6243
- }
6244
- };
6245
- HtmlInlineMarks.disableExtraAttributes = true;
6246
- HtmlInlineMarks = __decorateClass([
6247
- extension({
6248
- defaultOptions: {
6249
- handleViewImgSrcUrl: async (src) => src
6250
- },
6251
- staticKeys: [],
6252
- handlerKeys: [],
6253
- customHandlerKeys: []
6254
- })
6255
- ], HtmlInlineMarks);
6256
-
6257
6182
  // src/editor/extensions/Inline/inline-mark-extensions.ts
6258
6183
  var commonAttrs = {
6259
6184
  depth: { default: 0 }
@@ -6264,7 +6189,7 @@ var endpointAttrs = {
6264
6189
  last: { default: false },
6265
6190
  class: { default: "" }
6266
6191
  };
6267
- var MetaKey = class extends MarkExtension2 {
6192
+ var MetaKey = class extends MarkExtension {
6268
6193
  static {
6269
6194
  this.disableExtraAttributes = true;
6270
6195
  }
@@ -6284,7 +6209,7 @@ var MetaKey = class extends MarkExtension2 {
6284
6209
  };
6285
6210
  }
6286
6211
  };
6287
- var PlainText = class extends MarkExtension2 {
6212
+ var PlainText = class extends MarkExtension {
6288
6213
  static {
6289
6214
  this.disableExtraAttributes = true;
6290
6215
  }
@@ -6298,7 +6223,7 @@ var PlainText = class extends MarkExtension2 {
6298
6223
  };
6299
6224
  }
6300
6225
  };
6301
- var Emphasis = class extends MarkExtension2 {
6226
+ var Emphasis = class extends MarkExtension {
6302
6227
  static {
6303
6228
  this.disableExtraAttributes = true;
6304
6229
  }
@@ -6318,7 +6243,7 @@ var Emphasis = class extends MarkExtension2 {
6318
6243
  __decorateClass([
6319
6244
  keyBinding({ shortcut: "mod-i", command: "toggleEmphasis" })
6320
6245
  ], Emphasis.prototype, "shortcut", 1);
6321
- var Strong = class extends MarkExtension2 {
6246
+ var Strong = class extends MarkExtension {
6322
6247
  static {
6323
6248
  this.disableExtraAttributes = true;
6324
6249
  }
@@ -6338,7 +6263,7 @@ var Strong = class extends MarkExtension2 {
6338
6263
  __decorateClass([
6339
6264
  keyBinding({ shortcut: "mod-b", command: "toggleStrong" })
6340
6265
  ], Strong.prototype, "shortcut", 1);
6341
- var CodeText = class extends MarkExtension2 {
6266
+ var CodeText = class extends MarkExtension {
6342
6267
  static {
6343
6268
  this.disableExtraAttributes = true;
6344
6269
  }
@@ -6358,7 +6283,7 @@ var CodeText = class extends MarkExtension2 {
6358
6283
  __decorateClass([
6359
6284
  keyBinding({ shortcut: "mod-e", command: "toggleCodeText" })
6360
6285
  ], CodeText.prototype, "shortcut", 1);
6361
- var CodeSpace = class extends MarkExtension2 {
6286
+ var CodeSpace = class extends MarkExtension {
6362
6287
  static {
6363
6288
  this.disableExtraAttributes = true;
6364
6289
  }
@@ -6372,7 +6297,7 @@ var CodeSpace = class extends MarkExtension2 {
6372
6297
  };
6373
6298
  }
6374
6299
  };
6375
- var Delete = class extends MarkExtension2 {
6300
+ var Delete = class extends MarkExtension {
6376
6301
  static {
6377
6302
  this.disableExtraAttributes = true;
6378
6303
  }
@@ -6392,7 +6317,7 @@ var Delete = class extends MarkExtension2 {
6392
6317
  __decorateClass([
6393
6318
  keyBinding({ shortcut: "mod-shift-s", command: "toggleDelete" })
6394
6319
  ], Delete.prototype, "shortcut", 1);
6395
- var LinkText = class extends MarkExtension2 {
6320
+ var LinkText = class extends MarkExtension {
6396
6321
  static {
6397
6322
  this.disableExtraAttributes = true;
6398
6323
  }
@@ -6417,7 +6342,7 @@ var LinkText = class extends MarkExtension2 {
6417
6342
  };
6418
6343
  }
6419
6344
  };
6420
- var LinkUri = class extends MarkExtension2 {
6345
+ var LinkUri = class extends MarkExtension {
6421
6346
  static {
6422
6347
  this.disableExtraAttributes = true;
6423
6348
  }
@@ -6432,7 +6357,7 @@ var LinkUri = class extends MarkExtension2 {
6432
6357
  };
6433
6358
  }
6434
6359
  };
6435
- var ImgText = class extends MarkExtension2 {
6360
+ var ImgText = class extends MarkExtension {
6436
6361
  static {
6437
6362
  this.disableExtraAttributes = true;
6438
6363
  }
@@ -6448,7 +6373,7 @@ var ImgText = class extends MarkExtension2 {
6448
6373
  }
6449
6374
  };
6450
6375
  var globalImageHrefCache = /* @__PURE__ */ new Map();
6451
- var ImgUri = class extends MarkExtension2 {
6376
+ var ImgUri = class extends MarkExtension {
6452
6377
  constructor() {
6453
6378
  super(...arguments);
6454
6379
  this.createNodeViews = () => {
@@ -6496,7 +6421,7 @@ var ImgUri = class extends MarkExtension2 {
6496
6421
  };
6497
6422
  ImgUri.disableExtraAttributes = true;
6498
6423
  ImgUri = __decorateClass([
6499
- extension2({
6424
+ extension({
6500
6425
  defaultOptions: {
6501
6426
  handleViewImgSrcUrl: async (src) => src
6502
6427
  },
@@ -6528,8 +6453,8 @@ var markExtensions = (options = {}) => [
6528
6453
  new ImgText(),
6529
6454
  new ImgUri({
6530
6455
  handleViewImgSrcUrl: options.handleViewImgSrcUrl
6531
- }),
6532
- new HtmlInlineMarks()
6456
+ })
6457
+ // new HtmlInlineMarks(),
6533
6458
  ];
6534
6459
 
6535
6460
  // src/editor/extensions/Inline/inline-deco-extension.ts
@@ -6939,7 +6864,7 @@ var import_escape_string_regexp = __toESM(require_escape_string_regexp(), 1);
6939
6864
  var import_string_prototype = __toESM(require_string_prototype2(), 1);
6940
6865
  import {
6941
6866
  command,
6942
- extension as extension4,
6867
+ extension as extension3,
6943
6868
  helper,
6944
6869
  PlainExtension as PlainExtension5
6945
6870
  } from "@remirror/core";
@@ -6955,7 +6880,7 @@ function rotateIndex(index, length) {
6955
6880
 
6956
6881
  // src/editor/components/WysiwygEditor/index.tsx
6957
6882
  import { Remirror } from "@remirror/react";
6958
- import { memo as memo4, useMemo as useMemo4, useCallback as useCallback3 } from "react";
6883
+ import { memo as memo5, useMemo as useMemo4, useCallback as useCallback3 } from "react";
6959
6884
 
6960
6885
  // src/editor/theme/codemirror/dark.ts
6961
6886
  import { tags as t } from "@lezer/highlight";
@@ -7303,7 +7228,54 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
7303
7228
  }
7304
7229
 
7305
7230
  & input[type='checkbox'] {
7306
- accent-color: #58a6ff;
7231
+ /* Add if not using autoprefixer */
7232
+ -webkit-appearance: none;
7233
+ /* Remove most all native input styles */
7234
+ appearance: none;
7235
+ /* Not removed via appearance */
7236
+ margin: 0;
7237
+
7238
+ font: inherit;
7239
+ color: currentColor;
7240
+ width: 1.15em;
7241
+ height: 1.15em;
7242
+ border: 1px solid currentColor;
7243
+ border-radius: 4px;
7244
+ transform: translateY(0.25em);
7245
+
7246
+ display: grid;
7247
+ place-content: center;
7248
+ }
7249
+
7250
+ & input[type='checkbox']:checked {
7251
+ background-color: ${(props) => props.theme.accentColor};
7252
+ }
7253
+
7254
+ & input[type='checkbox']:checked::before {
7255
+ transform: scale(1);
7256
+ }
7257
+
7258
+ & input[type='checkbox']::before {
7259
+ content: '';
7260
+ width: 0.75em;
7261
+ height: 0.75em;
7262
+ clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
7263
+ transform: scale(0);
7264
+ transform-origin: bottom left;
7265
+ transition: 120ms transform ease-in-out;
7266
+ background-color: ${(props) => props.theme.bgColor};
7267
+ }
7268
+
7269
+ & input[type='checkbox']:focus {
7270
+ outline: max(2px, 0.15em) solid currentColor;
7271
+ outline-offset: max(2px, 0.15em);
7272
+ }
7273
+
7274
+ & input[type='checkbox']:disabled {
7275
+ --form-control-color: #eee;
7276
+
7277
+ color: #eee;
7278
+ cursor: not-allowed;
7307
7279
  }
7308
7280
 
7309
7281
  & a:focus,
@@ -7565,16 +7537,6 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
7565
7537
  padding-right: 20px;
7566
7538
  }
7567
7539
 
7568
- & code,
7569
- & tt {
7570
- padding: 0.2em 0.4em;
7571
- margin: 0;
7572
- font-size: 0.85em;
7573
- white-space: break-spaces;
7574
- background-color: rgba(110, 118, 129, 0.4);
7575
- border-radius: 6px;
7576
- }
7577
-
7578
7540
  & code br,
7579
7541
  & tt br {
7580
7542
  display: none;
@@ -7774,6 +7736,39 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
7774
7736
  transition: all 0.3s;
7775
7737
  }
7776
7738
 
7739
+ .inline-node-show {
7740
+ display: inline-block;
7741
+ }
7742
+
7743
+ .inline-html {
7744
+ position: relative;
7745
+ }
7746
+
7747
+ .inline-html-src {
7748
+ display: inline;
7749
+ padding: 0.2em 0.4em;
7750
+ margin: 0;
7751
+ background-color: ${(props) => props.theme.codeBgColor};
7752
+ border-radius: 6px;
7753
+ }
7754
+
7755
+ .inline-html-preview {
7756
+ position: absolute;
7757
+ top: calc(100% + 0.5em);
7758
+ left: 50%;
7759
+ transform: translateX(-50%);
7760
+ width: max-content;
7761
+ padding: 0.5em 1em;
7762
+ max-width: 400px;
7763
+ border-radius: 0.2em;
7764
+ background-color: ${(props) => props.theme.bgColor};
7765
+ z-index: 1;
7766
+ }
7767
+
7768
+ .inline-html-render {
7769
+ display: inline-block;
7770
+ }
7771
+
7777
7772
  .html-node {
7778
7773
  position: relative;
7779
7774
  min-height: 40px;
@@ -7789,7 +7784,7 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
7789
7784
  }
7790
7785
 
7791
7786
  & .ProseMirror-focused {
7792
- outline: 2px solid ${(props) => props.theme.accentColor};
7787
+ outline: none;
7793
7788
  }
7794
7789
 
7795
7790
  .img-input__container {
@@ -8553,13 +8548,13 @@ var TableToolbar_default = TableToolbar;
8553
8548
  import { ProsemirrorDevTools } from "@remirror/dev";
8554
8549
 
8555
8550
  // src/editor/components/ErrorBoundary.tsx
8556
- import React from "react";
8551
+ import React2 from "react";
8557
8552
  import styled5 from "styled-components";
8558
8553
  import { Fragment as Fragment4, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
8559
8554
  var Title = styled5.h1`
8560
8555
  color: ${({ theme }) => theme.dangerColor};
8561
8556
  `;
8562
- var ErrorBoundary = class extends React.Component {
8557
+ var ErrorBoundary = class extends React2.Component {
8563
8558
  constructor(props) {
8564
8559
  super(props);
8565
8560
  this.state = { hasError: this.props.hasError ?? false };
@@ -8583,7 +8578,7 @@ var ErrorBoundary = class extends React.Component {
8583
8578
  var ErrorBoundary_default = ErrorBoundary;
8584
8579
 
8585
8580
  // src/editor/components/Editor.tsx
8586
- import { forwardRef, memo, useImperativeHandle, useMemo, useState as useState2 } from "react";
8581
+ import { forwardRef, memo as memo2, useImperativeHandle, useMemo, useState as useState2 } from "react";
8587
8582
 
8588
8583
  // src/editor/components/useContextMounted.tsx
8589
8584
  import { useRemirrorContext as useRemirrorContext2 } from "@remirror/react-core";
@@ -8599,7 +8594,7 @@ var useContextMounted = (onContextMounted) => {
8599
8594
 
8600
8595
  // src/editor/components/Editor.tsx
8601
8596
  import { jsx as jsx6 } from "react/jsx-runtime";
8602
- var Editor = memo(
8597
+ var Editor = memo2(
8603
8598
  forwardRef((props, ref) => {
8604
8599
  const { initialType = "wysiwyg", hooks = [], onContextMounted, ...otherProps } = props;
8605
8600
  const [type, setType] = useState2(initialType);
@@ -8754,7 +8749,7 @@ var defaultIgnoredKeys = [
8754
8749
  ];
8755
8750
 
8756
8751
  // src/editor/extensions/SlashMenu/slashmenu-extension.ts
8757
- import { PlainExtension as PlainExtension4, extension as extension3 } from "remirror";
8752
+ import { PlainExtension as PlainExtension4, extension as extension2 } from "remirror";
8758
8753
 
8759
8754
  // src/editor/extensions/SlashMenu/case.ts
8760
8755
  var defaultConditions = (openInSelection = false) => {
@@ -8887,7 +8882,7 @@ var SlashMenuExtension = class extends PlainExtension4 {
8887
8882
  }
8888
8883
  };
8889
8884
  SlashMenuExtension = __decorateClass([
8890
- extension3({
8885
+ extension2({
8891
8886
  defaultOptions: {}
8892
8887
  })
8893
8888
  ], SlashMenuExtension);
@@ -8897,11 +8892,11 @@ import { useCallback as useCallback2, useEffect as useEffect4, useMemo as useMem
8897
8892
  import { usePopper } from "react-popper";
8898
8893
 
8899
8894
  // src/editor/toolbar/SlashMenu/SlashMenuRoot.tsx
8900
- import { memo as memo3, useCallback, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef2, useState as useState4 } from "react";
8895
+ import { memo as memo4, useCallback, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef2, useState as useState4 } from "react";
8901
8896
  import styled7, { css as css3 } from "styled-components";
8902
8897
 
8903
8898
  // src/editor/toolbar/SlashMenu/TablePanel.tsx
8904
- import { forwardRef as forwardRef2, useState as useState3, useImperativeHandle as useImperativeHandle2, memo as memo2 } from "react";
8899
+ import { forwardRef as forwardRef2, useState as useState3, useImperativeHandle as useImperativeHandle2, memo as memo3 } from "react";
8905
8900
  import styled6 from "styled-components";
8906
8901
  import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
8907
8902
  var TablePanelCell = styled6.div.attrs((p) => p)`
@@ -8912,7 +8907,7 @@ var TablePanelCell = styled6.div.attrs((p) => p)`
8912
8907
  height: 10px;
8913
8908
  background-color: ${(props) => props.inScope ? props.theme.blue : props.theme.contextMenuBgColor};
8914
8909
  `;
8915
- var TablePanel = memo2(
8910
+ var TablePanel = memo3(
8916
8911
  forwardRef2((props, ref) => {
8917
8912
  const { commands, closeMenu } = props;
8918
8913
  const [rowsCount, setRowsCount] = useState3(3);
@@ -8996,7 +8991,7 @@ var darken = (color, amount) => Color(color).darken(amount).string();
8996
8991
 
8997
8992
  // src/editor/toolbar/SlashMenu/SlashMenuRoot.tsx
8998
8993
  import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
8999
- var SlashMenuRoot = memo3(
8994
+ var SlashMenuRoot = memo4(
9000
8995
  ({ rootRef, commands, closeMenu }) => {
9001
8996
  const componentRefMap = useRef2({});
9002
8997
  const menuItems = useMemo2(() => {
@@ -9352,7 +9347,7 @@ var WysiwygEditor = (props) => {
9352
9347
  }
9353
9348
  ) }) });
9354
9349
  };
9355
- var WysiwygEditor_default = memo4(WysiwygEditor);
9350
+ var WysiwygEditor_default = memo5(WysiwygEditor);
9356
9351
 
9357
9352
  // src/editor/extensions/Find/find-extension.ts
9358
9353
  var FindExtension = class extends PlainExtension5 {
@@ -9557,7 +9552,7 @@ __decorateClass([
9557
9552
  helper()
9558
9553
  ], FindExtension.prototype, "findRanges", 1);
9559
9554
  FindExtension = __decorateClass([
9560
- extension4({
9555
+ extension3({
9561
9556
  defaultOptions: {
9562
9557
  decoration: { style: "background-color: yellow;" },
9563
9558
  activeDecoration: { style: "background-color: orange;" },
@@ -16645,7 +16640,7 @@ var LineHtmlBlockExtension = class extends NodeExtension {
16645
16640
  import {
16646
16641
  command as command2,
16647
16642
  ErrorConstant as ErrorConstant2,
16648
- extension as extension5,
16643
+ extension as extension4,
16649
16644
  ExtensionTag,
16650
16645
  getTextSelection,
16651
16646
  invariant,
@@ -16659,7 +16654,7 @@ import { insertPoint } from "@remirror/pm/transform";
16659
16654
  import { ExtensionImageTheme } from "@remirror/theme";
16660
16655
 
16661
16656
  // src/editor/extensions/Image/image-nodeview.tsx
16662
- import { Image, Popover } from "zens";
16657
+ import { Image as ZensImage, Popover } from "zens";
16663
16658
 
16664
16659
  // src/editor/extensions/Image/image-tool-tips.tsx
16665
16660
  import { useState as useState6 } from "react";
@@ -16692,7 +16687,7 @@ var ImageToolTips = (props) => {
16692
16687
 
16693
16688
  // src/editor/components/Resizable/Resizable.tsx
16694
16689
  import styled9 from "styled-components";
16695
- import { useRef as useRef4, useEffect as useEffect5, useCallback as useCallback4, memo as memo5, useState as useState7 } from "react";
16690
+ import { useRef as useRef4, useEffect as useEffect5, useCallback as useCallback4, memo as memo6, useState as useState7 } from "react";
16696
16691
 
16697
16692
  // node_modules/@remirror/core-helpers/dist/remirror-core-helpers.js
16698
16693
  var import_make_error = __toESM(require_make_error(), 1);
@@ -17008,7 +17003,7 @@ var ResizableContainer = styled9.div`
17008
17003
  transition: all 0.15s ease-out;
17009
17004
  `;
17010
17005
  var MIN_WIDTH = 20;
17011
- var Resizable = memo5((props) => {
17006
+ var Resizable = memo6((props) => {
17012
17007
  const {
17013
17008
  node,
17014
17009
  aspectRatio = 0 /* Fixed */,
@@ -17207,7 +17202,6 @@ import { jsx as jsx15 } from "react/jsx-runtime";
17207
17202
  var warningFallBack = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAAAAACIM/FCAAAChElEQVR4Ae3aMW/TQBxAcb70k91AAiGuGlZAtOlQApWaDiSdklZq2RPUTm1xUWL3PgqSpygkXlh88N54nn7S2Trd3y/CP5IQIUKECBEiRIgQIUKECBEiRIgQIUKECBEiRIgQIUKECBEiRIgQIUKECBEiRIgQIUKECBEiRIgQIUKECPmPIEKECBEiRIgQIeX82+FBO0naB4eTRRkt5P7sNWt1Rw9RQvKThI2SYR4f5OoVW2rfRAYpT6hqHc8WeVHki9mgRdWwiAmyfA9AdrlaW5tlAHxcxQMpK8feRbGxPEkrSREN5ARg/y780V0GMIwFcgXwLg9byvsAN3FA8lfAfr7jYQZ0nqKAfAb21vYVwNruSoEvMUDuE+Ai7IKECZA+RAA5A7JiN6TMgFHzIeUb4DLshoQZ0H1uPGQOvFzVQZYtYNF4yBg4DnWQMAAmjYccArN6yBQ4ajzkAFjUQ+ZAv/GQNpDXQ3Kg03hIAhT1kAJIhLi1/vJl39Ic6Mf3+a2K8PM7BgahtgEwjuKI0lqGjSI8opRdYFb3sk/jODSGEZCVuyFFDzgPzYc8JMBkN2QMpI8RQMIQ2LvdBblNgdM4Lh/aQJaHrf3sAe2nKCDhGqCfb3VEcx1UNQTItlzQ3fYAvoZYIMUHgHRSbiyPU4BPZUSX2JWEbLZcW5v2qByrmMYKxZCq1mA6z4sin08HLapOy8gGPddtttT5HuHobZiwUXr6K85h6KjLWm/PH+MdTy/GR/12knb6g8mPZ38YECJEiBAhQoQIESJEiBAhQoQIESJEiBAhQoQIESJEiBAhQoQIESJEiBAhQoQIESJEiBAhQoQIESJEiBAhQoQIESJEiBAh0fUb5q7oCGreEVEAAAAASUVORK5CYII=";
17208
17203
  function ImageNodeView(props) {
17209
17204
  const { node, selected, updateAttributes, handleViewImgSrcUrl } = props;
17210
- const [src, setSrc] = useState8("");
17211
17205
  const initRef = useRef5();
17212
17206
  const popoverStore = useRef5();
17213
17207
  const [open, setOpen] = useState8(selected);
@@ -17217,26 +17211,36 @@ function ImageNodeView(props) {
17217
17211
  }
17218
17212
  setOpen(selected);
17219
17213
  }, [selected]);
17220
- useEffect6(() => {
17221
- if (handleViewImgSrcUrl) {
17222
- handleViewImgSrcUrl(node.attrs.src).then((newSrc) => {
17223
- setSrc(newSrc);
17224
- });
17225
- } else {
17226
- setSrc(node.attrs.src);
17227
- }
17228
- }, [handleViewImgSrcUrl, node.attrs.src]);
17229
17214
  const handleStoreChange = (store) => popoverStore.current = store;
17230
- const Main = src ? /* @__PURE__ */ jsx15(Resizable, { controlInit: (init) => initRef.current = init, ...props, children: /* @__PURE__ */ jsx15(
17231
- Image,
17215
+ const Main = /* @__PURE__ */ jsx15(Resizable, { controlInit: (init) => initRef.current = init, ...props, children: /* @__PURE__ */ jsx15(
17216
+ ZensImage,
17232
17217
  {
17233
- fallback: warningFallBack,
17234
17218
  onLoad: () => initRef.current?.(),
17235
- preview: false,
17236
- ...node.attrs,
17237
- src
17219
+ src: node.attrs.src,
17220
+ imgPromise: (src) => {
17221
+ return new Promise((resolve, reject) => {
17222
+ const makeImageLoad = (targetSrc) => {
17223
+ const img = new Image();
17224
+ img.src = targetSrc;
17225
+ img.onload = () => {
17226
+ resolve(targetSrc);
17227
+ };
17228
+ img.onerror = () => {
17229
+ reject(warningFallBack);
17230
+ };
17231
+ };
17232
+ if (handleViewImgSrcUrl) {
17233
+ handleViewImgSrcUrl(node.attrs.src).then((newSrc) => {
17234
+ makeImageLoad(newSrc);
17235
+ });
17236
+ } else {
17237
+ makeImageLoad(node.attrs.src);
17238
+ }
17239
+ });
17240
+ },
17241
+ ...node.attrs
17238
17242
  }
17239
- ) }) : /* @__PURE__ */ jsx15(Image, { src: warningFallBack, style: { width: "80px", height: "80px" } });
17243
+ ) });
17240
17244
  if (!open) {
17241
17245
  return Main;
17242
17246
  }
@@ -17431,7 +17435,7 @@ __decorateClass([
17431
17435
  command2()
17432
17436
  ], HtmlImageExtension.prototype, "uploadImage", 1);
17433
17437
  HtmlImageExtension = __decorateClass([
17434
- extension5({
17438
+ extension4({
17435
17439
  defaultOptions: {
17436
17440
  createPlaceholder,
17437
17441
  handleViewImgSrcUrl: async (src) => src,
@@ -17507,7 +17511,7 @@ var import_querystringify = __toESM(require_querystringify(), 1);
17507
17511
  import {
17508
17512
  command as command3,
17509
17513
  cx as cx2,
17510
- extension as extension6,
17514
+ extension as extension5,
17511
17515
  ExtensionTag as ExtensionTag2,
17512
17516
  findSelectedNodeOfType,
17513
17517
  NodeExtension as NodeExtension3,
@@ -17670,7 +17674,7 @@ __decorateClass([
17670
17674
  command3()
17671
17675
  ], IframeExtension.prototype, "updateYouTubeVideo", 1);
17672
17676
  IframeExtension = __decorateClass([
17673
- extension6({
17677
+ extension5({
17674
17678
  defaultOptions: {
17675
17679
  defaultSource: "",
17676
17680
  class: "remirror-iframe",
@@ -17711,7 +17715,7 @@ function createYouTubeUrl(props) {
17711
17715
  }
17712
17716
 
17713
17717
  // src/editor/extensions/Placeholder/index.ts
17714
- import { extension as extension7, ManagerPhase, PlainExtension as PlainExtension6 } from "@remirror/core";
17718
+ import { extension as extension6, ManagerPhase, PlainExtension as PlainExtension6 } from "@remirror/core";
17715
17719
  import { Decoration as Decoration4, DecorationSet as DecorationSet4 } from "@remirror/pm/view";
17716
17720
  import { ExtensionPlaceholderTheme } from "@remirror/theme";
17717
17721
  var PlaceholderExtension = class extends PlainExtension6 {
@@ -17736,7 +17740,7 @@ var PlaceholderExtension = class extends PlainExtension6 {
17736
17740
  }
17737
17741
  };
17738
17742
  PlaceholderExtension = __decorateClass([
17739
- extension7({
17743
+ extension6({
17740
17744
  defaultOptions: {
17741
17745
  emptyNodeClass: ExtensionPlaceholderTheme.IS_EMPTY,
17742
17746
  placeholder: ""
@@ -17764,7 +17768,7 @@ function createDecorationSet(props) {
17764
17768
 
17765
17769
  // src/editor/extensions/Clipboard/clipboard-extension.ts
17766
17770
  import { PlainExtension as PlainExtension7 } from "@remirror/core";
17767
- import { DOMSerializer, DOMParser } from "@remirror/pm/model";
17771
+ import { DOMSerializer, DOMParser as DOMParser2 } from "@remirror/pm/model";
17768
17772
  function isPureText(content) {
17769
17773
  if (!content)
17770
17774
  return false;
@@ -17812,7 +17816,7 @@ var ClipboardExtension = class extends PlainExtension7 {
17812
17816
  const html2 = clipboardData.getData("text/html");
17813
17817
  if (html2.length === 0 && text.length === 0)
17814
17818
  return false;
17815
- const domParser = DOMParser.fromSchema(schema);
17819
+ const domParser = DOMParser2.fromSchema(schema);
17816
17820
  let dom;
17817
17821
  if (html2.length === 0) {
17818
17822
  const slice2 = parser4?.(text);
@@ -17852,7 +17856,7 @@ var ClipboardExtension = class extends PlainExtension7 {
17852
17856
  };
17853
17857
 
17854
17858
  // src/editor/extensions/HtmlBr/br-extension.ts
17855
- import { extension as extension8, ExtensionTag as ExtensionTag3, NodeExtension as NodeExtension4 } from "@remirror/core";
17859
+ import { extension as extension7, ExtensionTag as ExtensionTag3, NodeExtension as NodeExtension4, nodeInputRule as nodeInputRule4 } from "@remirror/core";
17856
17860
  var HtmlBrExtension = class extends NodeExtension4 {
17857
17861
  get name() {
17858
17862
  return "html_br";
@@ -17877,6 +17881,15 @@ var HtmlBrExtension = class extends NodeExtension4 {
17877
17881
  }
17878
17882
  };
17879
17883
  }
17884
+ createInputRules() {
17885
+ const rules = [
17886
+ nodeInputRule4({
17887
+ regexp: new RegExp("<br/>"),
17888
+ type: this.type
17889
+ })
17890
+ ];
17891
+ return rules;
17892
+ }
17880
17893
  fromMarkdown() {
17881
17894
  return [
17882
17895
  {
@@ -17892,11 +17905,379 @@ var HtmlBrExtension = class extends NodeExtension4 {
17892
17905
  };
17893
17906
  HtmlBrExtension.disableExtraAttributes = true;
17894
17907
  HtmlBrExtension = __decorateClass([
17895
- extension8({
17908
+ extension7({
17896
17909
  defaultOptions: {}
17897
17910
  })
17898
17911
  ], HtmlBrExtension);
17899
17912
 
17913
+ // src/editor/extensions/HtmlNode/html-inline-node.tsx
17914
+ import {
17915
+ ExtensionTag as ExtensionTag4,
17916
+ NodeExtension as NodeExtension5,
17917
+ extension as extension8,
17918
+ nodeInputRule as nodeInputRule5
17919
+ } from "remirror";
17920
+
17921
+ // src/editor/extensions/HtmlNode/html-inline-view.ts
17922
+ import {
17923
+ EditorState as EditorState2,
17924
+ TextSelection as TextSelection5,
17925
+ Plugin
17926
+ } from "@remirror/pm/state";
17927
+ import { EditorView as EditorView6 } from "@remirror/pm/view";
17928
+ import { keymap as keymap3 } from "@remirror/pm/keymap";
17929
+ import { history as history2, redo as redo2, undo as undo2 } from "@remirror/pm/history";
17930
+ function collapseCmd(outerView, dir, requireOnBorder, requireEmptySelection = true) {
17931
+ return (innerState, dispatch) => {
17932
+ let outerState = outerView.state;
17933
+ let { to: outerTo, from: outerFrom } = outerState.selection;
17934
+ let { to: innerTo, from: innerFrom } = innerState.selection;
17935
+ if (requireEmptySelection && innerTo !== innerFrom) {
17936
+ return false;
17937
+ }
17938
+ let currentPos = dir > 0 ? innerTo : innerFrom;
17939
+ if (requireOnBorder) {
17940
+ let nodeSize2 = innerState.doc.nodeSize - 2;
17941
+ if (dir > 0 && currentPos < nodeSize2) {
17942
+ return false;
17943
+ }
17944
+ if (dir < 0 && currentPos > 0) {
17945
+ return false;
17946
+ }
17947
+ }
17948
+ if (dispatch) {
17949
+ let targetPos = dir > 0 ? outerTo : outerFrom;
17950
+ outerView.dispatch(
17951
+ outerState.tr.setSelection(TextSelection5.create(outerState.doc, targetPos))
17952
+ );
17953
+ outerView.focus();
17954
+ }
17955
+ return true;
17956
+ };
17957
+ }
17958
+ var HTMLInlineView = class {
17959
+ constructor(node, view, getPos) {
17960
+ this.options = {};
17961
+ this._node = node;
17962
+ this._outerView = view;
17963
+ this._getPos = getPos;
17964
+ this._isEditing = false;
17965
+ this._tagName = "span";
17966
+ this.dom = document.createElement(this._tagName);
17967
+ this.dom.classList.add("inline-html");
17968
+ this._htmlRenderElt = document.createElement("span");
17969
+ this._htmlRenderElt.textContent = "";
17970
+ this._htmlRenderElt.classList.add("inline-html-render");
17971
+ this.dom.appendChild(this._htmlRenderElt);
17972
+ this._htmlSrcElt = document.createElement("span");
17973
+ this._htmlSrcElt.spellcheck = false;
17974
+ this.dom.appendChild(this._htmlSrcElt);
17975
+ this.dom.addEventListener("click", () => this.ensureFocus());
17976
+ if (node.attrs.fromInput) {
17977
+ setTimeout(() => {
17978
+ this.openEditor();
17979
+ });
17980
+ } else {
17981
+ this.renderHtml();
17982
+ }
17983
+ console.log("this._node.attrs", this._node.attrs);
17984
+ }
17985
+ destroy() {
17986
+ this.closeEditor(false);
17987
+ if (this._htmlRenderElt) {
17988
+ this._htmlRenderElt.remove();
17989
+ delete this._htmlRenderElt;
17990
+ }
17991
+ if (this._htmlSrcElt) {
17992
+ this._htmlSrcElt.remove();
17993
+ delete this._htmlSrcElt;
17994
+ }
17995
+ this.dom.remove();
17996
+ }
17997
+ ensureFocus() {
17998
+ if (this._innerView && this._outerView.hasFocus()) {
17999
+ this._innerView.focus();
18000
+ }
18001
+ }
18002
+ // == Updates ======================================= //
18003
+ update(node, decorations) {
18004
+ if (!node.sameMarkup(this._node))
18005
+ return false;
18006
+ this._node = node;
18007
+ console.log("update", node);
18008
+ if (!this._isEditing) {
18009
+ this.renderHtml();
18010
+ }
18011
+ return true;
18012
+ }
18013
+ // == Events ===================================== //
18014
+ selectNode() {
18015
+ if (!this._outerView.editable) {
18016
+ return;
18017
+ }
18018
+ if (!this._isEditing) {
18019
+ this.openEditor();
18020
+ }
18021
+ }
18022
+ deselectNode() {
18023
+ if (this._isEditing) {
18024
+ this.closeEditor();
18025
+ }
18026
+ }
18027
+ stopEvent(event) {
18028
+ return this._innerView !== void 0 && event.target !== void 0 && this._innerView.dom.contains(event.target);
18029
+ }
18030
+ ignoreMutation() {
18031
+ return true;
18032
+ }
18033
+ // == Rendering ===================================== //
18034
+ renderHtml(preview = false) {
18035
+ if (!this._htmlRenderElt) {
18036
+ return;
18037
+ }
18038
+ let content = this._innerView?.state.doc.textContent || this._node.attrs?.htmlText || "";
18039
+ let texString = content.trim();
18040
+ if (texString.length < 1) {
18041
+ while (this._htmlRenderElt.firstChild) {
18042
+ this._htmlRenderElt.firstChild.remove();
18043
+ }
18044
+ return;
18045
+ } else {
18046
+ }
18047
+ try {
18048
+ while (this._htmlRenderElt.firstChild) {
18049
+ this._htmlRenderElt.firstChild.remove();
18050
+ }
18051
+ const renderEl = document.createElement("span");
18052
+ const domParser = new DOMParser();
18053
+ const doc = domParser.parseFromString(texString, "text/html");
18054
+ doc.body.childNodes.forEach((child) => {
18055
+ if (isImageElement(child) && child.src && this.options.handleViewImgSrcUrl) {
18056
+ let targetUrl = child.src;
18057
+ if (child.src.includes(location.origin)) {
18058
+ targetUrl = child.src.split(location.origin)[1];
18059
+ }
18060
+ this.options.handleViewImgSrcUrl(targetUrl).then((newHref) => {
18061
+ child.src = newHref;
18062
+ });
18063
+ }
18064
+ renderEl.appendChild(child);
18065
+ });
18066
+ if (renderEl.childNodes.length === 1) {
18067
+ this._htmlRenderElt.remove();
18068
+ this._htmlRenderElt = renderEl.firstElementChild;
18069
+ }
18070
+ if (this._htmlRenderElt) {
18071
+ this.dom.append(this._htmlRenderElt);
18072
+ this._htmlRenderElt.classList.remove("node-hide");
18073
+ this._htmlRenderElt.classList.add("inline-node-show");
18074
+ if (preview) {
18075
+ this._htmlRenderElt.classList.add("inline-html-preview");
18076
+ }
18077
+ this._htmlRenderElt.innerHTML = texString;
18078
+ }
18079
+ } catch (err) {
18080
+ console.error(err);
18081
+ this._htmlRenderElt?.classList.add("parse-error");
18082
+ this.dom.setAttribute("title", err.toString());
18083
+ }
18084
+ }
18085
+ // == Inner Editor ================================== //
18086
+ dispatchInner(tr) {
18087
+ if (!this._innerView) {
18088
+ return;
18089
+ }
18090
+ let { state } = this._innerView.state.applyTransaction(tr);
18091
+ this._innerView.updateState(state);
18092
+ this.renderHtml(true);
18093
+ }
18094
+ openEditor() {
18095
+ if (this._innerView) {
18096
+ console.warn("[HTMLInlineView] editor already open when openEditor was called");
18097
+ return;
18098
+ }
18099
+ this._innerView = new EditorView6(this._htmlSrcElt, {
18100
+ state: EditorState2.create({
18101
+ doc: this._outerView.state.schema.node("paragraph", null, [
18102
+ this._outerView.state.schema.text(this._node.attrs?.htmlText)
18103
+ ]),
18104
+ plugins: [
18105
+ history2(),
18106
+ keymap3({
18107
+ Tab: (state, dispatch) => {
18108
+ if (dispatch) {
18109
+ dispatch(state.tr.insertText(" "));
18110
+ }
18111
+ return true;
18112
+ },
18113
+ ArrowLeft: collapseCmd(this._outerView, -1, true),
18114
+ ArrowRight: collapseCmd(this._outerView, 1, true),
18115
+ ArrowUp: collapseCmd(this._outerView, -1, true),
18116
+ ArrowDown: collapseCmd(this._outerView, 1, true),
18117
+ "Mod-z": (state, dispatch, view) => {
18118
+ return undo2(state, dispatch, view);
18119
+ },
18120
+ "Shift-Mod-z": (state, dispatch, view) => {
18121
+ return redo2(state, dispatch, view);
18122
+ }
18123
+ }),
18124
+ new Plugin({
18125
+ props: {
18126
+ handleDOMEvents: {
18127
+ blur: (view) => {
18128
+ const pos = this._getPos();
18129
+ if (pos !== void 0) {
18130
+ const text = this._innerView?.state.doc.textContent || "";
18131
+ const tr = this._outerView.state.tr;
18132
+ tr.setNodeAttribute(pos, "fromInput", false);
18133
+ tr.setNodeAttribute(pos, "htmlText", text);
18134
+ this._outerView.dispatch(tr);
18135
+ }
18136
+ this.closeEditor();
18137
+ }
18138
+ }
18139
+ }
18140
+ })
18141
+ ]
18142
+ }),
18143
+ dispatchTransaction: this.dispatchInner.bind(this)
18144
+ });
18145
+ this._innerView.dom.classList.add("inline-html-src");
18146
+ this._innerView.dom.classList.remove("ProseMirror");
18147
+ let innerState = this._innerView.state;
18148
+ this._innerView.focus();
18149
+ let innerPos = innerState.doc.textContent.length || 0;
18150
+ this._innerView.dispatch(
18151
+ innerState.tr.setSelection(TextSelection5.create(innerState.doc, innerPos))
18152
+ );
18153
+ this._htmlRenderElt?.classList.add("inline-html-preview");
18154
+ this._isEditing = true;
18155
+ }
18156
+ /**
18157
+ * Called when the inner ProseMirror editor should close.
18158
+ *
18159
+ * @param render Optionally update the rendered html after closing. (which
18160
+ * is generally what we want to do, since the user is done editing!)
18161
+ */
18162
+ closeEditor(render = true) {
18163
+ if (this._innerView) {
18164
+ const pos = this._getPos();
18165
+ if (pos !== void 0) {
18166
+ const text = this._innerView.state.doc.textContent || "";
18167
+ }
18168
+ this._innerView?.destroy();
18169
+ this._innerView = void 0;
18170
+ }
18171
+ if (render) {
18172
+ this.renderHtml();
18173
+ this._htmlRenderElt?.classList.add("inline-html-render");
18174
+ this._htmlRenderElt?.classList.remove("inline-html-preview");
18175
+ }
18176
+ this._isEditing = false;
18177
+ }
18178
+ };
18179
+
18180
+ // src/editor/extensions/HtmlNode/html-inline-node.tsx
18181
+ import block_names2 from "markdown-it/lib/common/html_blocks.mjs";
18182
+ var attr_name = "[a-zA-Z_:][a-zA-Z0-9:._-]*";
18183
+ var unquoted = "[^\"'=<>`\\x00-\\x20]+";
18184
+ var single_quoted = "'[^']*'";
18185
+ var double_quoted = '"[^"]*"';
18186
+ var attr_value = "(?:" + unquoted + "|" + single_quoted + "|" + double_quoted + ")";
18187
+ var attribute = "(?:\\s+" + attr_name + "(?:\\s*=\\s*" + attr_value + ")?)";
18188
+ var open_tag = "<[A-Za-z][A-Za-z0-9\\-]*" + attribute + "*\\s*\\/?>";
18189
+ var close_tag = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>";
18190
+ var HTML_OPEN_CLOSE_TAG_RE = new RegExp("(?:" + open_tag + "|" + close_tag + ")", "g");
18191
+ var HtmlInlineNodeExtension = class extends NodeExtension5 {
18192
+ get name() {
18193
+ return "html_inline_node";
18194
+ }
18195
+ createTags() {
18196
+ return [ExtensionTag4.InlineNode];
18197
+ }
18198
+ createNodeSpec() {
18199
+ return {
18200
+ inline: true,
18201
+ selectable: true,
18202
+ atom: true,
18203
+ marks: "",
18204
+ attrs: {
18205
+ key: {
18206
+ default: ""
18207
+ },
18208
+ htmlText: {
18209
+ default: ""
18210
+ },
18211
+ fromInput: {
18212
+ default: false
18213
+ }
18214
+ },
18215
+ toDOM: (node) => {
18216
+ const dom = document.createElement("div");
18217
+ dom.classList.add("inline-html-render");
18218
+ dom.innerHTML = node.attrs.htmlText;
18219
+ return dom;
18220
+ }
18221
+ };
18222
+ }
18223
+ createNodeViews() {
18224
+ return (node, view, getPos) => new HTMLInlineView(node, view, getPos);
18225
+ }
18226
+ createInputRules() {
18227
+ const rules = [
18228
+ nodeInputRule5({
18229
+ regexp: HTML_OPEN_CLOSE_TAG_RE,
18230
+ type: this.type,
18231
+ getAttributes: (match) => {
18232
+ return {
18233
+ htmlText: match[0],
18234
+ fromInput: true
18235
+ };
18236
+ },
18237
+ beforeDispatch: ({ tr, start, match }) => {
18238
+ const $pos = tr.doc.resolve(start);
18239
+ const node = $pos.node(1);
18240
+ console.log("last", node.lastChild);
18241
+ console.log("node", node);
18242
+ },
18243
+ shouldSkip: (props) => {
18244
+ const tagName = getTagName(props.fullMatch);
18245
+ if (needSplitInlineHtmlTokenTags.includes(tagName) || block_names2.includes(tagName)) {
18246
+ return true;
18247
+ }
18248
+ props.state.tr.replaceRangeWith(
18249
+ props.start,
18250
+ props.end,
18251
+ this.type.create({ htmlText: props.fullMatch, fromInput: true })
18252
+ );
18253
+ return false;
18254
+ }
18255
+ })
18256
+ ];
18257
+ return rules;
18258
+ }
18259
+ fromMarkdown() {
18260
+ return [
18261
+ {
18262
+ type: 6 /* inline */,
18263
+ token: "html_inline_node",
18264
+ node: this.name
18265
+ }
18266
+ ];
18267
+ }
18268
+ toMarkdown({ state, node }) {
18269
+ state.text(node.attrs.htmlText || "");
18270
+ }
18271
+ };
18272
+ HtmlInlineNodeExtension.disableExtraAttributes = true;
18273
+ HtmlInlineNodeExtension = __decorateClass([
18274
+ extension8({
18275
+ defaultOptions: {
18276
+ handleViewImgSrcUrl: async (src) => src
18277
+ }
18278
+ })
18279
+ ], HtmlInlineNodeExtension);
18280
+
17900
18281
  // src/editor/extensions/index.ts
17901
18282
  function extensions({ handleViewImgSrcUrl }) {
17902
18283
  return [
@@ -17912,6 +18293,9 @@ function extensions({ handleViewImgSrcUrl }) {
17912
18293
  new IframeExtension({
17913
18294
  enableResizing: true
17914
18295
  }),
18296
+ // new LineHtmlInlineExtension({
18297
+ // handleViewImgSrcUrl,
18298
+ // }),
17915
18299
  new PlaceholderExtension({ placeholder: "Type '/' for commands" }),
17916
18300
  new LineHorizontalRuleExtension({}),
17917
18301
  new LineParagraphExtension(),
@@ -17933,6 +18317,9 @@ function extensions({ handleViewImgSrcUrl }) {
17933
18317
  activeDecoration: { style: "background-color: orange; color: black" }
17934
18318
  }),
17935
18319
  new LineHtmlBlockExtension(),
18320
+ new HtmlInlineNodeExtension({
18321
+ handleViewImgSrcUrl
18322
+ }),
17936
18323
  new ClipboardExtension(),
17937
18324
  new ReactComponentExtension({}),
17938
18325
  new DropCursorExtension({}),
@@ -18114,7 +18501,7 @@ var MarkdownSerializer = class {
18114
18501
  };
18115
18502
 
18116
18503
  // src/editor/extensions/CodeMirror/codemirror-extension.ts
18117
- import { Decoration as Decoration5, DecorationSet as DecorationSet5 } from "@remirror/pm/view";
18504
+ import { Decoration as Decoration6, DecorationSet as DecorationSet5 } from "@remirror/pm/view";
18118
18505
 
18119
18506
  // src/editor/extensions/CodeMirror/codemirror-lang-menu.tsx
18120
18507
  import { languages as languages2 } from "@codemirror/language-data";
@@ -18938,11 +19325,11 @@ import {
18938
19325
  isEqual,
18939
19326
  isTextSelection as isTextSelection3,
18940
19327
  keyBinding as keyBinding2,
18941
- NodeExtension as NodeExtension5,
18942
- nodeInputRule as nodeInputRule4,
19328
+ NodeExtension as NodeExtension6,
19329
+ nodeInputRule as nodeInputRule6,
18943
19330
  setBlockType as setBlockType2
18944
19331
  } from "@remirror/core";
18945
- import { TextSelection as TextSelection5 } from "@remirror/pm/state";
19332
+ import { TextSelection as TextSelection6 } from "@remirror/pm/state";
18946
19333
 
18947
19334
  // src/editor/extensions/CodeMirror/codemirror-node-view.ts
18948
19335
  var CodeMirror6NodeView = class {
@@ -19000,7 +19387,7 @@ var CodeMirror6NodeView = class {
19000
19387
  // src/editor/extensions/CodeMirror/codemirror-extension.ts
19001
19388
  import { languages as languages3 } from "@codemirror/language-data";
19002
19389
  var fakeIndentedLanguage = "indent-code";
19003
- var LineCodeMirrorExtension = class extends NodeExtension5 {
19390
+ var LineCodeMirrorExtension = class extends NodeExtension6 {
19004
19391
  get name() {
19005
19392
  return "codeMirror";
19006
19393
  }
@@ -19065,12 +19452,12 @@ var LineCodeMirrorExtension = class extends NodeExtension5 {
19065
19452
  return { language };
19066
19453
  };
19067
19454
  return [
19068
- nodeInputRule4({
19455
+ nodeInputRule6({
19069
19456
  regexp,
19070
19457
  type: this.type,
19071
19458
  beforeDispatch: ({ tr, start }) => {
19072
19459
  const $pos = tr.doc.resolve(start);
19073
- tr.setSelection(TextSelection5.near($pos));
19460
+ tr.setSelection(TextSelection6.near($pos));
19074
19461
  },
19075
19462
  getAttributes
19076
19463
  })
@@ -19099,7 +19486,7 @@ var LineCodeMirrorExtension = class extends NodeExtension5 {
19099
19486
  const pos = tr.selection.$from.before();
19100
19487
  const end = pos + nodeSize2 + 1;
19101
19488
  tr.replaceWith(pos, end, this.type.create({ language }));
19102
- tr.setSelection(TextSelection5.near(tr.doc.resolve(pos + 1)));
19489
+ tr.setSelection(TextSelection6.near(tr.doc.resolve(pos + 1)));
19103
19490
  if (dispatch) {
19104
19491
  dispatch(tr);
19105
19492
  }
@@ -19174,7 +19561,7 @@ var LineCodeMirrorExtension = class extends NodeExtension5 {
19174
19561
  return DecorationSet5.empty;
19175
19562
  }
19176
19563
  const { create, destroy } = codemirror_lang_menu_default(found);
19177
- const deco = Decoration5.widget(found.pos, create, {
19564
+ const deco = Decoration6.widget(found.pos, create, {
19178
19565
  ignoreSelection: true,
19179
19566
  stopEvent: () => true,
19180
19567
  key: "language-menu",
@@ -19245,7 +19632,7 @@ var [SourceEditorProvider, useSourceCodeEditor] = createContextState(
19245
19632
  };
19246
19633
  }
19247
19634
  );
19248
- var SourceCodeEditorCore = memo6(
19635
+ var SourceCodeEditorCore = memo7(
19249
19636
  (props) => {
19250
19637
  const { markdownToolBar, styleToken } = props;
19251
19638
  const { content, markText, hooks, isTesting, editable } = useSourceCodeEditor();
@@ -19310,7 +19697,7 @@ var SourceEditor = (props) => {
19310
19697
  }
19311
19698
  );
19312
19699
  };
19313
- var SourceEditor_default = memo6(SourceEditor);
19700
+ var SourceEditor_default = memo7(SourceEditor);
19314
19701
 
19315
19702
  // src/editor/hooks/index.ts
19316
19703
  import { useHelpers, useKeymap, useRemirrorContext as useRemirrorContext4, useCommands as useCommands4 } from "@remirror/react";
@@ -19383,7 +19770,7 @@ import { prosemirrorNodeToHtml } from "remirror";
19383
19770
  import HTML2 from "html-parse-stringify";
19384
19771
  import { useEffect as useEffect8, useState as useState9 } from "react";
19385
19772
  import { nanoid as nanoid3 } from "nanoid";
19386
- import { Loading3QuartersOutlined } from "zens/esm/Icons";
19773
+ import { Icon } from "zens";
19387
19774
  import { jsx as jsx21 } from "react/jsx-runtime";
19388
19775
  var Preview = (props) => {
19389
19776
  const { doc, delegateOptions } = props;
@@ -19435,7 +19822,7 @@ var Preview = (props) => {
19435
19822
  justifyContent: "center",
19436
19823
  alignItems: "center"
19437
19824
  },
19438
- children: /* @__PURE__ */ jsx21(Loading3QuartersOutlined, { spin: true, size: 40 })
19825
+ children: /* @__PURE__ */ jsx21(Icon.Loading3QuartersOutlined, { spin: true, size: 40 })
19439
19826
  }
19440
19827
  );
19441
19828
  }