How to use the @sanity/block-tools.getBlockContentFeatures function in @sanity/block-tools

To help you get started, we’ve selected a few @sanity/block-tools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sanity-io / sanity / packages / @sanity / form-builder / src / inputs / BlockEditor / SyncWrapper.tsx View on Github external
isLoading: false,
        loading: {},
        userIsWritingText: false
      }
      let displayValue = null
      try {
        displayValue =
          deprecatedSchema || deprecatedBlockValue || invalidBlockValue
            ? deserialize([], type)
            : deserialize(value, type)
      } catch (err) {
        // @ts-ignore
        this.state.invalidBlockValue = true
        displayValue = deserialize([], type)
      }
      this._blockContentFeatures = getBlockContentFeatures(type)
      const editorSchema = buildEditorSchema(this._blockContentFeatures)
      const controllerOpts = {
        value: displayValue,
        plugins: [
          {
            schema: editorSchema
          }
        ]
      }
      this._controller = createEditorController(controllerOpts)
      this.operationToPatches = createOperationToPatches(this._blockContentFeatures, type)
      this.patchToOperations = createPatchToOperations(this._blockContentFeatures, type)
      // @ts-ignore
      this.state.editorValue = this._controller.value // Normalized value by editor schema
      this._unsubscribePatches = props.subscribe(this.handleDocumentPatches)
      this._changeSubscription = this.changes$.subscribe(this.handleChangeSet)