]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5468 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 7 Nov 2022 17:44:41 +0000 (18:44 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 7 Nov 2022 17:44:41 +0000 (18:44 +0100)
app/Fields/FluidbookLinkEditor/Target.php
app/SubForms/Link/Base.php
app/SubForms/Link/Web.php
package-lock.json
package.json
resources/linkeditor/js/linkeditor.js
resources/views/fluidbook_publication/link_editor.blade.php

index 0e82f1595bcae75a58aa97377d3059614667e28c..c702e260128eeacdf8db1099b02bc356630facf4 100644 (file)
@@ -6,6 +6,9 @@ use Cubist\Backpack\Magic\Fields\SelectFromArray;
 
 class Target extends SelectFromArray
 {
+    protected $_ajax=false;
+    protected $_allowNull=false;
+
     public function getOptions()
     {
         return [
index 7cc4eb6bdbd5f5fbc6335e79c6e279b669444117..dd6034aa000ba87212320e8fa354f15f6ab794ce 100644 (file)
@@ -5,10 +5,11 @@ namespace App\SubForms\Link;
 use App\Fields\FluidbookLinkEditor\Depth;
 use App\Fields\FluidbookLinkEditor\LinkType;
 use App\Fields\FluidbookLinkEditor\MultimediaIntegration;
+use App\Models\FluidbookPublication;
 use Cubist\Backpack\Magic\Fields\Checkbox;
-use Cubist\Backpack\Magic\Fields\Code;
 use Cubist\Backpack\Magic\Fields\FieldGroupEnd;
 use Cubist\Backpack\Magic\Fields\FieldGroupStart;
+use Cubist\Backpack\Magic\Fields\FilesOrURL;
 use Cubist\Backpack\Magic\Fields\FormSection;
 use Cubist\Backpack\Magic\Fields\Text;
 use Cubist\Backpack\Magic\Fields\Textarea;
@@ -62,9 +63,15 @@ class Base extends Form
     const ANCHOR = 40;
     const FLIPCARD = 41;
 
+    /**
+     * @var int
+     */
+    protected $fluidbook_id;
+
     protected $_displayedOnFluidbook = true;
     protected $_integration = false;
     protected $_multimedia = false;
+    protected $_addedContents = true;
     protected $_tooltip = true;
 
     /**
@@ -128,9 +135,24 @@ class Base extends Form
         return $res;
     }
 
-    public function init()
+    /**
+     * @return mixed
+     */
+    public function getFluidbookId()
+    {
+        return $this->fluidbook_id;
+    }
+
+    /**
+     * @param int|string $fluidbook_id
+     */
+    public function setFluidbookId(int|string $fluidbook_id = '0'): void
+    {
+        $this->fluidbook_id = $fluidbook_id;
+    }
+
+    public function initForm()
     {
-        parent::init();
         $this->addTypeField();
         $this->addSettingsFields();
         $this->addAppearanceFields();
@@ -156,7 +178,7 @@ class Base extends Form
 
     public function addDestinationField()
     {
-        $this->addField('to', Text::class, __('Destination'));
+
     }
 
     public function addUIDField()
@@ -174,6 +196,11 @@ class Base extends Form
 
     public function addBasicSettingsFields()
     {
+        if ($this->_addedContents) {
+            $this->addField('header_contents', FormSection::class, __('Contenus superposés'));
+            $this->addField('image', FilesOrURL::class, __('Image'), array_merge($this->getFilesOrURLEntry(), ['accept' => ['.jpg', '.jpeg', '.png', '.svg', '.gif']]));
+            $this->addField('animation', FilesOrURL::class, __('Animation'), array_merge($this->getFilesOrURLEntry(), ['accept' => ['.html']]));
+        }
         if ($this->_integration) {
             $this->addField('inline', MultimediaIntegration::class, __('Intégration'), ['default' => 'inline']);
         }
@@ -182,6 +209,15 @@ class Base extends Form
         }
     }
 
+    /**
+     * @return array
+     */
+    public function getFilesOrURLEntry()
+    {
+        $res = ['entry_class' => FluidbookPublication::class, 'entry_id' => $this->getFluidbookId()];
+        return $res;
+    }
+
     public function addMultimediaFields()
     {
         $this->addField('header_video', FormSection::class, __('Paramètres multimedia'));
@@ -216,7 +252,7 @@ class Base extends Form
     public function addExtraFields()
     {
         $this->addField('header_extra', FormSection::class, __('Autres paramètres'));
-        $this->addField('extra', Code::class, '', ['language' => 'properties']);
+        $this->addField('extra', Textarea::class, '');
     }
 
     public function getType()
index 034f406611d3c36df099a6c08823be43a7d8493e..a98904383544c54417d550cfa00fe47b31cd96b0 100644 (file)
@@ -2,6 +2,8 @@
 
 namespace App\SubForms\Link;
 
+use App\Fields\FluidbookLinkEditor\Target;
+use Cubist\Backpack\Magic\Fields\SelectFromArray;
 use Cubist\Backpack\Magic\Fields\URL;
 
 class Web extends Base
@@ -11,5 +13,6 @@ class Web extends Base
     public function addDestinationField()
     {
         $this->addField('to', URL::class, __('Adresse'));
+        $this->addField('target', Target::class, __('Ouvrir le lien dans'));
     }
 }
index 299d80d38472fbd66d4d07b939267f0f8dec1167..07b2bb013aa65fb4f7c763f8fc66cde33712e2ab 100644 (file)
@@ -5,6 +5,7 @@
     "packages": {
         "": {
             "dependencies": {
+                "ace-builds": "^1.12.5",
                 "codemirror": "^5",
                 "command-line-args": "^5.2.1",
                 "jquery-contextmenu": "^2.9.2",
                 "node": ">= 0.6"
             }
         },
+        "node_modules/ace-builds": {
+            "version": "1.12.5",
+            "resolved": "https://registry.npmjs.org/ace-builds/-/ace-builds-1.12.5.tgz",
+            "integrity": "sha512-2OTOZZdXVqWHfsV63n/bWLJ4uGnGNm9uwEQSECbEzMpKF2RKxD04lWu7s+eRBTZoEbqPXziyI1qamJH2OAwdwA=="
+        },
         "node_modules/acorn": {
             "version": "6.4.2",
             "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz",
                 "negotiator": "0.6.3"
             }
         },
+        "ace-builds": {
+            "version": "1.12.5",
+            "resolved": "https://registry.npmjs.org/ace-builds/-/ace-builds-1.12.5.tgz",
+            "integrity": "sha512-2OTOZZdXVqWHfsV63n/bWLJ4uGnGNm9uwEQSECbEzMpKF2RKxD04lWu7s+eRBTZoEbqPXziyI1qamJH2OAwdwA=="
+        },
         "acorn": {
             "version": "6.4.2",
             "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz",
index 893565966ccb595be724f682eeed5ec4696cf0fe..37fb2e6921a49227d94ec0a2d6687e47f4be188d 100644 (file)
@@ -43,6 +43,7 @@
         "webfont": "^11.2.26"
     },
     "dependencies": {
+        "ace-builds": "^1.12.5",
         "codemirror": "^5",
         "command-line-args": "^5.2.1",
         "jquery-contextmenu": "^2.9.2",
index 60930ba22d2c2eea0822acd92796cd7d94252cdb..5256dcd83c5425e6bb455a8faf02cf7248378233 100644 (file)
@@ -1,10 +1,6 @@
 import tippy from 'tippy.js';
 import 'tippy.js/dist/tippy.css';
 
-import CodeMirror from "codemirror";
-window.CodeMirror=CodeMirror;
-import 'codemirror/lib/codemirror.css';
-
 import Noty from "noty";
 import 'noty/lib/noty.css';
 import 'noty/lib/themes/mint.css';
index 774b76a8f186ccb8e30ebb509838f58b207f11c4..579a9b34cc4e3a25244b7e0da33e31e3d90697bc 100644 (file)
                 @continue;
             @endif
             @php
+                /** @var \App\SubForms\Link\Base $instance */
                 $instance=new $f['class']();
+                $instance->setFluidbookId($id);
+                $instance->initForm();
                 $instance->setValue('type',$f['type']);
                 echo $instance->render();
             @endphp
         @foreach(\App\SubForms\Link\Base::types() as $type)
             @if(isset($type['color']))
             .link[fb-type="{{$type['type']}}"] {
-                color: {{$type['color']}};
-                background-color: {{\Cubist\Util\Graphics\Color::colorToCSS($type['color'],0.25)}};
-            }
+            color: {{$type['color']}};
+            background-color: {{\Cubist\Util\Graphics\Color::colorToCSS($type['color'],0.25)}};
+        }
 
-            .linkeditor-linktype[data-type="{{$type['type']}}"]::before {
-                background-color: {{$type['color']}};
-            }
-            @endif
+        .linkeditor-linktype[data-type="{{$type['type']}}"]::before {
+            background-color: {{$type['color']}};
+        }
+        @endif
         @endforeach
     </style>
     <link rel="stylesheet"