@firecms/editor 3.0.0-canary.258 → 3.0.0-canary.259

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.
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { Editor } from "@tiptap/react";
3
- import { Node as ProseMirrorNode } from "prosemirror-model";
3
+ import { Node as ProseMirrorNode } from "@tiptap/pm/model";
4
4
  export interface CustomBlockComponentProps {
5
5
  node: ProseMirrorNode;
6
6
  updateAttributes: (attrs: Record<string, any>) => void;
@@ -1,5 +1,5 @@
1
- import { PluginKey } from "prosemirror-state";
2
- import { DecorationSet } from "prosemirror-view";
1
+ import { PluginKey } from "@tiptap/pm/state";
2
+ import { DecorationSet } from "@tiptap/pm/view";
3
3
  import { Extension } from "@tiptap/core";
4
4
  declare module "@tiptap/core" {
5
5
  interface Commands<ReturnType> {
@@ -1,4 +1,4 @@
1
- import { Slice } from "prosemirror-model";
1
+ import { Slice } from "@tiptap/pm/model";
2
2
  import { EditorView } from "@tiptap/pm/view";
3
3
  export declare function serializeForClipboard(view: EditorView, slice: Slice): {
4
4
  dom: HTMLDivElement;
package/dist/index.es.js CHANGED
@@ -22,17 +22,15 @@ import Placeholder from "@tiptap/extension-placeholder";
22
22
  import { TaskItem } from "@tiptap/extension-task-item";
23
23
  import { TaskList } from "@tiptap/extension-task-list";
24
24
  import { Extension, InputRule } from "@tiptap/core";
25
- import { PluginKey, Plugin } from "prosemirror-state";
26
- import { DecorationSet, Decoration } from "prosemirror-view";
25
+ import { PluginKey, Plugin, NodeSelection } from "@tiptap/pm/state";
26
+ import { DecorationSet, Decoration } from "@tiptap/pm/view";
27
27
  import OrderedList from "@tiptap/extension-ordered-list";
28
28
  import BulletList from "@tiptap/extension-bullet-list";
29
29
  import ListItem from "@tiptap/extension-list-item";
30
30
  import CodeBlock from "@tiptap/extension-code-block";
31
31
  import Blockquote from "@tiptap/extension-blockquote";
32
32
  import Code from "@tiptap/extension-code";
33
- import { DecorationSet as DecorationSet$1, Decoration as Decoration$1 } from "@tiptap/pm/view";
34
- import { PluginKey as PluginKey$1, Plugin as Plugin$1, NodeSelection } from "@tiptap/pm/state";
35
- import { DOMSerializer } from "prosemirror-model";
33
+ import { DOMSerializer } from "@tiptap/pm/model";
36
34
  import Suggestion from "@tiptap/suggestion";
37
35
  import tippy from "tippy.js";
38
36
  const EditorBubble = forwardRef((t0, ref) => {
@@ -809,7 +807,7 @@ async function onFileRead(view, readerEvent, pos, upload, image) {
809
807
  imageElement.setAttribute("class", "opacity-40 rounded-lg border " + defaultBorderMixin);
810
808
  imageElement.src = readerEvent.target?.result;
811
809
  placeholder2.appendChild(imageElement);
812
- const deco = Decoration$1.widget(pos, placeholder2);
810
+ const deco = Decoration.widget(pos, placeholder2);
813
811
  decorationSet = decorationSet?.add(view.state.doc, [deco]);
814
812
  view.dispatch(view.state.tr.setMeta(plugin, {
815
813
  decorationSet
@@ -826,13 +824,13 @@ async function onFileRead(view, readerEvent, pos, upload, image) {
826
824
  });
827
825
  view.dispatch(tr);
828
826
  }
829
- const ImagePluginKey = new PluginKey$1("imagePlugin");
827
+ const ImagePluginKey = new PluginKey("imagePlugin");
830
828
  const createDropImagePlugin = (upload) => {
831
- const plugin = new Plugin$1({
829
+ const plugin = new Plugin({
832
830
  key: ImagePluginKey,
833
831
  state: {
834
832
  // Initialize the plugin state with an empty DecorationSet
835
- init: () => DecorationSet$1.empty,
833
+ init: () => DecorationSet.empty,
836
834
  // Apply transactions to update the state
837
835
  apply: (tr, old) => {
838
836
  const meta = tr.getMeta(plugin);
@@ -1093,7 +1091,7 @@ function DragHandle(options) {
1093
1091
  dragHandleElement.classList.remove("hide");
1094
1092
  }
1095
1093
  }
1096
- return new Plugin$1({
1094
+ return new Plugin({
1097
1095
  view: (view) => {
1098
1096
  dragHandleElement = document.createElement("div");
1099
1097
  dragHandleElement.draggable = true;
@@ -1172,31 +1170,31 @@ const DragAndDrop = Extension.create({
1172
1170
  function buildDecorationSet(highlight, doc) {
1173
1171
  const decorations = [];
1174
1172
  if (highlight) {
1175
- decorations.push(Decoration$1.inline(highlight.from, highlight.to, {
1173
+ decorations.push(Decoration.inline(highlight.from, highlight.to, {
1176
1174
  class: "dark:bg-surface-accent-700 bg-surface-accent-300"
1177
1175
  }));
1178
1176
  }
1179
- const decorationSet = DecorationSet$1.create(doc, decorations);
1177
+ const decorationSet = DecorationSet.create(doc, decorations);
1180
1178
  return decorationSet;
1181
1179
  }
1182
1180
  const HighlightDecorationExtension = (initialHighlight) => Extension.create({
1183
1181
  name: "highlightDecoration",
1184
1182
  addOptions() {
1185
1183
  return {
1186
- pluginKey: new PluginKey$1("highlightDecoration"),
1184
+ pluginKey: new PluginKey("highlightDecoration"),
1187
1185
  highlight: initialHighlight
1188
1186
  };
1189
1187
  },
1190
1188
  addProseMirrorPlugins() {
1191
1189
  const pluginKey = this.options.pluginKey;
1192
- return [new Plugin$1({
1190
+ return [new Plugin({
1193
1191
  key: pluginKey,
1194
1192
  state: {
1195
1193
  init: (_, {
1196
1194
  doc
1197
1195
  }) => {
1198
1196
  const highlight = this.options.highlight;
1199
- const decorationSet = highlight && doc ? buildDecorationSet(highlight, doc) : DecorationSet$1.empty;
1197
+ const decorationSet = highlight && doc ? buildDecorationSet(highlight, doc) : DecorationSet.empty;
1200
1198
  return {
1201
1199
  decorationSet,
1202
1200
  highlight
@@ -1212,7 +1210,7 @@ const HighlightDecorationExtension = (initialHighlight) => Extension.create({
1212
1210
  } = action;
1213
1211
  if (remove) {
1214
1212
  return {
1215
- decorationSet: DecorationSet$1.empty
1213
+ decorationSet: DecorationSet.empty
1216
1214
  };
1217
1215
  }
1218
1216
  const decorationSet = buildDecorationSet(highlight, doc);
@@ -1231,7 +1229,7 @@ const HighlightDecorationExtension = (initialHighlight) => Extension.create({
1231
1229
  if (autocompleteState?.decorationSet) {
1232
1230
  return autocompleteState.decorationSet;
1233
1231
  } else {
1234
- return DecorationSet$1.empty;
1232
+ return DecorationSet.empty;
1235
1233
  }
1236
1234
  }
1237
1235
  }
@@ -1276,7 +1274,7 @@ const HighlightDecorationExtension = (initialHighlight) => Extension.create({
1276
1274
  };
1277
1275
  }
1278
1276
  });
1279
- const CommandPluginKey = new PluginKey$1("slash-command");
1277
+ const CommandPluginKey = new PluginKey("slash-command");
1280
1278
  const SlashCommand = Node.create({
1281
1279
  name: "command",
1282
1280
  addOptions() {
@@ -1912,8 +1910,13 @@ const FireCMSEditor = ({
1912
1910
  }
1913
1911
  }
1914
1912
  }, [deferredHighlight?.from, deferredHighlight?.to]);
1913
+ const firstUpdateRef = React.useRef(true);
1915
1914
  const onEditorUpdate = (editor) => {
1916
1915
  editorRef.current = editor;
1916
+ if (firstUpdateRef.current) {
1917
+ firstUpdateRef.current = false;
1918
+ return;
1919
+ }
1917
1920
  if (onMarkdownContentChange) {
1918
1921
  const markdown = editorRef.current.storage.markdown.getMarkdown();
1919
1922
  onMarkdownContentChange?.(addLineBreakAfterImages(markdown));