Skip to content

Commit

Permalink
use writer.writer or writer to be back compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
kiruh committed Jul 3, 2021
1 parent 391feec commit db77b59
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/placeholderediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,21 @@ export default class PlaceholderEditing extends Plugin {
name: "span",
classes: ["placeholder"],
},
model: (viewElement, { writer: modelWriter }) => {
model: (viewElement, writer) => {
// Extract the "name" from "{name}".
const name = viewElement.getChild(0).data.slice(1, -1);

const modelWriter = writer.writer || writer;

return modelWriter.createElement("placeholder", { name });
},
});

conversion.for("editingDowncast").elementToElement({
model: "placeholder",
view: (modelItem, { writer: viewWriter }) => {
view: (modelItem, writer) => {
const viewWriter = writer.writer || writer;

const widgetElement = createPlaceholderView(modelItem, viewWriter);

// Enable widget handling on placeholder element inside editing view.
Expand All @@ -82,8 +86,11 @@ export default class PlaceholderEditing extends Plugin {

conversion.for("dataDowncast").elementToElement({
model: "placeholder",
view: (modelItem, { writer: viewWriter }) =>
createPlaceholderView(modelItem, viewWriter),
view: (modelItem, writer) => {
const viewWriter = writer.writer || writer;

return createPlaceholderView(modelItem, viewWriter)
},
});

// Helper method for both downcast converters.
Expand Down

0 comments on commit db77b59

Please sign in to comment.