@ixo/editor 1.7.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6104,26 +6104,9 @@ var ActionsTab = ({ actions, onActionsChange, editor, block }) => {
6104
6104
 
6105
6105
  // src/mantine/blocks/proposal/template/VoteTab.tsx
6106
6106
  import React73 from "react";
6107
- import { Stack as Stack59, TextInput as TextInput32, Switch as Switch4 } from "@mantine/core";
6108
- var VoteTab = ({
6109
- voteEnabled,
6110
- voteTitle,
6111
- voteSubtitle,
6112
- voteIcon,
6113
- onVoteEnabledChange,
6114
- onVoteTitleChange,
6115
- onVoteSubtitleChange,
6116
- onVoteIconChange
6117
- }) => {
6118
- return /* @__PURE__ */ React73.createElement(Stack59, { gap: "md" }, /* @__PURE__ */ React73.createElement(
6119
- Switch4,
6120
- {
6121
- label: "Enable Voting",
6122
- description: "Allow users to vote on this proposal",
6123
- checked: voteEnabled,
6124
- onChange: (event) => onVoteEnabledChange(event.currentTarget.checked)
6125
- }
6126
- ), voteEnabled && /* @__PURE__ */ React73.createElement(React73.Fragment, null, /* @__PURE__ */ React73.createElement(TextInput32, { label: "Vote Button Title", placeholder: "Vote on this proposal", value: voteTitle, onChange: (event) => onVoteTitleChange(event.currentTarget.value) }), /* @__PURE__ */ React73.createElement(TextInput32, { label: "Vote Button Subtitle", placeholder: "Cast your vote", value: voteSubtitle, onChange: (event) => onVoteSubtitleChange(event.currentTarget.value) }), /* @__PURE__ */ React73.createElement(TextInput32, { label: "Vote Icon", placeholder: "checklist", value: voteIcon, onChange: (event) => onVoteIconChange(event.currentTarget.value) })));
6107
+ import { Stack as Stack59, TextInput as TextInput32 } from "@mantine/core";
6108
+ var VoteTab = ({ voteTitle, voteSubtitle, voteIcon, onVoteTitleChange, onVoteSubtitleChange, onVoteIconChange }) => {
6109
+ return /* @__PURE__ */ React73.createElement(Stack59, { gap: "md" }, /* @__PURE__ */ React73.createElement(TextInput32, { label: "Vote Button Title", placeholder: "Vote on this proposal", value: voteTitle, onChange: (event) => onVoteTitleChange(event.currentTarget.value) }), /* @__PURE__ */ React73.createElement(TextInput32, { label: "Vote Button Subtitle", placeholder: "Cast your vote", value: voteSubtitle, onChange: (event) => onVoteSubtitleChange(event.currentTarget.value) }), /* @__PURE__ */ React73.createElement(TextInput32, { label: "Vote Icon", placeholder: "checklist", value: voteIcon, onChange: (event) => onVoteIconChange(event.currentTarget.value) }));
6127
6110
  };
6128
6111
 
6129
6112
  // src/mantine/blocks/proposal/template/TemplateConfig.tsx
@@ -6192,11 +6175,9 @@ var TemplateConfig2 = ({ editor, block }) => {
6192
6175
  content: /* @__PURE__ */ React74.createElement(
6193
6176
  VoteTab,
6194
6177
  {
6195
- voteEnabled: block.props.voteEnabled || false,
6196
6178
  voteTitle: block.props.voteTitle || "",
6197
6179
  voteSubtitle: block.props.voteSubtitle || "",
6198
6180
  voteIcon: block.props.voteIcon || "checklist",
6199
- onVoteEnabledChange: (value) => updateProp("voteEnabled", value),
6200
6181
  onVoteTitleChange: (value) => updateProp("voteTitle", value),
6201
6182
  onVoteSubtitleChange: (value) => updateProp("voteSubtitle", value),
6202
6183
  onVoteIconChange: (value) => updateProp("voteIcon", value)
@@ -6984,10 +6965,8 @@ var FlowConfig = ({ editor, block }) => {
6984
6965
  label: "Actions",
6985
6966
  value: "actions",
6986
6967
  content: /* @__PURE__ */ React79.createElement(ActionsTab2, { actions: block.props.actions || "[]", onActionsChange: handleActionsChange, editor, block, isProposalCreated })
6987
- }
6988
- ];
6989
- if (block.props.voteEnabled) {
6990
- extraTabs.push({
6968
+ },
6969
+ {
6991
6970
  label: "Vote",
6992
6971
  value: "vote",
6993
6972
  content: /* @__PURE__ */ React79.createElement(
@@ -7004,8 +6983,8 @@ var FlowConfig = ({ editor, block }) => {
7004
6983
  status: voteLogic.status
7005
6984
  }
7006
6985
  )
7007
- });
7008
- }
6986
+ }
6987
+ ];
7009
6988
  return /* @__PURE__ */ React79.createElement(
7010
6989
  Paper4,
7011
6990
  {
@@ -7071,7 +7050,8 @@ var ProposalFlowView = ({ block, editor }) => {
7071
7050
 
7072
7051
  // src/mantine/blocks/proposal/ProposalBlock.tsx
7073
7052
  function ProposalBlock({ editor, block }) {
7074
- if (editor.isEditable) {
7053
+ const { docType } = useBlocknoteContext();
7054
+ if (docType === "template") {
7075
7055
  return /* @__PURE__ */ React81.createElement(ProposalTemplateView, { editor, block });
7076
7056
  }
7077
7057
  return /* @__PURE__ */ React81.createElement(ProposalFlowView, { block, editor });
@@ -7104,7 +7084,7 @@ var ProposalBlockSpec = createReactBlockSpec4(
7104
7084
  },
7105
7085
  // Vote configuration (from proposalVote)
7106
7086
  voteEnabled: {
7107
- default: false
7087
+ default: true
7108
7088
  },
7109
7089
  voteTitle: {
7110
7090
  default: ""
@@ -7879,7 +7859,7 @@ var EnumChecklistPreviewStep = ({ listType, onAddToBlock, onPrev }) => {
7879
7859
 
7880
7860
  // src/mantine/blocks/enumChecklist/EnumChecklistConfigurationStep.tsx
7881
7861
  import React92 from "react";
7882
- import { Stack as Stack71, TextInput as TextInput35, Text as Text46, Button as Button24, Group as Group29, Switch as Switch5, Select as Select10 } from "@mantine/core";
7862
+ import { Stack as Stack71, TextInput as TextInput35, Text as Text46, Button as Button24, Group as Group29, Switch as Switch4, Select as Select10 } from "@mantine/core";
7883
7863
  var EnumChecklistConfigurationStep = ({ enumChecklistType: listType, config, onConfigChange, onPrev, onNext, isValid }) => {
7884
7864
  const typeConfig = ENUM_LIST_CONFIG[listType];
7885
7865
  const configFields = getEnumListTypesConfigFields(listType);
@@ -7899,7 +7879,7 @@ var EnumChecklistConfigurationStep = ({ enumChecklistType: listType, config, onC
7899
7879
  );
7900
7880
  case "switch":
7901
7881
  return /* @__PURE__ */ React92.createElement(
7902
- Switch5,
7882
+ Switch4,
7903
7883
  {
7904
7884
  label: field.label,
7905
7885
  description: field.description,
@@ -8623,22 +8603,9 @@ function useMatrixProvider({
8623
8603
  // src/mantine/hooks/useCollaborativeYDoc.ts
8624
8604
  import { useMemo as useMemo15 } from "react";
8625
8605
  import * as Y from "yjs";
8626
- function useCollaborativeYDoc(options) {
8606
+ function useCollaborativeYDoc(_options) {
8627
8607
  return useMemo15(() => {
8628
8608
  const doc = new Y.Doc();
8629
- const root = doc.getMap("root");
8630
- root.set("@context", "https://ixo.world/flow/0.3");
8631
- root.set("_type", "ixo.flow.crdt");
8632
- root.set("schema_version", "0.3");
8633
- root.set("doc_id", options.docId || `flow_${Date.now()}`);
8634
- root.set("createdAt", (/* @__PURE__ */ new Date()).toISOString());
8635
- root.set("createdBy", options.user?.id || "anonymous");
8636
- root.set("docType", "");
8637
- const titleText = doc.getText("title");
8638
- if (titleText.length === 0 && options.title) {
8639
- titleText.insert(0, options.title);
8640
- }
8641
- doc.getMap("auditTrail");
8642
8609
  return doc;
8643
8610
  }, []);
8644
8611
  }
@@ -8659,7 +8626,8 @@ function useCreateCollaborativeIxoEditor(options) {
8659
8626
  filePanel = true,
8660
8627
  tableHandles = true,
8661
8628
  user,
8662
- matrixClient
8629
+ matrixClient,
8630
+ permissions = { write: false }
8663
8631
  } = options || {};
8664
8632
  const memoizedUser = useMemo16(
8665
8633
  () => ({
@@ -8753,6 +8721,10 @@ function useCreateCollaborativeIxoEditor(options) {
8753
8721
  return userFragment.get(block.id) || {};
8754
8722
  };
8755
8723
  ixoEditor.updateUserProps = (block, updates) => {
8724
+ if (!permissions.write) {
8725
+ console.warn("Cannot update user props: write permission denied");
8726
+ return;
8727
+ }
8756
8728
  const prev = userFragment.get(block.id) || {};
8757
8729
  userFragment.set(block.id, { ...prev, ...updates });
8758
8730
  };
@@ -8768,6 +8740,10 @@ function useCreateCollaborativeIxoEditor(options) {
8768
8740
  };
8769
8741
  };
8770
8742
  ixoEditor.updateFlowMetadata = (updates) => {
8743
+ if (!permissions.write) {
8744
+ console.warn("Cannot update flow metadata: write permission denied");
8745
+ return;
8746
+ }
8771
8747
  Object.entries(updates).forEach(([key, value]) => {
8772
8748
  if (key === "title") {
8773
8749
  titleText.delete(0, titleText.length);
@@ -8782,6 +8758,10 @@ function useCreateCollaborativeIxoEditor(options) {
8782
8758
  };
8783
8759
  ixoEditor.getDocType = () => root.get("docType") || "";
8784
8760
  ixoEditor.setDocType = (value) => {
8761
+ if (!permissions.write) {
8762
+ console.warn("Cannot set doc type: write permission denied");
8763
+ return;
8764
+ }
8785
8765
  root.set("docType", value);
8786
8766
  };
8787
8767
  }
@@ -8790,6 +8770,28 @@ function useCreateCollaborativeIxoEditor(options) {
8790
8770
  ixoEditor.isEditable = editable;
8791
8771
  }
8792
8772
  }, [ixoEditor, editable]);
8773
+ useEffect19(() => {
8774
+ if (connectionStatus !== "connected") {
8775
+ return;
8776
+ }
8777
+ const existingDocId = root.get("doc_id");
8778
+ if (existingDocId) {
8779
+ return;
8780
+ }
8781
+ if (!permissions.write) {
8782
+ return;
8783
+ }
8784
+ root.set("@context", "https://ixo.world/flow/0.3");
8785
+ root.set("_type", "ixo.flow.crdt");
8786
+ root.set("schema_version", "0.3");
8787
+ root.set("doc_id", options.docId || `flow_${Date.now()}`);
8788
+ root.set("createdAt", (/* @__PURE__ */ new Date()).toISOString());
8789
+ root.set("createdBy", memoizedUser.id || "anonymous");
8790
+ root.set("docType", "");
8791
+ if (titleText.length === 0 && options.title) {
8792
+ titleText.insert(0, options.title);
8793
+ }
8794
+ }, [connectionStatus, root, titleText, permissions.write, options.docId, options.title, memoizedUser.id]);
8793
8795
  return {
8794
8796
  editor: ixoEditor,
8795
8797
  connectionStatus,
@@ -9005,4 +9007,4 @@ export {
9005
9007
  ixoGraphQLClient,
9006
9008
  getEntity
9007
9009
  };
9008
- //# sourceMappingURL=chunk-URIMM24H.mjs.map
9010
+ //# sourceMappingURL=chunk-ASAGPCCF.mjs.map