fix editable
This commit is contained in:
@@ -145,7 +145,6 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
editor: new Editor({
|
editor: new Editor({
|
||||||
editable: true,
|
|
||||||
extensions: [
|
extensions: [
|
||||||
new BlockquoteNode(),
|
new BlockquoteNode(),
|
||||||
new BulletListNode(),
|
new BulletListNode(),
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
editor: new Editor({
|
editor: new Editor({
|
||||||
editable: true,
|
|
||||||
extensions: [
|
extensions: [
|
||||||
new BlockquoteNode(),
|
new BlockquoteNode(),
|
||||||
new BulletListNode(),
|
new BulletListNode(),
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export default class Editor {
|
|||||||
constructor(options = {}) {
|
constructor(options = {}) {
|
||||||
|
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
|
editable: true,
|
||||||
content: '',
|
content: '',
|
||||||
on: {
|
on: {
|
||||||
update: () => {},
|
update: () => {},
|
||||||
@@ -229,6 +230,7 @@ export default class Editor {
|
|||||||
|
|
||||||
updateMenuActions() {
|
updateMenuActions() {
|
||||||
this.menuActions = buildMenuActions({
|
this.menuActions = buildMenuActions({
|
||||||
|
editable: this.options.editable,
|
||||||
schema: this.schema,
|
schema: this.schema,
|
||||||
state: this.view.state,
|
state: this.view.state,
|
||||||
commands: this.commands,
|
commands: this.commands,
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
import { markIsActive, nodeIsActive, getMarkAttrs } from 'tiptap-utils'
|
import { markIsActive, nodeIsActive, getMarkAttrs } from 'tiptap-utils'
|
||||||
|
|
||||||
export default function ({ schema, state, commands }) {
|
export default function ({ schema, state, commands, editable }) {
|
||||||
|
|
||||||
const nodes = Object.entries(schema.nodes)
|
const nodes = Object.entries(schema.nodes)
|
||||||
.map(([name]) => {
|
.map(([name]) => {
|
||||||
const active = (attrs = {}) => nodeIsActive(state, schema.nodes[name], attrs)
|
const active = (attrs = {}) => nodeIsActive(state, schema.nodes[name], attrs)
|
||||||
const command = commands[name] ? commands[name] : () => {}
|
const command = commands[name] ? commands[name] : () => {}
|
||||||
return { name, active, command }
|
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
active,
|
||||||
|
command: editable ? command : () => {}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.reduce((actions, { name, active, command }) => ({
|
.reduce((actions, { name, active, command }) => ({
|
||||||
...actions,
|
...actions,
|
||||||
@@ -21,16 +26,17 @@ export default function ({ schema, state, commands }) {
|
|||||||
const active = () => markIsActive(state, schema.marks[name])
|
const active = () => markIsActive(state, schema.marks[name])
|
||||||
const attrs = getMarkAttrs(state, schema.marks[name])
|
const attrs = getMarkAttrs(state, schema.marks[name])
|
||||||
const command = commands[name] ? commands[name] : () => {}
|
const command = commands[name] ? commands[name] : () => {}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
active,
|
active,
|
||||||
attrs,
|
attrs,
|
||||||
command,
|
command: editable ? command : () => {}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.reduce((actions, {
|
.reduce((actions, {
|
||||||
name, active, attrs, command,
|
name, active, attrs, command,
|
||||||
}) => ({
|
}) => ({
|
||||||
...actions,
|
...actions,
|
||||||
[name]: {
|
[name]: {
|
||||||
active,
|
active,
|
||||||
|
|||||||
Reference in New Issue
Block a user