fix editable

This commit is contained in:
Philipp Kühn
2018-10-22 21:11:28 +02:00
parent a2dd57ad09
commit b913c84b58
4 changed files with 13 additions and 7 deletions

View File

@@ -145,7 +145,6 @@ export default {
data() {
return {
editor: new Editor({
editable: true,
extensions: [
new BlockquoteNode(),
new BulletListNode(),

View File

@@ -65,7 +65,6 @@ export default {
data() {
return {
editor: new Editor({
editable: true,
extensions: [
new BlockquoteNode(),
new BulletListNode(),

View File

@@ -23,6 +23,7 @@ export default class Editor {
constructor(options = {}) {
const defaultOptions = {
editable: true,
content: '',
on: {
update: () => {},
@@ -229,6 +230,7 @@ export default class Editor {
updateMenuActions() {
this.menuActions = buildMenuActions({
editable: this.options.editable,
schema: this.schema,
state: this.view.state,
commands: this.commands,

View File

@@ -1,12 +1,17 @@
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)
.map(([name]) => {
const active = (attrs = {}) => nodeIsActive(state, schema.nodes[name], attrs)
const command = commands[name] ? commands[name] : () => {}
return { name, active, command }
return {
name,
active,
command: editable ? command : () => {}
}
})
.reduce((actions, { name, active, command }) => ({
...actions,
@@ -21,16 +26,17 @@ export default function ({ schema, state, commands }) {
const active = () => markIsActive(state, schema.marks[name])
const attrs = getMarkAttrs(state, schema.marks[name])
const command = commands[name] ? commands[name] : () => {}
return {
name,
active,
attrs,
command,
command: editable ? command : () => {}
}
})
.reduce((actions, {
name, active, attrs, command,
}) => ({
}) => ({
...actions,
[name]: {
active,