Skip to content

954045: Added how to Disable Bookmark content #4162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: hotfix/hotfix-v29.1.33
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public ActionResult Default()
{
return View();
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@Html.EJS().DocumentEditor("container").IsReadOnly(false).SelectionChange("onSelectionChanged").Render()

<script>
var documentEditor;
document.addEventListener('DOMContentLoaded', function () {
documentEditor = document.getElementById("container").ej2_instances[0];
documentEditor.enableAllModules();
let sfdt = `{"sfdt":"UEsDBAoAAAAIACGOlVon0ykbLgMAAIIYAAAEAAAAc2ZkdM2YSY+bMBiG/wp1r9EogQQCt6pV1ENVjTSHHkY5GLCDNWYpOM3MRPnv/byQhEySIbMEuLzG27c9GMQa5YVgKXsmdzQWKBDlkgxQRSIU3K8RaFGiYI2KFQrckT1ARYICz4cGT6EBWhoVRkOjSYwCxx0gajSmBQqGoDnRjZBpAUvoN1nd4gVBA0QyigJYTqXCcMlqJUoZzVAwAiVai0VWwQbfShyyCNZnUc4rNUL+rpTyUERqqR65n2/AqIquoDK0MC4rqQLcWsMYF1rLhdbQ3Cda/kkBrUQmHc/LFHOwy6WfaiCieiJTNiJtA24o5hWBfsHBEPpDeJSnxBK5hTaD9XZV+CCUs3Lz6imL6LJiebabcmSru+20I1uNLtrqC9rMN3OIVQczH9QzzUQVlWnR6hm2h/0pTEHfMWdhySATS+V/pcMIsZJEVwCWSJt6kWztLcPRbmeKG0MUYCAHPY0O8P9dteQsM5BppUaF9j6slGAtBi9uIsz5lmbj/oO0WrdX2ba9iurHawcLrYxHgnLdiMVKPzCGWmIehAScRRB6ZZSm2n6hJU5Eqj2hVDsIeBWmFE8iNF7KPCD5xH2dqQspkp8Uqg2ezebvy+rhI5E97kxIDKXFnwTHLFtYo48y+mop5TG2X8uboeePXNedDD3PHvpjr1nc0YtIDPpuE33rF1skQlZG5deeTca+iw5o3k1qMr3Xf6Rbn1h7h81+3qzvCS7RK8mtJ+kTodMofhCKl1xYt7jEixIXiTXLM7F1+cRww/XNYXz21eC5jB37FDtOL9ix27Bjn2bH6Rk7tctOT3FwTuFgn03kaOZ4rvP5ODhtcHBO43D1KFriMO4pDuOXOLD6E6EHp8O4DQ7jYzh0FEVLHCY9xWFy5HTonoJJGwomRw+FPhbf7Wnx3YuKf603gtum+O6Fxe/uReD1tPje214E16LAa0OB99YXQXc4THuKw/TUZ+LwZnI2lY66Ph+IaRsgpqc/FDuIoyUSfk+R8M+dEL1iw2/Dhn/+sOgxJKT8GEKO/0x8+cuskWeVUuNF7dQsz0X3Thkv5B9jLn98g8Kg0ijVWprbR60sXVRq2/9QSwECFAAKAAAACAAhjpVaJ9MpGy4DAACCGAAABAAAAAAAAAAAAAAAAAAAAAAAc2ZkdFBLBQYAAAAAAQABADIAAABQAwAAAAA="}`;
documenteditor.open(sfdt);
});
function onSelectionChanged() {
var documenteditorElement = document.getElementById("container");
container = documenteditorElement.ej2_instances[0];
documenteditor = container.documentEditor;
let bookmarks =
documenteditor.selection.getBookmarks();
// Check whether selection have the mentioned bookmark
if (bookmarks.indexOf('syncfusion') != -1) {
// Change the document to read only mode
documenteditor.isReadOnly = true;
} else {
// Change the document to editable mode
documenteditor.isReadOnly = false;
}
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<ejs-documenteditor isReadOnly=false id="container" selectionChange="onSelectionChanged"></ejs-documenteditor>

<script>
var documentEditor;
document.addEventListener('DOMContentLoaded', function () {
documentEditor = document.getElementById("container").ej2_instances[0];
documentEditor.enableAllModules();
let sfdt = `{"sfdt":"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+cuskWeVUuNF7dQsz0X3Thkv5B9jLn98g8Kg0ijVWprbR60sXVRq2/9QSwECFAAKAAAACAAhjpVaJ9MpGy4DAACCGAAABAAAAAAAAAAAAAAAAAAAAAAAc2ZkdFBLBQYAAAAAAQABADIAAABQAwAAAAA="}`;
documenteditor.open(sfdt);
});
function onSelectionChanged() {
var documenteditorElement = document.getElementById("container");
container = documenteditorElement.ej2_instances[0];
documenteditor = container.documentEditor;
let bookmarks =
documenteditor.selection.getBookmarks();
// Check whether selection have the mentioned bookmark
if (bookmarks.indexOf('syncfusion') != -1) {
// Change the document to read only mode
documenteditor.isReadOnly = true;
} else {
// Change the document to editable mode
documenteditor.isReadOnly = false;
}
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public ActionResult Default()
{
return View();
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<div>
@Html.EJS().DocumentEditorContainer("container").Created("onCreated").SelectionChange("onSelectionChanged").EnableToolbar(true).Render()
</div>
<script>
var documenteditor;
var container;
function onCreated() {
var documenteditorElement = document.getElementById("container");
container = documenteditorElement.ej2_instances[0];
let sfdt = `{"sfdt":"UEsDBAoAAAAIACGOlVon0ykbLgMAAIIYAAAEAAAAc2ZkdM2YSY+bMBiG/wp1r9EogQQCt6pV1ENVjTSHHkY5GLCDNWYpOM3MRPnv/byQhEySIbMEuLzG27c9GMQa5YVgKXsmdzQWKBDlkgxQRSIU3K8RaFGiYI2KFQrckT1ARYICz4cGT6EBWhoVRkOjSYwCxx0gajSmBQqGoDnRjZBpAUvoN1nd4gVBA0QyigJYTqXCcMlqJUoZzVAwAiVai0VWwQbfShyyCNZnUc4rNUL+rpTyUERqqR65n2/AqIquoDK0MC4rqQLcWsMYF1rLhdbQ3Cda/kkBrUQmHc/LFHOwy6WfaiCieiJTNiJtA24o5hWBfsHBEPpDeJSnxBK5hTaD9XZV+CCUs3Lz6imL6LJiebabcmSru+20I1uNLtrqC9rMN3OIVQczH9QzzUQVlWnR6hm2h/0pTEHfMWdhySATS+V/pcMIsZJEVwCWSJt6kWztLcPRbmeKG0MUYCAHPY0O8P9dteQsM5BppUaF9j6slGAtBi9uIsz5lmbj/oO0WrdX2ba9iurHawcLrYxHgnLdiMVKPzCGWmIehAScRRB6ZZSm2n6hJU5Eqj2hVDsIeBWmFE8iNF7KPCD5xH2dqQspkp8Uqg2ezebvy+rhI5E97kxIDKXFnwTHLFtYo48y+mop5TG2X8uboeePXNedDD3PHvpjr1nc0YtIDPpuE33rF1skQlZG5deeTca+iw5o3k1qMr3Xf6Rbn1h7h81+3qzvCS7RK8mtJ+kTodMofhCKl1xYt7jEixIXiTXLM7F1+cRww/XNYXz21eC5jB37FDtOL9ix27Bjn2bH6Rk7tctOT3FwTuFgn03kaOZ4rvP5ODhtcHBO43D1KFriMO4pDuOXOLD6E6EHp8O4DQ7jYzh0FEVLHCY9xWFy5HTonoJJGwomRw+FPhbf7Wnx3YuKf603gtum+O6Fxe/uReD1tPje214E16LAa0OB99YXQXc4THuKw/TUZ+LwZnI2lY66Ph+IaRsgpqc/FDuIoyUSfk+R8M+dEL1iw2/Dhn/+sOgxJKT8GEKO/0x8+cuskWeVUuNF7dQsz0X3Thkv5B9jLn98g8Kg0ijVWprbR60sXVRq2/9QSwECFAAKAAAACAAhjpVaJ9MpGy4DAACCGAAABAAAAAAAAAAAAAAAAAAAAAAAc2ZkdFBLBQYAAAAAAQABADIAAABQAwAAAAA="}`;
documenteditor.open(sfdt);
}
function onSelectionChanged() {
var documenteditorElement = document.getElementById("container");
container = documenteditorElement.ej2_instances[0];
documenteditor = container.documentEditor;
let bookmarks =
documenteditor.selection.getBookmarks();
// Check whether selection have the mentioned bookmark
if (bookmarks.indexOf('syncfusion') != -1) {
// Change the document to read only mode
container.restrictEditing = true;
} else {
// Change the document to editable mode
container.restrictEditing = false;
}
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

<ejs-documenteditorcontainer id="container" serviceUrl="/api/DocumentEditor/" enableToolbar=true created="onCreated" .selectionChange="onSelectionChanged" height="590px"></ejs-documenteditorcontainer>

<script>
var documenteditor;
var container;
function onCreated() {
var documenteditorElement = document.getElementById("container");
container = documenteditorElement.ej2_instances[0];
let sfdt = `{"sfdt":"UEsDBAoAAAAIACGOlVon0ykbLgMAAIIYAAAEAAAAc2ZkdM2YSY+bMBiG/wp1r9EogQQCt6pV1ENVjTSHHkY5GLCDNWYpOM3MRPnv/byQhEySIbMEuLzG27c9GMQa5YVgKXsmdzQWKBDlkgxQRSIU3K8RaFGiYI2KFQrckT1ARYICz4cGT6EBWhoVRkOjSYwCxx0gajSmBQqGoDnRjZBpAUvoN1nd4gVBA0QyigJYTqXCcMlqJUoZzVAwAiVai0VWwQbfShyyCNZnUc4rNUL+rpTyUERqqR65n2/AqIquoDK0MC4rqQLcWsMYF1rLhdbQ3Cda/kkBrUQmHc/LFHOwy6WfaiCieiJTNiJtA24o5hWBfsHBEPpDeJSnxBK5hTaD9XZV+CCUs3Lz6imL6LJiebabcmSru+20I1uNLtrqC9rMN3OIVQczH9QzzUQVlWnR6hm2h/0pTEHfMWdhySATS+V/pcMIsZJEVwCWSJt6kWztLcPRbmeKG0MUYCAHPY0O8P9dteQsM5BppUaF9j6slGAtBi9uIsz5lmbj/oO0WrdX2ba9iurHawcLrYxHgnLdiMVKPzCGWmIehAScRRB6ZZSm2n6hJU5Eqj2hVDsIeBWmFE8iNF7KPCD5xH2dqQspkp8Uqg2ezebvy+rhI5E97kxIDKXFnwTHLFtYo48y+mop5TG2X8uboeePXNedDD3PHvpjr1nc0YtIDPpuE33rF1skQlZG5deeTca+iw5o3k1qMr3Xf6Rbn1h7h81+3qzvCS7RK8mtJ+kTodMofhCKl1xYt7jEixIXiTXLM7F1+cRww/XNYXz21eC5jB37FDtOL9ix27Bjn2bH6Rk7tctOT3FwTuFgn03kaOZ4rvP5ODhtcHBO43D1KFriMO4pDuOXOLD6E6EHp8O4DQ7jYzh0FEVLHCY9xWFy5HTonoJJGwomRw+FPhbf7Wnx3YuKf603gtum+O6Fxe/uReD1tPje214E16LAa0OB99YXQXc4THuKw/TUZ+LwZnI2lY66Ph+IaRsgpqc/FDuIoyUSfk+R8M+dEL1iw2/Dhn/+sOgxJKT8GEKO/0x8+cuskWeVUuNF7dQsz0X3Thkv5B9jLn98g8Kg0ijVWprbR60sXVRq2/9QSwECFAAKAAAACAAhjpVaJ9MpGy4DAACCGAAABAAAAAAAAAAAAAAAAAAAAAAAc2ZkdFBLBQYAAAAAAQABADIAAABQAwAAAAA="}`;
documenteditor.open(sfdt);
}
function onSelectionChanged() {
var documenteditorElement = document.getElementById("container");
container = documenteditorElement.ej2_instances[0];
documenteditor = container.documentEditor;
let bookmarks =
documenteditor.selection.getBookmarks();
// Check whether selection have the mentioned bookmark
if (bookmarks.indexOf('syncfusion') != -1) {
// Change the document to read only mode
container.restrictEditing = true;
} else {
// Change the document to editable mode
container.restrictEditing = false;
}
}
</script>

1 change: 1 addition & 0 deletions ej2-asp-core-mvc/document-editor/bookmark.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ The following example shows how to open bookmark dialog in Document Editor.

* [Feature modules](../document-editor/feature-module)
* [Bookmark dialog](../document-editor/dialog#bookmark-dialog)
* [How to Disable the Bookmark content edit in Document Editor](../document-editor/how-to/disable-bookmark-content-edit-in-document-editor)
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
layout: post
title: Disable Bookmark edit in ##Platform_Name## Document Editor Component
description: Learn how to to disable Bookmark content edit in Document from the Syncfusion ##Platform_Name## Document Editor component of Syncfusion Essential JS2 and more.
platform: ej2-asp-core-mvc
control: Disable Bookmark content edit
publishingplatform: ##Platform_Name##
documentation: ug
---

# How to Bookmark content edit in Document Editor component

## Bookmark content edit in DocumentEditorContainer instance

You can use [`restrictEditing`] property to Bookmark content editing based on selection context type.

RestrictEditing allows you to restrict the document modification and makes the Document read only mode. So, by using this property, and if selection inside header or footer, you can set this property as true.

The following example code illustrates how to header and footer edit in `DocumentEditorContainer` instance.

{% if page.publishingplatform == "aspnet-core" %}

{% tabs %}
{% highlight cshtml tabtitle="CSHTML" %}
{% include code-snippet/document-editor-container/disable-bookmark-content-edit-in-documenteditor-container/tagHelper %}
{% endhighlight %}
{% highlight c# tabtitle="document-editor.cs" %}
{% endhighlight %}{% endtabs %}

{% elsif page.publishingplatform == "aspnet-mvc" %}

{% tabs %}
{% highlight razor tabtitle="CSHTML" %}
{% include code-snippet/document-editor-container/disable-bookmark-content-edit-in-documenteditor-container/razor %}
{% endhighlight %}
{% highlight c# tabtitle="document-editor.cs" %}
{% endhighlight %}{% endtabs %}
{% endif %}


## Bookmark content edit in DocumentEditor instance

Like restrictEditing, you can use [`isReadOnly`] property in Document editor to Bookmark content edit.

The following example code illustrates how to header and footer edit in `DocumentEditor` instance.

{% if page.publishingplatform == "aspnet-core" %}

{% tabs %}
{% highlight cshtml tabtitle="CSHTML" %}
{% include code-snippet/document-editor-container/disable-bookmark-content-edit-in-document-editor/tagHelper %}
{% endhighlight %}
{% highlight c# tabtitle="document-editor.cs" %}
{% endhighlight %}{% endtabs %}

{% elsif page.publishingplatform == "aspnet-mvc" %}

{% tabs %}
{% highlight razor tabtitle="CSHTML" %}
{% include code-snippet/document-editor-container/disable-bookmark-content-edit-in-document-editor/razor %}
{% endhighlight %}
{% highlight c# tabtitle="document-editor.cs" %}
{% endhighlight %}{% endtabs %}
{% endif %}
1 change: 1 addition & 0 deletions ej2-asp-core-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,7 @@
<li><a href="/ej2-asp-core/document-editor/how-to/insert-page-number-and-navigate-to-page">Insert page number and navigate to specific page</a></li>
<li><a href="/ej2-asp-core/document-editor/how-to/move-selection-to-specific-position">Move the selection to specific position in Document</a></li>
<li><a href="/ej2-asp-core/document-editor/how-to/disable-header-and-footer-edit-in-document-editor">Disable Header and Footer edit in Document</a></li>
<li><a href="/ej2-asp-core/document-editor/how-to/disable-bookmark-content-edit-in-document-editor">Disable Bookmark content edit in Document</a></li>
<li><a href="/ej2-asp-core/document-editor/how-to/insert-text-in-current-position">Insert the text and rich-text content in Document editor</a></li>
<li><a href="/ej2-asp-core/document-editor/how-to/change-the-cursor-color-in-document-editor">Change the cursor color in document editor using CSS</a></li>
<li><a href="/ej2-asp-core/document-editor/how-to/hide-tool-bar-and-properties-pane">Hide the toolbar and properties pane in Document editor</a></li>
Expand Down
1 change: 1 addition & 0 deletions ej2-asp-mvc-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@
<li><a href="/ej2-asp-mvc/document-editor/how-to/insert-page-number-and-navigate-to-page">Insert page number and navigate to specific page</a></li>
<li><a href="/ej2-asp-mvc/document-editor/how-to/move-selection-to-specific-position">Move the selection to specific position in Document</a></li>
<li><a href="/ej2-asp-mvc/document-editor/how-to/disable-header-and-footer-edit-in-document-editor">Disable Header and Footer edit in Document</a></li>
<li><a href="/ej2-asp-mvc/document-editor/how-to/disable-bookmark-content-edit-in-document-editor">Disable Bookmark content edit in Document</a></li>
<li><a href="/ej2-asp-mvc/document-editor/how-to/insert-text-in-current-position">Insert the text and rich-text content in Document editor</a></li>
<li><a href="/ej2-asp-mvc/document-editor/how-to/change-the-cursor-color-in-document-editor">Change the cursor color in document editor using CSS</a></li>
<li><a href="/ej2-asp-mvc/document-editor/how-to/hide-tool-bar-and-properties-pane">Hide the toolbar and properties pane in Document editor</a></li>
Expand Down